annotate win/dw.c @ 1804:83b2bd4ca2a3

Drop out of dw_window_set_style() on Windows for status text widgets... Currently there are no available styles, and some will muck up the widget.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 27 Sep 2012 08:42:50 +0000
parents 5ed9f7ea3882
children c110191e3775
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 */
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
920 _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
921 _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
922 _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
923 _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
924 _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
925 _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
926 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
927 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
928 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
929
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
930 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
931 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
932 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
933
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
934 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
935 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
936 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
937 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
938
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
939 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
940 return cinfo->buddy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
941 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
942 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
943 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
944 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
945
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
946 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
947 return cinfo->buddy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
948 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
949 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
950 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
951
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
952 int _focus_check_box(Box *box, HWND handle, int start, HWND defaultitem)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
953 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
954 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
955 static HWND lasthwnd, firsthwnd;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
956 static int finish_searching;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
957
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
958 /* 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
959 * 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
960 * that was valid.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
961 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
962 if(start == 2)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
963 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
964 if(lasthwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
965 SetFocus(lasthwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
966 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
967 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
968
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
969 /* 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
970 * 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
971 * the function recursively.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
972 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
973 if(start == 1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
974 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
975 lasthwnd = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
976 finish_searching = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
977 firsthwnd = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
978 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
979
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
980 for(z=box->count-1;z>-1;z--)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
981 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
982 if(box->items[z].type == TYPEBOX)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
983 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
984 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
985
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
986 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0, defaultitem))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
987 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
988 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
989 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
990 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
991 if(box->items[z].hwnd == handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
992 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
993 if(lasthwnd == handle && firsthwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
994 SetFocus(firsthwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
995 else if(lasthwnd == handle && !firsthwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
996 finish_searching = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
997 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
998 SetFocus(lasthwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
999
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1000 /* 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
1001 * return immediately.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1002 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1003 if(!finish_searching)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1004 return 1;
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(_validate_focus(box->items[z].hwnd))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1007 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1008 /* 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
1009 * first valid item in the layout.
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 if(start == 3)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1012 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1013 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
1014 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1015 SetFocus(_normalize_handle(box->items[z].hwnd));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1016 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1017 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1018 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1019
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1020 if(!firsthwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1021 firsthwnd = _normalize_handle(box->items[z].hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1022
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1023 lasthwnd = _normalize_handle(box->items[z].hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1024 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1025 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1026 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1027 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1028
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1029 GetClassName(box->items[z].hwnd, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1030
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1031 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
1032 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1033 /* Then try the bottom or right box */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1034 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_bottomright");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1035
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1036 if(mybox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1037 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1038 Box *splitbox = (Box *)GetWindowLongPtr(mybox, GWLP_USERDATA);
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(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1041 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1042 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1043
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1044 /* Try the top or left box */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1045 mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_topleft");
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(mybox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1048 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1049 Box *splitbox = (Box *)GetWindowLongPtr(mybox, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1050
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1051 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1052 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1053 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1054 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1055 else if(_tcsnicmp(tmpbuf, WC_TABCONTROL, _tcslen(WC_TABCONTROL))==0) /* Notebook */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1056 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1057 NotebookPage **array = (NotebookPage **)dw_window_get_data(box->items[z].hwnd, "_dw_array");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1058 int pageid = TabCtrl_GetCurSel(box->items[z].hwnd);
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(pageid > -1 && array && array[pageid])
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 Box *notebox;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1063
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1064 if(array[pageid]->hwnd)
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 notebox = (Box *)GetWindowLongPtr(array[pageid]->hwnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1067
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1068 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, defaultitem))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1069 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1070 }
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 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1073 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
1074 {
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1075 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
1076 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
1077
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1078 if(scrollbox && _focus_check_box(scrollbox, handle, start == 3 ? 3 : 0, defaultitem))
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1079 return 1;
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1080 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1081 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1082 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1083 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1084 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1085 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1086
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
1087 int _focus_check_box_back(Box *box, HWND handle, int start, HWND defaultitem)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1088 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1089 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1090 static HWND lasthwnd, firsthwnd;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
1091 static int finish_searching;
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
1092
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1093 /* 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
1094 * 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
1095 * that was valid.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1096 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1097 if(start == 2)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1098 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1099 if(lasthwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1100 SetFocus(lasthwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1101 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1102 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1103
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1104 /* 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
1105 * 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
1106 * the function recursively.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1107 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1108 if(start == 1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1109 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1110 lasthwnd = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1111 finish_searching = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1112 firsthwnd = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1113 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1114
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1115 for(z=0;z<box->count;z++)
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 if(box->items[z].type == TYPEBOX)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1118 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1119 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
1120
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1121 if(thisbox && _focus_check_box_back(thisbox, handle, start == 3 ? 3 : 0, defaultitem))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1122 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1123 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1124 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1125 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1126 if(box->items[z].hwnd == handle)
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(lasthwnd == handle && firsthwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1129 SetFocus(firsthwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1130 else if(lasthwnd == handle && !firsthwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1131 finish_searching = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1132 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1133 SetFocus(lasthwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1134
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1135 /* 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
1136 * return immediately.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1137 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1138 if(!finish_searching)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1139 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1140 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1141 if(_validate_focus(box->items[z].hwnd))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1142 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1143 /* 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
1144 * first valid item in the layout.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1145 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1146 if(start == 3)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1147 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1148 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
1149 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1150 SetFocus(_normalize_handle(box->items[z].hwnd));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1151 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1152 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1153 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1154
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1155 if(!firsthwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1156 firsthwnd = _normalize_handle(box->items[z].hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1157
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1158 lasthwnd = _normalize_handle(box->items[z].hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1159 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1160 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1161 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1162 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1163
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1164 GetClassName(box->items[z].hwnd, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1165
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1166 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
1167 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1168 /* Try the top or left box */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1169 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_topleft");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1170
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1171 if(mybox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1172 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1173 Box *splitbox = (Box *)GetWindowLongPtr(mybox, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1174
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1175 if(splitbox && _focus_check_box_back(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1176 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1177 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1178
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1179 /* Then try the bottom or right box */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1180 mybox = (HWND)dw_window_get_data(box->items[z].hwnd, "_dw_bottomright");
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 if(mybox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1183 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1184 Box *splitbox = (Box *)GetWindowLongPtr(mybox, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1185
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1186 if(splitbox && _focus_check_box_back(splitbox, handle, start == 3 ? 3 : 0, defaultitem))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1187 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1188 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1189 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1190 else if(_tcsnicmp(tmpbuf, WC_TABCONTROL, _tcslen(WC_TABCONTROL))==0) /* Notebook */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1191 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1192 NotebookPage **array = (NotebookPage **)dw_window_get_data(box->items[z].hwnd, "_dw_array");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1193 int pageid = TabCtrl_GetCurSel(box->items[z].hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1194
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1195 if(pageid > -1 && array && array[pageid])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1196 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1197 Box *notebox;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1198
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1199 if(array[pageid]->hwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1200 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1201 notebox = (Box *)GetWindowLongPtr(array[pageid]->hwnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1202
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1203 if(notebox && _focus_check_box_back(notebox, handle, start == 3 ? 3 : 0, defaultitem))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1204 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1205 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1206 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1207 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1208 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
1209 {
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1210 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
1211 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
1212
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1213 if(scrollbox && _focus_check_box_back(scrollbox, handle, start == 3 ? 3 : 0, defaultitem))
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1214 return 1;
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1215 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1216 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1217 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1218 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1219 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
1220 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1221
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1222 /* This function finds the first widget in the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1223 * layout and moves the current focus to it.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1224 */
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1225 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
1226 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1227 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
1228 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1229
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1230 if(!handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1231 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1232
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1233 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1234
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1235 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
1236 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1237
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1238
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1239 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1240 thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1241
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1242 if(thisbox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1243 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1244 _focus_check_box(thisbox, handle, 3, thisbox->defaultitem);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1245 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1246 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1247
301
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
1248 HWND _toplevel_window(HWND handle)
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
1249 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1250 HWND box, lastbox = GetParent(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1251
1803
5ed9f7ea3882 Make sure _toplevel_window() when passed a top-level window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1799
diff changeset
1252 if(!lastbox)
5ed9f7ea3882 Make sure _toplevel_window() when passed a top-level window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1799
diff changeset
1253 lastbox = handle;
5ed9f7ea3882 Make sure _toplevel_window() when passed a top-level window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1799
diff changeset
1254
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1255 /* Find the toplevel window */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1256 while((box = GetParent(lastbox)))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1257 {
1467
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1258 /* 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
1259 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
1260 return 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1261 lastbox = box;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1262 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1263 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
1264 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1265 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
1266
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1267 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
1268
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1269 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
1270 return lastbox;
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1271 }
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1272 return 0;
301
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
1273 }
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
1274
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1275 /* This function finds the current widget in the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1276 * layout and moves the current focus to the next item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1277 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1278 void _shift_focus(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1279 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1280 Box *thisbox;
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 HWND box, lastbox = GetParent(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1283
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1284 /* Find the toplevel window */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1285 while((box = GetParent(lastbox)))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1286 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1287 lastbox = box;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1288 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1289
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1290 thisbox = (Box *)GetWindowLongPtr(lastbox, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1291 if(thisbox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1292 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1293 if(_focus_check_box(thisbox, handle, 1, 0) == 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1294 _focus_check_box(thisbox, handle, 2, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1295 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1296 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1297
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
1298 /* This function finds the current widget in the
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1299 * layout and moves the current focus to the next item.
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1300 */
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1301 void _shift_focus_back(HWND handle)
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1302 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1303 Box *thisbox;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1304
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1305 HWND box, lastbox = GetParent(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1306
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1307 /* Find the toplevel window */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1308 while((box = GetParent(lastbox)))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1309 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1310 lastbox = box;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1311 }
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 thisbox = (Box *)GetWindowLongPtr(lastbox, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1314 if(thisbox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1315 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1316 if(_focus_check_box_back(thisbox, handle, 1, 0) == 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1317 _focus_check_box_back(thisbox, handle, 2, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1318 }
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
1319 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1320 /* This function calculates how much space the widgets and boxes require
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1321 * and does expansion as necessary.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1322 */
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
1323 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
1324 {
bde7ebced556 Initial layout engine 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 /* 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
1326 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
1327 /* 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
1328 * 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
1329 * 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
1330 */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1331 int uymax = 0, uxmax = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1332 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
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 /* 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
1335 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
1336
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1337 if(thisbox->grouphwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1338 {
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
1339 /* 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
1340 * 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
1341 */
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
1342 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
1343 {
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
1344 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
1345
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
1346 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
1347
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
1348 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
1349 {
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
1350 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
1351 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
1352 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
1353 }
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
1354 /* 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
1355 * 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
1356 */
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
1357 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
1358 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
1359
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
1360 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
1361 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
1362 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
1363 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
1364
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
1365 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
1366 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1367
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
1368 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
1369 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
1370 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
1371 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
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
bde7ebced556 Initial layout engine 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 /* 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
1375 for(z=0;z<thisbox->count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1376 {
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
1377 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
1378
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1379 if(thisbox->items[z].type == TYPEBOX)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1380 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1381 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
1382
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1383 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1384 {
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
1385 /* 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
1386 if(pass == 1)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1387 {
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
1388 (*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
1389
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1390 /* 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
1391 _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
1392
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1393 /* 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
1394 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
1395 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
1396
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
1397 /* 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
1398 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
1399 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
1400 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
1401 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
1402
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
1403 (*depth)--;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1404 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1405 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1406 }
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
1407
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1408 /* 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
1409 * 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
1410 */
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1411 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
1412 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
1413 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
1414
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1415 /* Calculate the totals and maximums */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1416 if(thisbox->type == DW_VERT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1417 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1418 if(itemwidth > uxmax)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1419 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
1420
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1421 if(thisbox->items[z].hsize != SIZEEXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1422 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1423 if(itemwidth > upxmax)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1424 upxmax = itemwidth;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1425 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1426 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1427 {
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1428 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
1429 upxmax = itempad;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1430 }
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
1431 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
1432 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
1433 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
1434 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
1435 thisbox->usedpady += itempad;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1436 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1437 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1438 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1439 if(itemheight > uymax)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1440 uymax = itemheight;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1441 if(thisbox->items[z].vsize != SIZEEXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1442 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1443 if(itemheight > upymax)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1444 upymax = itemheight;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1445 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1446 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1447 {
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
1448 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
1449 upymax = itempad;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
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 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
1452 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
1453 thisbox->usedpadx += itemwidth;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1454 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
1455 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
1456 }
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1457 }
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1458
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1459 /* 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
1460 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
1461 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
1462 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
1463 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
1464
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1465 /* 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
1466 if(thisbox->grouphwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1467 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1468 currentx += 3;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1469 currenty += thisbox->grouppady - 3;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1470 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1471
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1472 /* 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
1473 if(pass > 1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1474 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1475 for(z=0;z<(thisbox->count);z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1476 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1477 int height = thisbox->items[z].height;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1478 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
1479 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
1480 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
1481
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1482 /* 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
1483 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
1484 {
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1485 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
1486 {
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1487 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
1488
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1489 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
1490 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
1491 }
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1492 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
1493 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
1494 }
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1495 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
1496 {
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1497 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
1498 {
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1499 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
1500
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1501 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
1502 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
1503 }
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1504 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
1505 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
1506 }
bde7ebced556 Initial layout engine 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
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1508 /* 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
1509 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
1510 {
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1511 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
1512 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
1513 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
1514
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1515 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1516
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1517 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
1518 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1519 /* Handle special case Combobox */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1520 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
1521 width, height + 400, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1522 }
1723
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1523 #ifdef TOOLBAR
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1524 /* Bitmap Buttons */
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1525 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
1526 {
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
1527 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
1528
f7a41d057a50 A much better solution that centering the button in the space on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1730
diff changeset
1529 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
1530 }
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1531 #endif
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1532 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
1533 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1534 /* Handle special case Spinbutton */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1535 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1536
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
1537 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
1538 20, height, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1539
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1540 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1541 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1542 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
1543 width - 20, height, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1544 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1545 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1546 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
1547 {
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1548 /* Handle special case of scrollbox */
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1549 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
1550 int cx, cy, depth = 0;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1551 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
1552 SCROLLINFO hsi, vsi;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1553 RECT rect;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1554
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1555 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
1556 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
1557
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1558 /* 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
1559 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
1560 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
1561
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1562 /* 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
1563 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
1564
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1565 GetClientRect(handle, &rect);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1566 cx = rect.right;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1567 cy = rect.bottom;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1568
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1569
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1570 /* 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
1571 _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
1572
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1573 if(cx < thisbox->minwidth)
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1574 {
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
1575 cx = thisbox->minwidth;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1576 }
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
1577 if(cy < thisbox->minheight)
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
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 cy = thisbox->minheight;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1580 }
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1581
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1582 /* 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
1583 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
1584 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
1585 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
1586 {
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
1587 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
1588 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
1589 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
1590 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1591 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
1592 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1593 }
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
1594 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
1595 {
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
1596 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
1597 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
1598 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
1599 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1600 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
1601 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1602 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1603 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
1604 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
1605 SetScrollInfo(handle, SB_VERT, &vsi, TRUE);
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1606
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1607 /* Layout the content of the scrollbox */
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1608 _do_resize(thisbox, cx, cy);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1609 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1610 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
1611 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1612 /* Then try the bottom or right box */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1613 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
1614 int type = (int)dw_window_get_data(handle, "_dw_type");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1615
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1616 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
1617 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
1618
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
1619 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
1620 _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
1621 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1622 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
1623 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1624 /* Handle special case Vertically Center static text */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1625 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1626
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1627 if(cinfo && cinfo->vcenter)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1628 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1629 /* 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
1630 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
1631 int textheight, diff, total = height;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1632
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
1633 GetWindowText(handle, thisbuf, 1023);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1634
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1635 /* 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
1636 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
1637
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1638 diff = (total - textheight) / 2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1639
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1640 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
1641 width, height - diff, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1642 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1643 else
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 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
1646 width, height, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1647 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1648 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1649 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1650 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1651 /* 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
1652 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
1653 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
1654 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
1655 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
1656
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1657 /* 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
1658 if(thisbox->items[z].type == TYPEBOX)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1659 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1660 Box *boxinfo = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1661
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
1662 if(boxinfo)
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
1663 {
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
1664 /* 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
1665 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
1666 {
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1667 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
1668 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
1669 }
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1670 /* 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
1671 (*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
1672 _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
1673 (*depth)--;
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
1674 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1675 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1676 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1677
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1678 /* 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
1679 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
1680 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1681 RECT rect;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1682 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
1683 int pageid = TabCtrl_GetCurSel(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1684
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1685 if(pageid > -1 && array && array[pageid])
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 GetClientRect(handle,&rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1688 TabCtrl_AdjustRect(handle,FALSE,&rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1689 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
1690 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
1691 dw_window_redraw(array[pageid]->hwnd);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1692 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1693 }
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
1694 /* 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
1695 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
1696 {
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
1697 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
1698
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
1699 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
1700 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
1701 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1702
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
1703 /* 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
1704 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
1705 currentx += width + (pad * 2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1706 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
1707 currenty += height + (pad * 2);
617
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1710 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1711 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1712
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1713 void _do_resize(Box *thisbox, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1714 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1715 if(x != 0 && y != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1716 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1717 if(thisbox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1718 {
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
1719 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
1720
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1721 /* 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
1722 _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
1723
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1724 /* 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
1725 _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
1726 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1727 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1728 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1729
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
1730 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
1731 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1732 SCROLLINFO si;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
1733
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
1734 ZeroMemory( &si, sizeof(si) );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1735 si.cbSize = sizeof(SCROLLINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1736 si.fMask = SIF_ALL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1737
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1738 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
1739
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1740 switch(which)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1741 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1742 case SB_THUMBTRACK:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1743 return pos;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1744 /*case SB_PAGEUP:*/
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1745 case SB_PAGELEFT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1746 pos = si.nPos - si.nPage;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1747 if(pos < si.nMin)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1748 pos = si.nMin;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1749 return pos;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1750 /*case SB_PAGEDOWN:*/
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1751 case SB_PAGERIGHT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1752 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
1753 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
1754 pos = (si.nMax - si.nPage) + 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1755 return pos;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1756 /*case SB_LINEUP:*/
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1757 case SB_LINELEFT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1758 pos = si.nPos - 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1759 if(pos < si.nMin)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1760 pos = si.nMin;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1761 return pos;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1762 /*case SB_LINEDOWN:*/
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1763 case SB_LINERIGHT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1764 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
1765 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
1766 pos = (si.nMax - si.nPage) + 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1767 return pos;
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 return -1;
211
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1770 }
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1771
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
1772 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
1773 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1774 MENUINFO mi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1775
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1776 mi.cbSize = sizeof(MENUINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1777 mi.fMask = MIM_MENUDATA;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1778
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
1779 if ( GetMenuInfo( menu, &mi ) )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1780 return (HMENU)mi.dwMenuData;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1781 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
1782 }
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1783
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1784 /* 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
1785 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
1786 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1787 HMENU menuowner = 0, lastowner = _get_owner(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1788
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1789 /* Find the toplevel menu */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1790 while((menuowner = _get_owner(lastowner)) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1791 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1792 if(menuowner == (HMENU)1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1793 return lastowner;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1794 lastowner = menuowner;
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 return (HMENU)0;
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 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1800 * 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
1801 * 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
1802 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1803 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
1804 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1805 char buffer[40];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1806 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
1807 sprintf( buffer, "_dw_checkable%d", id );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1808 checkable = (int)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
1809 if ( checkable )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1810 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1811 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
1812 sprintf( buffer, "_dw_ischecked%d", id );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1813 is_checked = (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
1814 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
1815 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
1816 }
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
1817 }
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1818
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1819 /* 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
1820 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
1821 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1822 int result = -1, taskbar = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1823 SignalHandler *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1824 void (*windowfunc)(PVOID);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1825 ULONG origmsg = msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1826
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1827 /* Deal with translating some messages */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1828 if (msg == WM_USER+2)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1829 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1830 taskbar = TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1831 origmsg = msg = (UINT)mp2; /* no else here */
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 if (msg == WM_RBUTTONDOWN || msg == WM_MBUTTONDOWN)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1834 msg = WM_LBUTTONDOWN;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1835 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
1836 msg = WM_LBUTTONUP;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1837 else if (msg == WM_HSCROLL)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1838 msg = WM_VSCROLL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1839 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
1840 msg = WM_CHAR;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1841
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1842 if (result == -1)
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 /* Find any callbacks for this function */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1845 while (tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1846 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1847 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
1848 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1849 switch (msg)
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 case WM_TIMER:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1852 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1853 if (!hWnd)
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 int (*timerfunc)(void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1856 if (tmp->id == (int)mp1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1857 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1858 if (!timerfunc(tmp->data))
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
1859 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1860 dw_timer_disconnect(tmp->id);
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
1861 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1862 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1863 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1864 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1865 result = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1866 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1867 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1868 case WM_SETFOCUS:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1869 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1870 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
1871
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1872 if(hWnd == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1873 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1874 result = setfocusfunc(tmp->window, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1875 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1876 }
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1879 case WM_SIZE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1880 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1881 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
1882 if(hWnd == tmp->window)
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 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
1885 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1886 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1887 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1888 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1889 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1890 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1891 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
1892
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1893 if(hWnd == tmp->window)
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 int button=0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1896
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1897 switch(origmsg)
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 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1900 button = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1901 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1902 case WM_RBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1903 button = 2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1904 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1905 case WM_MBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1906 button = 3;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1907 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1908 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1909 if(taskbar)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1910 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1911 POINT ptl;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1912 GetCursorPos(&ptl);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1913 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
1914 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1915 else
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 POINTS pts = MAKEPOINTS(mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1918 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
1919 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1920 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1921 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1922 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1923 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1924 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1925 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1926 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
1927
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1928 if(hWnd == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1929 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1930 int button=0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1931
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1932 switch(origmsg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1933 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1934 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1935 button = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1936 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1937 case WM_RBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1938 button = 2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1939 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1940 case WM_MBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1941 button = 3;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1942 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1943 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1944 if(taskbar)
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 POINT ptl;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1947 GetCursorPos(&ptl);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1948 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
1949 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1950 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1951 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1952 POINTS pts = MAKEPOINTS(mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1953 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
1954 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1955 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1956 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1957 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1958 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1959 case WM_MOUSEMOVE:
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 POINTS pts = MAKEPOINTS(mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1962 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
1963
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1964 if(hWnd == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1965 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1966 int keys = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1967
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1968 if (mp1 & MK_LBUTTON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1969 keys = DW_BUTTON1_MASK;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1970 if (mp1 & MK_RBUTTON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1971 keys |= DW_BUTTON2_MASK;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1972 if (mp1 & MK_MBUTTON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1973 keys |= DW_BUTTON3_MASK;
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 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
1976 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1977 }
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1980 case WM_CHAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1981 {
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1982 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
1983
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1984 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
1985 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1986 int special = 0;
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1987 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
1988 #ifdef UNICODE
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1989 WCHAR uc[2] = { 0 };
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1990
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1991 uc[0] = (WCHAR)mp1;
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1992 utf8 = WideToUTF8(uc);
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1993 #endif
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1994
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1995 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1996 special |= KC_SHIFT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1997 if(GetAsyncKeyState(VK_CONTROL) & 0x8000)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1998 special |= KC_CTRL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1999 if(mp2 & (1 << 29))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2000 special |= KC_ALT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2001
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2002 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
2003 ch[0] = (char)mp1;
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
2004
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
2005 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
2006 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2007 }
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2010 case WM_CLOSE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2011 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2012 int (*closefunc)(HWND, void *) = tmp->signalfunction;
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 if(hWnd == tmp->window)
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 result = closefunc(tmp->window, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2017 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2018 }
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2021 case WM_PAINT:
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 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2024 DWExpose exp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2025 int (*exposefunc)(HWND, DWExpose *, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2026
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2027 if ( hWnd == tmp->window )
617
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 BeginPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2030 exp.x = ps.rcPaint.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2031 exp.y = ps.rcPaint.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2032 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
2033 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
2034 result = exposefunc(hWnd, &exp, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2035 EndPaint(hWnd, &ps);
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2039 case WM_NOTIFY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2040 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2041 if(tmp->message == TVN_SELCHANGED ||
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2042 tmp->message == NM_RCLICK ||
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2043 tmp->message == TVN_ITEMEXPANDED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2044 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2045 NMTREEVIEW FAR *tem=(NMTREEVIEW FAR *)mp2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2046 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
2047 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2048
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2049 GetClassName(tem->hdr.hwndFrom, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2050
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2051 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
2052 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2053 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
2054 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2055 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
2056 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2057 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
2058 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2059 void **ptrs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2060
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
2061 tvi.mask = TVIF_HANDLE | TVIF_PARAM;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2062 tvi.hItem = tem->itemNew.hItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2063
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2064 TreeView_GetItem(tmp->window, &tvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2065
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2066 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2067 if(ptrs)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2068 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
2069
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2070 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2071 }
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 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
2074 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2075 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
2076 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2077 int (*treeexpandfunc)(HWND, HTREEITEM, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2078
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2079 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
2080 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2081 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2082 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2083 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
2084 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2085 if(tmp->window == tem->hdr.hwndFrom)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2086 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2087 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
2088 HTREEITEM hti;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2089 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2090 TVHITTESTINFO thi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2091 void **ptrs = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2092 LONG x, y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2093
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2094 dw_pointer_query_pos(&x, &y);
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 thi.pt.x = x;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2097 thi.pt.y = y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2098
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2099 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
2100
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2101 hti = TreeView_HitTest(tmp->window, &thi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2102
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2103 if(hti)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2104 {
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
2105 tvi.mask = TVIF_HANDLE | TVIF_PARAM;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2106 tvi.hItem = hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2107
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2108 TreeView_GetItem(tmp->window, &tvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2109 TreeView_SelectItem(tmp->window, hti);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2110
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2111 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2112 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2113 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
2114 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2115 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2116 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2117 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2118 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
2119 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2120 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
2121 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2122 if(tmp->window == tem->hdr.hwndFrom)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2123 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2124 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2125 int iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2126
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2127 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
2128
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2129 memset(&lvi, 0, sizeof(LV_ITEM));
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(iItem > -1)
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 (*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
2134
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2135 lvi.iItem = iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2136 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2137
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2138 ListView_GetItem(tmp->window, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2139
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2140 /* 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
2141 if(lvi.lParam < 100)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2142 lvi.lParam = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2143
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2144 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
2145 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2146 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2147 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2148 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2149 }
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 else if(tmp->message == TCN_SELCHANGE)
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 NMHDR FAR *tem=(NMHDR FAR *)mp2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2154 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
2155 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2156 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
2157 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
2158 result = switchpagefunc(tem->hwndFrom, num, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2159 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2160 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2161 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2162 else if(tmp->message == LVN_COLUMNCLICK)
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 NMLISTVIEW FAR *tem=(NMLISTVIEW FAR *)mp2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2165 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
2166 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2167 int (*columnclickfunc)(HWND, int, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2168 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
2169 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2170 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2171 }
1624
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2172 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
2173 {
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2174 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
2175 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
2176 {
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2177 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
2178 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
2179 tmp = NULL;
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2180 }
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2181 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2182 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2183 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2184 case WM_COMMAND:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2185 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2186 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2187 HWND command;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2188 ULONG passthru = (ULONG)LOWORD(mp1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2189 ULONG message = HIWORD(mp1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2190
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2191 command = (HWND)passthru;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2192
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2193 if (message == LBN_SELCHANGE || message == CBN_SELCHANGE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2194 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2195 int (*listboxselectfunc)(HWND, int, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2196
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2197 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
2198 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2199 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
2200 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2201 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2202 }
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
2203 #ifdef TOOLBAR
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
2204 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
2205 {
1760
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2206 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
2207
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2208 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
2209
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2210 /* 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
2211 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
2212 {
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2213 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
2214 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
2215 }
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
2216 }
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
2217 #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
2218 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
2219 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2220 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
2221
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2222 if (menuowner == hwndmenu || !menuowner)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2223 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2224 _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
2225 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2226 * Call the user supplied callback
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2227 */
1367
a595e368a393 Menu clicked callbacks on OS/2 and Windows should pass the menu ID as the window handle...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1363
diff changeset
2228 result = clickfunc((HWND)tmp->id, tmp->data);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2229 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2230 }
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2231 } /* this fires for checkable menu items */
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2232 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
2233 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2234 _dw_toggle_checkable_menu_item( popup ? popup : tmp->window, (int)tmp->data );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2235 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
2236 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2237 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2238 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2239 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2240 case WM_HSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2241 case WM_VSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2242 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2243 TCHAR tmpbuf[100] = {0};
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2244 HWND handle = (HWND)mp2;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2245 int (*valuechangefunc)(HWND, int, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2246
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
2247 if(!GetClassName(handle, tmpbuf, 99))
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
2248 {
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
2249 GetClassName(hWnd, tmpbuf, 99);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
2250 }
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
2251
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2252 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
2253 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2254
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2255 if (handle == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2256 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2257 int 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
2258 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
2259 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE);
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 if(currentstyle & TBS_VERT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2262 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
2263 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2264 result = valuechangefunc(tmp->window, value, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2265 tmp = NULL;
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 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2268 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
2269 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2270 if(handle == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2271 {
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2272 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
2273 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
2274
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2275 if(value > -1)
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 dw_scrollbar_set_pos(tmp->window, value);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2278 result = valuechangefunc(tmp->window, value, tmp->data);
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 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2281 msg = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2282 }
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2285 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2286 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2287 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2288 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2289 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2290 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2291 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2292
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2293 /* 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
2294 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2295 {
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
2296 #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
2297 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
2298 {
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
2299 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
2300
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2301 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
2302 _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
2303
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2304 /* 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
2305 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
2306 {
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2307 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
2308
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2309 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
2310 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
2311 _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
2312 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2313 }
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
2314 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
2315 #endif
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2316 #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
2317 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
2318 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
2319 {
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
2320 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
2321 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
2322
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
2323 if(!hbrush)
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2324 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
2325
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
2326 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
2327 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
2328 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
2329 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2330 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
2331 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2332 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2333 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2334 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2335
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2336 BeginPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2337 EndPaint(hWnd, &ps);
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2340 case WM_SIZE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2341 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2342 static int lastx = -1, lasty = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2343 static HWND lasthwnd = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2344
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2345 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
2346 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2347 Box *mybox = (Box *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2348
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2349 if(mybox && mybox->count)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2350 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2351 lastx = LOWORD(mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2352 lasty = HIWORD(mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2353 lasthwnd = hWnd;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2354
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2355 ShowWindow(mybox->items[0].hwnd, SW_HIDE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2356 _do_resize(mybox,LOWORD(mp2),HIWORD(mp2));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2357 ShowWindow(mybox->items[0].hwnd, SW_SHOW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2358 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2359 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2360 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2361 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2362 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2363 case WM_USER:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2364 windowfunc = (void *)mp1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2365
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2366 if(windowfunc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2367 windowfunc((void *)mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2368 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2369 case WM_USER+5:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2370 _free_menu_data((HMENU)mp1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2371 DestroyMenu((HMENU)mp1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2372 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2373 case WM_NOTIFY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2374 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2375 NMHDR FAR *tem=(NMHDR FAR *)mp2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2376
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2377 if(tem->code == TCN_SELCHANGING)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2378 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2379 int num=TabCtrl_GetCurSel(tem->hwndFrom);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2380 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
2381
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2382 if(num > -1 && array && array[num])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2383 SetParent(array[num]->hwnd, DW_HWND_OBJECT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2384
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2385 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2386 else if(tem->code == TCN_SELCHANGE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2387 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2388 int num=TabCtrl_GetCurSel(tem->hwndFrom);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2389 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
2390
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2391 if(num > -1 && array && array[num])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2392 SetParent(array[num]->hwnd, tem->hwndFrom);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2393
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2394 _resize_notebook_page(tem->hwndFrom, num);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2395 }
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2398 case WM_HSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2399 case WM_VSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2400 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2401 HWND handle = (HWND)mp2;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2402 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
2403
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2404 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
2405 {
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2406 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
2407
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2408 if(value > -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2409 dw_scrollbar_set_pos(handle, value);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2410 }
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2411 else
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2412 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2413 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
2414
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2415 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
2416 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
2417 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
2418 _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
2419 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2420 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2421 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2422 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2423 case WM_GETMINMAXINFO:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2424 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2425 MINMAXINFO *info = (MINMAXINFO *)mp2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2426 info->ptMinTrackSize.x = 8;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2427 info->ptMinTrackSize.y = 8;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2428 return 0;
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2431 case WM_DESTROY:
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 HMENU menu = GetMenu(hWnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2434
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2435 if(menu)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2436 _free_menu_data(menu);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2437
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2438 /* Free memory before destroying */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2439 _free_window_memory(hWnd, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2440 EnumChildWindows(hWnd, _free_window_memory, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2441 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2442 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2443 case WM_MOUSEMOVE:
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 HCURSOR cursor;
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 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
2448 (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
2449 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2450 SetCursor(cursor);
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 case WM_CTLCOLORSTATIC:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2455 case WM_CTLCOLORLISTBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2456 case WM_CTLCOLORBTN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2457 case WM_CTLCOLOREDIT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2458 case WM_CTLCOLORMSGBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2459 case WM_CTLCOLORSCROLLBAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2460 case WM_CTLCOLORDLG:
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2461 return _colorwndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2462 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2463 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
2464 {
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
2465 /* 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
2466 _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
2467 /* Then finally return */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2468 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
2469 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
2470 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
2471 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2472
461
12ba7e744560 Fixes timer problems on Windows, however this may break Win95 support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 456
diff changeset
2473 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
2474 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2475 _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
2476 }
12ba7e744560 Fixes timer problems on Windows, however this may break Win95 support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 456
diff changeset
2477
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
2478 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
2479 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2480 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2481 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2482 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2483 case WM_MBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2484 case WM_RBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2485 SetActiveWindow(hWnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2486 SetFocus(hWnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2487 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2488 case WM_COMMAND:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2489 case WM_NOTIFY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2490 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2491 _wndproc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2492 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
2493 #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
2494 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
2495 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
2496 {
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
2497 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
2498 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
2499
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
2500 if(!hbrush)
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2501 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
2502
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
2503 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
2504 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
2505 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
2506 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2507 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
2508 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2509 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2510 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2511 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2512
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2513 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
2514 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2515 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2516 HDC hdcPaint = BeginPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2517 int success = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2518
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2519 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
2520 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2521 /* Handle foreground */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2522 if(thiscinfo->fore > -1 && thiscinfo->fore < 18)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2523 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2524 if(thiscinfo->fore != DW_CLR_DEFAULT)
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 SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2527 _green[thiscinfo->fore],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2528 _blue[thiscinfo->fore]));
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2531 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
2532 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2533 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
2534 DW_GREEN_VALUE(thiscinfo->fore),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2535 DW_BLUE_VALUE(thiscinfo->fore)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2536 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2537 /* Handle background */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2538 if(thiscinfo->back > -1 && thiscinfo->back < 18)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2539 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2540 if(thiscinfo->back != DW_CLR_DEFAULT)
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 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2543 _green[thiscinfo->back],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2544 _blue[thiscinfo->back]));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2545 if(thiscinfo->hbrush)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2546 DeleteObject(thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2547 thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2548 _green[thiscinfo->back],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2549 _blue[thiscinfo->back]));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2550 SelectObject(hdcPaint, thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2551 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
2552 success = TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2553 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2554 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2555 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
2556 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2557 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
2558 DW_GREEN_VALUE(thiscinfo->back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2559 DW_BLUE_VALUE(thiscinfo->back)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2560 if(thiscinfo->hbrush)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2561 DeleteObject(thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2562 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
2563 DW_GREEN_VALUE(thiscinfo->back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2564 DW_BLUE_VALUE(thiscinfo->back)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2565 SelectObject(hdcPaint, thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2566 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
2567 success = TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2568 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2569 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2570
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2571 EndPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2572 if(success)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2573 return FALSE;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2577 break;
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 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
2580 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2581
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
2582 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
2583 {
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
2584 LRESULT rcode = TRUE;
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2585
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2586 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2587 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2588 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2589 case WM_MBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2590 case WM_RBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2591 SetFocus(hWnd);
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2592 rcode = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2593 break;
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2594 case WM_MOUSEMOVE:
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2595 /* 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
2596 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
2597 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
2598 case WM_USER+2:
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2599 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2600 case WM_MBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2601 case WM_RBUTTONUP:
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2602 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
2603 break;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2604 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2605 case WM_SIZE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2606 case WM_COMMAND:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2607 case WM_CHAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2608 case WM_KEYDOWN:
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2609 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
2610 break;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2611 default:
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2612 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2613 }
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2614 /* 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
2615 if ( rcode != 0 )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2616 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
2617 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
2618 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2619
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
2620 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
2621 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2622 ColorInfo *cinfo;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2623
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2624 cinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2625
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2626 if(msg == WM_MOUSEMOVE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2627 _wndproc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2628
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2629 if(cinfo)
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 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2632 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2633 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2634 case WM_MBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2635 case WM_RBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2636 case WM_KEYDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2637 {
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
2638 LRESULT ret;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2639
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2640 if(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2641 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2642 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
2643
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2644 /* 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
2645 * 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
2646 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2647 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2648 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
2649
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2650 SetTimer(hWnd, 100, 100, (TIMERPROC)NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2651
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2652 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2653 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2654 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2655 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2656 case WM_MBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2657 case WM_RBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2658 case WM_KEYUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2659 {
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
2660 LRESULT ret;
617
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 if(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2663 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2664 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
2665
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2666 /* 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
2667 * 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
2668 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2669 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2670 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
2671
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2672 if(hWnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2673 KillTimer(hWnd, 100);
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 return ret;
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2678 case WM_TIMER:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2679 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2680 if(mp1 == 100)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2681 {
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
2682 LRESULT ret;
617
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)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2685 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
2686
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2687 if(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2688 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2689 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
2690
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2691 /* 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
2692 * 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
2693 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2694 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2695 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
2696
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2697 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2698 }
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2701 case WM_USER+10:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2702 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2703 if(cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2704 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2705 TCHAR tempbuf[100] = { 0 };
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2706 long position;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2707
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2708 GetWindowText(cinfo->buddy, tempbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2709
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2710 position = _tstol(tempbuf);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2711
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
2712 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
2713 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2714 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2715 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2716 }
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
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2719 if(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2720 return DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2721 return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2722 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2723
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2724 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
2725 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2726 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2727
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2728 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2729
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2730 /* These are the window classes which can
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2731 * obtain input focus.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2732 */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2733 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
2734 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2735 /* Generate click on default item */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2736 SignalHandler *tmp = Root;
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 /* Find any callbacks for this function */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2739 while (tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2740 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2741 if (tmp->message == WM_COMMAND)
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 /* 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
2744 if (tmp->window == handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2745 {
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
2746 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2747 clickfunc(tmp->window, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2748 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2749 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2750 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2751 if (tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2752 tmp= tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2753 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2754 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2755 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2756 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
2757 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2758
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2759 /* 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
2760 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
2761 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2762 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
2763 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2764 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
2765 LRESULT ret = -1;
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 cinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2768
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2769 GetClassName(hWnd, tmpbuf, 99);
1624
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2770 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
2771 cinfo = &(((Box *)cinfo)->cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2772
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
2773 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
2774 ret = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2775
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2776 if (cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2777 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2778 pOldProc = cinfo->pOldProc;
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 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2781 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2782 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
2783 if(cinfo->combo)
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2784 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
2785 else
1131
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2786 ret = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2787 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2788 case WM_VSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2789 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
2790 ret = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2791 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2792 case WM_KEYDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2793 case WM_KEYUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2794 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2795 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
2796 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2797 if (!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2798 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2799 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
2800
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2801 /* 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
2802 * 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
2803 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2804 if (cinfo && cinfo->buddy && !cinfo->combo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2805 PostMessage(hWnd, WM_USER+10, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2806
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2807 if(msg == WM_KEYDOWN)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2808 SetTimer(hWnd, 101, 100, (TIMERPROC)NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2809 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2810 KillTimer(hWnd, 101);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2811
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2812 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2813 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2814 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2815 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2816 case WM_TIMER:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2817 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2818 if(mp1 == 101)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2819 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2820 if(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2821 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2822 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
2823
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2824 /* 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
2825 * 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
2826 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2827 if(cinfo && cinfo->buddy && !cinfo->combo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2828 PostMessage(hWnd, WM_USER+10, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2829
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2830 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2831 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2832 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2833 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2834 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
2835 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
2836 if (ret != TRUE && LOWORD(mp1) == '\t')
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2837 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2838 if (GetAsyncKeyState(VK_SHIFT) & 0x8000)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2839 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2840 if (cinfo->combo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2841 _shift_focus_back(cinfo->combo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2842 else if(cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2843 _shift_focus_back(cinfo->buddy);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2844 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2845 _shift_focus_back(hWnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2846 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2847 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2848 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2849 if (cinfo->combo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2850 _shift_focus(cinfo->combo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2851 else if(cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2852 _shift_focus(cinfo->buddy);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2853 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2854 _shift_focus(hWnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2855 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2856 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2857 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2858 else if(LOWORD(mp1) == '\r')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2859 {
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2860
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2861 if ( cinfo->clickdefault )
617
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 _click_default(cinfo->clickdefault);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2864 }
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2865 else
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2866 {
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2867 /*
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2868 * 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
2869 * has a default click set
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2870 */
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2871 HWND tl = _toplevel_window( hWnd );
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2872 ColorInfo *mycinfo = (ColorInfo *)GetWindowLongPtr( tl, GWLP_USERDATA );
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
2873 if ( mycinfo && mycinfo->clickdefault )
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2874 {
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2875 _click_default( mycinfo->clickdefault );
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2876 }
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2877 }
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
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2880 /* 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
2881 * 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
2882 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2883 if (cinfo->buddy && !cinfo->combo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2884 {
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
2885 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
2886 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2887 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2888 case WM_USER+10:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2889 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2890 if(cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2891 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2892 long val;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2893
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
2894 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
2895
1621
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
2896 _sntprintf(tmpbuf, 99, TEXT("%ld"), val);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2897 SetWindowText(hWnd, tmpbuf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2898 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2899 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2900 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2901 case WM_CTLCOLORSTATIC:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2902 case WM_CTLCOLORLISTBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2903 case WM_CTLCOLORBTN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2904 case WM_CTLCOLOREDIT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2905 case WM_CTLCOLORMSGBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2906 case WM_CTLCOLORSCROLLBAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2907 case WM_CTLCOLORDLG:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2908 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2909 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
2910 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
2911 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2912 int thisback = thiscinfo->back;
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2913
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2914 /* Handle foreground */
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2915 if(thiscinfo->fore != DW_CLR_DEFAULT)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2916 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2917 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
2918
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2919 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
2920 DW_GREEN_VALUE(fore),
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2921 DW_BLUE_VALUE(fore)));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2922 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2923 /* Handle background */
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2924 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
2925 {
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2926 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
2927
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2928 if(parentcinfo && parentcinfo->back != -1)
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2929 thisback = parentcinfo->back;
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2930 }
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2931 if(thisback == DW_CLR_DEFAULT)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2932 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2933 HBRUSH hbr = GetSysColorBrush(COLOR_3DFACE);
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2934
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2935 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
2936
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2937 SelectObject((HDC)mp1, hbr);
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2938 return (LONG)hbr;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2939 }
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2940 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
2941 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2942 int back = _internal_color(thisback);
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2943
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2944 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
2945 DW_GREEN_VALUE(back),
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2946 DW_BLUE_VALUE(back)));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2947 if(thiscinfo->hbrush)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2948 DeleteObject(thiscinfo->hbrush);
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2949 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
2950 DW_GREEN_VALUE(back),
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2951 DW_BLUE_VALUE(back)));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2952 SelectObject((HDC)mp1, thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2953 return (LONG)thiscinfo->hbrush;
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 }
1514
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2956 #ifdef AEROGLASS
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2957 switch(msg)
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2958 {
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2959 case WM_CTLCOLORSTATIC:
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2960 case WM_CTLCOLORBTN:
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2961 case WM_CTLCOLORDLG:
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2962 {
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2963
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2964 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
2965 (!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
2966 {
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
2967 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
2968 {
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
2969 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
2970 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
2971 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
2972 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
2973 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
2974 return (LONG)thiscinfo->hbrush;
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2975 }
1514
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2976 }
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2977 }
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2978 }
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2979 #endif
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2980 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2981 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2982 }
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
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
2985 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
2986 {
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2987 if(!pOldProc)
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2988 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
2989 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
2990 }
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2991 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
2992 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2993
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2994 /* 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
2995 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
2996 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
2997 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
2998
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2999 switch( msg )
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 case WM_COMMAND:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3002 case WM_NOTIFY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3003 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3004 _wndproc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3005 break;
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3006 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
3007 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
3008 {
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
3009 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
3010 int iItems, iTop, i;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3011 COLORREF c;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3012
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3013 /* 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
3014 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
3015 /* 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
3016 GetUpdateRect(hWnd, &rectUpd, FALSE);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3017 /* 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
3018 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
3019 /* number of displayed rows */
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3020 iItems = ListView_GetCountPerPage(hWnd);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3021 /* first visible row */
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3022 iTop = ListView_GetTopIndex(hWnd);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3023
1214
e16e7c51b6c7 Another attempt at fixing alternating row issues on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1213
diff changeset
3024 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
3025 {
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3026 /* 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
3027 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
3028 {
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3029 /* 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
3030 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
3031
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3032 if(c != DW_RGB_TRANSPARENT)
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3033 {
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3034 ListView_SetTextBkColor(hWnd, c);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3035 /* 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
3036 InvalidateRect(hWnd, &rectDestin, FALSE);
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3037 /* ...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
3038 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
3039 }
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3040 }
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3041 }
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3042 }
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3043 break;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3044 case WM_LBUTTONDBLCLK:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3045 case WM_CHAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3046 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3047 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3048 int iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3049
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3050 if(LOWORD(mp1) == '\t')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3051 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3052 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3053 _shift_focus_back(hWnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3054 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3055 _shift_focus(hWnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3056 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3057 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3058
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3059 if(msg == WM_CHAR && (char)mp1 != '\r')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3060 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3061
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3062 iItem = ListView_GetNextItem(hWnd, -1, LVNI_FOCUSED);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3063
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3064 memset(&lvi, 0, sizeof(LV_ITEM));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3065
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3066 if(iItem > -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3067 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3068 lvi.iItem = iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3069 lvi.mask = LVIF_PARAM;
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 ListView_GetItem(hWnd, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3072 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3073
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3074 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3075 SignalHandler *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3076
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3077 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3078 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3079 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
3080 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3081 int (*containerselectfunc)(HWND, char *, void *) = tmp->signalfunction;
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 /* 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
3084 if(lvi.lParam < 100)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3085 lvi.lParam = 0;
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 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
3088 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3089 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3090 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3091 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3092 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3093 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3094 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3095 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3096 case WM_CONTEXTMENU:
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 SignalHandler *tmp = Root;
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 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3101 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3102 if(tmp->message == NM_RCLICK && tmp->window == hWnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3103 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3104 int (*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
3105 LONG x,y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3106 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3107 int iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3108 LVHITTESTINFO lhi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3109
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3110 dw_pointer_query_pos(&x, &y);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3111
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3112 lhi.pt.x = x;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3113 lhi.pt.y = y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3114
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3115 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
3116
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3117 iItem = ListView_HitTest(tmp->window, &lhi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3118
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3119 memset(&lvi, 0, sizeof(LV_ITEM));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3120
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3121 if(iItem > -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3122 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3123 lvi.iItem = iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3124 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3125
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3126 ListView_GetItem(tmp->window, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3127 ListView_SetSelectionMark(tmp->window, iItem);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3128 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3129
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3130 /* 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
3131 if(lvi.lParam < 100)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3132 lvi.lParam = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3133
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3134 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
3135 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3136 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3137 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3138 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3139 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3140 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3141 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3142 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3143
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3144 if(!continfo || !continfo->cinfo.pOldProc)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3145 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
3146 return CallWindowProc(continfo->cinfo.pOldProc, hWnd, msg, mp1, mp2);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3147 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3148
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
3149 LRESULT CALLBACK _treewndproc(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
3150 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3151 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
3152 LRESULT ret = -1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3153
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3154 cinfo = (ContainerInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3155
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3156 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3157 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3158 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
3159 ret = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3160 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3161 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
3162 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
3163 if(ret != TRUE && LOWORD(mp1) == '\t')
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3164 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3165 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3166 _shift_focus_back(hWnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3167 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3168 _shift_focus(hWnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3169 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3170 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3171 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3172 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3173
1131
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3174 if(ret != TRUE)
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3175 {
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3176 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
3177 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
3178 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
3179 }
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3180 return ret;
68
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3181 }
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3182
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3183 void _changebox(Box *thisbox, int percent, int type)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3184 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3185 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3186
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3187 for(z=0;z<thisbox->count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3188 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3189 if(thisbox->items[z].type == TYPEBOX)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3190 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3191 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
3192 _changebox(tmp, percent, type);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3193 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3194 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3195 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3196 if(type == DW_HORZ)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3197 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3198 if(thisbox->items[z].hsize == SIZEEXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3199 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
3200 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3201 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3202 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3203 if(thisbox->items[z].vsize == SIZEEXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3204 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
3205 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3206 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3207 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3208 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3209
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3210 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
3211 {
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
3212 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
3213 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
3214
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
3215 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
3216 ShowWindow(handle2, SW_HIDE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3217
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3218 if(type == DW_HORZ)
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 int newx = x;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3221 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
3222 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
3223
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3224 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
3225
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3226 MoveWindow(handle1, 0, 0, newx, y, FALSE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3227 _do_resize(tmp, newx - 1, y - 1);
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 tmp = (Box *)GetWindowLongPtr(handle2, GWLP_USERDATA);
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 newx = x - newx - SPLITBAR_WIDTH;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3232
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3233 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
3234 _do_resize(tmp, newx - 1, y - 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3235
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3236 dw_window_set_data(hwnd, "_dw_start", (void *)newx);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3237 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3238 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3239 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3240 int newy = y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3241 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
3242 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
3243
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3244 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
3245
1450
145edf67013e Fixed accidentally flipping splitbars vertically on Windows in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1449
diff changeset
3246 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
3247 _do_resize(tmp, x - 1, newy - 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3248
1450
145edf67013e Fixed accidentally flipping splitbars vertically on Windows in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1449
diff changeset
3249 tmp = (Box *)GetWindowLongPtr(handle1, GWLP_USERDATA);
617
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 newy = y - newy - SPLITBAR_WIDTH;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3252
1450
145edf67013e Fixed accidentally flipping splitbars vertically on Windows in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1449
diff changeset
3253 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
3254 _do_resize(tmp, x - 1, newy - 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3255
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3256 dw_window_set_data(hwnd, "_dw_start", (void *)newy);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3257 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3258
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3259 ShowWindow(handle1, SW_SHOW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3260 ShowWindow(handle2, SW_SHOW);
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3261 }
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3262
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3263 /* 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
3264 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
3265 {
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3266 switch (msg)
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3267 {
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3268 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
3269 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
3270 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3271 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
3272 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
3273 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
3274 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
3275
896
529c27638936 Added missing SIF_PAGE getting SCROLLINFO on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 865
diff changeset
3276 /* 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
3277 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
3278 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
3279
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3280 /* 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
3281 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
3282 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
3283
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3284 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
3285 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3286 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
3287 si = &vsi;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3288 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3289
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3290 switch(which)
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3291 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3292 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
3293 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
3294 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3295 /*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
3296 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
3297 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
3298 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
3299 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
3300 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3301 /*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
3302 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
3303 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
3304 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
3305 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
3306 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3307 /*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
3308 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
3309 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
3310 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
3311 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
3312 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3313 /*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
3314 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
3315 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
3316 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
3317 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
3318 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3319 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3320
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3321 /* 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
3322 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
3323 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
3324 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
3325 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3326 break;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3327 }
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3328 return DefWindowProc(hwnd, msg, mp1, mp2);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3329 }
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3330
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3331 /* 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
3332 LRESULT CALLBACK _splitwndproc(HWND hwnd, UINT msg, WPARAM mp1, LPARAM mp2)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3333 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3334 switch (msg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3335 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3336 case WM_ACTIVATE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3337 case WM_SETFOCUS:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3338 return FALSE;
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 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3341 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3342 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3343 HDC hdcPaint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3344 int type = (int)dw_window_get_data(hwnd, "_dw_type");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3345 int start = (int)dw_window_get_data(hwnd, "_dw_start");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3346
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3347 BeginPaint(hwnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3348
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3349 if((hdcPaint = GetDC(hwnd)) != NULL)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3350 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3351 unsigned long cx, cy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3352 HBRUSH oldBrush = SelectObject(hdcPaint, GetSysColorBrush(COLOR_3DFACE));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3353 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
3354
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3355 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
3356
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3357 if(type == DW_HORZ)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3358 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
3359 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3360 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
3361
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3362 SelectObject(hdcPaint, oldBrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3363 DeleteObject(SelectObject(hdcPaint, oldPen));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3364 ReleaseDC(hwnd, hdcPaint);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3365 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3366 EndPaint(hwnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3367 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3368 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3369 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3370 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3371 SetCapture(hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3372 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3373 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3374 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3375 {
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3376 if(GetCapture() == hwnd)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3377 ReleaseCapture();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3378 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3379 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3380 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3381 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3382 float *percent = (float *)dw_window_get_data(hwnd, "_dw_percent");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3383 int type = (int)dw_window_get_data(hwnd, "_dw_type");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3384 int start;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3385
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3386 if(type == DW_HORZ)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3387 SetCursor(LoadCursor(NULL, IDC_SIZEWE));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3388 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3389 SetCursor(LoadCursor(NULL, IDC_SIZENS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3390
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3391 if(GetCapture() == hwnd && percent)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3392 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3393 POINT point;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3394 RECT rect;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3395 static POINT lastpoint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3396
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3397 GetCursorPos(&point);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3398 GetWindowRect(hwnd, &rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3399
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3400 if(memcmp(&point, &lastpoint, sizeof(POINT)))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3401 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3402 if(PtInRect(&rect, point))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3403 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3404 int width = (rect.right - rect.left);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3405 int height = (rect.bottom - rect.top);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3406
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3407 if(type == DW_HORZ)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3408 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3409 start = point.x - rect.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3410 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
3411 *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
3412 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3413 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3414 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3415 start = point.y - rect.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3416 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
3417 *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
3418 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3419 _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
3420 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3421 memcpy(&lastpoint, &point, sizeof(POINT));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3422 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3423 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3424 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3425 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3426 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3427 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
3428 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3429
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3430 /* 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
3431 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
3432 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3433 switch (msg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3434 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3435 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3436 _wndproc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3437 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3438 case WM_SETTEXT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3439 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3440 /* 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
3441 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
3442
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3443 InvalidateRgn(hwnd, NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3444 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3445 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3446 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3447 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3448 HDC hdcPaint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3449 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3450 RECT rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3451 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
3452 TCHAR tempbuf[1025] = { 0 };
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3453 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3454 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
3455 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
3456
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3457 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
3458 GetWindowText(hwnd, tempbuf, 1024);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3459
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3460 hdcPaint = BeginPaint(hwnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3461 if(hfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3462 oldfont = (HFONT)SelectObject(hdcPaint, hfont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3463 rc.top = rc.left = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3464 rc.right = cx;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3465 rc.bottom = cy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3466 DrawStatusText(hdcPaint, &rc, tempbuf, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3467 if(hfont && oldfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3468 SelectObject(hdcPaint, oldfont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3469 if(hfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3470 DeleteObject(hfont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3471 EndPaint(hwnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3472 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3473 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3474 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3475 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
3476 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3477
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
3478 #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
3479 /* 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
3480 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
3481 {
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
3482 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
3483 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
3484
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 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
3486 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
3487
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
3488 /* 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
3489 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
3490
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
3491 /* 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
3492 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
3493 || !_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
3494 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
3495
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
3496 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
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 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
3499 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3500 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
3501 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3502 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
3503 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
3504
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3505 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
3506 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3507 /* 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
3508 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
3509 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
3510 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
3511 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
3512 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
3513
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3514 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
3515
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3516 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
3517 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3518 /* 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
3519 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
3520
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3521 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
3522 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3523 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
3524 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
3525 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
3526 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
3527 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
3528
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3529 /* 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
3530 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
3531 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
3532
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3533 /* 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
3534 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
3535 _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
3536
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3537 /* 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
3538 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
3539 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
3540 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
3541
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3542 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
3543
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3544 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
3545 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
3546
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3547 /* 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
3548 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
3549 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3550 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
3551
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3552 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
3553 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3554 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
3555 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
3556 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3557 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
3558
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3559 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
3560 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3561 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
3562 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
3563 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
3564 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
3565 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
3566 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
3567 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
3568 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
3569 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
3570 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3571
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3572 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
3573 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3574 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
3575 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
3576 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3577
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3578
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3579 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
3580 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
3581 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
3582 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
3583 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
3584 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
3585
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3586 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
3587 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
3588
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3589 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
3590 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
3591
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3592 /* 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
3593 _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
3594 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
3595 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3596 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3597 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3598
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3599 /* 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
3600 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
3601 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
3602 _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
3603 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3604 _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
3605 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3606 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3607
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3608 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
3609 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
3610 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3611 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
3612 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3613
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3614 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
3615 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
3616 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
3617 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3618 #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
3619
58
5c66a108aa47 Fixed 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 /* Function: _BtProc
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3621 * Abstract: Subclass procedure for buttons
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3622 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3623
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
3624 LRESULT CALLBACK _BtProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3625 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3626 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
3627 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
3628 int retval = -1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3629
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3630 if ( !cinfo )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3631 return DefWindowProc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3632
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3633 /* 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
3634 * window procedure because if a signal
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3635 * handler attached here destroys this
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3636 * window it will then be invalid.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3637 */
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3638 pOldProc = cinfo->pOldProc;
617
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 switch(msg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3641 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3642 case WM_CTLCOLORSTATIC:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3643 case WM_CTLCOLORLISTBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3644 case WM_CTLCOLORBTN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3645 case WM_CTLCOLOREDIT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3646 case WM_CTLCOLORMSGBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3647 case WM_CTLCOLORSCROLLBAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3648 case WM_CTLCOLORDLG:
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
3649 return _colorwndproc(hwnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3650 case WM_SETFOCUS:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3651 _wndproc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3652 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3653 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3654 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3655 SignalHandler *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3656
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3657 /* Find any callbacks for this function */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3658 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3659 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3660 if(tmp->message == WM_COMMAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3661 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3662 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3663
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3664 /* 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
3665 if(tmp->window == hwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3666 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3667 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
3668
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3669 if(checkbox)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3670 in_checkbox_handler = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3671
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
3672 retval = clickfunc(tmp->window, tmp->data);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3673
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3674 if(checkbox)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3675 in_checkbox_handler = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3676 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3677 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3678 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3679 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3680 tmp= tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3681 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3682 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3683 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3684 case WM_CHAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3685 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3686 /* 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
3687 * 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
3688 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3689 if(LOWORD(mp1) == '\r' || LOWORD(mp1) == ' ')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3690 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3691 SignalHandler *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3692
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3693 /* Find any callbacks for this function */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3694 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3695 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3696 if(tmp->message == WM_COMMAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3697 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3698 int (*clickfunc)(HWND, void *) = tmp->signalfunction;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3699
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3700 /* 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
3701 if(tmp->window == hwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3702 {
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
3703 retval = clickfunc(tmp->window, tmp->data);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3704 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3705 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3706 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3707 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3708 tmp= tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3709 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3710 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3711 if(LOWORD(mp1) == '\t')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3712 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3713 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3714 _shift_focus_back(hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3715 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3716 _shift_focus(hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3717 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3718 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3719 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3720 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3721 case WM_KEYDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3722 if(mp1 == VK_LEFT || mp1 == VK_UP)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3723 _shift_focus_back(hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3724 if(mp1 == VK_RIGHT || mp1 == VK_DOWN)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3725 _shift_focus(hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3726 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3727 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3728
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
3729 /* 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
3730 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
3731 _dw_redraw(0, FALSE);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3732 if ( !pOldProc )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3733 return DefWindowProc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3734 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
3735 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3736
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3737 /* 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
3738 * 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
3739 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3740 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
3741 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3742 RECT rect;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3743 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
3744
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3745 if(array && array[pageid])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3746 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3747 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
3748
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3749 GetClientRect(handle,&rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3750 TabCtrl_AdjustRect(handle,FALSE,&rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3751 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
3752 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
3753 if(box && box->count)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3754 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3755 ShowWindow(box->items[0].hwnd, SW_HIDE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3756 _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
3757 ShowWindow(box->items[0].hwnd, SW_SHOW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3758 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3759
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3760 ShowWindow(array[pageid]->hwnd, SW_SHOWNORMAL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3761 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3762 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3763
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
3764 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
3765 {
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
3766 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
3767
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
3768 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
3769 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
3770 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
3771
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
3772 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
3773 if(text)
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3774 {
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3775 /* 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
3776 * 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
3777 */
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3778 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
3779 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
3780 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
3781
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3782 /* 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
3783 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
3784 }
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
3785 }
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
3786
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
3787 #ifndef GDIPLUS
578
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3788 /* 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
3789 */
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3790 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
3791 {
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3792 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
3793 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
3794
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3795 *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
3796 *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
3797
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3798 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
3799 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3800 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
3801 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3802
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3803 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
3804
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3805 /* 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
3806 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
3807 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3808 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
3809 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
3810 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3811 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
3812 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
3813 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3814 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
3815 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3816 *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
3817 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
3818 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3819 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
3820 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3821 *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
3822 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
3823 }
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3824 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
3825 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3826 *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
3827 windowtype = BS_BITMAP;
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3828 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3829 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
3830 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3831 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3832 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3833 /* 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
3834 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
3835 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
3836 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3837 *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
3838 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
3839 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3840 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3841 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3842 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
3843 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
3844 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
3845 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3846 *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
3847 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
3848 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3849 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3850 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
3851 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3852 return windowtype;
578
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3853 }
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
3854 #endif
578
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3855
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3856 /* 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
3857 void _init_thread(void)
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3858 {
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3859 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
3860 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
3861 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
3862 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
3863 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
3864 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
3865
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
3866 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
3867 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
3868 GdipCreateSolidFill(gpfore, &brush);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
3869 TlsSetValue(_gpBrush, (LPVOID)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
3870 #endif
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3871 TlsSetValue(_foreground, (LPVOID)foreground);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3872 TlsSetValue(_background, (LPVOID)background);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3873 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
3874 TlsSetValue(_hBrush, CreateSolidBrush(foreground));
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3875 }
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3876
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3877 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3878 * Initializes the Dynamic Windows engine.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3879 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3880 * newthread: True if this is the only thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3881 * False if there is already a message loop running.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3882 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3883 int API dw_init(int newthread, int argc, char *argv[])
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3884 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3885 WNDCLASS wc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3886 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3887 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
3888 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
3889 #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
3890 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
3891 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3892
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3893 /* 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
3894 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
3895 {
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3896 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
3897
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3898 /* 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
3899 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
3900 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
3901
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3902 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
3903 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
3904 }
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3905 /* 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
3906 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
3907 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
3908
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3909 /* Initialize our thread local storage */
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3910 _foreground = TlsAlloc();
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3911 _background = TlsAlloc();
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3912 _hPen = TlsAlloc();
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3913 _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
3914 #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
3915 _gpPen = TlsAlloc();
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
3916 _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
3917 #endif
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3918
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3919 icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3920 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
3921
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3922 InitCommonControlsEx(&icc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3923
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3924 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
3925
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3926 /* Register the generic Dynamic Windows class */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3927 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3928 wc.style = CS_DBLCLKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3929 wc.lpfnWndProc = (WNDPROC)_wndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3930 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3931 wc.cbWndExtra = 32;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3932 wc.hbrBackground = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3933 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3934 wc.lpszClassName = ClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3935
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3936 RegisterClass(&wc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3937
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3938 /* Register the splitbar control */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3939 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3940 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
3941 wc.lpfnWndProc = (WNDPROC)_splitwndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3942 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3943 wc.cbWndExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3944 wc.hbrBackground = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3945 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3946 wc.lpszClassName = SplitbarClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3947
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3948 RegisterClass(&wc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3949
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3950 /* Register the scroller control */
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3951 memset(&wc, 0, sizeof(WNDCLASS));
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3952 wc.style = CS_DBLCLKS;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3953 wc.lpfnWndProc = (WNDPROC)_scrollwndproc;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3954 wc.cbClsExtra = 0;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3955 wc.cbWndExtra = 32;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3956 wc.hbrBackground = NULL;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3957 wc.lpszMenuName = NULL;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3958 wc.lpszClassName = ScrollClassName;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3959
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3960 RegisterClass(&wc);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3961
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3962 /* 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
3963 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3964 wc.style = CS_DBLCLKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3965 wc.lpfnWndProc = (WNDPROC)_framewndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3966 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3967 wc.cbWndExtra = 32;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3968 wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_3DFACE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3969 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3970 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3971 wc.lpszClassName = FRAMECLASSNAME;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3972
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3973 RegisterClass(&wc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3974
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
3975 /* 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
3976 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
3977 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
3978 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
3979 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
3980 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
3981 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
3982 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
3983 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
3984 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
3985
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
3986 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
3987
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3988 #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
3989 /* Register HTML renderer class */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3990 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3991 wc.lpfnWndProc = (WNDPROC)_browserWindowProc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3992 wc.lpszClassName = BrowserClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3993 wc.style = CS_HREDRAW|CS_VREDRAW;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3994 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
3995 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3996
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3997 /* 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
3998 for(z=0;z<18;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3999 _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
4000
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4001 /* 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
4002 * 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
4003 * of Windows.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4004 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4005 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4006 wc.style = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4007 wc.lpfnWndProc = (WNDPROC)_wndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4008 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4009 wc.cbWndExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4010 wc.hbrBackground = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4011 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4012 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4013 wc.lpszClassName = ObjectClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4014
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4015 RegisterClass(&wc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4016
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4017 /* 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
4018 * 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
4019 * 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
4020 * 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
4021 * packed into their correct parent.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4022 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4023
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
4024 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
4025 0, 0, HWND_DESKTOP, NULL, DWInstance, NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4026
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4027 if(!DW_HWND_OBJECT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4028 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4029 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
4030 exit(1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4031 }
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
4032
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
4033 /* 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
4034 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
4035 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
4036
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
4037 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
4038
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
4039 /* 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
4040 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
4041
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4042 /* 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
4043 dwVersion = GetVersion();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4044 dwComctlVer = GetDllVersion(TEXT("comctl32.dll"));
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 /* Initialize Security for named events and memory */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4047 InitializeSecurityDescriptor(&_dwsd, SECURITY_DESCRIPTOR_REVISION);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4048 SetSecurityDescriptorDacl(&_dwsd, TRUE, (PACL) NULL, FALSE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4049
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4050 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
4051
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
4052 /*
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
4053 * 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
4054 */
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
4055 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
4056 {
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
4057 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
4058 }
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
4059 else
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
4060 {
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
4061 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
4062 }
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
4063
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
4064 #ifdef GDIPLUS
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
4065 /* Setup GDI+ */
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
4066 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
4067 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
4068 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
4069 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
4070 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
4071 #endif
1628
2571d6b23065 _init_thread() needs to be called after initializing GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1627
diff changeset
4072
2571d6b23065 _init_thread() needs to be called after initializing GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1627
diff changeset
4073 /* 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
4074 _init_thread();
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
4075
1730
3828f3faec8c Had to move uxtheme/SetWindowTheme out of the AERO #ifdefs to get
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1729
diff changeset
4076 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
4077 _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
4078 #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
4079 /* 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
4080 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
4081 {
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
4082 _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
4083 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
4084 _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
4085 _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
4086 _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
4087 _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
4088 _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
4089 _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
4090 _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
4091 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
4092 /* 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
4093 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
4094 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
4095 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
4096 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
4097 }
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
4098 #endif
1550
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
4099 #ifdef RICHEDIT
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
4100 /* 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
4101 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
4102 hrichedit = LoadLibrary("riched32");
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
4103 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4104 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4105 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4106
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4107 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
4108
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4109 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4110 * 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
4111 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4112 void API dw_main(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4113 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4114 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4115
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4116 _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
4117 /* 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
4118 _dw_redraw(0, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4119
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4120 /* 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
4121 _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
4122
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4123 /* 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
4124 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
4125 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4126 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
4127 _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
4128 else
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 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4131 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4132 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4133 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4134 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4135
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4136 /*
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4137 * 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
4138 */
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4139 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
4140 {
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4141 _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
4142 }
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4143
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4144 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4145 * 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
4146 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4147 * 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
4148 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4149 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
4150 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4151 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4152 double start = (double)clock();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4153
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4154 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
4155 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4156 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
4157 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4158 GetMessage(&msg, NULL, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4159 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
4160 _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
4161 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4162 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4163 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4164 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4165 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4166 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4167 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4168 Sleep(1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4169 }
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4170 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4171
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4172 /*
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
4173 * 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
4174 */
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4175 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
4176 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4177 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4178
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4179 _dwtid = dw_thread_id();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4180
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4181 if(GetMessage(&msg, NULL, 0, 0))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4182 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4183 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
4184 _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
4185 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4186 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4187 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4188 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4189 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4190 }
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
4191 }
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4192
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4193 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4194 * Free's memory allocated by dynamic windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4195 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4196 * ptr: Pointer to dynamic windows allocated
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4197 * memory to be free()'d.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4198 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4199 void API dw_free(void *ptr)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4200 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4201 free(ptr);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4202 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4203
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4204 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4205 * Allocates and initializes a dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4206 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4207 * data: User defined data to be passed to functions.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4208 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4209 DWDialog * API dw_dialog_new(void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4210 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4211 DWDialog *tmp = malloc(sizeof(DWDialog));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4212
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4213 tmp->eve = dw_event_new();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4214 dw_event_reset(tmp->eve);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4215 tmp->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4216 tmp->done = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4217 tmp->result = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4218
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4219 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4220 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4221
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4222 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4223 * Accepts a dialog struct and returns the given data to the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4224 * initial called of dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4225 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4226 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4227 * result: Data to be returned by dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4228 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4229 int API dw_dialog_dismiss(DWDialog *dialog, void *result)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4230 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4231 dialog->result = result;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4232 dw_event_post(dialog->eve);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4233 dialog->done = TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4234 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4235 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4236
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4237 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4238 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4239 * called by a signal handler with the given dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4240 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4241 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4242 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4243 void * API dw_dialog_wait(DWDialog *dialog)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4244 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4245 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4246 void *tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4247
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4248 while (GetMessage(&msg,NULL,0,0))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4249 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4250 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
4251 _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
4252 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4253 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4254 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4255 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4256 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4257 if(dialog->done)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4258 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4259 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4260 dw_event_close(&dialog->eve);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4261 tmp = dialog->result;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4262 free(dialog);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4263 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4264 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4265
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4266 /*
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
4267 * 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
4268 * 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
4269 * 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
4270 * ...: 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
4271 */
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
4272 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
4273 {
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
4274 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
4275 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
4276
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
4277 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
4278 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
4279 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
4280
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
4281 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
4282 }
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
4283
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
4284 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4285 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4286 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4287 * title: The title of the message box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4288 * format: printf style format string.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4289 * ...: Additional variables for use in the format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4290 */
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 389
diff changeset
4291 int API dw_messagebox(char *title, int flags, char *format, ...)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4292 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4293 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
4294 char outbuf[1025] = { 0 }, *thisbuf = outbuf;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4295 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4296
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4297 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
4298 vsnprintf(outbuf, 1024, format, args);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4299 va_end(args);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4300
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
4301 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
4302 if(rc == IDOK)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4303 return DW_MB_RETURN_OK;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4304 else if(rc == IDYES)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4305 return DW_MB_RETURN_YES;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4306 else if(rc == IDNO)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4307 return DW_MB_RETURN_NO;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4308 else if(rc == IDCANCEL)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4309 return DW_MB_RETURN_CANCEL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4310 else return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4311 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4312
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4313 /*
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4314 * 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
4315 * 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
4316 * 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
4317 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4318 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
4319 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4320 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
4321 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4322
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4323 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4324 * Makes the window topmost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4325 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4326 * 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
4327 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4328 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
4329 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4330 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
4331 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4332
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4333 /*
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4334 * Makes the window bottommost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4335 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4336 * 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
4337 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4338 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
4339 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4340 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
4341 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4342
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4343 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4344 * Makes the window visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4345 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4346 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4347 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4348 int API dw_window_show(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4349 {
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
4350 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
4351 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
4352
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
4353 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
4354
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
4355 /* 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
4356 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
4357 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
4358
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
4359 rc = ShowWindow(handle, SW_SHOW);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4360 SetFocus(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4361 _initial_focus(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4362 return rc;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4363 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4364
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4365 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4366 * Makes the window invisible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4367 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4368 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4369 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4370 int API dw_window_hide(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4371 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4372 return ShowWindow(handle, SW_HIDE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4373 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4374
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4375 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4376 * Destroys a window and all of it's children.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4377 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4378 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4379 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4380 int API dw_window_destroy(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4381 {
1371
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4382 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
4383 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
4384
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4385 /* 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
4386 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
4387 {
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4388 char buffer[31] = {0};
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4389 ULONG id = (ULONG)handle;
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4390
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4391 _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
4392 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
4393
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4394 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
4395 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
4396 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
4397 }
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4398
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4399 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
4400 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
4401
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
4402 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
4403 _free_menu_data(menu);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4404
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
4405 /* 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
4406 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
4407 {
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
4408 dw_box_unpack(handle);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4409 _free_window_memory(handle, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4410 EnumChildWindows(handle, _free_window_memory, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4411 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4412 return DestroyWindow(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4413 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4414
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
4415 /* 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
4416 * 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
4417 * 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
4418 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4419 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
4420 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4421 Box *mybox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4422
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4423 if(mybox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4424 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4425 RECT rect;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4426 int istoplevel = (GetParent(handle) == HWND_DESKTOP);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4427
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4428 GetClientRect(handle, &rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4429
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4430 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
4431 _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
4432 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
4433 }
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
4434 }
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
4435
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4436 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4437 * Changes a window's parent to newparent.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4438 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4439 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4440 * newparent: The window's new parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4441 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4442 void API dw_window_reparent(HWND handle, HWND newparent)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4443 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4444 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
4445 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4446
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4447 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
4448 {
1621
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4449 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
4450 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
4451 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
4452
1621
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4453 /* 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
4454 if(myFontName)
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4455 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
4456 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
4457 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
4458
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4459 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
4460 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
4461 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
4462 lf.lfWidth = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4463 lf.lfEscapement = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4464 lf.lfOrientation = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4465 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
4466 lf.lfUnderline = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4467 lf.lfStrikeOut = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4468 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
4469 lf.lfCharSet = DEFAULT_CHARSET;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4470 lf.lfOutPrecision = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4471 lf.lfClipPrecision = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4472 lf.lfQuality = DEFAULT_QUALITY;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4473 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
4474 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
4475 *Italic = 0;
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4476 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
4477 *Bold = 0;
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4478 _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
4479 free(myFontName);
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4480 return lf;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4481 }
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4482
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
4483 /* 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
4484 * 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
4485 */
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
4486 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
4487 {
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
4488 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
4489 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
4490 }
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
4491
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
4492 /* 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
4493 * 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
4494 */
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4495 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
4496 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4497 HFONT hfont = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4498
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4499 if(fontname != DefaultFont && fontname[0])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4500 {
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4501 LOGFONT lf = _get_logfont(hdc, fontname);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4502 hfont = CreateFontIndirect(&lf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4503 }
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
4504 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
4505 hfont = _DupFontHandle(_DefaultFont);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4506 if(!hfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4507 hfont = GetStockObject(DEFAULT_GUI_FONT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4508 return hfont;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4509 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4510
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4511 /* 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
4512 * 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
4513 */
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4514 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
4515 {
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4516 HDC hdc = GetDC(handle);
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4517 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
4518 ReleaseDC(handle, hdc);
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4519 return hfont;
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4520 }
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4521
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4522 /*
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
4523 * 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
4524 * 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
4525 * 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
4526 */
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
4527 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
4528 {
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
4529 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
4530
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
4531 _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
4532 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
4533 {
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
4534 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
4535 }
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
4536 }
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
4537
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
4538 /* 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
4539 * 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
4540 */
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4541 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
4542 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4543 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
4544 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
4545
22ba64e357de 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 /* 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
4547 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
4548 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4549 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
4550 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4551 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
4552 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
4553
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4554 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
4555 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4556 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
4557 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
4558 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4559 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4560 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4561 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
4562 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4563
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4564 /* 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
4565 * 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
4566 *
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
4567 * 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
4568 * 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
4569 * 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
4570 * 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
4571 * 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
4572 * 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
4573 * 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
4574 */
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4575 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
4576 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4577 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
4578 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
4579 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
4580 HBITMAP hbm = 0;
1658
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4581 HICON hic = 0;
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4582 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
4583
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4584 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
4585
1660
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4586 /* 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
4587 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
4588 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
4589 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
4590 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
4591
1658
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4592 /* 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
4593 if(hic)
1658
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4594 {
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4595 if(GetIconInfo(hic, &ii))
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4596 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
4597 }
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4598
1660
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4599 /* 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
4600 if(!hbm)
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4601 {
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4602 /* 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
4603 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
4604 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
4605 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
4606 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
4607 }
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4608
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
4609 /* 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
4610 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
4611 {
1448
508dde3dc398 Windows needs a little more extra vertical space for text buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1445
diff changeset
4612 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
4613
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4614 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
4615 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
4616 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
4617 }
1792
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4618 else
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4619 {
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4620 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
4621
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4622 /* 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
4623 * 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
4624 */
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4625 if(buf)
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4626 {
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4627 if(*buf)
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4628 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
4629 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
4630 _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
4631 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
4632 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
4633 }
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4634 }
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
4635
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
4636 /* Combobox */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4637 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
4638 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4639 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
4640 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
4641 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
4642 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
4643 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
4644 }
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
4645 /* 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
4646 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
4647 _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
4648 _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
4649 {
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4650 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
4651 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
4652 {
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4653 /* 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
4654 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
4655 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
4656 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4657 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
4658 {
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4659 /* 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
4660 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
4661 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
4662 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4663 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4664 /* Spinbuttons */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4665 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
4666 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4667 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
4668 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
4669 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
4670 }
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4671 #ifdef TOOLBAR
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4672 /* Bitmap Buttons */
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4673 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
4674 {
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4675 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
4676 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
4677
1729
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4678 if(imlist)
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4679 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
4680
1728
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4681 /* 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
4682 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
4683 minsize = 20;
1729
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4684 else
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4685 {
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4686 thiswidth += 4;
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4687 thisheight += 4;
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4688 }
1728
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4689
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4690 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
4691 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
4692 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
4693 thisheight = minsize;
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4694 }
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4695 #endif
1570
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4696 /* Listbox */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4697 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
4698 {
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4699 char buf[1025] = {0};
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4700 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
4701 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
4702
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4703 thisheight = 8;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4704
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4705 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
4706 {
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4707 int height, width = 0;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4708
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4709 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
4710
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4711 if(strlen(buf))
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4712 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
4713 else
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4714 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
4715
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4716 width += basicwidth;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4717
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4718 if(width > thiswidth)
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4719 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
4720 thisheight += height;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4721 }
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4722
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4723 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
4724 thiswidth = _DW_SCROLLED_MIN_WIDTH;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4725 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
4726 thisheight = _DW_SCROLLED_MIN_HEIGHT;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4727 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
4728 thisheight = _DW_SCROLLED_MAX_HEIGHT;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4729 }
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
4730 /* 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
4731 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
4732 _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
4733 {
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
4734 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
4735 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
4736 {
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4737 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
4738 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
4739 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
4740 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
4741
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4742 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
4743 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
4744 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
4745 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
4746 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
4747
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4748 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
4749
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4750 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
4751 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
4752 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
4753 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
4754
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
4755 /* MLE */
1581
a80ec948c3eb Fixed a MinGW warning and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1570
diff changeset
4756 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
4757 {
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4758 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
4759 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
4760 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
4761 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
4762 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
4763 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
4764
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4765 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
4766
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4767 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
4768 {
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4769 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
4770 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
4771 }
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4772 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
4773 {
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4774 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
4775 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
4776 }
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4777 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
4778 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
4779 }
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4780
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4781 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
4782 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
4783 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
4784 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
4785 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
4786 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
4787 }
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
4788 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
4789 {
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
4790 /* 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
4791 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
4792 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
4793 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
4794 }
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
4795 }
1542
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4796 /* Container */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4797 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
4798 {
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4799 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
4800
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4801 thiswidth = LOWORD(result);
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4802 thisheight = HIWORD(result);
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4803
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4804 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
4805 thiswidth = _DW_SCROLLED_MAX_WIDTH;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4806 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
4807 thiswidth = _DW_SCROLLED_MIN_WIDTH;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4808 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
4809 thisheight = _DW_SCROLLED_MIN_HEIGHT;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4810 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
4811 thisheight = _DW_SCROLLED_MAX_HEIGHT;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4812 }
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4813 /* Tree */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4814 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
4815 {
1566
035bc006afbe Experimental change... halfway between min and max for tree controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1561
diff changeset
4816 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
4817 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
4818 }
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
4819 /* Buttons */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4820 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
4821 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4822 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
4823
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
4824 /* 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
4825 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
4826 {
1431
0676561865ac Better extra border values for bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
4827 extrawidth = 5;
0676561865ac Better extra border values for bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
4828 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
4829 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4830 /* 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
4831 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
4832 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4833 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
4834 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
4835 }
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
4836 /* 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
4837 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
4838 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4839 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
4840 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
4841 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4842 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4843 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
4844 {
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
4845 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
4846 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
4847 }
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
4848
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4849 /* 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
4850 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
4851 *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
4852 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
4853 *height = thisheight + extraheight;
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4854
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4855 /* Free temporary bitmaps */
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4856 if(ii.hbmColor)
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4857 DeleteObject(ii.hbmColor);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4858 if(ii.hbmMask);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4859 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
4860 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4861
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
4862 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4863 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4864 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4865 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4866 * fontname: Name and size of the font in the form "size.fontname"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4867 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4868 int API dw_window_set_font(HWND handle, char *fontname)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4869 {
1039
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4870 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
4871 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
4872 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
4873
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4874 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
4875
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4876 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
4877 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
4878 {
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4879 /* groupbox */
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4880 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
4881 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
4882 {
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4883 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
4884 }
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4885 }
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
4886
1039
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4887 /* 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
4888 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
4889 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
4890
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
4891 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
4892 {
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4893 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
4894 {
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4895 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
4896 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
4897 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
4898 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
4899 }
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4900 else
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4901 {
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4902 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
4903 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
4904
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
4905 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
4906
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4907 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
4908 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
4909 }
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4910 }
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
4911 /* 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
4912 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
4913 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4914 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
4915
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4916 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
4917 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
4918 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
4919
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4920 /* 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
4921 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
4922 {
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
4923 _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
4924 /* 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
4925 _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
4926 }
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
4927 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
4928 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4929 return DW_ERROR_UNKNOWN;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4930 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4931
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4932 /* 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
4933 * Parameters:
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4934 * currfont: current font
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4935 * Returns:
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4936 * 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
4937 */
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4938 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
4939 {
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4940 CHOOSEFONT cf = { 0 };
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4941 LOGFONT lf = { 0 };
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4942 char *str = NULL;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4943 char *bold = "";
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4944 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
4945
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4946 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
4947 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
4948
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4949 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
4950 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
4951 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
4952
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4953 if(ChooseFont(&cf))
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4954 {
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
4955 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
4956 if ( str )
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4957 {
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4958 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
4959 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
4960
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4961 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
4962 bold = " Bold";
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4963 if ( lf.lfItalic )
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4964 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
4965 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
4966 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
4967 _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
4968 }
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4969 }
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4970 return str;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4971 }
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4972
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4973 /*
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4974 * 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
4975 * Parameters:
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4976 * handle: The window (widget) handle.
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4977 * 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
4978 */
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4979 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
4980 {
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4981 HFONT oldfont = NULL;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4982 char *str = NULL;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4983 char *bold = "";
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4984 char *italic = "";
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4985 LOGFONT lf = { 0 };
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4986 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
4987 TCHAR tmpbuf[100] = {0};
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4988
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4989 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
4990 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
4991 {
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4992 /* groupbox */
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4993 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
4994 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
4995 {
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4996 handle = thisbox->grouphwnd;
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4997 }
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4998 }
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4999 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
5000 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
5001 {
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
5002 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
5003 if ( str )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5004 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5005 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
5006 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
5007
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5008 if ( lf.lfWeight > FW_MEDIUM )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5009 bold = " Bold";
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5010 if ( lf.lfItalic )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5011 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
5012 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
5013 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
5014 _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
5015 }
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
5016 }
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5017 if ( oldfont )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5018 DeleteObject( oldfont );
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5019 return str;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5020 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5021
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5022 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5023 * Sets the colors used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5024 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5025 * 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
5026 * 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
5027 * back: Background color in RGB format.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5028 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5029 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5030 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5031 ColorInfo *cinfo;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5032 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
5033 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5034
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5035 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
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 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5038
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5039 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
5040 {
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
5041 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
5042 cinfo->back = back = _internal_color(back);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5043
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5044 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
5045 DW_GREEN_VALUE(fore),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5046 DW_BLUE_VALUE(fore)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5047 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
5048 DW_GREEN_VALUE(back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5049 DW_BLUE_VALUE(back)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5050 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
5051 DW_GREEN_VALUE(back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5052 DW_BLUE_VALUE(back)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5053 InvalidateRgn(handle, NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5054 return TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5055 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5056 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
5057 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5058 /* groupbox */
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5059 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
5060 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
5061 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5062 thisbox->cinfo.fore = fore;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5063 thisbox->cinfo.back = back;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5064 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5065 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5066
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5067 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5068 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5069 cinfo->fore = fore;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5070 cinfo->back = back;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5071 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5072 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5073 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5074 cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5075
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5076 cinfo->fore = fore;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5077 cinfo->back = back;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5078
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5079 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5080 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5081 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5082 InvalidateRgn(handle, NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5083 return TRUE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5084 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5085
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5086 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5087 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5088 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5089 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5090 * border: Size of the window border in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5091 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5092 int API dw_window_set_border(HWND handle, int border)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5093 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5094 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5095 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5096
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5097 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5098 * Captures the mouse input to this window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5099 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5100 * handle: Handle to receive mouse input.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5101 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5102 void API dw_window_capture(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5103 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5104 SetCapture(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5105 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5106
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5107 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5108 * Releases previous mouse capture.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5109 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5110 void API dw_window_release(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5111 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5112 ReleaseCapture();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5113 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5114
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5115 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5116 * 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
5117 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5118 * 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
5119 * 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
5120 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
5121 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
5122 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5123 HCURSOR cursor = pointertype < 65536 ? LoadCursor(NULL, MAKEINTRESOURCE(pointertype)) : (HCURSOR)pointertype;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5124
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5125 if(!pointertype)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5126 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
5127 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5128 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5129 dw_window_set_data(handle, "_dw_cursor", (void *)cursor);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5130 SetCursor(cursor);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5131 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5132 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5133
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5134 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5135 * Create a new Window Frame.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5136 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5137 * owner: The Owner's window handle or HWND_DESKTOP.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5138 * 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
5139 * flStyle: Style flags, see the DW reference.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5140 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5141 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5142 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5143 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5144 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
5145 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
5146 #ifdef AEROGLASS
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5147 MARGINS mar = {-1};
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
5148
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
5149 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
5150 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
5151 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5152
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5153 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
5154 newbox->vsize = newbox->hsize = SIZEEXPAND;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5155 newbox->cinfo.fore = newbox->cinfo.back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5156
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5157 if(!(flStyle & WS_CAPTION))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5158 flStyle |= WS_POPUPWINDOW;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5159
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
5160 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
5161 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
5162 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5163 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
5164 0, 0, hwndOwner, NULL, DWInstance, NULL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5165 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5166 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5167 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5168 flStyleEx |= WS_EX_TOOLWINDOW;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5169
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5170 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
5171 0, 0, hwndOwner, NULL, DWInstance, NULL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5172 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5173 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5174
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5175 if(hwndOwner)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5176 SetParent(hwndframe, hwndOwner);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5177
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5178 #ifdef AEROGLASS
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5179 /* 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
5180 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
5181 {
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
5182 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
5183 _DwmExtendFrameIntoClientArea(hwndframe, &mar);
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
5184 }
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5185 #endif
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5186
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5187 return hwndframe;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5188 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5189
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5190 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5191 * Create a new Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5192 * 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
5193 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5194 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5195 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5196 HWND API dw_box_new(int type, int pad)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5197 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5198 Box *newbox = calloc(sizeof(Box), 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5199 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5200
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5201 newbox->pad = pad;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5202 newbox->type = type;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5203 newbox->count = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5204 newbox->grouphwnd = (HWND)NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5205 newbox->cinfo.fore = newbox->cinfo.back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5206
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5207 hwndframe = CreateWindow(FRAMECLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5208 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5209 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
5210 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5211 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5212 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5213 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5214 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5215
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5216 newbox->cinfo.pOldProc = SubclassWindow(hwndframe, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5217 newbox->cinfo.fore = newbox->cinfo.back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5218
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5219 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5220 return hwndframe;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5221 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5222
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5223 /*
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5224 * 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
5225 * Parameters:
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5226 * 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
5227 * 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
5228 */
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5229 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
5230 {
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5231 ColorInfo *cinfo = calloc(sizeof(ColorInfo), 1);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5232 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
5233 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
5234 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
5235
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5236 cinfo->fore = cinfo->back = -1;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5237
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5238 hwndframe = CreateWindow(ScrollClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5239 NULL,
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5240 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
5241 0,0,0,0,
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5242 DW_HWND_OBJECT,
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5243 NULL,
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5244 DWInstance,
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5245 NULL);
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5246
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5247 cinfo->buddy = box;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5248 cinfo->combo = tmpbox;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5249 SetParent(tmpbox, hwndframe);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5250 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)cinfo);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5251 return hwndframe;
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5252 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5253
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5254 /*
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5255 * 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
5256 * Parameters:
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5257 * 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
5258 * 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
5259 */
833
53b677d126dc Scrollbox cleanups on Windows and added stubs on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 832
diff changeset
5260 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
5261 {
842
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5262 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
5263 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
5264
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5265 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
5266 {
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5267 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
5268 }
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5269
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5270 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
5271 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
5272
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5273 /* 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
5274 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
5275 {
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5276 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
5277 }
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5278 return si.nPos;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5279 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5280
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5281 /*
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5282 * 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
5283 * Parameters:
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5284 * 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
5285 * 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
5286 */
833
53b677d126dc Scrollbox cleanups on Windows and added stubs on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 832
diff changeset
5287 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
5288 {
842
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5289 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
5290 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
5291
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5292 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
5293 {
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5294 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
5295 }
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5296
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5297 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
5298 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
5299
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5300 /* 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
5301 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
5302 {
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5303 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
5304 }
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5305 return si.nMax;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5306 }
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5307 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5308 * Create a new Group Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5309 * 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
5310 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5311 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5312 * title: Text to be displayined in the group outline.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5313 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5314 HWND API dw_groupbox_new(int type, int pad, char *title)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5315 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5316 Box *newbox = calloc(sizeof(Box), 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5317 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5318
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5319 newbox->pad = pad;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5320 newbox->type = type;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5321 newbox->count = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5322 newbox->cinfo.fore = newbox->cinfo.back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5323
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5324 hwndframe = CreateWindow(FRAMECLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5325 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5326 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
5327 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5328 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5329 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5330 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5331 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5332
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5333 newbox->grouphwnd = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5334 UTF8toWide(title),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5335 WS_CHILD | BS_GROUPBOX |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5336 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
5337 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5338 hwndframe,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5339 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5340 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5341 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5342
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5343 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
5344 dw_window_set_font(hwndframe, DefaultFont);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5345 return hwndframe;
3
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 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5349 * 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
5350 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5351 * 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
5352 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5353 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
5354 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5355 CLIENTCREATESTRUCT ccs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5356 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5357
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5358 ccs.hWindowMenu = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5359 ccs.idFirstChild = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5360
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5361 hwndframe = CreateWindow(TEXT("MDICLIENT"),
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5362 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5363 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
5364 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5365 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5366 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5367 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5368 &ccs);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5369 return hwndframe;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5370 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5371
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5372 /*
584
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5373 * 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
5374 * Parameters:
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5375 * 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
5376 */
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5377 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
5378 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5379 #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
5380 return CreateWindow(BrowserClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5381 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5382 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
5383 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5384 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5385 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5386 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5387 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
5388 #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
5389 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
5390 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
5391 #endif
584
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5392 }
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5393
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5394 #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
5395 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
5396 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
5397 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
5398 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5399
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5400 /*
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5401 * 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
5402 * Parameters:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5403 * 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
5404 * 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
5405 */
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5406 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
5407 {
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5408 #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
5409 _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
5410 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5411 }
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5412
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5413 /*
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5414 * 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
5415 * Parameters:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5416 * 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
5417 * 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
5418 * be rendered.
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5419 * Returns:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5420 * 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
5421 */
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5422 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
5423 {
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5424 #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
5425 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
5426 #else
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5427 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
5428 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5429 }
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5430
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5431 /*
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5432 * 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
5433 * Parameters:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5434 * 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
5435 * 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
5436 * 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
5437 * Returns:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5438 * 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
5439 */
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5440 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
5441 {
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5442 #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
5443 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
5444 #else
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5445 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
5446 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5447 }
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5448
584
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5449 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5450 * Create a bitmap object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5451 * 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
5452 * id: An ID to be used with dw_window_from_id or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5453 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5454 HWND API dw_bitmap_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5455 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5456 return CreateWindow(STATICCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5457 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
5458 SS_BITMAP | SS_CENTERIMAGE | WS_VISIBLE |
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5459 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
5460 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5461 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5462 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5463 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5464 NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5465 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5466
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5467 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5468 * Create a notebook object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5469 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5470 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5471 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5472 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5473 HWND API dw_notebook_new(ULONG id, int top)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5474 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5475 ULONG flags = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5476 HWND tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5477 NotebookPage **array = calloc(256, sizeof(NotebookPage *));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5478
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5479 if(!top)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5480 flags = TCS_BOTTOM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5481
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5482 tmp = CreateWindow(WC_TABCONTROL,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5483 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5484 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
5485 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5486 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5487 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5488 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5489 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5490 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
5491 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5492 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5493 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5494
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5495 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5496 * Create a menu object to be popped up.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5497 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5498 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5499 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5500 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5501 HMENUI API dw_menu_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5502 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5503 return (HMENUI)CreatePopupMenu();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5504 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5505
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5506 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5507 * Create a menubar on a window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5508 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5509 * location: Handle of a window frame to be attached to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5510 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5511 HMENUI API dw_menubar_new(HWND location)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5512 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5513 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
5514 MENUINFO mi;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5515
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5516 tmp = (HMENUI)CreateMenu();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5517
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
5518 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
5519 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
5520 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
5521
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
5522 SetMenuInfo( (HMENU)tmp, &mi );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5523
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5524 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
5525
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5526 SetMenu(location, (HMENU)tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5527 return location;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5528 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5529
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5530 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5531 * Destroys a menu created with dw_menubar_new or dw_menu_new.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5532 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5533 * menu: Handle of a menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5534 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5535 void API dw_menu_destroy(HMENUI *menu)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5536 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5537 if(menu)
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 HMENU mymenu = (HMENU)*menu;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5540
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5541 if(IsWindow((HWND)mymenu) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5542 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
5543 if(IsMenu(mymenu))
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5544 DestroyMenu(mymenu);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5545 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5546 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5547
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
5548 /* 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
5549 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
5550 {
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
5551 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
5552
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
5553 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
5554 {
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
5555 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
5556 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
5557 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
5558 }
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
5559 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
5560 }
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
5561
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5562 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5563 * Adds a menuitem or submenu to an existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5564 * Parameters:
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5565 * menu: The handle to the existing menu.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5566 * title: The title text on the menu item to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5567 * id: An ID to be used for message passing.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5568 * end: If TRUE memu is positioned at the end of the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5569 * 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
5570 * flags: Extended attributes to set on the menu.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5571 * submenu: Handle to an existing menu to be a submenu or NULL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5572 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5573 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
5574 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5575 MENUITEMINFO mii;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5576 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
5577 char buffer[31] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5578 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
5579 char *menutitle = title;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5580
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5581 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5582 * 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
5583 * for the menubar
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5584 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5585 if (IsWindow(menux) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5586 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
5587
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5588 memset( &mii, 0, sizeof(mii) );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5589 mii.cbSize = sizeof(MENUITEMINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5590 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
5591
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5592 /* 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
5593 if (title)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5594 {
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
5595 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
5596
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
5597 strcpy(tmp, title);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5598
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5599 while(*tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5600 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5601 if(*tmp == '~')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5602 *tmp = '&';
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5603 tmp++;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5606
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
5607 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
5608 {
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
5609 /* 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
5610 * 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
5611 */
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
5612 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
5613 {
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
5614 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
5615
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
5616 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
5617 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
5618
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
5619 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
5620 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
5621 }
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
5622 /* 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
5623 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
5624 {
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
5625 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
5626
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
5627 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
5628 {
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
5629 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
5630 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
5631 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
5632 }
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
5633 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
5634 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
5635 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5636 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
5637 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5638 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5639 mii.fType = MFT_SEPARATOR;
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 * Handle flags
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 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
5645 if ( is_checked )
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 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5648 mii.fState |= MFS_UNCHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5649 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
5650 if ( is_disabled )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5651 mii.fState |= MFS_DISABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5652 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5653 mii.fState |= MFS_ENABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5654
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5655 mii.wID = id;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5656 if (IsMenu((HMENU)submenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5657 mii.hSubMenu = (HMENU)submenu;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5658 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5659 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
5660 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
5661 mii.cch = (UINT)_tcslen(mii.dwTypeData);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5662
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5663 InsertMenuItem(mymenu, 65535, TRUE, &mii);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5664
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
5665 _snprintf(buffer, 30, "_dw_id%ld", id);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5666 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)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
5667 _snprintf(buffer, 30, "_dw_checkable%ld", id);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5668 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)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
5669 _snprintf(buffer, 30, "_dw_ischecked%ld", id);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5670 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)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
5671 _snprintf(buffer, 30, "_dw_isdisabled%ld", id);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5672 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)is_disabled );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5673
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
5674 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
5675 {
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
5676 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
5677
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
5678 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
5679 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
5680 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
5681
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
5682 SetMenuInfo( (HMENU)submenu, &mi );
617
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 if (IsWindow(menux) && !IsMenu((HMENU)menux))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5686 DrawMenuBar(menux);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5687 return (HWND)id;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5688 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5689
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5690 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5691 * 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
5692 * Deprecated: use dw_menu_item_set_state()
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5693 * Parameters:
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5694 * menu: The handle to the existing menu.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5695 * id: Menuitem id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5696 * check: TRUE for checked FALSE for not checked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5697 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5698 void API dw_menu_item_set_check(HMENUI menux, unsigned long id, int check)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5699 {
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5700 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
5701 HMENU mymenu = (HMENU)menux;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5702 char buffer[30];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5703
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5704 if (IsWindow(menux) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5705 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
5706
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5707 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5708 * 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
5709 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5710 memset( &mii, 0, sizeof(mii) );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5711 GetMenuItemInfo( mymenu, id, FALSE, &mii);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5712
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5713 mii.cbSize = sizeof(MENUITEMINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5714 mii.fMask = MIIM_STATE | MIIM_CHECKMARKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5715 if (check)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5716 mii.fState |= MFS_CHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5717 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5718 mii.fState |= MFS_UNCHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5719 SetMenuItemInfo( mymenu, id, FALSE, &mii );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5720 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5721 * Keep our internal state consistent
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5722 */
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
5723 _snprintf( buffer, 30, "_dw_ischecked%ld", id );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5724 dw_window_set_data( DW_HWND_OBJECT, buffer, (void *)check );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5725 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5726
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5727 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5728 * Sets the state of a menu item.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5729 * Parameters:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5730 * menu: The handle to the existing menu.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5731 * id: Menuitem id.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5732 * flags: DW_MIS_ENABLED/DW_MIS_DISABLED
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5733 * DW_MIS_CHECKED/DW_MIS_UNCHECKED
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5734 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5735 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
5736 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5737 MENUITEMINFO mii;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5738 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
5739 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
5740 int check;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5741 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
5742
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5743 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
5744 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
5745
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
5746 _snprintf( buffer1, 30, "_dw_ischecked%ld", id );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5747 check = (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
5748 _snprintf( buffer2, 30, "_dw_isdisabled%ld", id );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5749 disabled = (int)dw_window_get_data( DW_HWND_OBJECT, buffer2 );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5750
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5751 memset( &mii, 0, sizeof(mii) );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5752
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5753 mii.cbSize = sizeof(MENUITEMINFO);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5754 mii.fMask = MIIM_STATE | MIIM_CHECKMARKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5755 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
5756 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5757 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5758 * 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
5759 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5760 if ( state & DW_MIS_CHECKED )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5761 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5762 mii.fState |= MFS_CHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5763 check = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5764 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5765 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5766 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5767 mii.fState |= MFS_UNCHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5768 check = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5769 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5770 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5771 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5772 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5773 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5774 * ...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
5775 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5776 if ( check )
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 mii.fState |= MFS_CHECKED;
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 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5781 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5782 mii.fState |= MFS_UNCHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5783 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5784 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5785 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
5786 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5787 if ( state & DW_MIS_DISABLED )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5788 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5789 mii.fState |= MFS_DISABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5790 disabled = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5791 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5792 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5793 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5794 mii.fState |= MFS_ENABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5795 disabled = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5796 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5797 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5798 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5799 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5800 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5801 * ...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
5802 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5803 if ( disabled )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5804 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5805 mii.fState |= MFS_DISABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5806 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5807 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5808 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5809 mii.fState |= MFS_ENABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5810 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5811 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5812 SetMenuItemInfo( mymenu, id, FALSE, &mii );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5813 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5814 * Keep our internal checked state consistent
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5815 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5816 dw_window_set_data( DW_HWND_OBJECT, buffer1, (void *)check );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5817 dw_window_set_data( DW_HWND_OBJECT, buffer2, (void *)disabled );
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5818 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5819
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5820 /*
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5821 * Deletes the menu item specified
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5822 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5823 * 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
5824 * 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
5825 * Returns:
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
5826 * 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
5827 */
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
5828 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
5829 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5830 HMENU mymenu = (HMENU)menux;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5831
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5832 if ( IsWindow(menux) && !IsMenu(mymenu) )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5833 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
5834
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
5835 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
5836 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
5837
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
5838 /* 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
5839 if(id >= 30000)
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
5840 dw_signal_disconnect_by_window((HWND)id);
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
5841
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
5842 /* 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
5843 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
5844 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
5845 return DW_ERROR_NONE;
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5846 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5847
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5848 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5849 * Pops up a context menu at given x and y coordinates.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5850 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5851 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5852 * parent: Handle to the window initiating the popup.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5853 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5854 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5855 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5856 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5857 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5858 if(menu)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5859 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5860 HMENU mymenu = (HMENU)*menu;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5861
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5862 if(IsWindow(*menu) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5863 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
5864
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5865 popup = parent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5866 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
5867 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
5868 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5869 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5870
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5871
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5872 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5873 * Create a container object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5874 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5875 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5876 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5877 */
350
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
5878 HWND API dw_container_new(ULONG id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5879 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5880 HWND tmp = CreateWindow(WC_LISTVIEW,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5881 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5882 WS_VISIBLE | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5883 (multi ? 0 : LVS_SINGLESEL) |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5884 LVS_REPORT | LVS_SHOWSELALWAYS |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5885 LVS_SHAREIMAGELISTS | WS_BORDER |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5886 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
5887 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5888 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5889 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5890 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5891 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5892 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5893
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5894 if(!cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5895 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5896 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5897 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5898 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5899
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
5900 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _containerwndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5901 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
5902 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
5903
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5904 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5905 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
5906 /* 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
5907 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
5908 {
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
5909 /* 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
5910 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
5911 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5912 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5913 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5914
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5915 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5916 * 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
5917 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5918 * 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
5919 * 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
5920 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5921 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
5922 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5923 HWND tmp = CreateWindow(WC_TREEVIEW,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5924 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5925 WS_VISIBLE | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5926 TVS_HASLINES | TVS_SHOWSELALWAYS |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5927 TVS_HASBUTTONS | TVS_LINESATROOT |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5928 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
5929 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5930 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5931 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5932 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5933 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5934 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5935 TreeView_SetItemHeight(tmp, 16);
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
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
5943 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _treewndproc);
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;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5950 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5951
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5952 /*
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5953 * 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
5954 * 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
5955 * 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
5956 * 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
5957 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5958 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
5959 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5960 POINT ptl;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5961
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5962 GetCursorPos(&ptl);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5963 if(x && y)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5964 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5965 *x = ptl.x;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5966 *y = ptl.y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5967 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5968 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5969
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5970 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5971 * 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
5972 * 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
5973 * 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
5974 * 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
5975 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5976 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
5977 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5978 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
5979 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5980
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5981 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5982 * Create a new static text window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5983 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5984 * 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
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_text_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 = CreateWindow(STATICCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5990 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
5991 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
5992 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
5993 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5994 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5995 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5996 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5997 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
5998 #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
5999 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
6000
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
6001 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
6002
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
6003 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
6004 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
6005 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6006 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
6007 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
6008 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6009 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6010
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6011 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
6012 * 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
6013 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
6014 * 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
6015 * 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
6016 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6017 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
6018 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6019 HWND tmp = CreateWindow(StatusbarClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6020 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
6021 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
6022 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6023 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6024 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6025 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6026 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6027 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6028 return tmp;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
6029 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
6030
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
6031 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6032 * Create a new Multiline Editbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6033 * 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
6034 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6035 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6036 HWND API dw_mle_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6037 {
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
6038
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6039 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
6040 hrichedit ? RICHEDIT_CLASS : EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6041 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6042 WS_VISIBLE | WS_BORDER |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6043 WS_VSCROLL | ES_MULTILINE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6044 ES_WANTRETURN | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6045 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
6046 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6047 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6048 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6049 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6050 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6051 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
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 if(!cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6054 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6055 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6056 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6057 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6058
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6059 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _treewndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6060 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
6061 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
6062
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6063 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6064 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6065 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6066 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6067
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6068 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6069 * Create a new Entryfield window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6070 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6071 * 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
6072 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6073 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6074 HWND API dw_entryfield_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6075 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6076 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
6077 EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6078 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6079 ES_WANTRETURN | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6080 WS_BORDER | ES_AUTOHSCROLL |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6081 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
6082 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6083 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6084 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6085 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6086 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6087 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6088
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6089 cinfo->back = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6090
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6091 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6092 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6093 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6094 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6095 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6096
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6097 /*
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6098 * Create a new Entryfield passwird window (widget) to be packed.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6099 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6100 * 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
6101 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6102 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6103 HWND API dw_entryfield_password_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6104 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6105 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
6106 EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6107 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6108 ES_WANTRETURN | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6109 ES_PASSWORD | WS_BORDER | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6110 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
6111 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6112 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6113 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6114 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6115 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6116 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6117
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6118 cinfo->back = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6119
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6120 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6121 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6122 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6123 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6124 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6125
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6126 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
6127 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6128 ColorInfo *cinfo = (ColorInfo *)lp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6129
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6130 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6131 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6132 cinfo->buddy = handle;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6133 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6134 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6135 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6136 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
6137 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6138
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6139 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6140 * Create a new Combobox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6141 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6142 * 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
6143 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6144 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6145 HWND API dw_combobox_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6146 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6147 HWND tmp = CreateWindow(COMBOBOXCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6148 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6149 WS_CHILD | CBS_DROPDOWN | WS_VSCROLL |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6150 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
6151 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6152 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6153 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6154 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6155 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6156 ColorInfo *cinfo = (ColorInfo *)calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6157 ColorInfo *cinfo2 = (ColorInfo *)calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6158
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6159 if(!cinfo || !cinfo2)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6160 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6161 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6162 free(cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6163 if(cinfo2)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6164 free(cinfo2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6165 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6166 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6167 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6168
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6169 cinfo2->fore = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6170 cinfo2->back = cinfo->back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6171 cinfo2->combo = cinfo->combo = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6172 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
6173 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
6174
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6175 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6176 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
6177 SetWindowText(tmp, UTF8toWide(text));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6178 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6179 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6180
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6181 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6182 * Create a new button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6183 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6184 * 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
6185 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6186 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6187 HWND API dw_button_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6188 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6189 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6190
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6191 HWND tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6192 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
6193 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
6194 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
6195 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
6196 DW_HWND_OBJECT,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6197 (HMENU)id,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6198 DWInstance,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6199 NULL);
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6200 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6201 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
6202
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6203 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
6204 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
6205 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6206 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6207
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6208 #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
6209 /* 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
6210 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
6211 {
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
6212 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
6213 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
6214 {
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
6215 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
6216 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
6217
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
6218 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
6219 {
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
6220 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
6221 {
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
6222 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
6223 /* 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
6224 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
6225
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
6226 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
6227 }
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
6228 }
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
6229 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
6230 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
6231 }
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
6232 }
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
6233
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6234 /* 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
6235 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
6236 {
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6237 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
6238 HIMAGELIST imlist, dimlist;
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6239 BITMAP bmi = { 0 };
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6240 TBBUTTON tbButtons[] = {
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6241 { 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
6242 };
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6243
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6244 /* 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
6245 if(hbitmap)
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6246 {
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6247 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
6248 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
6249 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
6250 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
6251 _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
6252 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
6253 DeleteObject(hbitmap);
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6254 }
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6255 else if(icon)
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6256 {
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6257 ICONINFO iconinfo;
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6258
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6259 GetIconInfo(icon, &iconinfo);
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6260 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
6261 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
6262 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
6263 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
6264 _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
6265 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
6266 DeleteObject(iconinfo.hbmColor);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6267 DeleteObject(iconinfo.hbmMask);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6268 DestroyIcon(icon);
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6269 }
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6270 else
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6271 return 0;
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6272
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6273 /* Create the toolbar */
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6274 tmp = CreateWindowEx(0L, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | TBSTYLE_AUTOSIZE | CCS_NORESIZE |
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6275 CCS_NOPARENTALIGN | CCS_NODIVIDER, 0, 0, 100, 30, DW_HWND_OBJECT, (HMENU)id, DWInstance, NULL);
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6276
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
6277 /* 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
6278 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
6279 _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
6280
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6281 /* 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
6282 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
6283 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
6284 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
6285 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
6286 SendMessage(tmp, TB_SETDISABLEDIMAGELIST, 0, (LPARAM)dimlist);
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6287 SendMessage(tmp, TB_ADDBUTTONS, 1, (LONG) &tbButtons);
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6288
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6289 _create_tooltip(tmp, text);
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6290 return tmp;
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6291 }
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6292 #endif
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6293
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6294 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6295 * Create a new bitmap button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6296 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6297 * text: Bubble help text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6298 * id: An ID of a bitmap in the resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6299 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6300 HWND API dw_bitmapbutton_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6301 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6302 HWND tmp;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6303 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
6304 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
6305 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
6306 #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
6307 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
6308 {
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
6309 cinfo->fore = cinfo->back = -1;
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
6310 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
6311 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
6312 }
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
6313 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6314
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6315 tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6316 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6317 WS_CHILD | BS_PUSHBUTTON |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6318 WS_VISIBLE | WS_CLIPCHILDREN |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6319 (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
6320 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6321 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6322 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6323 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6324 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6325
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6326 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6327 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
6328
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6329 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
6330
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
6331 _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
6332
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6333 if(icon)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6334 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6335 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
6336 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6337 else if(hbitmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6338 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6339 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
6340 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6341 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6342 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6343
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6344 /*
281
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6345 * 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
6346 * Parameters:
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6347 * 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
6348 * 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
6349 * 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
6350 * DW pick the appropriate file extension.
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6351 * (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
6352 */
507
c607eb385e58 Added missing calling conventions. Thanks Bastian for pointing this out.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 506
diff changeset
6353 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
6354 {
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6355 HWND tmp;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6356 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6357 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
6358 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
6359 int windowtype = 0;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6360
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6361 if (!cinfo)
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6362 return 0;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6363
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
6364 #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
6365 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
6366 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
6367 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
6368 {
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
6369 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
6370 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
6371 }
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
6372 #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
6373 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
6374 #endif
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6375
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6376 #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
6377 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
6378 {
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
6379 cinfo->fore = cinfo->back = -1;
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
6380 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
6381 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
6382 }
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
6383 #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
6384 tmp = CreateWindow( BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6385 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
6386 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
6387 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
6388 DW_HWND_OBJECT,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6389 (HMENU)id,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6390 DWInstance,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6391 NULL);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6392
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6393 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6394 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
6395
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6396 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6397
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
6398 _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
6399
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
6400 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
6401 {
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
6402 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
6403 }
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
6404 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
6405 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6406 SendMessage(tmp, BM_SETIMAGE,(WPARAM) IMAGE_BITMAP, (LPARAM) hbitmap);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6407 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6408 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
6409 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6410
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6411 /*
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6412 * 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
6413 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6414 * 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
6415 * 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
6416 * 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
6417 * (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
6418 * 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
6419 */
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6420 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
6421 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6422 HWND tmp;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6423 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
6424 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
6425 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
6426 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
6427 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
6428 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
6429
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6430 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
6431 return 0;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6432
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
6433 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
6434 if ( file != NULL )
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6435 {
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6436 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
6437 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
6438 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6439 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
6440 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
6441 #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
6442 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
6443 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
6444 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
6445 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
6446 #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
6447 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
6448 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
6449 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
6450 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
6451 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
6452 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
6453 }
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
6454 #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
6455 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6456 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6457 {
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
6458 _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
6459 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
6460 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
6461 }
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
6462 _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
6463 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
6464 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6465
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6466 #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
6467 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
6468 {
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
6469 cinfo->fore = cinfo->back = -1;
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
6470 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
6471 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
6472 }
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
6473 #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
6474 tmp = CreateWindow( BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6475 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
6476 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
6477 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
6478 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
6479 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
6480 DW_HWND_OBJECT,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6481 (HMENU)id,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6482 DWInstance,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6483 NULL );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6484
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6485 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6486 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
6487
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6488 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
6489
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
6490 _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
6491
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
6492 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
6493 {
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
6494 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
6495 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6496 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
6497 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6498 SendMessage( tmp, BM_SETIMAGE, (WPARAM) IMAGE_BITMAP, (LPARAM) hbitmap);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6499 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6500 return tmp;
281
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6501 }
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6502
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6503 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6504 * Create a new spinbutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6505 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6506 * 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
6507 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6508 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6509 HWND API dw_spinbutton_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6510 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6511 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
6512 EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6513 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6514 WS_CHILD | WS_BORDER | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6515 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
6516 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6517 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6518 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6519 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6520 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6521 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6522 UPDOWN_CLASS,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6523 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6524 WS_CHILD | UDS_ALIGNRIGHT | WS_BORDER |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6525 UDS_ARROWKEYS | UDS_SETBUDDYINT |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6526 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
6527 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6528 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6529 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6530 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6531 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6532 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6533
1025
3573878d1239 Make sure the initial spinbutton limits on Windows match the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1006
diff changeset
6534 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
6535 SendMessage(tmp, UDM_SETBUDDY, (WPARAM)buddy, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6536 cinfo->back = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6537 cinfo->buddy = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6538
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6539 cinfo->pOldProc = SubclassWindow(buddy, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6540 SetWindowLongPtr(buddy, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6541
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6542 cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6543 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
6544 /* 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
6545 * 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
6546 * 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
6547 */
e8e7f048f0b8 Removed spinbutton workaround on Vista and higher... still needed for XP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1115
diff changeset
6548 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
6549 {
e8e7f048f0b8 Removed spinbutton workaround on Vista and higher... still needed for XP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1115
diff changeset
6550 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
6551 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6552
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6553 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6554 dw_window_set_font(buddy, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6555 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6556 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6557
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6558 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6559 * Create a new radiobutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6560 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6561 * 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
6562 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6563 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6564 HWND API dw_radiobutton_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6565 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6566 HWND tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6567 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6568 WS_CHILD | BS_AUTORADIOBUTTON |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6569 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
6570 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6571 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6572 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6573 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6574 NULL);
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6575 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
6576 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6577 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
6578 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
6579 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
6580 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
6581 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
6582 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6583
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6584
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6585 /*
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6586 * 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
6587 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6588 * 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
6589 * 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
6590 * 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
6591 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6592 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
6593 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6594 HWND tmp = CreateWindow(TRACKBAR_CLASS,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6595 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6596 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6597 (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
6598 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6599 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6600 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6601 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6602 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6603 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6604
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6605 cinfo->back = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6606
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6607 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6608 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6609 SendMessage(tmp, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(0, increments-1));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6610 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6611 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6612
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6613 /*
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6614 * 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
6615 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6616 * 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
6617 * 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
6618 * 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
6619 */
511
80dbd5a1f403 Removed the increments parameter from dw_scrollbar_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 510
diff changeset
6620 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
6621 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6622 HWND tmp = CreateWindow(SCROLLBARCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6623 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6624 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6625 (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
6626 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6627 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6628 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6629 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6630 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6631 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6632
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6633 cinfo->back = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6634
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6635 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6636 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6637 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
6638 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
6639 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6640
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6641 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 32
diff changeset
6642 * Create a new percent bar window (widget) to be packed.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6643 * 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
6644 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6645 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6646 HWND API dw_percent_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6647 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6648 return CreateWindow(PROGRESS_CLASS,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6649 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6650 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
6651 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6652 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6653 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6654 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6655 NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6656 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6657
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6658 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6659 * Create a new checkbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6660 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6661 * 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
6662 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6663 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6664 HWND API dw_checkbox_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6665 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6666 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
6667 HWND tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6668 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6669 WS_CHILD | BS_AUTOCHECKBOX |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6670 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
6671 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6672 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6673 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6674 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6675 NULL);
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6676 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
6677 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
6678 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
6679 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
6680 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
6681 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6682 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6683
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6684 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6685 * Create a new listbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6686 * 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
6687 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6688 * multi: Multiple select TRUE or FALSE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6689 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6690 HWND API dw_listbox_new(ULONG id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6691 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6692 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6693 LISTBOXCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6694 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6695 WS_VISIBLE | LBS_NOINTEGRALHEIGHT |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6696 WS_CHILD | LBS_HASSTRINGS |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6697 LBS_NOTIFY | WS_BORDER | WS_CLIPCHILDREN |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6698 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
6699 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6700 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6701 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6702 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6703 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6704 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6705
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6706 if(!cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6707 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6708 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6709 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6710 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6711
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6712 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
6713 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
6714 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _containerwndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6715
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6716 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6717 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6718 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6719 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6720
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6721 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6722 * Sets the icon used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6723 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6724 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6725 * id: An ID to be used to specify the icon.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6726 */
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
6727 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
6728 {
975
52cd98b7e45c Changed to using HANDLE as the base type for HICN on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 970
diff changeset
6729 int iicon = (int)icon;
52cd98b7e45c Changed to using HANDLE as the base type for HICN on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 970
diff changeset
6730 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
6731
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6732 SendMessage(handle, WM_SETICON,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6733 (WPARAM) IMAGE_ICON,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6734 (LPARAM) hicon);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
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
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6737 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6738 * Sets the bitmap used for a given static window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6739 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6740 * 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
6741 * 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
6742 * (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
6743 * 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
6744 * 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
6745 * 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
6746 */
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6747 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
6748 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
6749 HBITMAP hbitmap = 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6750 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0);
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
6751 HANDLE icon = 0;
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
6752 HANDLE oldicon = (HICON)SendMessage(handle, STM_GETIMAGE, IMAGE_ICON, 0);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6753
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6754 if(id)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6755 {
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
6756 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
6757 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
6758 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6759 else if(filename)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6760 {
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
6761 #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
6762 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
6763 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6764 _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
6765 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6766 if (icon == 0 && hbitmap == 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6767 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6768 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6769
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6770 if(icon)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6771 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6772 SendMessage(handle, BM_SETIMAGE,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6773 (WPARAM) IMAGE_ICON,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6774 (LPARAM) icon);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6775 SendMessage(handle, STM_SETIMAGE,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6776 (WPARAM) IMAGE_ICON,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6777 (LPARAM) icon);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6778 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6779 else if(hbitmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6780 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6781 SendMessage(handle, BM_SETIMAGE,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6782 (WPARAM) IMAGE_BITMAP,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6783 (LPARAM) hbitmap);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6784 SendMessage(handle, STM_SETIMAGE,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6785 (WPARAM) IMAGE_BITMAP,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6786 (LPARAM) hbitmap);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6787 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6788
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6789 if(hbitmap && oldbitmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6790 DeleteObject(oldbitmap);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6791 else if(icon && oldicon)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6792 DeleteObject(oldicon);
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
6793
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
6794 /* If we changed the bitmap... */
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
6795 {
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
6796 Item *item = _box_item(handle);
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
6797
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
6798 /* Check to see if any of the sizes need to be recalculated */
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
6799 if(item && (item->origwidth == -1 || item->origheight == -1))
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
6800 {
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
6801 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL);
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
6802 /* 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
6803 _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
6804 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
6805 }
578
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
6806 }
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
6807
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6808 /*
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6809 * 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
6810 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6811 * 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
6812 * 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
6813 * (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
6814 * 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
6815 * 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
6816 * 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
6817 * 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
6818 */
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6819 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
6820 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6821 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
6822 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0);
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6823 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
6824 HICON oldicon = (HICON)SendMessage(handle, STM_GETIMAGE, IMAGE_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
6825 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
6826 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
6827
1717
8228b3cf8f37 Same fix on Windows as I just committed on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6828 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
6829 {
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
6830 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
6831 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
6832 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6833 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
6834 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
6835 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6836 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
6837 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
6838 #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
6839 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
6840 #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
6841 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
6842 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
6843 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
6844 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
6845 #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
6846 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6847 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6848 {
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
6849 _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
6850 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
6851 return;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6852 }
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
6853 _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
6854 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
6855 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6856 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
6857 return;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6858 }
1717
8228b3cf8f37 Same fix on Windows as I just committed on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6859 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
6860 {
8228b3cf8f37 Same fix on Windows as I just committed on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6861 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
6862 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
6863 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6864
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6865 if ( icon )
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6866 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6867 SendMessage( handle, BM_SETIMAGE,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6868 (WPARAM) IMAGE_ICON,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6869 (LPARAM) icon );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6870 SendMessage( handle, STM_SETIMAGE,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6871 (WPARAM) IMAGE_ICON,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6872 (LPARAM) icon );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6873 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6874 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
6875 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6876 SendMessage( handle, BM_SETIMAGE,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6877 (WPARAM) IMAGE_BITMAP,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6878 (LPARAM) hbitmap );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6879 SendMessage( handle, STM_SETIMAGE,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6880 (WPARAM) IMAGE_BITMAP,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6881 (LPARAM) hbitmap );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6882 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6883
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6884 if( hbitmap && oldbitmap )
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6885 DeleteObject( oldbitmap );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6886 else if ( icon && oldicon )
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6887 DeleteObject( oldicon );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6888 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6889
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6890
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6891 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6892 * Sets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6893 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6894 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6895 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6896 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6897 void API dw_window_set_text(HWND handle, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6898 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6899 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
6900 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
6901
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6902 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6903
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6904 SetWindowText(handle, wtext);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6905
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6906 /* Combobox */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6907 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
6908 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
6909 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
6910 {
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6911 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
6912 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
6913 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
6914 }
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6915 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
6916 {
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6917 /* groupbox */
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6918 thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6919 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
6920 SetWindowText( thisbox->grouphwnd, wtext );
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6921 }
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
6922 /* 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
6923 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
6924 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
6925
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
6926 /* 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
6927 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
6928 {
1792
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6929 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
6930
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6931 _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
6932
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6933 /* 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
6934 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
6935 (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
6936 {
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6937 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
6938 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
6939 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
6940 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
6941 /* 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
6942 _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
6943 }
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
6944 }
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
6945 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6946 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6947
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6948 /*
1389
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6949 * 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
6950 * Parameters:
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6951 * 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
6952 * 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
6953 */
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6954 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
6955 {
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
6956 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
6957
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
6958 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
6959 _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
6960 _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
6961 }
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6962
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6963 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6964 * Gets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6965 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6966 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6967 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6968 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6969 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6970 char * API dw_window_get_text(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6971 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6972 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
6973 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
6974 int len;
1028
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6975
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6976 GetClassName(handle, tmpbuf, 99);
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
6977
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6978 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
6979 {
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6980 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
6981
1028
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6982 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
6983 handle = cinfo->buddy;
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6984 else
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6985 return NULL;
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6986 }
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
6987
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6988 /* 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
6989 * and fill it with the current text.
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6990 */
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
6991 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
6992 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
6993 GetWindowText(handle, tempbuf, len);
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6994
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6995 /* 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
6996 * 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
6997 */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6998 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
6999 retbuf = _strdup(retbuf);
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
7000 return retbuf;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7001 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7002
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7003 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7004 * Disables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7005 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7006 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7007 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7008 void API dw_window_disable(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7009 {
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
7010 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
7011 {
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
7012 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
7013 HMENU 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
7014 ULONG id = (ULONG)handle;
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
7015
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
7016 _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
7017 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
7018
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
7019 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
7020 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
7021 }
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
7022 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
7023 EnableWindow(handle, FALSE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7024 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7025
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7026 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7027 * Enables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7028 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7029 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7030 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7031 void API dw_window_enable(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7032 {
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
7033 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
7034 {
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
7035 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
7036 HMENU 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
7037 ULONG id = (ULONG)handle;
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
7038
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
7039 _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
7040 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
7041
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
7042 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
7043 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
7044 }
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
7045 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7046 EnableWindow(handle, TRUE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7047 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7048
247
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
7049 static HWND _dw_wfid_hwnd = NULL;
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
7050
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
7051 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
7052 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7053 if(GetWindowLong(handle, GWL_ID) == lParam)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7054 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7055 _dw_wfid_hwnd = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7056 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7057 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7058 return TRUE;
247
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
7059 }
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
7060
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7061 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7062 * Gets the child window handle with specified ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7063 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7064 * handle: Handle to the parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7065 * id: Integer ID of the child.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7066 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7067 HWND API dw_window_from_id(HWND handle, int id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7068 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7069 _dw_wfid_hwnd = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7070 EnumChildWindows(handle, _wfid, (LPARAM)id);
247
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
7071 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
7072 }
248
0f9a185deeb6 Minor change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 247
diff changeset
7073
1084
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7074 /* 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
7075 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
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 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
7078 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
7079
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7080 /*
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7081 * 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
7082 * 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
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(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
7085 {
1084
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7086 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
7087 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
7088 }
34f1d6f5f1c3 Added function dw_box_pack_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 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
7091
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
7092 /* 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
7093 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
7094 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7095 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
7096 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
7097 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7098 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
7099 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
7100 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7101 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7102 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
7103 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
7104 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
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 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
7107 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
7108
1077
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7109 /* 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
7110 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
7111 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
7112 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
7113 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
7114 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
7115 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
7116
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7117 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
7118
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7119 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
7120 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7121 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
7122 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
7123 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
7124 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
7125 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7126
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7127 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
7128
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7129 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
7130 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
7131 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
7132 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
7133
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7134 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
7135 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
7136 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
7137 {
1618
428148fd0976 Switch to UNICODE builds by default on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1617
diff changeset
7138 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
7139 {
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
7140 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
7141 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
7142 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
7143 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
7144 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
7145 }
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
7146 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
7147 {
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
7148 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
7149 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
7150 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
7151 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
7152
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
7153 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
7154 }
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
7155 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7156
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7157 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
7158 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
7159 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
7160 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
7161 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
7162 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
7163
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
7164 /* 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
7165 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
7166 _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
7167
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7168 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
7169
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7170 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
7171 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
7172
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7173 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
7174
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7175 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
7176 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
7177 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7178 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
7179
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7180 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
7181 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7182 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
7183 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
7184 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
7185 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7186 }
1726
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7187 #ifdef TOOLBAR
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7188 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
7189 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
7190 #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
7191 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
7192 #endif
1726
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7193 {
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7194 /* 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
7195 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
7196 }
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7197 }
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7198 #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
7199 /* 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
7200 _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
7201 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7202 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7203
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7204 /*
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7205 * 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
7206 * Parameters:
1679
e19b93a8229b More comment cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1673
diff changeset
7207 * 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
7208 * Returns:
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7209 * 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
7210 */
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
7211 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
7212 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7213 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
7214
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7215 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
7216 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7217 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
7218
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7219 /* If 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
7220 * 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
7221 */
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7222 if(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
7223 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7224 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
7225 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
7226
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7227 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
7228 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
7229
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7230 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
7231 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7232 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
7233 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
7234 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7235
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7236 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
7237 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
7238
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7239 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
7240 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7241 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
7242
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7243 /* 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
7244 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
7245 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7246 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
7247 }
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7248 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
7249 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7250 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
7251 }
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7252 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7253
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7254 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
7255 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
7256 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
7257 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
7258 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
7259 else
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7260 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
7261
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7262 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
7263 /* 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
7264 _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
7265 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
7266 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7267 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7268 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
7269 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7270
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7271 /*
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7272 * 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
7273 * Parameters:
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7274 * 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
7275 * 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
7276 * Returns:
1679
e19b93a8229b More comment cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1673
diff changeset
7277 * 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
7278 */
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
7279 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
7280 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7281 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
7282
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7283 /* 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
7284 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
7285 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7286 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
7287 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
7288 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
7289
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7290 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
7291 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7292 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
7293
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7294 /* 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
7295 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
7296 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7297 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
7298 }
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7299 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
7300 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7301 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
7302 }
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7303 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7304
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7305 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
7306 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
7307 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
7308 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
7309 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
7310 else
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7311 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
7312
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7313 /* 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
7314 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
7315 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
7316 /* 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
7317 _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
7318 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
7319 }
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
7320 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
7321 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7322
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7323 /*
1084
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7324 * 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
7325 * Parameters:
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7326 * 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
7327 * 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
7328 * 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
7329 * 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
7330 * 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
7331 * 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
7332 * 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
7333 * 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
7334 */
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7335 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
7336 {
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7337 _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
7338 }
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7339
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7340 /*
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7341 * Pack windows (widgets) into a box from the start (or top).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7342 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7343 * 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
7344 * item: Window handle of the item to pack.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7345 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7346 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7347 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7348 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7349 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7350 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7351 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
7352 {
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
7353 /* 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
7354 * 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
7355 */
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7356 _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
7357 }
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7358
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7359 /*
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7360 * 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
7361 * Parameters:
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7362 * 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
7363 * 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
7364 * 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
7365 * 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
7366 * 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
7367 * 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
7368 * 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
7369 */
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7370 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
7371 {
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7372 _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
7373 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7374
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7375 /*
1443
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7376 * 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
7377 * 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
7378 */
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7379 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
7380 {
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7381 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
7382
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7383 if(thisbox)
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7384 {
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7385 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
7386 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
7387 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
7388 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
7389 RECT rc = { 0 } ;
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7390
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7391 /* Calculate space requirements */
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7392 _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
7393
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7394 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
7395 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
7396
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7397 /* 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
7398 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
7399
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7400 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
7401 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
7402 }
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7403 }
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7404
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7405 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7406 * Sets the size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7407 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7408 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7409 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7410 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7411 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
7412 void API dw_window_set_size(HWND handle, ULONG width, ULONG height)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7413 {
1443
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7414 /* 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
7415 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
7416 _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
7417
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
7418 /* 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
7419 SetWindowPos(handle, (HWND)NULL, 0, 0, width, height, SWP_NOZORDER | SWP_NOMOVE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7420 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7421
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7422 /*
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
7423 * 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
7424 * 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
7425 * 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
7426 * 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
7427 * 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
7428 */
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
7429 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
7430 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7431 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
7432
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
7433 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
7434
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7435 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
7436 {
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
7437 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
7438
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
7439 /* 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
7440 _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
7441
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
7442 /* 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
7443 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
7444 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
7445 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7446 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
7447 {
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
7448 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
7449
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
7450 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
7451 {
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
7452 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
7453
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
7454 /* 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
7455 _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
7456
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
7457 /* 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
7458 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
7459 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
7460 }
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
7461 }
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
7462 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
7463 _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
7464 }
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
7465
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
7466 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7467 * Returns the width of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7468 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7469 int API dw_screen_width(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7470 {
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7471 return GetSystemMetrics(SM_CXSCREEN);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7472 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7473
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7474 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7475 * Returns the height of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7476 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7477 int API dw_screen_height(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7478 {
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7479 return GetSystemMetrics(SM_CYSCREEN);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7480 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7481
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7482 /* 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
7483 unsigned long API dw_color_depth_get(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7484 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7485 int bpp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7486 HDC hdc = GetDC(HWND_DESKTOP);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7487
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7488 bpp = GetDeviceCaps(hdc, BITSPIXEL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7489
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7490 ReleaseDC(HWND_DESKTOP, hdc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7491
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7492 return bpp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7493 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7494
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7495 /*
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7496 * 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
7497 * 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
7498 * Parameters:
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7499 * 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
7500 * 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
7501 * 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
7502 */
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7503 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
7504 {
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7505 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
7506 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
7507 }
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7508
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7509 /* 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
7510 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
7511 {
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7512 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
7513 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
7514
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7515 /* 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
7516 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
7517 {
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7518 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
7519
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7520 /* 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
7521 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
7522 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
7523 /* 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
7524 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
7525 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
7526 /* 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
7527 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
7528 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
7529 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
7530 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
7531
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7532 /* 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
7533 *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
7534 *y = newy;
1493
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7535
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7536 /* Adjust the values to avoid Taskbar if requested */
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7537 if((horz | vert) & DW_GRAV_OBSTACLES)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7538 {
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7539 POINT pt = { 0, 0 };
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7540 HMONITOR mon = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7541 MONITORINFO mi;
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7542
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7543 mi.cbSize = sizeof(MONITORINFO);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7544
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7545 GetMonitorInfo(mon, &mi);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7546
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7547 if(horz & DW_GRAV_OBSTACLES)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7548 {
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7549 if((horz & 0xf) == DW_GRAV_LEFT)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7550 *x += (mi.rcWork.left - mi.rcMonitor.left);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7551 else if((horz & 0xf) == DW_GRAV_RIGHT)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7552 *x -= (mi.rcMonitor.right - mi.rcWork.right);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7553 }
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7554 if(vert & DW_GRAV_OBSTACLES)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7555 {
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7556 if((vert & 0xf) == DW_GRAV_TOP)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7557 *y += (mi.rcWork.top - mi.rcMonitor.top);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7558 else if((vert & 0xf) == DW_GRAV_BOTTOM)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7559 *y -= (mi.rcMonitor.bottom - mi.rcWork.bottom);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7560 }
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7561 }
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7562 }
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7563 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7564
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7565 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7566 * Sets the position of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7567 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7568 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7569 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7570 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7571 */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7572 void API dw_window_set_pos(HWND handle, long x, long y)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7573 {
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7574 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
7575 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
7576
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
7577 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
7578
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
7579 /* 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
7580 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
7581 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
7582
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7583 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
7584 _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
7585 SetWindowPos(handle, (HWND)NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7586 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7587
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7588 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7589 * Sets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7590 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7591 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7592 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7593 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7594 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7595 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7596 */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7597 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
7598 {
1443
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7599 /* 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
7600 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
7601 _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
7602
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7603 _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
7604 /* 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
7605 SetWindowPos(handle, (HWND)NULL, x, y, width, height, SWP_NOZORDER | SWP_NOACTIVATE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7606 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7607
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7608 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7609 * Gets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7610 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7611 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7612 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7613 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7614 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7615 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7616 */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7617 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
7618 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7619 WINDOWPLACEMENT wp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7620
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7621 wp.length = sizeof(WINDOWPLACEMENT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7622
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7623 GetWindowPlacement(handle, &wp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7624 if( wp.showCmd == SW_SHOWMAXIMIZED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7625 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7626 if(x)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7627 *x=0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7628 if(y)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7629 *y=0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7630 if(width)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7631 *width=dw_screen_width();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7632 if(height)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7633 *height=dw_screen_height();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7634 }
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7635 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7636 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7637 if(x)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7638 *x = wp.rcNormalPosition.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7639 if(y)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7640 *y = wp.rcNormalPosition.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7641 if(width)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7642 *width = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7643 if(height)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7644 *height = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7645 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7646 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7647
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7648 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7649 * Sets the style of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7650 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7651 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7652 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7653 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7654 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7655 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7656 {
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
7657 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
7658 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
7659 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
7660
1790
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7661 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
7662 return;
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7663
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
7664 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
7665 {
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7666 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
7667 HMENU 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
7668 ULONG id = (ULONG)handle;
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7669
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7670 _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
7671 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
7672
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7673 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
7674 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
7675 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
7676 }
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7677
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7678 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
7679
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
7680 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
7681 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7682
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7683 #ifdef TOOLBAR
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7684 /* Bitmap Buttons */
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7685 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
7686 {
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7687 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
7688
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7689 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
7690 {
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7691 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
7692
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
7693 /* 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
7694 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
7695 _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
7696
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7697 return;
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7698 }
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7699 }
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7700 #endif
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7701
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7702 tmp = currentstyle | mask;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7703 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
7704 tmp |= style & mask;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7705
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
7706 /* 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
7707 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
7708 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
7709 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
7710 {
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7711 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
7712 #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
7713 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
7714 {
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
7715 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
7716
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7717 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
7718 {
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7719 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
7720
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7721 /* 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
7722 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
7723 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
7724 _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
7725 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7726 else
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7727 {
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7728 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
7729
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7730 /* 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
7731 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
7732 _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
7733 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7734 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7735 #endif
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7736 }
1790
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7737 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
7738 {
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7739 static ULONG halign = (SS_LEFTNOWORDWRAP | SS_RIGHT | SS_CENTER);
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7740 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
7741 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
7742 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
7743
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7744 /* 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
7745 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
7746 tmp ^= thismask;
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7747 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
7748
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7749 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
7750 {
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7751 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
7752 {
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7753 if(cinfo)
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7754 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
7755 else
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7756 {
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7757 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
7758 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
7759 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
7760
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7761 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
7762 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
7763 }
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7764 }
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7765 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
7766 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
7767 }
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7768 /* 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
7769 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
7770 tmp &= ~(0xFL);
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7771 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
7772 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
7773 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
7774 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
7775 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
7776 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
7777 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7778
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7779 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
7780 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7781
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7782 /* 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
7783 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
7784 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7785 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7786
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7787 for(z=0;z<256;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7788 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7789 if(array[z] && array[z]->realid == pageid)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7790 return z;
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 return -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7793 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7794
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7795 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7796 * Adds a new page to specified notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7797 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7798 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7799 * flags: Any additional page creation flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7800 * front: If TRUE page is added at the beginning.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7801 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7802 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7803 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7804 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
7805
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7806 if(array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7807 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7808 int z, refid = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7809
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7810 for(z=0;z<256;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7811 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7812 if(_findnotebookid(array, z) == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7813 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7814 refid = z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7815 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7816 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7817 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7818
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7819 if(refid == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7820 return -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7821
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7822 for(z=0;z<256;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7823 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7824 if(!array[z])
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 array[z] = calloc(1, sizeof(NotebookPage));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7827 array[z]->realid = refid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7828 array[z]->item.mask = TCIF_TEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7829 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
7830 array[z]->item.pszText = TEXT("");
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7831 TabCtrl_InsertItem(handle, z, &(array[z]->item));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7832 return refid;
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 }
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 return -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7837 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7838
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7839 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7840 * Sets the text on the specified notebook tab.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7841 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7842 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7843 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7844 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7845 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7846 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
7847 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7848
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7849 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
7850 int pageid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7851
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7852 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7853 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7854
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7855 pageid = _findnotebookid(array, pageidx);
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(pageid > -1 && array[pageid])
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 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
7860 array[pageid]->item.pszText = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7861 TabCtrl_SetItem(handle, pageid, &(array[pageid]->item));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7862 _resize_notebook_page(handle, pageid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7863 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7864 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7865
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7866 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7867 * Sets the text on the specified notebook tab status area.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7868 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7869 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7870 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7871 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7872 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7873 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7874 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7875 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7876
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7877 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7878 * Packs the specified box into the notebook page.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7879 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7880 * handle: Handle to the notebook to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7881 * pageid: Page ID in the notebook which is being packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7882 * page: Box handle to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7883 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7884 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
7885 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7886 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
7887 int pageid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7888
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7889 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7890 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7891
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7892 pageid = _findnotebookid(array, pageidx);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7893
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7894 if(pageid > -1 && array[pageid])
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 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
7897
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7898 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
7899 if(array[pageid]->hwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7900 dw_window_destroy(array[pageid]->hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7901 array[pageid]->hwnd = tmpbox;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7902 if(pageidx == dw_notebook_page_get(handle))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7903 {
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
7904 ShowWindow(tmpbox, SW_HIDE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7905 SetParent(tmpbox, handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7906 _resize_notebook_page(handle, pageid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7907 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7908 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7909 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7910
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7911 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7912 * 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
7913 * 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
7914 * 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
7915 * 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
7916 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7917 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
7918 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7919 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
7920 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
7921 HWND pagehwnd = 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7922
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7923 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7924 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7925
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7926 pageid = _findnotebookid(array, pageidx);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7927
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7928 if(pageid < 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7929 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7930
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7931 if(array[pageid])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7932 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7933 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
7934 pagehwnd = array[pageid]->hwnd;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7935 free(array[pageid]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7936 array[pageid] = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7937 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7938
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7939 TabCtrl_DeleteItem(handle, pageid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7940
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7941 /* Shift the pages over 1 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7942 for(z=pageid;z<255;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7943 array[z] = array[z+1];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7944 array[255] = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7945
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7946 for(z=0;z<256;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7947 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7948 if(array[z])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7949 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7950 newid = z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7951 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7952 }
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 if(newid > -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7955 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7956 SetParent(array[newid]->hwnd, handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7957 _resize_notebook_page(handle, newid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7958 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
7959 }
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
7960 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
7961 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
7962 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7963
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7964 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7965 * 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
7966 * 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
7967 * 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
7968 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
7969 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
7970 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7971 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
7972 int physid = TabCtrl_GetCurSel(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7973
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7974 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
7975 return array[physid]->realid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7976 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
7977 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7978
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7979 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7980 * 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
7981 * 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
7982 * 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
7983 * 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
7984 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7985 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
7986 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7987 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
7988 int pageid;
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 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7991 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7992
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7993 pageid = _findnotebookid(array, pageidx);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7994
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7995 if(pageid > -1 && pageid < 256)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7996 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7997 int oldpage = TabCtrl_GetCurSel(handle);
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(oldpage > -1 && array && array[oldpage])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8000 SetParent(array[oldpage]->hwnd, DW_HWND_OBJECT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8001
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8002 TabCtrl_SetCurSel(handle, pageid);
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 SetParent(array[pageid]->hwnd, handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8005 _resize_notebook_page(handle, pageid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8006 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8007 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8008
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8009 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8010 * Appends the specified text to the listbox's (or combobox) entry list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8011 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8012 * handle: Handle to the listbox to be appended to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8013 * text: Text to append into listbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8014 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8015 void API dw_listbox_append(HWND handle, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8016 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8017 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8018
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8019 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8020
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8021 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
8022 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8023 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
8024 0, (LPARAM)UTF8toWide(text));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8025 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8026 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8027 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
8028 0, (LPARAM)UTF8toWide(text));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8029 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8030
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8031 /*
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
8032 * 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
8033 * Parameters:
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
8034 * 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
8035 * text: Text strings to append into listbox.
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
8036 * count: Number of text strings to append
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
8037 */
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
8038 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
8039 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8040 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8041 int listbox_type;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8042 int i;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8043
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8044 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8045
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8046 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
8047 listbox_type = CB_ADDSTRING;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8048 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8049 listbox_type = LB_ADDSTRING;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8050
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8051 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
8052 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
8053 }
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
8054
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
8055 /*
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
8056 * 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
8057 * Parameters:
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
8058 * handle: Handle to the listbox to be appended to.
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
8059 * text: Text to append into listbox.
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
8060 * pos: 0 based position to insert text
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
8061 */
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
8062 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
8063 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8064 TCHAR tmpbuf[100] = {0};
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
8065
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
8066 GetClassName(handle, tmpbuf, 99);
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
8067
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8068 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0)
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
8069 SendMessage(handle,
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
8070 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
8071 pos, (LPARAM)UTF8toWide(text));
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
8072 else
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
8073 SendMessage(handle,
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
8074 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
8075 pos, (LPARAM)UTF8toWide(text));
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
8076 }
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
8077
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
8078 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8079 * Clears the listbox's (or combobox) list of all entries.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8080 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8081 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8082 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8083 void API dw_listbox_clear(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8084 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8085 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8086
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8087 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8088
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8089 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
8090 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8091 char *buf = dw_window_get_text(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8092
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8093 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8094 CB_RESETCONTENT, 0L, 0L);
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 if(buf)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8097 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8098 dw_window_set_text(handle, buf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8099 free(buf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8100 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8101 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8102 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8103 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8104 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
8105 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8106
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8107 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8108 * 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
8109 * 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
8110 * 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
8111 * 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
8112 * 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
8113 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8114 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
8115 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8116 TCHAR tmpbuf[100] = {0};
617
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 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8119
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8120 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
8121 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8122 SendMessage(handle, CB_DELETESTRING, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8123 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
8124 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8125 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8126 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8127 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
8128 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8129 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
8130 SendMessage(handle, LB_SETCURSEL, (WPARAM)sel, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8131 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
8132 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8133 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8134
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8135 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8136 * Copies the given index item's text into buffer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8137 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8138 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8139 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8140 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8141 * length: Length of the buffer (including NULL).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8142 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8143 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
8144 {
1622
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8145 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
8146 unsigned int len;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8147
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
8148 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
8149
33d7cf373938 After looking at that last commit I realized what I was doing was
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1622
diff changeset
8150 if(!buffer || !length)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8151 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8152
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8153 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8154
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8155 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
8156 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8157 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
8158
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
8159 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
8160 {
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8161 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
8162 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
8163 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8164 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8165 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8166 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8167 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
8168
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
8169 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
8170 {
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8171 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
8172 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
8173 }
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8174 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8175 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8176
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8177 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8178 * Returns the index to the item in the list currently selected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8179 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8180 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8181 */
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
8182 int API dw_listbox_selected(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8183 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8184 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8185
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8186 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8187
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8188 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
8189 return (unsigned int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8190 CB_GETCURSEL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8191 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8192
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8193 return (unsigned int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8194 LB_GETCURSEL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8195 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8196 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8197
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8198 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8199 * Returns the index to the current selected item or -1 when done.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8200 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8201 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8202 * where: Either the previous return or -1 to restart.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8203 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8204 int API dw_listbox_selected_multi(HWND handle, int where)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8205 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8206 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
8207 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8208
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8209 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8210
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8211 /* 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
8212 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
8213 return -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8214
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8215 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
8216 if(count > 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8217 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8218 array = malloc(sizeof(int)*count);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8219 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
8220
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8221 if(where == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8222 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8223 int ret = array[0];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8224 free(array);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8225 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8226 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8227 for(z=0;z<count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8228 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8229 if(array[z] == where && (z+1) < count)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8230 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8231 int ret = array[z+1];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8232 free(array);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8233 return ret;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8236 free(array);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8237 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8238 return -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8239 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8240
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8241 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8242 * Sets the selection state of a given index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8243 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8244 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8245 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8246 * state: TRUE if selected FALSE if unselected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8247 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8248 void API dw_listbox_select(HWND handle, int index, int state)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8249 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8250 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8251
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8252 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8253
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8254 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
8255 SendMessage(handle, CB_SETCURSEL, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8256 else
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 SendMessage(handle, LB_SETCURSEL, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8259 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
8260 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8261 _wndproc(handle, WM_COMMAND, (WPARAM)(LBN_SELCHANGE << 16), (LPARAM)handle);
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 * Deletes the item with given index from the list.
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 listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8268 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8269 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8270 void API dw_listbox_delete(HWND handle, int index)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8271 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8272 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8273
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8274 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8275
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8276 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
8277 SendMessage(handle, CB_DELETESTRING, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8278 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8279 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
8280 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8281
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8282 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8283 * 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
8284 * 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
8285 * 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
8286 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8287 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
8288 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8289 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8290
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8291 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8292
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8293 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
8294 return (int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8295 CB_GETCOUNT,0L, 0L);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8296
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8297 return (int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8298 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
8299 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8300
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8301 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8302 * 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
8303 * 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
8304 * 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
8305 * 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
8306 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8307 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
8308 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8309 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8310
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8311 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8312
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8313 /* 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
8314 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
8315 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8316
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8317 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
8318 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8319
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8320 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8321 * Adds text to an MLE box and returns the current point.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8322 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8323 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8324 * buffer: Text buffer to be imported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8325 * startpoint: Point to start entering text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8326 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8327 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8328 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8329 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
8330 TCHAR *tmpbuf, *srcbuf = UTF8toWide(buffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8331
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8332 if(startpoint < 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8333 startpoint = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8334
1641
cdbf4cc929fc Fixed issue with dw_mle_import() in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1633
diff changeset
8335 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
8336 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
8337
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8338 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
8339
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8340 if(len)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8341 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8342 TCHAR *dest, *start;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8343 int copylen = len - startpoint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8344
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8345 GetWindowText(handle, tmpbuf, len+1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8346
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
8347 dest = &tmpbuf[startpoint+textlen];
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8348 start = &tmpbuf[startpoint];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8349
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8350 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
8351 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
8352 }
1641
cdbf4cc929fc Fixed issue with dw_mle_import() in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1633
diff changeset
8353 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
8354
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8355 SetWindowText(handle, tmpbuf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8356
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8357 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
8358 return (startpoint + textlen);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8359 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8360
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8361 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8362 * Grabs text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8363 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8364 * 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
8365 * buffer: Text buffer to be exported. MUST allow for trailing nul character.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8366 * startpoint: Point to start grabbing text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8367 * length: Amount of text to be grabbed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8368 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8369 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8370 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8371 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
8372 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
8373
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8374 if(len)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8375 GetWindowText(handle, tmpbuf, len+1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8376
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8377 buffer[0] = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8378
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8379 if(startpoint < len)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8380 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8381 max = MIN(length, len - startpoint);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8382
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8383 memcpy(buffer, WideToUTF8(&tmpbuf[startpoint]), max);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8384 buffer[max] = '\0';
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8385 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8386
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8387 free(tmpbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8388 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8389
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8390 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8391 * Obtains information about 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 queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8394 * bytes: A pointer to a variable to return the total bytes.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8395 * lines: A pointer to a variable to return the number of lines.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8396 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8397 void API dw_mle_get_size(HWND handle, unsigned long *bytes, unsigned long *lines)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8398 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8399 if(bytes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8400 *bytes = GetWindowTextLength(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8401 if(lines)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8402 *lines = (unsigned long)SendMessage(handle, EM_GETLINECOUNT, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8403 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8404
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8405 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8406 * Deletes text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8407 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8408 * handle: Handle to the MLE to be deleted from.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8409 * startpoint: Point to start deleting text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8410 * length: Amount of text to be deleted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8411 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8412 void API dw_mle_delete(HWND handle, int startpoint, int length)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8413 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8414 int len = GetWindowTextLength(handle);
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8415 TCHAR *tmpbuf = calloc(sizeof(TCHAR), len+2);
617
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
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8419 if(startpoint + length < len)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8420 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8421 _tcscpy(&tmpbuf[startpoint], &tmpbuf[startpoint+length]);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8422
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8423 SetWindowText(handle, tmpbuf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8424 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8425
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8426 free(tmpbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8427 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8428
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8429 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8430 * Clears all text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8431 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8432 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8433 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8434 void API dw_mle_clear(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8435 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8436 SetWindowText(handle, TEXT(""));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8437 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8438
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8439 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8440 * Sets the visible line of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8441 * 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
8442 * handle: Handle to the MLE.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8443 * line: Line to be visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8444 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8445 void API dw_mle_set_visible(HWND handle, int line)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8446 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8447 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
8448 dw_mle_set_cursor(handle, point);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8449 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8450
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8451 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8452 * Sets the editablity of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8453 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8454 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8455 * 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
8456 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8457 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
8458 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8459 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
8460 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8461
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8462 /*
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8463 * Sets the word wrap state of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8464 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8465 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8466 * 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
8467 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8468 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
8469 {
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
8470 /* 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
8471 * horizontal scrollbar it word wraps.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8472 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8473 if(state)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8474 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
8475 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8476 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
8477 /* 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
8478 if(hrichedit)
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8479 {
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8480 if(state)
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8481 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
8482 else
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8483 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
8484 }
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8485 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8486
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8487 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8488 * Sets the current cursor position of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8489 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8490 * handle: Handle to the MLE to be positioned.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8491 * point: Point to position cursor.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8492 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8493 void API dw_mle_set_cursor(HWND handle, int point)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8494 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8495 SendMessage(handle, EM_SETSEL, 0, MAKELONG(point,point));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8496 SendMessage(handle, EM_SCROLLCARET, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8497 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8498
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8499 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8500 * Finds text in an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8501 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8502 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8503 * text: Text to search for.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8504 * point: Start point of search.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8505 * flags: Search specific flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8506 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8507 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8508 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8509 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
8510 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
8511 TCHAR *searchtext = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8512 int z, textlen, retval = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8513
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8514 GetWindowText(handle, tmpbuf, len+1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8515
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
8516 textlen = (int)strlen(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8517
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8518 if(flags & DW_MLE_CASESENSITIVE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8519 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8520 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
8521 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8522 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
8523 retval = z + textlen;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8524 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8525 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8526 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8527 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8528 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
8529 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8530 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
8531 retval = z + textlen;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8534
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8535 if(retval)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8536 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8537 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
8538 SendMessage(handle, EM_SCROLLCARET, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8539 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8540
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8541 free(tmpbuf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8542
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8543 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8544 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8545
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8546 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8547 * Stops redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8548 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8549 * handle: Handle to the MLE to freeze.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8550 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8551 void API dw_mle_freeze(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8552 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8553 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8554
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8555 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8556 * Resumes redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8557 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8558 * handle: Handle to the MLE to thaw.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8559 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8560 void API dw_mle_thaw(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8561 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8562 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8563
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8564 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 32
diff changeset
8565 * Sets the percent bar position.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8566 * 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
8567 * 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
8568 * position: Position of the percent bar withing the range.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8569 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8570 void API dw_percent_set_pos(HWND handle, unsigned int position)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8571 {
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
8572 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
8573 {
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
8574 /* 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
8575 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
8576 {
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
8577 /* 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
8578 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
8579 /* 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
8580 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
8581 }
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
8582 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
8583 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
8584 }
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
8585 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
8586 {
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
8587 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
8588 {
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
8589 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
8590
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
8591 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
8592 {
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
8593 /* 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
8594 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
8595 /* 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
8596 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
8597 }
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
8598 }
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
8599 /* 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
8600 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
8601 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8602 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8603
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8604 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8605 * 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
8606 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8607 * 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
8608 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8609 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
8610 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8611 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
8612 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8613
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8614 if(currentstyle & TBS_VERT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8615 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
8616 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
8617 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8618
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8619 /*
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8620 * 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
8621 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8622 * 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
8623 * 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
8624 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8625 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
8626 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8627 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
8628 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8629
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8630 if(currentstyle & TBS_VERT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8631 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
8632 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8633 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
8634 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8635
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8636 /*
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8637 * 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
8638 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8639 * 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
8640 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8641 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
8642 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8643 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
8644 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8645
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8646 /*
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8647 * 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
8648 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8649 * 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
8650 * 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
8651 */
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8652 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
8653 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8654 dw_window_set_data(handle, "_dw_scrollbar_value", (void *)position);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8655 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
8656 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8657
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8658 /*
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8659 * 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
8660 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8661 * 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
8662 * 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
8663 * 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
8664 */
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
8665 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
8666 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8667 SCROLLINFO si;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8668
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8669 si.cbSize = sizeof(SCROLLINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8670 si.fMask = SIF_RANGE | SIF_PAGE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8671 si.nMin = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8672 si.nMax = range - 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8673 si.nPage = visible;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8674 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
8675 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8676
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8677 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8678 * Sets the spinbutton value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8679 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8680 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8681 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8682 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8683 void API dw_spinbutton_set_pos(HWND handle, long position)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8684 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8685 TCHAR tmpbuf[101] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8686 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8687
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8688 _sntprintf(tmpbuf, 100, TEXT("%ld"), position);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8689
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8690 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8691 SetWindowText(cinfo->buddy, tmpbuf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8692
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
8693 SendMessage(handle, UDM_SETPOS32, 0, (LPARAM)position);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8694 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8695
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8696 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8697 * Sets the spinbutton limits.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8698 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8699 * 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
8700 * 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
8701 * position: Current value of the spinbutton.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8702 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8703 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8704 {
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
8705 SendMessage(handle, UDM_SETRANGE32, (WPARAM)lower,(LPARAM)upper);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8706 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8707
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8708 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8709 * Sets the entryfield character limit.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8710 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8711 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8712 * limit: Number of characters the entryfield will take.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8713 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8714 void API dw_entryfield_set_limit(HWND handle, ULONG limit)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8715 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8716 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
8717 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8718
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8719 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8720 * Returns the current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8721 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8722 * handle: Handle to the spinbutton to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8723 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8724 long API dw_spinbutton_get_pos(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8725 {
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
8726 return (long)SendMessage(handle, UDM_GETPOS32, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8727 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8728
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8729 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8730 * Returns the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8731 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8732 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8733 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8734 int API dw_checkbox_get(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8735 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8736 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
8737 return (in_checkbox_handler ? FALSE : TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8738 return (in_checkbox_handler ? TRUE : FALSE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8739 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8740
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8741 /* 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
8742 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
8743 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8744 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8745
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8746 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8747
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8748 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
8749 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
8750 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
8751 SendMessage(handle, BM_SETCHECK, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8752 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8753 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
8754 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8755 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8756 * Sets the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8757 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8758 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8759 * value: TRUE for checked, FALSE for unchecked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8760 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8761 void API dw_checkbox_set(HWND handle, int value)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8762 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
8763 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
8764 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8765 HWND parent = GetParent(handle);
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 if(parent)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8768 EnumChildWindows(parent, _uncheck_radios, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8769 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8770 SendMessage(handle, BM_SETCHECK, (WPARAM)value, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8771 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8772
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8773 /*
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8774 * 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
8775 * Parameters:
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8776 * 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
8777 * 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
8778 * title: The text title of the entry.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8779 * icon: Handle to coresponding icon.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8780 * parent: Parent handle or 0 if root.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8781 * itemdata: Item specific data.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8782 */
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
8783 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
8784 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8785 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8786 TVINSERTSTRUCT tvins;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8787 HTREEITEM hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8788 void **ptrs= malloc(sizeof(void *) * 2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8789
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8790 ptrs[0] = title;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8791 ptrs[1] = itemdata;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8792
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8793 tvi.mask = TVIF_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
8794 tvi.pszText = UTF8toWide(title);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8795 tvi.lParam = (LONG)ptrs;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8796 tvi.cchTextMax = (int)_tcslen(tvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8797 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
8798
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8799 tvins.item = tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8800 tvins.hParent = parent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8801 tvins.hInsertAfter = item ? item : TVI_FIRST;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8802
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8803 hti = TreeView_InsertItem(handle, &tvins);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8804
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8805 return hti;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8806 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8807
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8808 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8809 * 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
8810 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8811 * 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
8812 * 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
8813 * 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
8814 * 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
8815 * 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
8816 */
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
8817 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
8818 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8819 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8820 TVINSERTSTRUCT tvins;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8821 HTREEITEM hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8822 void **ptrs= malloc(sizeof(void *) * 2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8823
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8824 ptrs[0] = title;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8825 ptrs[1] = itemdata;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8826
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8827 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
8828 tvi.pszText = UTF8toWide(title);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8829 tvi.lParam = (LONG)ptrs;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8830 tvi.cchTextMax = (int)_tcslen(tvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8831 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
8832
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8833 tvins.item = tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8834 tvins.hParent = parent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8835 tvins.hInsertAfter = TVI_LAST;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8836
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8837 hti = TreeView_InsertItem(handle, &tvins);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8838
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8839 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
8840 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8841
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8842 /*
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
8843 * 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
8844 * 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
8845 * 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
8846 * 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
8847 * 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
8848 * 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
8849 */
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
8850 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
8851 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8852 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8853 void **ptrs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8854
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8855 tvi.mask = TVIF_HANDLE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8856 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8857
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8858 if(TreeView_GetItem(handle, &tvi))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8859 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8860
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8861 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8862 ptrs[0] = title;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8863
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8864 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
8865 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
8866 tvi.cchTextMax = (int)_tcslen(tvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8867 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
8868 tvi.hItem = (HTREEITEM)item;
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 TreeView_SetItem(handle, &tvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8871 }
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
8872 }
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
8873
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
8874 /*
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
8875 * 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
8876 * 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
8877 * 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
8878 * 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
8879 * 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
8880 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8881 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
8882 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8883 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8884 void **ptrs;
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 tvi.mask = TVIF_HANDLE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8887 tvi.hItem = item;
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 if(TreeView_GetItem(handle, &tvi))
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 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8892 ptrs[1] = itemdata;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8893 }
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
8894 }
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
8895
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
8896 /*
317
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8897 * 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
8898 * Parameters:
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8899 * 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
8900 * 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
8901 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8902 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
8903 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8904 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8905 void **ptrs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8906
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
8907 tvi.mask = TVIF_HANDLE | TVIF_PARAM;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8908 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8909
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8910 if(TreeView_GetItem(handle, &tvi))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8911 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8912 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8913 return ptrs[1];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8914 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8915 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
8916 }
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8917
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8918 /*
481
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8919 * 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
8920 * Parameters:
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8921 * 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
8922 * 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
8923 */
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8924 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
8925 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8926 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8927
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8928 tvi.mask = TVIF_HANDLE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8929 tvi.hItem = item;
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(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
8932 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
8933 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
8934 }
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8935
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8936 /*
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8937 * 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
8938 * Parameters:
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8939 * 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
8940 * 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
8941 */
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8942 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
8943 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8944 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
8945 }
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8946
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8947 /*
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
8948 * 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
8949 * 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
8950 * 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
8951 * 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
8952 */
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
8953 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
8954 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8955 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
8956 }
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
8957
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
8958 /* 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
8959 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
8960 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8961 HTREEITEM hti;
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 hti = TreeView_GetChild(handle, node);
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 while(hti)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8966 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8967 HTREEITEM lastitem = hti;
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 hti = TreeView_GetNextSibling(handle, hti);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8970 dw_tree_item_delete(handle, lastitem);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8971 }
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
8972 }
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
8973
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
8974 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8975 * Removes all nodes from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8976 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8977 * 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
8978 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8979 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
8980 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8981 HTREEITEM hti = TreeView_GetRoot(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8982
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8983 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
8984 while(hti)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8985 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8986 HTREEITEM lastitem = hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8987
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8988 _dw_tree_item_delete_recursive(handle, hti);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8989 hti = TreeView_GetNextSibling(handle, hti);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8990 dw_tree_item_delete(handle, lastitem);
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 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
8993 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8994
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8995 /*
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
8996 * 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
8997 * 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
8998 * 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
8999 * 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
9000 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
9001 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
9002 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9003 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
9004 }
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
9005
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
9006 /*
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
9007 * 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
9008 * 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
9009 * 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
9010 * 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
9011 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
9012 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
9013 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9014 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
9015 }
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
9016
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
9017 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
9018 * Removes a node from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
9019 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
9020 * 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
9021 * item: Handle to node to be deleted.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
9022 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
9023 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
9024 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9025 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9026 void **ptrs=NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9027
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9028 if(item == TVI_ROOT || !item)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9029 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9030
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9031 tvi.mask = TVIF_HANDLE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9032 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9033
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9034 if(TreeView_GetItem(handle, &tvi))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9035 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9036
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9037 _dw_tree_item_delete_recursive(handle, item);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9038 TreeView_DeleteItem(handle, item);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9039 if(ptrs)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9040 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
9041 }
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
9042
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
9043 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9044 * Sets up the container columns.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9045 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9046 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9047 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9048 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9049 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9050 * 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
9051 * (only used on OS/2 but must be >= 0 on all)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9052 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9053 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
9054 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9055 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9056 int z, l = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9057 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
9058 LVCOLUMN lvc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9059
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9060 if(separator == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9061 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9062 tempflags[0] = DW_CFA_RESERVED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9063 l = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9064 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9065
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9066 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
9067 tempflags[count + l] = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9068 cinfo->flags = tempflags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9069 cinfo->columns = count + l;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9070
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9071
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9072 for(z=0;z<count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9073 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9074 if(titles[z])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9075 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9076 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
9077 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
9078 lvc.cchTextMax = (int)_tcslen(lvc.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9079 if(flags[z] & DW_CFA_RIGHT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9080 lvc.fmt = LVCFMT_RIGHT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9081 else if(flags[z] & DW_CFA_CENTER)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9082 lvc.fmt = LVCFMT_CENTER;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9083 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9084 lvc.fmt = LVCFMT_LEFT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9085 lvc.cx = 75;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9086 lvc.iSubItem = count;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9087 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
9088 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9089 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9090 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
9091 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9092 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9093
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9094 /*
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
9095 * 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
9096 * Parameters:
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9097 * 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
9098 * 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
9099 */
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9100 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
9101 {
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
9102 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
9103
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
9104 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
9105 }
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9106
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9107 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9108 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9109 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9110 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9111 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9112 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9113 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9114 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9115 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9116 {
1744
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9117 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
9118 LV_COLUMN lvc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9119
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9120 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
9121 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
9122 lvc.cchTextMax = 8;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9123 lvc.fmt = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9124 if(!count)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9125 lvc.cx = 300;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9126 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9127 lvc.cx = 150;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9128 lvc.iSubItem = count;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9129 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
9130 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
9131 if(coltitle)
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9132 {
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
9133 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
9134 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
9135 }
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
9136 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9137 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9138
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9139 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9140 * Obtains an icon from a module (or header in GTK).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9141 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9142 * module: Handle to module (DLL) in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9143 * id: A unsigned long id int the resources on OS/2 and
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9144 * Windows, on GTK this is converted to a pointer
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9145 * to an embedded XPM.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9146 */
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
9147 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
9148 {
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
9149 return (HICN)LoadIcon(DWInstance, MAKEINTRESOURCE(id));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9150 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9151
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9152 /*
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
9153 * 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
9154 * 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
9155 * 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
9156 * 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
9157 * (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
9158 */
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
9159 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
9160 {
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
9161 #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
9162 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
9163 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9164 char *file = malloc(strlen(filename) + 5);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9165 HANDLE icon;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9166
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9167 if(!file)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9168 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9169
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9170 strcpy(file, filename);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9171
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9172 /* 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
9173 if(access(file, 04) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9174 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9175 /* Try with .bmp extention */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9176 strcat(file, ".ico");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9177 if(access(file, 04) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9178 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9179 free(file);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9180 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9181 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9182 }
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
9183 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
9184 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
9185 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
9186 #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
9187 }
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
9188
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
9189 /*
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9190 * 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
9191 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9192 * 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
9193 * 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
9194 * (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
9195 */
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
9196 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
9197 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
9198 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
9199 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
9200 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
9201
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9202 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
9203 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
9204 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
9205 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
9206 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9207 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
9208 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
9209 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9210 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
9211 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
9212 #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
9213 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
9214 #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
9215 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
9216 #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
9217 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9218 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9219 {
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
9220 _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
9221 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
9222 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
9223 }
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
9224 _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
9225 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
9226 }
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
9227 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
9228 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9229
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9230 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9231 * Frees a loaded resource in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9232 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9233 * handle: Handle to icon returned by dw_icon_load().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9234 */
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
9235 void API dw_icon_free(HICN handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9236 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9237 DestroyIcon((HICON)handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9238 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9239
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9240 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9241 * Allocates memory used to populate a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9242 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9243 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9244 * rowcount: The number of items to be populated.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9245 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9246 void * API dw_container_alloc(HWND handle, int rowcount)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9247 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9248 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9249 int z, item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9250
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9251 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
9252 lvi.iSubItem = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9253 /* Insert at the end */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9254 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
9255 lvi.pszText = TEXT("");
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9256 lvi.cchTextMax = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9257 lvi.iImage = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9258
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9259 ShowWindow(handle, SW_HIDE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9260 item = ListView_InsertItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9261 for(z=1;z<rowcount;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9262 ListView_InsertItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9263 dw_window_set_data(handle, "_dw_insertitem", (void *)item);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9264 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
9265 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9266
5c66a108aa47 Fixed 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 /* 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
9268 * 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
9269 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9270 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
9271 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9272 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9273 static HWND lasthwnd = NULL;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
9274 HIMAGELIST himl;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9275
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
9276 /* 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
9277 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
9278 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
9279
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9280 if(!hSmall || !hLarge)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9281 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9282 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
9283 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
9284 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9285 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
9286 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9287 if(!lookup[z])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9288 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9289 lookup[z] = hicon;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9290 ImageList_AddIcon(hSmall, hicon);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9291 ImageList_AddIcon(hLarge, hicon);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9292 if(type)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9293 {
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
9294 himl = TreeView_SetImageList(handle, hSmall, TVSIL_NORMAL);
617
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 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9297 {
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
9298 himl = ListView_SetImageList(handle, hSmall, LVSIL_SMALL);
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
9299 himl = ListView_SetImageList(handle, hLarge, LVSIL_NORMAL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9300 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9301 lasthwnd = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9302 return z;
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
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9305 if(hicon == lookup[z])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9306 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9307 if(lasthwnd != handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9308 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9309 if(type)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9310 {
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
9311 himl = TreeView_SetImageList(handle, hSmall, TVSIL_NORMAL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9312 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9313 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9314 {
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
9315 himl = ListView_SetImageList(handle, hSmall, LVSIL_SMALL);
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
9316 himl = ListView_SetImageList(handle, hLarge, LVSIL_NORMAL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9317 }
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
9318 lasthwnd = handle;
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 return z;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9323 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
9324 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9325
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9326 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9327 * 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
9328 * 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
9329 * 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
9330 * 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
9331 * 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
9332 * 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
9333 * 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
9334 */
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
9335 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
9336 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9337 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
9338 int item = 0;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9339
832
37cdfec6d3fa Fix for dw_filesystem_set_file() not working as designed on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 819
diff changeset
9340 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
9341 {
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9342 item = (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
9343 }
37cdfec6d3fa Fix for dw_filesystem_set_file() not working as designed on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 819
diff changeset
9344
37cdfec6d3fa Fix for dw_filesystem_set_file() not working as designed on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 819
diff changeset
9345 lvi.iItem = row + item;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9346 lvi.iSubItem = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9347 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
9348 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
9349 lvi.cchTextMax = (int)_tcslen(lvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9350 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
9351
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9352 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
9353 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9354
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9355 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9356 * 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
9357 * 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
9358 * 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
9359 * 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
9360 * 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
9361 * 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
9362 * 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
9363 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9364 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
9365 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9366 dw_container_set_item(handle, pointer, column + 1, row, data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9367 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9368
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9369 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9370 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9371 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9372 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9373 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9374 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9375 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9376 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9377 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9378 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
9379 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9380 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9381 ULONG *flags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9382 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
9383 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
9384 int item = 0;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9385
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
9386 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
9387 {
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9388 item = (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
9389 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9390
1500
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9391 if(!cinfo || !cinfo->flags)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9392 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9393
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9394 flags = cinfo->flags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9395
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9396 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9397 lvi.iItem = row + item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9398 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
9399 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
9400 lvi.cchTextMax = 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9401
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9402 if(flags[column] & DW_CFA_BITMAPORICON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9403 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9404 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9405 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
9406
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9407 if(data)
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9408 {
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9409 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
9410
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9411 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
9412 }
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9413 else
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9414 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
9415 }
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9416 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
9417 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9418 char *tmp = *((char **)data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9419
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9420 if(!tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9421 tmp = "";
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9422
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9423 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
9424 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
9425 }
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9426 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
9427 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9428 ULONG tmp = *((ULONG *)data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9429
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9430 _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
9431
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9432 lvi.cchTextMax = (int)_tcslen(textbuffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9433 }
1500
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9434 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
9435 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9436 struct tm curtm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9437 CDATE cdate = *((CDATE *)data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9438
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9439 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
9440
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9441 /* 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
9442 * Visual Studio 2008. -Brian
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9443 */
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9444 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
9445 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9446 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
9447 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
9448 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
9449 _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
9450 }
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9451
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9452 lvi.cchTextMax = (int)_tcslen(textbuffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9453 }
1500
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9454 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
9455 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9456 struct tm curtm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9457 CTIME ctime = *((CTIME *)data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9458
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9459 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
9460 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
9461 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
9462
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9463 _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
9464
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9465 lvi.cchTextMax = (int)_tcslen(textbuffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9466 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9467
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9468 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
9469 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9470
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9471 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9472 * 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
9473 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9474 * 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
9475 * 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
9476 * 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
9477 * 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
9478 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9479 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
9480 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9481 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
9482 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9483
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9484 /*
503
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9485 * 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
9486 * Parameters:
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9487 * 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
9488 * 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
9489 * 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
9490 * 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
9491 */
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9492 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
9493 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9494 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
9495 }
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9496
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9497 /*
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9498 * 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
9499 * Parameters:
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9500 * 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
9501 * 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
9502 * 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
9503 * 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
9504 * 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
9505 */
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
9506 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
9507 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9508 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
9509 }
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9510
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9511 /*
508
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9512 * 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
9513 * Parameters:
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9514 * 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
9515 * 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
9516 */
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9517 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
9518 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9519 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9520 ULONG *flags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9521 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9522
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9523 if(!cinfo || !cinfo->flags)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9524 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9525
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9526 flags = cinfo->flags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9527
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9528 if(flags[column] & DW_CFA_BITMAPORICON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9529 rc = DW_CFA_BITMAPORICON;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9530 else if(flags[column] & DW_CFA_STRING)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9531 rc = DW_CFA_STRING;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9532 else if(flags[column] & DW_CFA_ULONG)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9533 rc = DW_CFA_ULONG;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9534 else if(flags[column] & DW_CFA_DATE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9535 rc = DW_CFA_DATE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9536 else if(flags[column] & DW_CFA_TIME)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9537 rc = DW_CFA_TIME;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9538 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9539 rc = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9540 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
9541 }
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9542
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9543 /*
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9544 * 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
9545 * Parameters:
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9546 * 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
9547 * 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
9548 */
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9549 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
9550 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9551 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
9552 }
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9553
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9554 /*
1208
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9555 * 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
9556 * Parameters:
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9557 * 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
9558 * 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
9559 * 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
9560 * 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
9561 * 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
9562 */
1291
b99b0b2c2826 Renamed dw_container_set_row_bg() to dw_container_set_stripe().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1275
diff changeset
9563 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
9564 {
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9565 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
9566 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
9567 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
9568 temp = _internal_color(evencolor);
0712ee0f311e Grr flippin' tabs again!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1292
diff changeset
9569 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
9570
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9571 /* Drop out on error */
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9572 if(!cinfo)
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9573 return;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9574
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9575 /* 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
9576 if(oddcolor != DW_RGB_TRANSPARENT)
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9577 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
9578 else
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9579 cinfo->odd = oddcolor;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9580
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9581 if(evencolor != DW_RGB_TRANSPARENT)
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9582 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
9583 else
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9584 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
9585 }
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9586
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9587 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9588 * 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
9589 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9590 * 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
9591 * 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
9592 * 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
9593 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9594 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
9595 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9596 ListView_SetColumnWidth(handle, column, width);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9597 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9598
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
9599 /* 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
9600 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
9601 {
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
9602 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
9603 int item = 0;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9604
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
9605 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
9606 {
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9607 item = (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
9608 }
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
9609
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
9610 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
9611 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
9612 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
9613 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
9614
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
9615 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
9616 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
9617
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
9618 }
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
9619
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9620 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9621 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9622 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9623 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9624 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9625 * title: String title of the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9626 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9627 void API dw_container_set_row_title(void *pointer, int row, char *title)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9628 {
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9629 _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
9630 }
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
9631
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
9632 /*
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
9633 * 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
9634 * 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
9635 * 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
9636 * 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
9637 * 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
9638 */
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
9639 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
9640 {
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9641 _dw_container_set_row_title(handle, NULL, row, title);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9642 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9643
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9644 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9645 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9646 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9647 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9648 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9649 * rowcount: The number of rows to be inserted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9650 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9651 void API dw_container_insert(HWND handle, void *pointer, int rowcount)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9652 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9653 ShowWindow(handle, SW_SHOW);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9654 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9655
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9656 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9657 * Removes all rows from a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9658 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9659 * 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
9660 * 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
9661 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9662 void API dw_container_clear(HWND handle, int redraw)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9663 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9664 ListView_DeleteAllItems(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9665 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9666
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9667 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9668 * 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
9669 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9670 * 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
9671 * 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
9672 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9673 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
9674 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9675 int z, _index = (int)dw_window_get_data(handle, "_dw_index");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9676
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9677 for(z=0;z<rowcount;z++)
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 ListView_DeleteItem(handle, 0);
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 if(rowcount > _index)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9682 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
9683 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9684 dw_window_set_data(handle, "_dw_index", (void *)(_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
9685 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9686
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9687 /*
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9688 * 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
9689 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9690 * 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
9691 * 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
9692 * 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
9693 * 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
9694 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9695 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
9696 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9697 switch(direction)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9698 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9699 case DW_SCROLL_TOP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9700 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
9701 break;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9702 case DW_SCROLL_BOTTOM:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9703 ListView_Scroll(handle, 0, 10000000);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9704 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9705 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9706 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9707
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9708 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9709 * Starts a new query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9710 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9711 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9712 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9713 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9714 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9715 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9716 char * API dw_container_query_start(HWND handle, unsigned long flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9717 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9718 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9719 int _index = ListView_GetNextItem(handle, -1, flags);
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 if(_index == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9722 return NULL;
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 memset(&lvi, 0, sizeof(LV_ITEM));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9725
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9726 lvi.iItem = _index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9727 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9728
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9729 ListView_GetItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9730
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9731 dw_window_set_data(handle, "_dw_index", (void *)_index);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9732 return (char *)lvi.lParam;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9733 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9734
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9735 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9736 * Continues an existing query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9737 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9738 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9739 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9740 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9741 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9742 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9743 char * API dw_container_query_next(HWND handle, unsigned long flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9744 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9745 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9746 int _index = (int)dw_window_get_data(handle, "_dw_index");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9747
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9748 _index = ListView_GetNextItem(handle, _index, flags);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9749
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9750 if(_index == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9751 return NULL;
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 memset(&lvi, 0, sizeof(LV_ITEM));
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 lvi.iItem = _index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9756 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9757
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9758 ListView_GetItem(handle, &lvi);
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 dw_window_set_data(handle, "_dw_index", (void *)_index);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9761 return (char *)lvi.lParam;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9762 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9763
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9764 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9765 * 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
9766 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9767 * 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
9768 * 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
9769 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9770 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
9771 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9772 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
9773 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
9774
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9775 while ( index != -1 )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9776 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9777 LV_ITEM lvi;
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 memset(&lvi, 0, sizeof(LV_ITEM));
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 lvi.iItem = index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9782 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9783
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9784 ListView_GetItem( handle, &lvi );
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9785
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
9786 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
9787 {
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
9788 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
9789
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9790 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
9791 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
9792 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
9793 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
9794 ListView_EnsureVisible( handle, index, TRUE );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9795 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9796 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9797
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9798 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
9799 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9800 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9801
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9802 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9803 * 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
9804 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9805 * 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
9806 * 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
9807 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9808 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
9809 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9810 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
9811 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
9812
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9813 while(index != -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9814 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9815 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9816
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9817 memset(&lvi, 0, sizeof(LV_ITEM));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9818
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9819 lvi.iItem = index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9820 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9821
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9822 ListView_GetItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9823
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
9824 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
9825 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9826 int _index = (int)dw_window_get_data(handle, "_dw_index");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9827
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9828 if(index < _index)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9829 dw_window_set_data(handle, "_dw_index", (void *)(_index - 1));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9830
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9831 ListView_DeleteItem(handle, index);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9832 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9833 }
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9834
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9835 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
9836 }
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9837 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9838
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9839 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9840 * 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
9841 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9842 * 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
9843 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9844 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
9845 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9846 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9847 if(cinfo && cinfo->columns == 1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9848 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9849 ListView_SetColumnWidth(handle, 0, LVSCW_AUTOSIZE);
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 else if(cinfo && cinfo->columns > 1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9852 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9853 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
9854 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
9855 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
9856 int index;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9857
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9858 /* Initialize with sizes of column labels */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9859 for(z=0;z<cinfo->columns;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9860 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9861 if(flags[z] & DW_CFA_BITMAPORICON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9862 columns[z] = 5;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9863 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9864 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9865 LVCOLUMN lvc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9866
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9867 lvc.mask = LVCF_TEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9868 lvc.cchTextMax = 1023;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9869 lvc.pszText = text;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9870
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9871 if(ListView_GetColumn(handle, z, &lvc))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9872 columns[z] = ListView_GetStringWidth(handle, lvc.pszText);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9873
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9874 if(flags[z] & DW_CFA_RESERVED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9875 columns[z] += 20;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9876 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9877 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9878
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9879 index = ListView_GetNextItem(handle, -1, LVNI_ALL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9880
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9881 /* Query all the item texts */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9882 while(index != -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9883 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9884 for(z=0;z<cinfo->columns;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9885 {
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
9886 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
9887
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9888 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
9889 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
9890
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9891 /* 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
9892 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
9893 width += 20;
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9894
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9895 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
9896 columns[z] = width;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9897 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9898
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9899 index = ListView_GetNextItem(handle, index, LVNI_ALL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9900 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9901
1387
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9902 /* 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
9903 * 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
9904 * 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
9905 */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9906 for(z=0;z<cinfo->columns;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9907 ListView_SetColumnWidth(handle, z, columns[z] + 16);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9908
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9909 free(columns);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9910 free(text);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9911 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9912 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9913
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9914 /*
487
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9915 * 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
9916 * Parameters:
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9917 * 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
9918 * 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
9919 * 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
9920 */
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
9921 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
9922 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9923 NOTIFYICONDATA tnid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9924
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9925 tnid.cbSize = sizeof(NOTIFYICONDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9926 tnid.hWnd = handle;
975
52cd98b7e45c Changed to using HANDLE as the base type for HICN on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 970
diff changeset
9927 tnid.uID = (UINT)icon;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9928 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
9929 tnid.uCallbackMessage = WM_USER+2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9930 tnid.hIcon = (HICON)icon;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9931 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
9932 _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
9933 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9934 tnid.szTip[0] = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9935
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9936 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
9937 }
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9938
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9939 /*
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9940 * 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
9941 * Parameters:
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9942 * 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
9943 * 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
9944 */
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
9945 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
9946 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9947 NOTIFYICONDATA tnid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9948
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9949 tnid.cbSize = sizeof(NOTIFYICONDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9950 tnid.hWnd = handle;
975
52cd98b7e45c Changed to using HANDLE as the base type for HICN on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 970
diff changeset
9951 tnid.uID = (UINT)icon;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9952
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9953 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
9954 }
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9955
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9956 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9957 * Creates a rendering context widget (window) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9958 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9959 * id: An id to be used with dw_window_from_id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9960 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9961 * A handle to the widget or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9962 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9963 HWND API dw_render_new(unsigned long id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9964 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9965 Box *newbox = calloc(sizeof(Box), 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9966 HWND tmp = CreateWindow(ObjectClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
9967 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9968 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
9969 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9970 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9971 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9972 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9973 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9974 newbox->pad = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9975 newbox->type = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9976 newbox->count = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9977 newbox->grouphwnd = (HWND)NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9978 newbox->cinfo.pOldProc = SubclassWindow(tmp, _rendwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9979 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
9980 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
9981 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9982 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9983
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9984 /* Sets the current foreground drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9985 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9986 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9987 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9988 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9989 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9990 void API dw_color_foreground_set(unsigned long value)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9991 {
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9992 HPEN hPen = TlsGetValue(_hPen);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9993 HBRUSH hBrush = TlsGetValue(_hBrush);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9994 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
9995 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
9996 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
9997 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
9998 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
9999 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10000
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10001 value = _internal_color(value);
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10002 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
10003 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10004 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
10005
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10006 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
10007 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
10008 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
10009 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
10010 #endif
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
10011
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10012 DeleteObject(hPen);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10013 DeleteObject(hBrush);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10014 TlsSetValue(_foreground, (LPVOID)foreground);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10015 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
10016 TlsSetValue(_hBrush, CreateSolidBrush(foreground));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10017 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10018
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10019 /* Sets the current background drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10020 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10021 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10022 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10023 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10024 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10025 void API dw_color_background_set(unsigned long value)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10026 {
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10027 COLORREF background;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10028
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10029 value = _internal_color(value);
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10030 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
10031
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10032 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
10033 TlsSetValue(_background, (LPVOID)DW_RGB_TRANSPARENT);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10034 else
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10035 TlsSetValue(_background, (LPVOID)background);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10036 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10037
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
10038 /* 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
10039 * Parameters:
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
10040 * value: current color
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
10041 * Returns:
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
10042 * The selected color or the current color if cancelled.
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
10043 */
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
10044 unsigned long API dw_color_choose(unsigned long value)
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
10045 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10046 CHOOSECOLOR cc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10047 unsigned long newcolor;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10048 COLORREF acrCustClr[16] = {0};
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10049
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10050 value = _internal_color(value);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10051 if(value == DW_RGB_TRANSPARENT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10052 newcolor = DW_RGB_TRANSPARENT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10053 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10054 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
10055 ZeroMemory(&cc, sizeof(CHOOSECOLOR));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10056 cc.lStructSize = sizeof(CHOOSECOLOR);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10057 cc.rgbResult = newcolor;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10058 cc.hwndOwner = HWND_DESKTOP;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10059 cc.lpCustColors = (LPDWORD)acrCustClr;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10060 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10061 if (ChooseColor(&cc) == TRUE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10062 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
10063 return newcolor;
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
10064 }
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
10065
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10066 /* Draw a point on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10067 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10068 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10069 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10070 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10071 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10072 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10073 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10074 {
1682
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
10075 #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
10076 /* 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
10077 * 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
10078 */
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
10079 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
10080 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10081 HDC hdcPaint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10082
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10083 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10084 hdcPaint = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10085 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10086 hdcPaint = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10087 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10088 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10089
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10090 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
10091 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10092 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
10093 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10094 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10095
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10096 /* Draw a line on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10097 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10098 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10099 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10100 * x1: First X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10101 * y1: First Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10102 * x2: Second X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10103 * y2: Second Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10104 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10105 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
10106 {
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10107 #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
10108 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
10109 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
10110
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10111 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
10112 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
10113 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
10114 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
10115 else
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10116 return;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10117
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10118 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
10119 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
10120 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
10121 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10122 HDC hdcPaint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10123 HPEN oldPen;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10124
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10125 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10126 hdcPaint = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10127 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10128 hdcPaint = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10129 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10130 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10131
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10132 oldPen = SelectObject(hdcPaint, TlsGetValue(_hPen));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10133 MoveToEx(hdcPaint, x1, y1, NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10134 LineTo(hdcPaint, x2, y2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10135 SelectObject(hdcPaint, oldPen);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10136 /* For some reason Win98 (at least) fails
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10137 * 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
10138 */
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10139 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
10140 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10141 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
10142 #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
10143 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
10144
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10145 /* 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
10146 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
10147 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10148 POINT *points;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10149 int i;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10150
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10151 /*
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10152 * 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
10153 * 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
10154 * 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
10155 */
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10156 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
10157
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 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10160 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
10161 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10162 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
10163 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
10164 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10165 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
10166 && 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
10167 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10168 /* 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
10169 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
10170 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
10171 /* ... 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
10172 (*npoints)++;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10173 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10174 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10175 return points;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10176 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10177
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10178 /* 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
10179 * Parameters:
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10180 * handle: Handle to the window.
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10181 * 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
10182 * 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
10183 * number of points
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10184 * x[]: X coordinates.
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10185 * y[]: Y coordinates.
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10186 */
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
10187 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
10188 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
10189 POINT *points = NULL;
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10190
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10191 /* Sanity check */
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10192 if(npoints < 1)
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10193 return;
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10194
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10195 #ifdef GDIPLUS
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10196 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10197 GpGraphics *graphics = NULL;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10198
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10199 if(handle)
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10200 GdipCreateFromHWND(handle, &graphics);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10201 else if(pixmap)
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10202 GdipCreateFromHDC(pixmap->hdc, &graphics);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10203 else
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10204 return;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10205
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10206 /* 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
10207 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
10208 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
10209
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10210 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
10211 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10212 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
10213 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10214 GpBrush *brush = TlsGetValue(_gpBrush);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10215
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10216 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
10217 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10218 else
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10219 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10220 GpPen *pen = TlsGetValue(_gpPen);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10221
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10222 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
10223 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10224 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10225 GdipDeleteGraphics(graphics);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10226 }
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10227 #else
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10228 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10229 HDC hdcPaint;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10230
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10231 if ( handle )
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10232 hdcPaint = GetDC( handle );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10233 else if ( pixmap )
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10234 hdcPaint = pixmap->hdc;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10235 else
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10236 return;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10237
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10238 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
10239 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10240 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
10241 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
10242
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10243 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
10244 Polygon( hdcPaint, points, npoints );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10245 else
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10246 Polyline( hdcPaint, points, npoints );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10247
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10248 SelectObject( hdcPaint, oldBrush );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10249 SelectObject( hdcPaint, oldPen );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10250 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10251
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10252 if ( !pixmap )
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10253 ReleaseDC( handle, hdcPaint );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10254 }
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10255 #endif
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10256 if(points)
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10257 free(points);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10258 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10259
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
10260 /* 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
10261 * 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
10262 * 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
10263 * 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
10264 * 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
10265 * 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
10266 * 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
10267 * 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
10268 * 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
10269 */
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
10270 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
10271 {
1682
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
10272 #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
10273 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
10274
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10275 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10276 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
10277 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
10278 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
10279 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10280 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10281
1682
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
10282 /* 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
10283 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
10284 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
10285
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10286 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
10287 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10288 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
10289
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10290 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
10291 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10292 else
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10293 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10294 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
10295
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10296 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
10297 }
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10298 GdipDeleteGraphics(graphics);
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 HDC hdcPaint;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10301 RECT Rect;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10302
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10303 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10304 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
10305 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
10306 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
10307 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10308 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10309
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10310 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
10311 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
10312 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
10313 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10314 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
10315 if(!pixmap)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10316 ReleaseDC(handle, hdcPaint);
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10317 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10318 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10319
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10320 /* 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
10321 * Parameters:
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10322 * 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
10323 * 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
10324 * 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
10325 * 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
10326 * 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
10327 * 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
10328 * 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
10329 * 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
10330 * 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
10331 * 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
10332 */
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10333 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
10334 {
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10335 #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
10336 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
10337 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
10338
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10339 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10340 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
10341 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
10342 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
10343 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10344 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10345
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10346 /* 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
10347 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
10348 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
10349
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10350 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
10351 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10352 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
10353 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10354 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
10355
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10356 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
10357 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10358 else
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10359 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
10360 }
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
10361 else
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10362 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10363 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
10364 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
10365 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
10366 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
10367 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
10368 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
10369 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
10370
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10371 /* 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
10372 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
10373 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
10374 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
10375
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10376 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
10377 }
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10378 GdipDeleteGraphics(graphics);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10379 #else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10380 HDC hdcPaint;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10381 HBRUSH oldBrush;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10382 HPEN oldPen;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10383 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
10384 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
10385 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
10386 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
10387
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10388 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10389 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
10390 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
10391 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
10392 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10393 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10394
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10395 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
10396 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
10397 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10398 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
10399 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
10400 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
10401 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
10402 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10403 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
10404 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
10405 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
10406
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10407 if(!pixmap)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10408 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
10409 #endif
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10410 }
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10411
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10412 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10413 /* 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
10414 * 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
10415 */
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10416 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
10417 {
1684
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10418 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
10419 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
10420 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
10421 {
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10422 if(mult)
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10423 {
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10424 if(x)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10425 *x *= ratiox;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10426 if(y)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10427 *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
10428 }
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10429 else
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10430 {
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10431 if(x)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10432 *x /= ratiox;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10433 if(y)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10434 *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
10435 }
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10436 }
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10437 }
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10438 #endif
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10439
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10440 /* Draw text on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10441 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10442 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10443 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10444 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10445 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10446 * text: Text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10447 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10448 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
10449 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10450 HDC hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10451 int mustdelete = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10452 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
10453 ColorInfo *cinfo = NULL;
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10454 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
10455 TCHAR *wtext = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10456
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10457 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10458 hdc = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10459 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10460 hdc = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10461 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10462 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10463
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10464 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10465 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
10466 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
10467 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
10468 else if(pixmap->handle)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10469 cinfo = (ColorInfo *)GetWindowLongPtr(pixmap->handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10470
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10471 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10472 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10473 hFont = _acquire_font(handle, cinfo->fontname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10474 mustdelete = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10475 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10476
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10477 background = (COLORREF)TlsGetValue(_background);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10478 if(hFont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10479 oldFont = SelectObject(hdc, hFont);
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10480 SetTextColor(hdc, (COLORREF)TlsGetValue(_foreground));
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10481 if(background == DW_RGB_TRANSPARENT)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10482 SetBkMode(hdc, TRANSPARENT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10483 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10484 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10485 SetBkMode(hdc, OPAQUE);
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10486 SetBkColor(hdc, background);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10487 }
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10488 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10489 _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
10490 #endif
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10491 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
10492 if(oldFont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10493 SelectObject(hdc, oldFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10494 if(mustdelete)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10495 DeleteObject(hFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10496 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10497 ReleaseDC(handle, hdc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10498 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10499
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
10500 /* 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
10501 * 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
10502 * 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
10503 * 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
10504 * 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
10505 * 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
10506 * 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
10507 */
514
08d770271709 More function name changes for Rexx/DW compatibility.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 513
diff changeset
10508 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
10509 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10510 HDC hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10511 int mustdelete = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10512 HFONT hFont = NULL, oldFont;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10513 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
10514 TCHAR *wtext = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10515
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10516 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10517 hdc = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10518 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10519 hdc = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10520 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10521 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10522
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
10523 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
10524 {
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
10525 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
10526 }
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
10527 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10528 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10529 ColorInfo *cinfo;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10530
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10531 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10532 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10533 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10534 cinfo = (ColorInfo *)GetWindowLongPtr(pixmap->handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10535
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10536 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10537 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10538 hFont = _acquire_font(handle, cinfo->fontname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10539 mustdelete = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10540 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10541 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10542 oldFont = SelectObject(hdc, hFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10543
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
10544 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
10545
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10546 if(width)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10547 *width = sz.cx;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10548
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10549 if(height)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10550 *height = sz.cy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10551
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10552 #ifdef GDIPLUS
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10553 _convert_dpi(hdc, width, height, FALSE);
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10554 #endif
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10555
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10556 SelectObject(hdc, oldFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10557 if(mustdelete)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10558 DeleteObject(hFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10559 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10560 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
10561 }
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
10562
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10563 /* Call this after drawing to the screen to make sure
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10564 * anything you have drawn is visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10565 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10566 void API dw_flush(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10567 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10568 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10569
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10570 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10571 * Creates a pixmap with given parameters.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10572 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10573 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10574 * width: Width of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10575 * height: Height of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10576 * depth: Color depth of the pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10577 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10578 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10579 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10580 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
10581 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10582 HPIXMAP pixmap;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10583 HDC hdc;
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 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10586 return NULL;
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 hdc = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10589
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10590 pixmap->width = width; pixmap->height = height;
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 pixmap->handle = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10593 pixmap->hbm = CreateCompatibleBitmap(hdc, width, height);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10594 pixmap->hdc = CreateCompatibleDC(hdc);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10595 pixmap->transcolor = DW_RGB_TRANSPARENT;
617
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 SelectObject(pixmap->hdc, pixmap->hbm);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10598
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10599 ReleaseDC(handle, hdc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10600
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10601 return pixmap;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10602 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10603
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
10604 #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
10605 /* 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
10606 * 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
10607 * 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
10608 */
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
10609 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
10610 {
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
10611 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
10612 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
10613 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
10614 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
10615 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
10616
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
10617 /* 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
10618 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
10619 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
10620
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
10621 /* 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
10622 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
10623 {
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
10624 /* Couldn't read the file header */
967
c8490b0d8577 Minor formatting fix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 966
diff changeset
10625 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
10626 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
10627 }
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
10628
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
10629 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
10630 {
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
10631 /* 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
10632 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
10633 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
10634 }
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
10635
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
10636 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
10637 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
10638 {
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
10639 /* 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
10640 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
10641 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
10642 }
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
10643
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
10644 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
10645 {
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
10646 /* 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
10647 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
10648 }
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
10649 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
10650 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
10651 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
10652 }
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
10653 #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
10654
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10655 /*
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10656 * Creates a pixmap from a file.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10657 * Parameters:
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10658 * 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
10659 * 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
10660 * DW pick the appropriate file extension.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10661 * (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
10662 * Returns:
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10663 * 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
10664 */
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10665 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
10666 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10667 HPIXMAP pixmap;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10668 BITMAP bm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10669 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
10670 #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
10671 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
10672 #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
10673
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10674 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
10675 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
10676
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10677 #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
10678 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
10679 #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
10680 file = _alloca(strlen(filename) + 5);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10681 strcpy(file, filename);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10682
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10683 /* 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
10684 if(access(file, 04) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10685 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10686 /* Try with .bmp extention */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10687 strcat(file, ".bmp");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10688 if(access(file, 04) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10689 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10690 free(pixmap);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10691 free(file);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10692 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10693 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10694 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10695
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
10696 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
10697 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
10698 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10699
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10700 pixmap->handle = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10701
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10702 if ( !pixmap->hbm )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10703 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10704 free(pixmap);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10705 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10706 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10707
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
10708 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
10709
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10710 pixmap->hdc = CreateCompatibleDC( hdc );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10711 GetObject( pixmap->hbm, sizeof(bm), &bm );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10712 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
10713 SelectObject( pixmap->hdc, pixmap->hbm );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10714 ReleaseDC( handle, hdc );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10715 pixmap->transcolor = DW_RGB_TRANSPARENT;
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10716
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10717 return pixmap;
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10718 }
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10719
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10720 /*
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10721 * 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
10722 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10723 * 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
10724 * 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
10725 * (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
10726 * 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
10727 * Returns:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10728 * 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
10729 */
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10730 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
10731 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10732 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
10733 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
10734 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
10735 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
10736 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
10737
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10738 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
10739 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10740 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
10741 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10742
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10743 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
10744
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10745 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
10746
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
10747 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
10748 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
10749 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10750 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
10751 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
10752 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10753 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
10754 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
10755 #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
10756 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
10757 #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
10758 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
10759 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
10760 #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
10761 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10762 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10763 {
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
10764 _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
10765 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
10766 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
10767 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
10768 }
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
10769 _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
10770 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
10771 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10772
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10773 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
10774 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10775 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
10776 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
10777 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
10778 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10779
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10780 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
10781
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10782 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
10783
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10784 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
10785
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10786 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
10787
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10788 ReleaseDC( handle, hdc );
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10789 pixmap->transcolor = DW_RGB_TRANSPARENT;
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10790
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10791 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
10792 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10793
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10794 /*
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10795 * 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
10796 */
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10797 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
10798 {
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
10799 if ( pixmap && pixmap->depth < 32)
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10800 {
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10801 pixmap->transcolor = _internal_color(color);
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10802 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10803 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10804
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10805 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10806 * Creates a pixmap from internal resource graphic specified by id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10807 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10808 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10809 * id: Resource ID associated with requested pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10810 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10811 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10812 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10813 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10814 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10815 HPIXMAP pixmap;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10816 BITMAP bm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10817 HDC hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10818
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10819 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10820 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10821
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10822 hdc = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10823
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10824 pixmap->hbm = LoadBitmap(DWInstance, MAKEINTRESOURCE(id));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10825 pixmap->hdc = CreateCompatibleDC(hdc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10826
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10827 GetObject(pixmap->hbm, sizeof(BITMAP), (void *)&bm);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10828
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10829 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
10830 pixmap->depth = bm.bmBitsPixel;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10831
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10832 SelectObject(pixmap->hdc, pixmap->hbm);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10833
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10834 ReleaseDC(handle, hdc);
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10835 pixmap->transcolor = DW_RGB_TRANSPARENT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10836
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10837 return pixmap;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10838 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10839
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10840 /*
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
10841 * 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
10842 * 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
10843 * 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
10844 * 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
10845 * 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
10846 * 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
10847 * 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
10848 * 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
10849 * 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
10850 */
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
10851 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
10852 {
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
10853 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
10854 {
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
10855 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
10856
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
10857 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
10858 {
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
10859 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
10860 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
10861 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
10862 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
10863 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
10864 }
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
10865 }
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
10866 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
10867 }
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
10868
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
10869 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10870 * Destroys an allocated pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10871 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10872 * pixmap: Handle to a pixmap returned by
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10873 * dw_pixmap_new..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10874 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10875 void API dw_pixmap_destroy(HPIXMAP pixmap)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10876 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10877 if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10878 {
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
10879 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
10880 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
10881 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
10882 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
10883 free(pixmap);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10884 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10885 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10886
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10887 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10888 * Copies from one item to another.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10889 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10890 * dest: Destination window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10891 * destp: Destination pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10892 * xdest: X coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10893 * ydest: Y coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10894 * width: Width of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10895 * height: Height of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10896 * src: Source window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10897 * srcp: Source pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10898 * xsrc: X coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10899 * ysrc: Y coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10900 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10901 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
10902 {
1243
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10903 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
10904 }
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10905
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10906 /*
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10907 * 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
10908 * Parameters:
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10909 * 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
10910 * 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
10911 * 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
10912 * 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
10913 * 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
10914 * 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
10915 * 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
10916 * 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
10917 * 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
10918 * 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
10919 * 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
10920 * 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
10921 * Returns:
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10922 * 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
10923 */
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10924 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
10925 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10926 HDC hdcdest;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10927 HDC hdcsrc;
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10928 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
10929 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
10930
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10931 /* Do some sanity checks */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10932 if ( dest )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10933 hdcdest = GetDC( dest );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10934 else if ( destp )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10935 hdcdest = destp->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10936 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
10937 return DW_ERROR_GENERAL;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10938
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10939 if ( src )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10940 hdcsrc = GetDC( src );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10941 else if ( srcp )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10942 hdcsrc = srcp->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10943 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
10944 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
10945
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10946 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
10947 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
10948
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10949 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
10950 {
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10951 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
10952 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
10953 }
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10954
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10955 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10956 /* 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
10957 _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
10958 _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
10959 _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
10960 _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
10961 #endif
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10962
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10963 /* 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
10964 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
10965 {
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10966 /* Don't do anything */
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10967 }
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10968 /* 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
10969 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
10970 {
1243
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10971 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
10972 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10973 else
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10974 {
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10975 /* 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
10976 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
10977 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
10978 else
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10979 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
10980 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10981 if ( !destp )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10982 ReleaseDC( dest, hdcdest );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10983 if ( !srcp )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10984 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
10985
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10986 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10987 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10988
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
10989 /* 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
10990 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
10991 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10992 int *info = (int *)data;
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 if(data)
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 Beep(info[0], info[1]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10997 free(data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10998 }
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
10999 }
e0ea29c3d1eb Fixed dw_window_pointer() so it works on Windows. Tried to fix the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 526
diff changeset
11000
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11001 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11002 * Emits a beep.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11003 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11004 * freq: Frequency.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11005 * dur: Duration.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11006 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11007 void API dw_beep(int freq, int dur)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11008 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11009 int *info = malloc(sizeof(int) * 2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11010
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11011 if(info)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11012 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11013 info[0] = freq;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11014 info[1] = dur;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11015
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11016 _beginthread(_beepthread, 100, (void *)info);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11017 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11018 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11019
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11020 /* Open a shared library and return a handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11021 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11022 * name: Base name of the shared library.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11023 * handle: Pointer to a module handle,
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11024 * will be filled in with the handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11025 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11026 int API dw_module_load(char *name, HMOD *handle)
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11027 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11028 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
11029 return DW_ERROR_UNKNOWN;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11030
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11031 *handle = LoadLibrary(UTF8toWide(name));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11032 return (NULL == *handle);
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11033 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11034
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11035 /* Queries the address of a symbol within open handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11036 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11037 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11038 * name: Name of the symbol you want the address of.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11039 * func: A pointer to a function pointer, to obtain
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11040 * the address.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11041 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11042 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
11043 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11044 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
11045 return DW_ERROR_UNKNOWN;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11046
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11047 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
11048 return DW_ERROR_UNKNOWN;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11049
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11050 *func = (void*)GetProcAddress(handle, name);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11051 return (NULL == *func);
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11052 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11053
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11054 /* Frees the shared library previously opened.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11055 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11056 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11057 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11058 int API dw_module_close(HMOD handle)
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11059 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11060 return FreeLibrary(handle);
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11061 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
11062
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11063 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11064 * Returns the handle to an unnamed mutex semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11065 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11066 HMTX API dw_mutex_new(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11067 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11068 return (HMTX)CreateMutex(NULL, FALSE, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11069 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11070
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11071 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11072 * Closes a semaphore created by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11073 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11074 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11075 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11076 void API dw_mutex_close(HMTX mutex)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11077 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11078 CloseHandle((HANDLE)mutex);
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 * Tries to gain access to the semaphore, if it can't it blocks.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11083 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11084 * mutex: The handle to the mutex returned by dw_mutex_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 void API dw_mutex_lock(HMTX mutex)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11087 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11088 if(_dwtid == dw_thread_id())
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11089 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11090 int rc = WaitForSingleObject((HANDLE)mutex, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11091
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11092 while(rc == WAIT_TIMEOUT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11093 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11094 dw_main_sleep(1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11095 rc = WaitForSingleObject((HANDLE)mutex, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11096 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11097 }
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
11098 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11099 WaitForSingleObject((HANDLE)mutex, INFINITE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11100 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11101
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11102 /*
1158
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11103 * 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
11104 * Parameters:
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11105 * 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
11106 * Returns:
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11107 * 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
11108 */
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11109 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
11110 {
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11111 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
11112 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
11113 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
11114 }
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11115
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11116 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11117 * Reliquishes the access to the semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11118 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11119 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11120 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11121 void API dw_mutex_unlock(HMTX mutex)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11122 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11123 ReleaseMutex((HANDLE)mutex);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11124 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11125
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11126 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11127 * Returns the handle to an unnamed event semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11128 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11129 HEV API dw_event_new(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11130 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
11131 return CreateEvent(NULL, TRUE, FALSE, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11132 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11133
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11134 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11135 * Resets a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11136 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11137 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11138 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11139 int API dw_event_reset(HEV eve)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11140 {
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
11141 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
11142 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
11143 return DW_ERROR_GENERAL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11144 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11145
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11146 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11147 * Posts a semaphore created by dw_event_new(). Causing all threads
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11148 * waiting on this event in dw_event_wait to continue.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11149 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11150 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11151 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11152 int API dw_event_post(HEV eve)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11153 {
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
11154 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
11155 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
11156 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
11157 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11158
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11159 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11160 * Waits on a semaphore created by dw_event_new(), until the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11161 * event gets posted or until the timeout expires.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11162 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11163 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11164 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11165 int API dw_event_wait(HEV eve, unsigned long timeout)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11166 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11167 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11168
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
11169 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
11170 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
11171 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
11172 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
11173 return DW_ERROR_TIMEOUT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11174 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
11175 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
11176 return DW_ERROR_GENERAL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11177 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11178
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11179 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11180 * Closes a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11181 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11182 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11183 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11184 int API dw_event_close(HEV *eve)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11185 {
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
11186 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
11187 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
11188 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
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
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 /* 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
11192 * 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
11193 * 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
11194 * 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
11195 * 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
11196 * 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
11197 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11198 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
11199 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11200 SECURITY_ATTRIBUTES sa;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11201
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11202 sa.nLength = sizeof( SECURITY_ATTRIBUTES);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11203 sa.lpSecurityDescriptor = &_dwsd;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11204 sa.bInheritHandle = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11205
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11206 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
11207 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11208
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11209 /* 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
11210 * 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
11211 * 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
11212 * 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
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 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
11215 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11216 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
11217 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11218
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11219 /* 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
11220 * 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
11221 * Parameters:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11222 * 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
11223 * 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
11224 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11225 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
11226 {
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
11227 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
11228 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
11229 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
11230 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11231
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11232 /* 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
11233 * 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
11234 * 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
11235 * 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
11236 * 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
11237 */
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 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
11239 {
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
11240 if(SetEvent(eve))
1170
4b94c9f5ddeb Missing return on Windows... surprised this compiled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
11241 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
11242 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
11243 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11244
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11245 /* 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
11246 * 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
11247 * 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
11248 * 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
11249 * 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
11250 * 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
11251 * 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
11252 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11253 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
11254 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11255 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11256
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
11257 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
11258 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
11259 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
11260 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
11261 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
11262 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
11263 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
11264 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
11265 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11266
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11267 /* 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
11268 * 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
11269 * 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
11270 * 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
11271 * 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
11272 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11273 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
11274 {
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
11275 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
11276 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
11277 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
11278 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11279
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11280 /*
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11281 * 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
11282 * 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
11283 * 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
11284 * 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
11285 * 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
11286 * 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
11287 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11288 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
11289 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11290 SECURITY_ATTRIBUTES sa;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11291 HSHM handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11292
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11293 sa.nLength = sizeof(SECURITY_ATTRIBUTES);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11294 sa.lpSecurityDescriptor = &_dwsd;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11295 sa.bInheritHandle = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11296
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11297 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
11298
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11299 if(!handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11300 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11301
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11302 *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
11303
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11304 if(!*dest)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11305 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11306 CloseHandle(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11307 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11308 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11309
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11310 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
11311 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11312
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11313 /*
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11314 * 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
11315 * 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
11316 * 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
11317 * 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
11318 * 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
11319 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11320 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
11321 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11322 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
11323
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11324 if(!handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11325 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11326
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11327 *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
11328
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11329 if(!*dest)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11330 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11331 CloseHandle(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11332 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11333 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11334
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11335 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
11336 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11337
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11338 /*
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11339 * 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
11340 * 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
11341 * 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
11342 * 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
11343 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11344 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
11345 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11346 UnmapViewOfFile(ptr);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11347 CloseHandle(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11348 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11349 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11350
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11351 /*
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11352 * Encapsulate thread creation on Win32.
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11353 */
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11354 void _dwthreadstart(void *data)
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11355 {
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11356 void (* threadfunc)(void *) = NULL;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11357 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
11358 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
11359 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
11360 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
11361 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
11362 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
11363 #endif
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11364
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11365 _init_thread();
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11366
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11367 threadfunc = (void (*)(void *))tmp[0];
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11368 threadfunc(tmp[1]);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11369
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11370 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
11371 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
11372 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
11373 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
11374 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
11375 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
11376 if((brush = TlsGetValue(_gpBrush)))
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
11377 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
11378 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
11379 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
11380 #endif
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11381 }
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11382
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11383 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11384 * Creates a new thread with a starting point of func.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11385 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11386 * func: Function which will be run in the new thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11387 * data: Parameter(s) passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11388 * stack: Stack size of new thread (OS/2 and Windows only).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11389 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11390 DWTID API dw_thread_new(void *func, void *data, int stack)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11391 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
11392 #if defined(__CYGWIN__)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11393 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
11394 #else
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11395 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
11396
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11397 tmp[0] = func;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11398 tmp[1] = data;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11399
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11400 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
11401 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11402 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11403
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11404 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11405 * Ends execution of current thread immediately.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11406 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11407 void API dw_thread_end(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11408 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
11409 #if !defined(__CYGWIN__)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11410 _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
11411 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11412 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11413
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11414 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11415 * Returns the current thread's ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11416 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11417 DWTID API dw_thread_id(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11418 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
11419 #if defined(__CYGWIN__)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11420 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
11421 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11422 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
11423 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11424 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11425
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11426 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11427 * Cleanly terminates a DW session, should be signal handler safe.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11428 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11429 * exitcode: Exit code reported to the operating system.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11430 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11431 void API dw_exit(int exitcode)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11432 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11433 OleUninitialize();
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
11434 #ifdef AEROGLASS
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
11435 /* 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
11436 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
11437 #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
11438 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
11439 DestroyWindow(hwndTooltip);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11440 exit(exitcode);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11441 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11442
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11443 /*
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11444 * 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
11445 * 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
11446 * 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
11447 * 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
11448 * 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
11449 * Returns:
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11450 * 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
11451 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11452 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
11453 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11454 HWND tmp = CreateWindow(SplitbarClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
11455 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11456 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
11457 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11458 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11459 (HMENU)id,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11460 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11461 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11462
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11463 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11464 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11465 HWND tmpbox = dw_box_new(DW_VERT, 0);
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
11466 float *percent = (float *)malloc(sizeof(float));
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11467
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11468 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
11469 SetParent(tmpbox, tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11470 dw_window_set_data(tmp, "_dw_topleft", (void *)tmpbox);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11471
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11472 tmpbox = dw_box_new(DW_VERT, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11473 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
11474 SetParent(tmpbox, tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11475 dw_window_set_data(tmp, "_dw_bottomright", (void *)tmpbox);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11476 *percent = 50.0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11477 dw_window_set_data(tmp, "_dw_percent", (void *)percent);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11478 dw_window_set_data(tmp, "_dw_type", (void *)type);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11479 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11480 return tmp;
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11481 }
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11482
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11483 /*
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11484 * Sets the position of a splitbar (pecentage).
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11485 * Parameters:
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11486 * 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
11487 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11488 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
11489 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11490 float *mypercent = (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
11491 int type = (int)dw_window_get_data(handle, "_dw_type");
129
e47c52b37cdd Code cleanup and OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 127
diff changeset
11492 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
11493
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11494 if(mypercent)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11495 *mypercent = percent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11496
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11497 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
11498
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
11499 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
11500 _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
11501 }
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11502
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11503 /*
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11504 * Gets the position of a splitbar (pecentage).
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11505 * Parameters:
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11506 * 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
11507 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11508 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
11509 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11510 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
11511
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11512 if(percent)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11513 return *percent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11514 return 0.0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11515 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11516
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11517 /*
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11518 * Creates a calendar window (widget) with given parameters.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11519 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11520 * type: Value can be DW_VERT or DW_HORZ.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11521 * topleft: Handle to the window to be top or left.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11522 * bottomright: Handle to the window to be bottom or right.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11523 * Classname: SysMonthCal32
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11524 * Returns:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11525 * A handle to a calendar window or NULL on failure.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11526 */
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11527 HWND API dw_calendar_new(unsigned long id)
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11528 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11529 RECT rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11530 MONTHDAYSTATE mds[3];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11531 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11532 MONTHCAL_CLASS,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
11533 NULL,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11534 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
11535 0,0,0,0,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11536 DW_HWND_OBJECT,
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11537 (HMENU)id,
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11538 DWInstance,
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11539 NULL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11540 if ( tmp )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11541 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11542 // 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
11543 MonthCal_GetMinReqRect(tmp, &rc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11544 // 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
11545 SetWindowPos(tmp, NULL, 0, 0,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11546 rc.right, rc.bottom,
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11547 SWP_NOZORDER | SWP_NOMOVE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11548 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
11549 MonthCal_SetDayState(tmp,3,mds);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11550 return tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11551 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11552 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11553 return NULL;
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11554 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11555
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11556 /*
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11557 * Sets the current date of a calendar
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11558 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11559 * 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
11560 * year: The year to set the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11561 * month: The month to set the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11562 * day: The day to set the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11563 */
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11564 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
11565 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11566 MONTHDAYSTATE mds[3];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11567 SYSTEMTIME date;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11568 date.wYear = year;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11569 date.wMonth = month;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11570 date.wDay = day;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11571 if ( MonthCal_SetCurSel( handle, &date ) )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11572 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11573 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11574 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11575 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11576 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11577 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
11578 MonthCal_SetDayState(handle,3,mds);
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11579 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11580
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11581 /*
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11582 * Gets the date from the calendar
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11583 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11584 * 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
11585 * year: Pointer to the year to get the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11586 * month: Pointer to the month to get the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11587 * day: Pointer to the day to get the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11588 */
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11589 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
11590 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11591 SYSTEMTIME date;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11592 if ( MonthCal_GetCurSel( handle, &date ) )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11593 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11594 *year = date.wYear;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11595 *month = date.wMonth;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11596 *day = date.wDay;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11597 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11598 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11599 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11600 *year = *month = *day = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11601 }
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11602 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11603
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
11604 /* 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
11605 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
11606 {
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11607 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
11608 }
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11609
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11610 /*
1795
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11611 * 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
11612 * Parameters:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11613 * 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
11614 * Remarks:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11615 * 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
11616 */
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11617 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
11618 {
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
11619 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
11620 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
11621 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
11622 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
11623 }
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11624
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11625 /*
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
11626 * 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
11627 * 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
11628 * 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
11629 * 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
11630 * Remarks:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11631 * 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
11632 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11633 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
11634 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11635 Box *thisbox = (Box *)GetWindowLongPtr(window, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11636
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11637 if(thisbox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11638 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
11639 }
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11640
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11641 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11642 * 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
11643 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11644 * 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
11645 * 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
11646 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11647 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
11648 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11649 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11650
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11651 if (cinfo)
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11652 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11653 cinfo->clickdefault = next;
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11654 }
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11655 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11656
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11657 /*
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11658 * Gets the contents of the default clipboard as text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11659 * Parameters:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11660 * None.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11661 * Returns:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11662 * 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
11663 * be converted to text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11664 */
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11665 char * API dw_clipboard_get_text(void)
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11666 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11667 HANDLE handle;
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11668 char *ret = NULL;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11669 TCHAR *tmp;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11670 #ifdef UNICODE
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11671 int type = CF_UNICODETEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11672 #else
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11673 int type = CF_TEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11674 #endif
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11675
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11676 if ( !OpenClipboard( NULL ) )
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11677 return ret;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11678
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11679 if ( ( handle = GetClipboardData(type) ) == NULL )
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11680 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11681 CloseClipboard();
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11682 return ret;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11683 }
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11684
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11685 if ( (tmp = GlobalLock(handle)) && _tcslen(tmp) )
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11686 {
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11687 ret = _strdup(WideToUTF8(tmp));
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11688 GlobalUnlock(handle);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11689 }
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11690 CloseClipboard();
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11691 return ret;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11692 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11693
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11694 /*
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11695 * 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
11696 * Parameters:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11697 * Text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11698 */
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11699 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
11700 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11701 HGLOBAL ptr1;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11702 LPTSTR ptr2;
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11703 TCHAR *buf;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11704 #ifdef UNICODE
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11705 int type = CF_UNICODETEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11706 char *src = calloc(len + 1, 1);
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11707
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11708 memcpy(src, str, len);
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11709 buf = UTF8toWide(src);
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11710 free(src);
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
11711 len = (int)_tcslen(buf);
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11712 #else
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11713 int type = CF_TEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11714
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11715 buf = str;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11716 #endif
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11717
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11718 if ( !OpenClipboard( NULL ) )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11719 return;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11720
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11721 ptr1 = GlobalAlloc( GMEM_MOVEABLE|GMEM_DDESHARE, (len + 1) * sizeof(TCHAR) );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11722
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11723 if ( !ptr1 )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11724 return;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11725
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11726 ptr2 = GlobalLock( ptr1 );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11727
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11728 memcpy(ptr2, buf, (len + 1) * sizeof(TCHAR));
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11729 GlobalUnlock( ptr1 );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11730 EmptyClipboard();
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11731
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11732 SetClipboardData( type, ptr1 );
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11733
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11734 CloseClipboard();
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11735 GlobalFree( ptr1 );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11736 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11737
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11738 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11739 * Returns some information about the current operating environment.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11740 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11741 * env: Pointer to a DWEnv struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11742 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11743 void API dw_environment_query(DWEnv *env)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11744 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11745 if(!env)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11746 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11747
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11748 /* Get the Windows version. */
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 env->MajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11751 env->MinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
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 /* 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
11754
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11755 env->MinorBuild = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11756
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11757 if (dwVersion < 0x80000000)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11758 {
716
67f2e890b9df Added "Windows Vista" and "Windows 7" to the operating system names reported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
11759 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
11760 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
11761 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
11762 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
11763 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
11764 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
11765 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
11766 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
11767 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
11768 strcpy(env->osName, "Windows 8");
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11769 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11770 strcpy(env->osName, "Windows NT");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11771
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11772 env->MajorBuild = (DWORD)(HIWORD(dwVersion));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11773 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11774 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11775 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11776 strcpy(env->osName, "Windows 95/98/ME");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11777 env->MajorBuild = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11778 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11779
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11780 strcpy(env->buildDate, __DATE__);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11781 strcpy(env->buildTime, __TIME__);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11782 env->DWMajorVersion = DW_MAJOR_VERSION;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11783 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
11784 #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
11785 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
11786 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11787 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
11788 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11789 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11790
1294
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11791 /* 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
11792 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
11793 {
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11794 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
11795
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11796 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
11797 {
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11798 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
11799 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
11800 else
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11801 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
11802 x++;
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11803 }
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11804 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
11805 }
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11806
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11807 #define BROWSEBUFSIZE 1000
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11808
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11809 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11810 * Opens a file dialog and queries user selection.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11811 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11812 * title: Title bar text for dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11813 * defpath: The default path of the open dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11814 * 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
11815 * flags: DW_FILE_OPEN or DW_FILE_SAVE or DW_DIRECTORY_OPEN.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11816 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11817 * NULL on error. A malloced buffer containing
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11818 * the file path on success.
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
11819 *
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11820 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11821 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11822 {
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11823 OPENFILENAME of = {0};
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11824 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
11825 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
11826 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
11827 TCHAR *dpath = UTF8toWide(defpath);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11828 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11829
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11830 if ( flags == DW_DIRECTORY_OPEN )
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11831 {
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
11832 /* 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
11833 #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
11834 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
11835 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
11836 LPITEMIDLIST pidl;
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11837 LPMALLOC pMalloc;
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11838
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11839 if (SUCCEEDED(SHGetMalloc(&pMalloc)))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11840 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11841 bi.hwndOwner = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11842 bi.pszDisplayName = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11843 bi.pidlRoot = 0;
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1694
diff changeset
11844 bi.lpszTitle = UTF8toWide(title);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11845 bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11846 bi.lpfn = NULL; /*BrowseCallbackProc*/
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11847
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11848 pidl = SHBrowseForFolder(&bi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11849 if (pidl)
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 if (SHGetPathFromIDList(pidl,szDir))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11852 {
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11853 _tcsncpy(filenamebuf,szDir,BROWSEBUFSIZE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11854 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11855
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11856 /* 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
11857 pMalloc->lpVtbl->Free(pMalloc,pidl);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11858 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
11859 return _strdup(WideToUTF8(filenamebuf));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11860 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11861 }
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11862 #else
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11863 if ( XBrowseForFolder( NULL,
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1694
diff changeset
11864 (LPCTSTR)dpath,
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11865 -1,
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1694
diff changeset
11866 (LPCTSTR)UTF8toWide(title),
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11867 (LPTSTR)filenamebuf,
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11868 BROWSEBUFSIZE,
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11869 FALSE ) )
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11870 {
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
11871 return _strdup( WideToUTF8(fbuf) );
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11872 }
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11873 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11874 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11875 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11876 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11877 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
11878
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11879 if (ext)
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11880 {
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11881 /*
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11882 * 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
11883 * 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
11884 */
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11885 int len;
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11886 TCHAR *ptr = filterbuf;
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11887 TCHAR *start = filterbuf;
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11888
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11889 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
11890 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
11891 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
11892 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
11893 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
11894 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
11895 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
11896 }
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11897
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11898 memset( &of, 0, sizeof(OPENFILENAME) );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11899
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11900 of.lStructSize = sizeof(OPENFILENAME);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11901 of.hwndOwner = HWND_DESKTOP;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11902 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
11903 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
11904 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
11905 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
11906 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
11907 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
11908 _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
11909 of.lpstrFile = filenamebuf;
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11910 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
11911 of.nFilterIndex = 1;
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11912 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
11913 /*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
11914 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
11915
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11916 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
11917 {
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11918 of.Flags |= OFN_OVERWRITEPROMPT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11919 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
11920 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11921 else
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11922 {
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11923 of.Flags |= OFN_FILEMUSTEXIST;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11924 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
11925 }
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11926
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11927 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
11928 return _strdup(WideToUTF8(of.lpstrFile));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11929 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11930 return NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11931 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11932
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11933 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11934 * Execute and external program in a seperate session.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11935 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11936 * program: Program name with optional path.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11937 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11938 * params: An array of pointers to string arguements.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11939 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11940 * -1 on error.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11941 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11942 int API dw_exec(char *program, int type, char **params)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11943 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11944 char **newparams;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11945 int retcode, count = 0, z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11946
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11947 while(params[count])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11948 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11949 count++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11950 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11951
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11952 newparams = (char **)malloc(sizeof(char *) * (count+1));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11953
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11954 for(z=0;z<count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11955 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11956 newparams[z] = malloc(strlen(params[z])+3);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11957 strcpy(newparams[z], "\"");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11958 strcat(newparams[z], params[z]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11959 strcat(newparams[z], "\"");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11960 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11961 newparams[count] = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11962
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
11963 /* 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
11964 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
11965
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11966 for(z=0;z<count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11967 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11968 free(newparams[z]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11969 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11970 free(newparams);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11971
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11972 return retcode;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11973 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11974
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11975 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11976 * Loads a web browser pointed at the given URL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11977 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11978 * url: Uniform resource locator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11979 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11980 int API dw_browse(char *url)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11981 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11982 char *browseurl = url;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11983 int retcode;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11984
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11985 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
11986 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11987 int len, z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11988
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11989 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
11990 len = (int)strlen(browseurl);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11991
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11992 for(z=0;z<len;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11993 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11994 if(browseurl[z] == '|')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11995 browseurl[z] = ':';
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11996 if(browseurl[z] == '/')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11997 browseurl[z] = '\\';
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11998 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11999 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12000
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
12001 retcode = (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
12002 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
12003 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
12004 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12005 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12006
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12007 typedef struct _dwprint
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12008 {
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12009 PRINTDLG pd;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12010 DOCINFO di;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12011 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
12012 void *drawdata;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12013 unsigned long flags;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12014 } DWPrint;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12015
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12016 /*
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12017 * 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
12018 * Parameters:
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
12019 * 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
12020 * 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
12021 * 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
12022 * 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
12023 * 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
12024 * Returns:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12025 * 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
12026 */
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
12027 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
12028 {
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12029 DWPrint *print;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12030
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12031 if(!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
12032 return NULL;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12033
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12034 print->drawfunc = drawfunc;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12035 print->drawdata = drawdata;
1139
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
12036 print->pd.lStructSize = sizeof(PRINTDLG);
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
12037 print->pd.hwndOwner = HWND_DESKTOP;
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
12038 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
12039 print->pd.nCopies = 1;
1140
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
12040 print->pd.nFromPage = 1;
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
12041 print->pd.nToPage = pages;
1139
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
12042 print->pd.nMinPage = 1;
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
12043 print->pd.nMaxPage = pages;
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
12044
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
12045 if(!PrintDlg(&(print->pd)))
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12046 {
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12047 free(print);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12048 return NULL;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12049 }
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12050
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12051 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
12052 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
12053 return print;
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12054 }
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12055
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12056 /*
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12057 * 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
12058 * Parameters:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12059 * 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
12060 * 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
12061 * Returns:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12062 * 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
12063 */
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12064 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
12065 {
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12066 DWPrint *p = print;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12067 HPIXMAP pixmap;
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
12068 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
12069
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12070 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
12071 return result;
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12072
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12073 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
12074 return result;
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12075
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
12076 width = GetDeviceCaps(p->pd.hDC, HORZRES);
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
12077 height = GetDeviceCaps(p->pd.hDC, VERTRES);
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
12078
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
12079 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
12080 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
12081 pixmap->transcolor = DW_RGB_TRANSPARENT;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12082
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
12083 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
12084 /* 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
12085 _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
12086 #endif
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
12087
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
12088 pixmap->width = width;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
12089 pixmap->height = height;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
12090
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12091 SelectObject(pixmap->hdc, pixmap->hbm);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12092
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12093 /* Start the job */
1139
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
12094 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
12095
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12096 /* Cycle through each page */
1140
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
12097 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
12098 {
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12099 StartPage(p->pd.hDC);
1140
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
12100 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
12101 EndPage(p->pd.hDC);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12102 }
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1140
diff changeset
12103 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
12104 {
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1140
diff changeset
12105 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
12106 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
12107 }
b23ae7d9f729 AbortDoc() needs to be issued instead of EndDoc() to cancel printing on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1336
diff changeset
12108 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
12109 AbortDoc(p->pd.hDC);
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12110 /* Free memory */
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12111 dw_pixmap_destroy(pixmap);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12112 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
12113 return result;
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12114 }
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12115
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12116 /*
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12117 * 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
12118 * Parameters:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12119 * 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
12120 */
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12121 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
12122 {
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12123 DWPrint *p = print;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12124
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12125 if(p)
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12126 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
12127 }
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12128
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12129 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12130 * Returns a pointer to a static buffer which containes the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12131 * current user directory. Or the root directory (C:\ on
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12132 * OS/2 and Windows).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12133 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12134 char * API dw_user_dir(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12135 {
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
12136 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
12137
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12138 if(!_user_dir[0])
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12139 {
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12140 HANDLE hToken = 0;
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
12141
907
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12142 /* 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
12143 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
12144 {
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12145 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
12146 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
12147
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
12148 GetUserProfileDirectory(hToken, Buf, &BufSize);
907
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12149 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
12150 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
12151 }
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12152 /* 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
12153 if(!_user_dir[0])
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12154 {
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12155 strcpy(_user_dir, "C:\\");
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12156 }
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12157 }
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12158 return _user_dir;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12159 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12160
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12161 /*
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12162 * 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
12163 * 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
12164 */
1384
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1381
diff changeset
12165 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
12166 {
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12167 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
12168 }
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12169
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12170 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12171 * Call a function from the window (widget)'s context.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12172 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12173 * handle: Window handle of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12174 * function: Function pointer to be called.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12175 * data: Pointer to the data to be passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12176 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12177 void API dw_window_function(HWND handle, void *function, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12178 {
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
12179 SendMessage(_toplevel_window(handle), WM_USER, (WPARAM)function, (LPARAM)data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12180 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12181
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12182 /* 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
12183 * 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
12184 * 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
12185 */
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
12186 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
12187 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12188 UserData *tmp = *root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12189
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12190 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12191 {
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
12192 if(_stricmp(tmp->varname, varname) == 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12193 return tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12194 tmp = tmp->next;
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 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
12197 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12198
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
12199 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
12200 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12201 UserData *new = _find_userdata(root, varname);
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(new)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12204 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12205 new->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12206 return 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 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12209 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12210 new = malloc(sizeof(UserData));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12211 if(new)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12212 {
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
12213 new->varname = _strdup(varname);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12214 new->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12215
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12216 new->next = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12217
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12218 if (!*root)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12219 *root = new;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12220 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12221 {
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
12222 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
12223
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12224 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12225 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12226 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12227 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12228 }
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
12229 prev->next = new;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12230 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12231 return TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12232 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12233 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12234 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
12235 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12236
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
12237 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
12238 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12239 UserData *prev = NULL, *tmp = *root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12240
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12241 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12242 {
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
12243 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
12244 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12245 if(!prev)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12246 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12247 *root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12248 free(tmp->varname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12249 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12250 if(!all)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12251 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12252 tmp = *root;
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 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12255 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12256 /* If all is true we should
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12257 * never get here.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12258 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12259 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12260 free(tmp->varname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12261 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12262 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12263 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12264 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12265 else
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 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12268 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12269 }
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 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
12272 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12273
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12274 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12275 * 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
12276 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12277 * 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
12278 * 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
12279 * 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
12280 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12281 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
12282 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12283 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA);
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 if(!cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12286 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12287 if(!dataname)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12288 return;
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 cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12291 cinfo->fore = cinfo->back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12292 SetWindowLongPtr(window, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12293 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12294
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12295 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12296 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12297 if(data)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12298 _new_userdata(&(cinfo->root), dataname, data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12299 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12300 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12301 if(dataname)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12302 _remove_userdata(&(cinfo->root), dataname, FALSE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12303 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12304 _remove_userdata(&(cinfo->root), NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12305 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12306 }
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12307 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12308
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12309 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12310 * 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
12311 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12312 * 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
12313 * 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
12314 * 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
12315 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12316 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
12317 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12318 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12319
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12320 if(cinfo && cinfo->root && dataname)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12321 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12322 UserData *ud = _find_userdata(&(cinfo->root), dataname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12323 if(ud)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12324 return ud->data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12325 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12326 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
12327 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12328
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12329 /*
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12330 * 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
12331 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12332 * 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
12333 * 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
12334 * 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
12335 * Returns:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12336 * 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
12337 */
200
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
12338 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
12339 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12340 if(sigfunc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12341 {
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
12342 /* 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
12343 * 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
12344 */
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
12345 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
12346
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12347 if(timerid)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12348 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12349 _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
12350 return timerid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12351 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12352 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12353 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
12354 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12355
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12356 /*
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12357 * 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
12358 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12359 * 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
12360 */
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12361 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
12362 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12363 SignalHandler *prev = NULL, *tmp = Root;
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 /* 0 is an invalid timer ID */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12366 if(!id)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12367 return;
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 KillTimer(NULL, id);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12370
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12371 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12372 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12373 if(tmp->id == id)
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 if(prev)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12376 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12377 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12378 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12379 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12380 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12381 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12382 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12383 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12384 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12385 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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12388 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12389 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12390 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12391 tmp = tmp->next;
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 }
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12394 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12395
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12396 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12397 * Add a callback to a window event.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12398 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12399 * window: Window handle of signal to be called back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12400 * signame: A string pointer identifying which signal to be hooked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12401 * sigfunc: The pointer to the function to be used as the callback.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12402 * data: User data to be passed to the handler function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12403 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12404 void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12405 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12406 ULONG message = 0, id = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12407
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12408 if (window && signame && sigfunc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12409 {
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
12410 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
12411 window = _normalize_handle(window);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12412
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12413 if ((message = _findsigmessage(signame)) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12414 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12415 /* Handle special case of the menu item */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12416 if (message == WM_COMMAND && window < (HWND)65536)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12417 {
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
12418 char buffer[16];
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12419 HWND owner;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12420
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
12421 _snprintf(buffer, 15, "_dw_id%d", (int)window);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12422 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
12423
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
12424 /* 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
12425 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
12426
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12427 if (owner)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12428 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12429 id = (ULONG)window;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12430 window = owner;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12433 _new_signal(message, window, id, sigfunc, data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12434 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12435 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12436 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12437
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12438 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12439 * Removes callbacks for a given window with given name.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12440 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12441 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12442 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12443 void API dw_signal_disconnect_by_name(HWND window, char *signame)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12444 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12445 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12446 ULONG message;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12447
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12448 if(!window || !signame || (message = _findsigmessage(signame)) == 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12449 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12450
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12451 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12452 {
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
12453 if(((window < (HWND)65536 && (int)window == tmp->id) || tmp->window == window) && tmp->message == message)
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
12454 {
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
12455 if(prev)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12456 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12457 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12458 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12459 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12460 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12461 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12462 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12463 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12464 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12465 tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12466 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12467 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12468 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12469 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12470 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12471 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12472 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12473 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12474 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12475
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12476 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12477 * Removes all callbacks for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12478 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12479 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12480 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12481 void API dw_signal_disconnect_by_window(HWND window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12482 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12483 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12484
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12485 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12486 {
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
12487 if((window < (HWND)65536 && (int)window == tmp->id) || tmp->window == window)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12488 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12489 if(prev)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12490 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12491 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12492 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12493 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12494 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12495 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12496 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12497 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12498 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12499 tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12500 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12501 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12502 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12503 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12504 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12505 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12506 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12507 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12508 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12509
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12510 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12511 * Removes all callbacks for a given window with specified data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12512 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12513 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12514 * data: Pointer to the data to be compared against.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12515 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12516 void API dw_signal_disconnect_by_data(HWND window, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12517 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12518 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12519
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12520 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12521 {
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
12522 if(((window < (HWND)65536 && (int)window == tmp->id) || tmp->window == window) && tmp->data == data)
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
12523 {
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
12524 if(prev)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12525 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12526 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12527 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12528 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12529 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12530 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12531 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12532 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12533 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12534 tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12535 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12536 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12537 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12538 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12539 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12540 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12541 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12542 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12543 }
1784
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12544
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12545 /*
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12546 * 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
12547 * Parameters:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12548 * 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
12549 * Returns:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12550 * 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
12551 * 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
12552 */
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12553 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
12554 {
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12555 #ifdef UNICODE
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12556 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
12557 #else
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12558 return NULL;
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12559 #endif
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12560 }
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12561
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12562 /*
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12563 * 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
12564 * Parameters:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12565 * 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
12566 * Returns:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12567 * 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
12568 * 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
12569 */
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12570 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
12571 {
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12572 #ifdef UNICODE
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12573 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
12574 #else
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12575 return NULL;
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12576 #endif
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12577 }
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12578