annotate win/dw.c @ 1868:dc3260e1a915

Use the cached text from the tree on Windows instead of caching parameters... This also fixes a memory leak in the tree code.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 21 Mar 2013 21:14:04 +0000
parents c836603d3f14
children a2d556368be1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
1 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2 * Dynamic Windows:
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3 * A GTK like implementation of the Win32 GUI
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4 *
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
5 * (C) 2000-2013 Brian Smith <brian@dbsoft.org>
1386
fd1de4e9e542 Updated the readme and comments in the source files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1384
diff changeset
6 * (C) 2003-2011 Mark Hessling <mark@rexx.org>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7 *
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8 */
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
9
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
10 #ifdef AEROGLASS
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
11 #define _WIN32_IE 0x0501
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
12 #define WINVER 0x501
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
13 #else
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
14 #define _WIN32_IE 0x0500
466
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
15 #define WINVER 0x500
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
16 #endif
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
17 #include <windows.h>
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
18 #include <windowsx.h>
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
19 #include <commctrl.h>
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
20 #include <shlwapi.h>
449
787cc1e27897 Add support for directory browsing under Win32. DW_DIRECTORY_OPEN can be
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 448
diff changeset
21 #include <shlobj.h>
907
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
22 #include <userenv.h>
1618
428148fd0976 Switch to UNICODE builds by default on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1617
diff changeset
23 #include <tchar.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
24 #include <stdlib.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
25 #include <string.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
26 #include <stdio.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
27 #include <process.h>
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
28 #include <malloc.h>
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
29 #include <io.h>
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
30 #include <time.h>
1633
c441c85baa57 Fix rendering Arc segments in anti-antialiased mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1632
diff changeset
31 #define _USE_MATH_DEFINES
1268
148daf522080 Fixed on Windows sqrt() issue due to missing header...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1261
diff changeset
32 #include <math.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
33 #include "dw.h"
1336
63e05ef4a59a Fixes to the source on Windows so it will build standalone again. (With HTML widget disabled)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1332
diff changeset
34 #ifdef BUILD_DLL
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
35 #include "XBrowseForFolder.h"
1336
63e05ef4a59a Fixes to the source on Windows so it will build standalone again. (With HTML widget disabled)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1332
diff changeset
36 #endif
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
37 #ifdef AEROGLASS
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
38 #include <uxtheme.h>
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
39 #endif
1550
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
40 #include <richedit.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
41
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
42 #define STATICCLASSNAME TEXT("STATIC")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
43 #define COMBOBOXCLASSNAME TEXT("COMBOBOX")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
44 #define LISTBOXCLASSNAME TEXT("LISTBOX")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
45 #define BUTTONCLASSNAME TEXT("BUTTON")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
46 #define POPUPMENUCLASSNAME TEXT("POPUPMENU")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
47 #define EDITCLASSNAME TEXT("EDIT")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
48 #define FRAMECLASSNAME TEXT("FRAME")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
49 #define SCROLLBARCLASSNAME TEXT("SCROLLBAR")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
50
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
51 #define ClassName TEXT("dynamicwindows")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
52 #define SplitbarClassName TEXT("dwsplitbar")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
53 #define ObjectClassName TEXT("dwobjectclass")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
54 #define BrowserClassName TEXT("dwbrowserclass")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
55 #define ScrollClassName TEXT("dwscrollclass")
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
56 #define StatusbarClassName TEXT("dwstatusbar")
1556
4a9c574d5c17 Fixed on Windows showing themed static text on colored boxes when the window is glass.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1550
diff changeset
57 #define DefaultFont NULL
4a9c574d5c17 Fixed on Windows showing themed static text on colored boxes when the window is glass.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1550
diff changeset
58
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
59 #ifdef GDIPLUS
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
60 /* GDI+ Headers are not C compatible... so define what we need here instead */
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
61 struct GdiplusStartupInput
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
62 {
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
63 UINT32 GdiplusVersion;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
64 void *DebugEventCallback;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
65 BOOL SuppressBackgroundThread;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
66 BOOL SuppressExternalCodecs;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
67 };
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
68
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
69 typedef enum {
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
70 Ok = 0,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
71 GenericError = 1,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
72 InvalidParameter = 2,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
73 OutOfMemory = 3,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
74 ObjectBusy = 4,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
75 InsufficientBuffer = 5,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
76 NotImplemented = 6,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
77 Win32Error = 7,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
78 WrongState = 8,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
79 Aborted = 9,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
80 FileNotFound = 10,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
81 ValueOverflow = 11,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
82 AccessDenied = 12,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
83 UnknownImageFormat = 13,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
84 FontFamilyNotFound = 14,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
85 FontStyleNotFound = 15,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
86 NotTrueTypeFont = 16,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
87 UnsupportedGdiplusVersion = 17,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
88 GdiplusNotInitialized = 18,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
89 PropertyNotFound = 19,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
90 PropertyNotSupported = 20,
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
91 ProfileNotFound = 21
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
92 } GpStatus;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
93
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
94 typedef enum {
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
95 UnitWorld,
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
96 UnitDisplay,
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
97 UnitPixel,
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
98 UnitPoint,
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
99 UnitInch,
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
100 UnitDocument,
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
101 UnitMillimeter
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
102 } GpUnit;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
103
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
104 typedef enum {
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
105 FlushIntentionFlush = 0,
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
106 FlushIntentionSync = 1
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
107 } GpFlushIntention;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
108
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
109 typedef enum {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
110 QualityModeInvalid = -1,
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
111 QualityModeDefault = 0,
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
112 QualityModeLow = 1,
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
113 QualityModeHigh = 2
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
114 } QualityMode;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
115
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
116 typedef enum {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
117 SmoothingModeInvalid = QualityModeInvalid,
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
118 SmoothingModeDefault = QualityModeDefault,
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
119 SmoothingModeHighSpeed = QualityModeLow,
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
120 SmoothingModeHighQuality = QualityModeHigh,
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
121 SmoothingModeNone,
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
122 SmoothingModeAntiAlias
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
123 } SmoothingMode;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
124
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
125 typedef void GpGraphics;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
126 typedef void GpPen;
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
127 typedef void GpBrush;
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
128 typedef void GpBitmap;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
129 typedef void GpImage;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
130 typedef POINT GpPoint;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
131 typedef DWORD ARGB;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
132 typedef float REAL;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
133
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
134 #define ALPHA_SHIFT 24
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
135 #define RED_SHIFT 16
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
136 #define GREEN_SHIFT 8
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
137 #define BLUE_SHIFT 0
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
138 #define ALPHA_MASK ((ARGB) 0xff << ALPHA_SHIFT)
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
139
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
140 #define MAKEARGB(a, r, g, b) \
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
141 (((ARGB) ((a) & 0xff) << ALPHA_SHIFT)| \
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
142 ((ARGB) ((r) & 0xff) << RED_SHIFT) | \
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
143 ((ARGB) ((g) & 0xff) << GREEN_SHIFT)| \
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
144 ((ARGB) ((b) & 0xff) << BLUE_SHIFT))
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
145
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
146 /* Graphic conversion functions */
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
147 GpStatus WINAPI GdipCreateBitmapFromFile(const WCHAR* filename, GpBitmap **bitmap);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
148 GpStatus WINAPI GdipCreateHBITMAPFromBitmap(GpBitmap *bitmap, HBITMAP* hbmReturn, DWORD background);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
149 GpStatus WINAPI GdipCreateHICONFromBitmap(GpBitmap *bitmap, HICON *hbmReturn);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
150 GpStatus WINAPI GdipDisposeImage(GpImage *image);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
151 GpStatus WINAPI GdipGetImagePixelFormat(GpImage *image, INT *format);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
152 /* Startup and Shutdown */
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
153 GpStatus WINAPI GdiplusStartup(ULONG_PTR *token, const struct GdiplusStartupInput *input, void *output);
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
154 VOID WINAPI GdiplusShutdown(ULONG_PTR token);
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
155 /* Drawing functions */
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
156 GpStatus WINAPI GdipCreateFromHDC(HDC hdc, GpGraphics **graphics);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
157 GpStatus WINAPI GdipCreateFromHWND(HWND hwnd, GpGraphics **graphics);
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
158 GpStatus WINAPI GdipDeleteGraphics(GpGraphics *graphics);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
159 GpStatus WINAPI GdipSetSmoothingMode(GpGraphics *graphics, SmoothingMode smoothingMode);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
160 GpStatus WINAPI GdipCreatePen1(ARGB color, REAL width, GpUnit unit, GpPen **pen);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
161 GpStatus WINAPI GdipDeletePen(GpPen *pen);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
162 GpStatus WINAPI GdipCreateSolidFill(ARGB color, GpBrush **brush);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
163 GpStatus WINAPI GdipDeleteBrush(GpBrush *brush);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
164 GpStatus WINAPI GdipSetSolidFillColor(GpBrush *brush, ARGB color);
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
165 GpStatus WINAPI GdipDrawLineI(GpGraphics *graphics, GpPen *pen, INT x1, INT y1, INT x2, INT y2);
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
166 GpStatus WINAPI GdipDrawLinesI(GpGraphics *graphics, GpPen *pen, const GpPoint *points, INT count);
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
167 GpStatus WINAPI GdipDrawRectangleI(GpGraphics *graphics, GpPen *pen, INT x, INT y, INT width, INT height);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
168 GpStatus WINAPI GdipFillRectangleI(GpGraphics *graphics, GpBrush *brush, INT x, INT y, INT width, INT height);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
169 GpStatus WINAPI GdipDrawArcI(GpGraphics *graphics, GpPen *pen, INT x, INT y, INT width, INT height, REAL startAngle, REAL sweepAngle);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
170 GpStatus WINAPI GdipDrawPolygonI(GpGraphics *graphics, GpPen *pen, const GpPoint *points, INT count);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
171 GpStatus WINAPI GdipFillPolygon2I(GpGraphics *graphics, GpBrush *brush, const GpPoint *points, INT count);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
172 GpStatus WINAPI GdipDrawEllipseI(GpGraphics *graphics, GpPen *pen, INT x, INT y, INT width, INT height);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
173 GpStatus WINAPI GdipFillEllipseI(GpGraphics *graphics, GpBrush *brush, INT x, INT y, INT width, INT height);
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
174 GpStatus WINAPI GdipFlush(GpGraphics *graphics, GpFlushIntention intention);
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
175
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
176 /* Pixel format information */
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
177 #define PixelFormatIndexed 0x00010000
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
178 #define PixelFormatGDI 0x00020000
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
179 #define PixelFormatAlpha 0x00040000
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
180 #define PixelFormatPAlpha 0x00080000
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
181 #define PixelFormatExtended 0x00100000
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
182 #define PixelFormatCanonical 0x00200000
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
183
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
184 #define PixelFormatUndefined 0
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
185 #define PixelFormatDontCare 0
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
186
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
187 #define PixelFormat1bppIndexed (1 | ( 1 << 8) | PixelFormatIndexed | PixelFormatGDI)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
188 #define PixelFormat4bppIndexed (2 | ( 4 << 8) | PixelFormatIndexed | PixelFormatGDI)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
189 #define PixelFormat8bppIndexed (3 | ( 8 << 8) | PixelFormatIndexed | PixelFormatGDI)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
190 #define PixelFormat16bppGrayScale (4 | (16 << 8) | PixelFormatExtended)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
191 #define PixelFormat16bppRGB555 (5 | (16 << 8) | PixelFormatGDI)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
192 #define PixelFormat16bppRGB565 (6 | (16 << 8) | PixelFormatGDI)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
193 #define PixelFormat16bppARGB1555 (7 | (16 << 8) | PixelFormatAlpha | PixelFormatGDI)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
194 #define PixelFormat24bppRGB (8 | (24 << 8) | PixelFormatGDI)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
195 #define PixelFormat32bppRGB (9 | (32 << 8) | PixelFormatGDI)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
196 #define PixelFormat32bppARGB (10 | (32 << 8) | PixelFormatAlpha | PixelFormatGDI | PixelFormatCanonical)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
197 #define PixelFormat32bppPARGB (11 | (32 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatGDI)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
198 #define PixelFormat48bppRGB (12 | (48 << 8) | PixelFormatExtended)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
199 #define PixelFormat64bppARGB (13 | (64 << 8) | PixelFormatAlpha | PixelFormatCanonical | PixelFormatExtended)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
200 #define PixelFormat64bppPARGB (14 | (64 << 8) | PixelFormatAlpha | PixelFormatPAlpha | PixelFormatExtended)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
201 #define PixelFormat32bppCMYK (15 | (32 << 8))
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
202
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
203 /* Token to the GDI+ Instance */
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
204 ULONG_PTR gdiplusToken;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
205 #endif
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
206
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
207 #ifdef AEROGLASS
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
208 HRESULT (WINAPI *_DwmExtendFrameIntoClientArea)(HWND hWnd, const MARGINS *pMarInset) = 0;
1515
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
209 HRESULT (WINAPI *_DwmIsCompositionEnabled)(BOOL *pfEnabled) = 0;
1727
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
210 HTHEME (WINAPI *_OpenThemeData)(HWND hwnd, LPCWSTR pszClassList) = 0;
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
211 HPAINTBUFFER (WINAPI *_BeginBufferedPaint)(HDC hdcTarget, const RECT *prcTarget, BP_BUFFERFORMAT dwFormat, BP_PAINTPARAMS *pPaintParams, HDC *phdc) = 0;
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
212 HRESULT (WINAPI *_BufferedPaintSetAlpha)(HPAINTBUFFER hBufferedPaint, const RECT *prc, BYTE alpha) = 0;
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
213 HRESULT (WINAPI *_DrawThemeTextEx)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwFlags, LPRECT pRect, const DTTOPTS *pOptions) = 0;
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
214 HRESULT (WINAPI *_EndBufferedPaint)(HPAINTBUFFER hBufferedPaint, BOOL fUpdateTarget) = 0;
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
215 HRESULT (WINAPI *_CloseThemeData)(HTHEME hTheme) = 0;
1515
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
216 BOOL _dw_composition = FALSE;
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
217 COLORREF _dw_transparencykey = RGB(200,201,202);
1730
3828f3faec8c Had to move uxtheme/SetWindowTheme out of the AERO #ifdefs to get
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1729
diff changeset
218 HANDLE hdwm = 0;
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
219 #endif
1730
3828f3faec8c Had to move uxtheme/SetWindowTheme out of the AERO #ifdefs to get
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1729
diff changeset
220 /* Aero related but separate functions and handles */
3828f3faec8c Had to move uxtheme/SetWindowTheme out of the AERO #ifdefs to get
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1729
diff changeset
221 HRESULT (WINAPI *_SetWindowTheme)(HWND hwnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList) = 0;
3828f3faec8c Had to move uxtheme/SetWindowTheme out of the AERO #ifdefs to get
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1729
diff changeset
222 HANDLE huxtheme = 0;
3828f3faec8c Had to move uxtheme/SetWindowTheme out of the AERO #ifdefs to get
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1729
diff changeset
223
1550
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
224 /* Needed for Rich Edit controls */
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
225 HANDLE hrichedit = 0;
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
226
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
227 /*
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
228 * MinGW Is missing a bunch of definitions
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
229 * so #define them here...
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
230 */
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
231
1653
a7a24a3b8899 Fixes for the latest MinGW (gcc 4.6.2). Only ANSI mode is currently supported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1643
diff changeset
232 #if !defined( _tstol )
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
233 #if defined(UNICODE)
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
234 # define _tstol _wtol
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
235 #else
1653
a7a24a3b8899 Fixes for the latest MinGW (gcc 4.6.2). Only ANSI mode is currently supported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1643
diff changeset
236 # define _tstol atol
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
237 #endif
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
238 #endif
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
239 #if !defined(PBS_MARQUEE)
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
240 # define PBS_MARQUEE 0x08
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
241 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
242 #if !defined(PBM_SETMARQUEE)
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
243 # define PBM_SETMARQUEE (WM_USER+10)
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
244 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
245 #if !defined(LVS_EX_DOUBLEBUFFER)
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
246 # define LVS_EX_DOUBLEBUFFER 0x10000
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
247 #endif
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
248
1763
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
249 HWND popup = (HWND)NULL, DW_HWND_OBJECT = (HWND)NULL, hwndTooltip = (HWND)0;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
250
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
251 HINSTANCE DWInstance = NULL;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
252
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
253 DWORD dwVersion = 0, dwComctlVer = 0;
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
254 DWTID _dwtid = -1;
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
255 SECURITY_DESCRIPTOR _dwsd;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
256
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
257 #define PACKVERSION(major,minor) MAKELONG(minor,major)
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
258
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
259 #define IS_XPPLUS (dwComctlVer >= PACKVERSION(5,82))
1119
e8e7f048f0b8 Removed spinbutton workaround on Vista and higher... still needed for XP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1115
diff changeset
260 #define IS_VISTAPLUS (dwComctlVer >= PACKVERSION(6,10))
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
261
95
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
262 #ifndef MIN
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
263 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
264 #endif
636c37ca7238 Avoid allocating super huge buffers when dealing with the MLEs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 93
diff changeset
265
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
266 /*
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
267 * For the dw*from_data() functions, a temporary file is required to write
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
268 * the contents of the image to so it can be loaded by the Win32 API
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
269 * We use _tempnam() which uses TMP env variable by default. It can be passed
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
270 * an alternate temporary directory if TMP is not set, so we get the value
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
271 * of TEMP and store it here.
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
272 */
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
273 static char _dw_alternate_temp_dir[MAX_PATH+1] = {0};
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
274 static char _dw_exec_dir[MAX_PATH+1] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
275
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
276 int main(int argc, char *argv[]);
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
277
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
278 #define ICON_INDEX_LIMIT 200
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
279 HICON lookup[200];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
280 HIMAGELIST hSmall = 0, hLarge = 0;
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
281
105
ad95fc623ff3 Some changes to the container optimization code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 104
diff changeset
282 /* Special flag used for internal tracking */
ad95fc623ff3 Some changes to the container optimization code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 104
diff changeset
283 #define DW_CFA_RESERVED (1 << 30)
ad95fc623ff3 Some changes to the container optimization code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 104
diff changeset
284
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
285 DWORD _foreground;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
286 DWORD _background;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
287 DWORD _hPen;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
288 DWORD _hBrush;
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
289 #ifdef GDIPLUS
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
290 DWORD _gpPen;
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
291 DWORD _gpBrush;
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
292 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
293
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
294 BYTE _red[] = { 0x00, 0xbb, 0x00, 0xaa, 0x00, 0xbb, 0x00, 0xaa, 0x77,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
295 0xff, 0x00, 0xee, 0x00, 0xff, 0x00, 0xff, 0xaa, 0x00 };
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
296 BYTE _green[] = { 0x00, 0x00, 0xbb, 0xaa, 0x00, 0x00, 0xbb, 0xaa, 0x77,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
297 0x00, 0xff, 0xee, 0x00, 0x00, 0xee, 0xff, 0xaa, 0x00 };
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
298 BYTE _blue[] = { 0x00, 0x00, 0x00, 0x00, 0xcc, 0xbb, 0xbb, 0xaa, 0x77,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
299 0x00, 0x00, 0x00, 0xff, 0xff, 0xee, 0xff, 0xaa, 0x00};
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
300
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
301 HBRUSH _colors[18];
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
302
1075
3d117071a50b Renamed Mac _dw_default_font() to dw_font_set_default() and added it on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1073
diff changeset
303 HFONT _DefaultFont = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
304
1856
285bf986e4fd Get HTML support building with MinGW... some warnings need to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1853
diff changeset
305 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
584
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
306 LRESULT CALLBACK _browserWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
1336
63e05ef4a59a Fixes to the source on Windows so it will build standalone again. (With HTML widget disabled)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1332
diff changeset
307 #endif
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
308 LRESULT CALLBACK _colorwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
309 void _resize_notebook_page(HWND handle, int pageid);
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
310 void _handle_splitbar_resize(HWND hwnd, float percent, int type, int x, int y);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
311 int _lookup_icon(HWND handle, HICON hicon, int type);
299
2a97f8d9b297 Use DrawStatusText() to make the status lines, instead of doing it ourself.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 298
diff changeset
312 HFONT _acquire_font(HWND handle, char *fontname);
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
313 void _click_default(HWND handle);
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
314 void _do_resize(Box *thisbox, int x, int y);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
315
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
316 /* Internal function to queue a window redraw */
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
317 void _dw_redraw(HWND window, int skip)
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
318 {
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
319 static HWND lastwindow = 0;
1425
1628bf383893 Changes to _dw_redraw() to prevent infinite recursion on OS/2, Win and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1422
diff changeset
320 HWND redraw = lastwindow;
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
321
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
322 if(skip && !window)
1425
1628bf383893 Changes to _dw_redraw() to prevent infinite recursion on OS/2, Win and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1422
diff changeset
323 return;
1628bf383893 Changes to _dw_redraw() to prevent infinite recursion on OS/2, Win and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1422
diff changeset
324
1628bf383893 Changes to _dw_redraw() to prevent infinite recursion on OS/2, Win and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1422
diff changeset
325 lastwindow = window;
1628bf383893 Changes to _dw_redraw() to prevent infinite recursion on OS/2, Win and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1422
diff changeset
326 if(redraw != lastwindow && redraw)
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
327 {
1425
1628bf383893 Changes to _dw_redraw() to prevent infinite recursion on OS/2, Win and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1422
diff changeset
328 dw_window_redraw(redraw);
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
329 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
330 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
331
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
332 typedef struct _sighandler
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
333 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
334 struct _sighandler *next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
335 ULONG message;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
336 HWND window;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
337 int id;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
338 void *signalfunction;
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
339 void *discfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
340 void *data;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
341
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
342 } SignalHandler;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
343
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
344 SignalHandler *Root = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
345
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
346 typedef struct
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
347 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
348 ULONG message;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
349 char name[30];
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
350
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
351 } SignalList;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
352
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
353 static int in_checkbox_handler = 0;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
354
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
355 /* List of signals and their equivilent Win32 message */
481
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
356 #define SIGNALMAX 17
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
357
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
358 SignalList SignalTranslate[SIGNALMAX] = {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
359 { WM_SIZE, DW_SIGNAL_CONFIGURE },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
360 { WM_CHAR, DW_SIGNAL_KEY_PRESS },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
361 { WM_LBUTTONDOWN, DW_SIGNAL_BUTTON_PRESS },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
362 { WM_LBUTTONUP, DW_SIGNAL_BUTTON_RELEASE },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
363 { WM_MOUSEMOVE, DW_SIGNAL_MOTION_NOTIFY },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
364 { WM_CLOSE, DW_SIGNAL_DELETE },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
365 { WM_PAINT, DW_SIGNAL_EXPOSE },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
366 { WM_COMMAND, DW_SIGNAL_CLICKED },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
367 { NM_DBLCLK, DW_SIGNAL_ITEM_ENTER },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
368 { NM_RCLICK, DW_SIGNAL_ITEM_CONTEXT },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
369 { LBN_SELCHANGE, DW_SIGNAL_LIST_SELECT },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
370 { TVN_SELCHANGED, DW_SIGNAL_ITEM_SELECT },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
371 { WM_SETFOCUS, DW_SIGNAL_SET_FOCUS },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
372 { WM_VSCROLL, DW_SIGNAL_VALUE_CHANGED },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
373 { TCN_SELCHANGE, DW_SIGNAL_SWITCH_PAGE },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
374 { LVN_COLUMNCLICK, DW_SIGNAL_COLUMN_CLICK },
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
375 { TVN_ITEMEXPANDED,DW_SIGNAL_TREE_EXPAND }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
376 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
377
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
378 #ifdef BUILD_DLL
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
379 void Win32_Set_Instance(HINSTANCE hInstance)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
380 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
381 DWInstance = hInstance;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
382 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
383 #else
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
384 char **_convertargs(int *count, char *start)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
385 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
386 char *tmp, *argstart, **argv;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
387 int loc = 0, inquotes = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
388
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
389 (*count) = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
390
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
391 tmp = start;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
392
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
393 /* Count the number of entries */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
394 if(*start)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
395 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
396 (*count)++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
397
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
398 while(*tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
399 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
400 if(*tmp == '"' && inquotes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
401 inquotes = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
402 else if(*tmp == '"' && !inquotes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
403 inquotes = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
404 else if(*tmp == ' ' && !inquotes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
405 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
406 /* Push past any white space */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
407 while(*(tmp+1) == ' ')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
408 tmp++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
409 /* If we aren't at the end of the command
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
410 * line increment the count.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
411 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
412 if(*(tmp+1))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
413 (*count)++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
414 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
415 tmp++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
416 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
417 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
418
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
419 argv = (char **)malloc(sizeof(char *) * ((*count)+1));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
420 argv[0] = malloc(260);
1620
32b5fba0b00a Must convert from UTF8 for the raw HTML on Windows regardless of the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1618
diff changeset
421 GetModuleFileNameA(DWInstance, argv[0], 260);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
422
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
423 argstart = tmp = start;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
424
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
425 if(*start)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
426 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
427 loc = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
428
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
429 while(*tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
430 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
431 if(*tmp == '"' && inquotes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
432 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
433 *tmp = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
434 inquotes = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
435 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
436 else if(*tmp == '"' && !inquotes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
437 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
438 argstart = tmp+1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
439 inquotes = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
440 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
441 else if(*tmp == ' ' && !inquotes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
442 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
443 *tmp = 0;
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
444 argv[loc] = _strdup(argstart);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
445
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
446 /* Push past any white space */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
447 while(*(tmp+1) == ' ')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
448 tmp++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
449
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
450 /* Move the start pointer */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
451 argstart = tmp+1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
452
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
453 /* If we aren't at the end of the command
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
454 * line increment the count.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
455 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
456 if(*(tmp+1))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
457 loc++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
458 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
459 tmp++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
460 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
461 if(*argstart)
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
462 argv[loc] = _strdup(argstart);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
463 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
464 argv[loc+1] = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
465 return argv;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
466 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
467
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
468 /* Ok this is a really big hack but what the hell ;) */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
469 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
470 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
471 char **argv;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
472 int argc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
473
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
474 DWInstance = hInstance;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
475
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
476 argv = _convertargs(&argc, lpCmdLine);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
477
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
478 return main(argc, argv);
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
479 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
480 #endif
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
481
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
482 #ifdef UNICODE
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
483 /* Macro and internal function to convert UTF8 to Unicode wide characters */
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
484 #define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL)
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
485 LPWSTR _myUTF8toWide(char *utf8string, void *outbuf)
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
486 {
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
487 LPWSTR retbuf = outbuf;
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
488
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
489 if(retbuf)
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
490 MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, retbuf, MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0) * sizeof(WCHAR));
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
491 return retbuf;
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
492 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
493 #define WideToUTF8(a) _myWideToUTF8(a, a ? _alloca(WideCharToMultiByte(CP_UTF8, 0, a, -1, NULL, 0, NULL, NULL)) : NULL)
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
494 char *_myWideToUTF8(LPWSTR widestring, void *outbuf)
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
495 {
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
496 char *retbuf = outbuf;
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
497
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
498 if(retbuf)
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
499 WideCharToMultiByte(CP_UTF8, 0, widestring, -1, retbuf, WideCharToMultiByte(CP_UTF8, 0, widestring, -1, NULL, 0, NULL, NULL), NULL, NULL);
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
500 return retbuf;
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
501 }
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
502 #else
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
503 #define UTF8toWide(a) a
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
504 #define WideToUTF8(a) a
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
505 #endif
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
506
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
507 DWORD GetDllVersion(LPCTSTR lpszDllName)
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
508 {
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
509
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
510 HINSTANCE hinstDll;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
511 DWORD dwVersion = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
512
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
513 hinstDll = LoadLibrary(lpszDllName);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
514
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
515 if(hinstDll)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
516 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
517 DLLGETVERSIONPROC pDllGetVersion;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
518
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
519 pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hinstDll, "DllGetVersion");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
520
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
521 /* Because some DLLs might not implement this function, you
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
522 * must test for it explicitly. Depending on the particular
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
523 * DLL, the lack of a DllGetVersion function can be a useful
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
524 * indicator of the version.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
525 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
526 if(pDllGetVersion)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
527 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
528 DLLVERSIONINFO dvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
529 HRESULT hr;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
530
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
531 ZeroMemory(&dvi, sizeof(dvi));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
532 dvi.cbSize = sizeof(dvi);
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
533
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
534 hr = (*pDllGetVersion)(&dvi);
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
535
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
536 if(SUCCEEDED(hr))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
537 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
538 dwVersion = PACKVERSION(dvi.dwMajorVersion, dvi.dwMinorVersion);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
539 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
540 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
541
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
542 FreeLibrary(hinstDll);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
543 }
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
544 return dwVersion;
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
545 }
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 73
diff changeset
546
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
547 #ifdef GDIPLUS
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
548 /*
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
549 * List those icons that have transparency first
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
550 * GDI+ List of supported formats: BMP, ICON, GIF, JPEG, Exif, PNG, TIFF, WMF, and EMF.
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
551 * Not sure if we should include all these or not... maybe we should add TIFF and GIF?
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
552 */
1255
363d859e8372 Fixed GDI+ loading files with no extension needed. Fixed the *_from_data() functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1252
diff changeset
553 #define NUM_EXTS 8
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
554 char *image_exts[NUM_EXTS] =
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
555 {
1255
363d859e8372 Fixed GDI+ loading files with no extension needed. Fixed the *_from_data() functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1252
diff changeset
556 "",
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
557 ".png",
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
558 ".ico",
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
559 ".gif",
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
560 ".jpg",
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
561 ".jpeg",
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
562 ".tiff",
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
563 ".bmp"
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
564 };
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
565
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
566 /* Section for loading files of types besides BMP and ICO and return HBITMAP or HICON */
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
567 void *_dw_load_gpbitmap( char *filename )
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
568 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
569 int i, wclen = (int)(strlen(filename) + 6) * sizeof(wchar_t);
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
570 char *file = _alloca(strlen(filename) + 6);
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
571 wchar_t *wfile = _alloca(wclen);
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
572 void *image;
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
573
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
574 /* Try various extentions */
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
575 for ( i = 0; i < NUM_EXTS; i++ )
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
576 {
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
577 strcpy( file, filename );
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
578 strcat( file, image_exts[i] );
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
579 if ( _access( file, 04 ) == 0 )
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
580 {
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
581 /* Convert to wide format */
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
582 MultiByteToWideChar(CP_ACP, 0, file, (int)strlen(file)+1, wfile, wclen);
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
583 if(!GdipCreateBitmapFromFile(wfile, &image))
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
584 return image;
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
585 }
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
586 }
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
587 return NULL;
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
588 }
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
589
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
590 /* Try to load the appropriate image and return the HBITMAP handle */
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
591 HBITMAP _dw_load_bitmap(char *filename, unsigned long *depth)
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
592 {
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
593 void *bitmap = _dw_load_gpbitmap(filename);
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
594 if(bitmap)
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
595 {
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
596 HBITMAP hbm = NULL;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
597
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
598 if(!GdipCreateHBITMAPFromBitmap(bitmap, &hbm, 0))
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
599 {
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
600 if(depth)
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
601 {
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
602 INT pf;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
603
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
604 /* Default to 0 */
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
605 *depth = 0;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
606
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
607 /* Query the pixel format so we can determine the depth */
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
608 if(!GdipGetImagePixelFormat(bitmap, &pf))
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
609 {
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
610 switch(pf)
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
611 {
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
612 case PixelFormat1bppIndexed:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
613 *depth = 1;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
614 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
615 case PixelFormat4bppIndexed:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
616 *depth = 4;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
617 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
618 case PixelFormat8bppIndexed:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
619 *depth = 8;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
620 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
621 case PixelFormat16bppGrayScale:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
622 case PixelFormat16bppRGB555:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
623 case PixelFormat16bppRGB565:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
624 case PixelFormat16bppARGB1555:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
625 *depth = 16;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
626 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
627 case PixelFormat24bppRGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
628 *depth = 24;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
629 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
630 case PixelFormat32bppRGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
631 case PixelFormat32bppARGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
632 case PixelFormat32bppPARGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
633 case PixelFormat32bppCMYK:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
634 *depth = 32;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
635 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
636 case PixelFormat48bppRGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
637 *depth = 48;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
638 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
639 case PixelFormat64bppARGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
640 case PixelFormat64bppPARGB:
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
641 *depth = 64;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
642 break;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
643 }
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
644 }
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
645 }
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
646 }
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
647 GdipDisposeImage(bitmap);
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
648 return hbm;
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
649 }
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
650 return NULL;
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
651 }
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
652
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
653 /* Try to load the appropriate image and return the HICON handle */
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
654 HICON _dw_load_icon(char *filename)
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
655 {
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
656 void *bitmap = _dw_load_gpbitmap(filename);
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
657 if(bitmap)
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
658 {
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
659 HICON hicon = NULL;
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
660
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
661 GdipCreateHICONFromBitmap(bitmap, &hicon);
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
662 GdipDisposeImage(bitmap);
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
663 return hicon;
1250
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
664 }
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
665 return NULL;
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
666 }
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
667 #endif
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
668
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
669 /* This function adds a signal handler callback into the linked list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
670 */
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
671 void _new_signal(ULONG message, HWND window, int id, void *signalfunction, void *discfunc, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
672 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
673 SignalHandler *new = malloc(sizeof(SignalHandler));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
674
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
675 new->message = message;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
676 new->window = window;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
677 new->id = id;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
678 new->signalfunction = signalfunction;
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
679 new->discfunction = discfunc;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
680 new->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
681 new->next = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
682
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
683 if (!Root)
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
684 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
685 Root = new;
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
686 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
687 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
688 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
689 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
690 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
691 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
692 if(tmp->message == message &&
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
693 tmp->window == window &&
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
694 tmp->id == id &&
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
695 tmp->signalfunction == signalfunction)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
696 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
697 tmp->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
698 free(new);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
699 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
700 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
701 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
702 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
703 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
704 if(prev)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
705 prev->next = new;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
706 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
707 Root = new;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
708 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
709 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
710
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
711 /* Finds the message number for a given signal name */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
712 ULONG _findsigmessage(char *signame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
713 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
714 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
715
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
716 for(z=0;z<SIGNALMAX;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
717 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
718 if(_stricmp(signame, SignalTranslate[z].name) == 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
719 return SignalTranslate[z].message;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
720 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
721 return 0L;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
722 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
723
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
724 /* This function removes any handlers on windows and frees
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
725 * the user memory and resources allocated to it.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
726 */
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
727 BOOL CALLBACK _free_window_memory(HWND handle, LPARAM lParam)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
728 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
729 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
730 HFONT oldfont = (HFONT)SendMessage(handle, WM_GETFONT, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
731 HICON oldicon = (HICON)SendMessage(handle, WM_GETICON, 0, 0);
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
732 TCHAR tmpbuf[100] = {0};
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
733
1763
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
734 TOOLINFO ti = { 0 };
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
735
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
736 ti.cbSize = sizeof(TOOLINFO);
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
737 ti.hwnd = handle;
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
738 ti.hinst = DWInstance;
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
739
d894f87387b2 Switch to using a single tooltip window to prevent leaking tooltip handles on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1762
diff changeset
740 SendMessage(hwndTooltip, TTM_DELTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
741
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
742 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
743
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
744 /* Don't try to free memory from an OLE embedded IE */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
745 if(_tcsncmp(tmpbuf, TEXT("Internet Explorer_Server"), 25) == 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
746 return TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
747
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
748 /* Delete font, icon and bitmap GDI objects in use */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
749 if(oldfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
750 DeleteObject(oldfont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
751 if(oldicon)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
752 DeleteObject(oldicon);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
753
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
754 if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
755 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
756 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
757
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
758 if(oldbitmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
759 DeleteObject(oldbitmap);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
760 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
761 if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
762 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
763 HBITMAP oldbitmap = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0);
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
764 HICON oldicon = (HICON)SendMessage(handle, BM_GETIMAGE, IMAGE_ICON, 0);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
765
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
766 if(oldbitmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
767 DeleteObject(oldbitmap);
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
768 if(oldicon)
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
769 DestroyIcon(oldicon);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
770 }
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
771 #ifdef TOOLBAR
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
772 /* Bitmap Buttons */
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
773 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0)
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
774 {
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
775 HIMAGELIST imlist = (HIMAGELIST)SendMessage(handle, TB_GETIMAGELIST, 0, 0);
1725
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
776 HIMAGELIST dimlist = (HIMAGELIST)SendMessage(handle, TB_GETDISABLEDIMAGELIST, 0, 0);
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
777
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
778 SendMessage(handle, TB_SETIMAGELIST, 0, 0);
1725
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
779 SendMessage(handle, TB_SETDISABLEDIMAGELIST, 0, 0);
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
780
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
781 if(imlist)
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
782 ImageList_Destroy(imlist);
1725
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
783 if(dimlist)
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
784 ImageList_Destroy(dimlist);
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
785 }
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
786 #endif
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
787 else if(_tcsnicmp(tmpbuf, FRAMECLASSNAME, _tcslen(FRAMECLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
788 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
789 Box *box = (Box *)thiscinfo;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
790
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
791 if(box && box->count && box->items)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
792 free(box->items);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
793 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
794 else if(_tcsnicmp(tmpbuf, SplitbarClassName, _tcslen(SplitbarClassName)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
795 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
796 void *data = dw_window_get_data(handle, "_dw_percent");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
797
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
798 if(data)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
799 free(data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
800 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
801 else if(_tcsnicmp(tmpbuf, WC_TREEVIEW, _tcslen(WC_TREEVIEW)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
802 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
803 dw_tree_clear(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
804 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
805 else if(_tcsnicmp(tmpbuf, WC_TABCONTROL, _tcslen(WC_TABCONTROL)+1)==0) /* Notebook */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
806 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
807 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
808
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
809 if(array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
810 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
811 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
812
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
813 for(z=0;z<256;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
814 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
815 if(array[z])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
816 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
817 _free_window_memory(array[z]->hwnd, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
818 EnumChildWindows(array[z]->hwnd, _free_window_memory, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
819 DestroyWindow(array[z]->hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
820 free(array[z]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
821 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
822 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
823 free(array);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
824 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
825 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
826 else if(_tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1)==0)
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
827 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
828 /* for spinbuttons, we need to get the spinbutton's "buddy", the text window associated and destroy it */
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
829 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
830
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
831 if(cinfo && cinfo->buddy)
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
832 DestroyWindow( cinfo->buddy );
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
833 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
834
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
835 dw_signal_disconnect_by_window(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
836
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
837 if(thiscinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
838 {
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
839 if(thiscinfo->pOldProc)
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
840 SetWindowLongPtr(handle, GWLP_WNDPROC, (LPARAM)(WNDPROC)thiscinfo->pOldProc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
841
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
842 /* Delete the brush so as not to leak GDI objects */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
843 if(thiscinfo->hbrush)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
844 DeleteObject(thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
845
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
846 /* Free user data linked list memory */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
847 if(thiscinfo->root)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
848 dw_window_set_data(handle, NULL, NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
849
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
850 SetWindowLongPtr(handle, GWLP_USERDATA, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
851 free(thiscinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
852 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
853 return TRUE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
854 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
855
468
0a2f13ba2d5c More menu fixes, free signal handlers and memory on OS/2, and the begining
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 467
diff changeset
856 void _free_menu_data(HMENU menu)
0a2f13ba2d5c More menu fixes, free signal handlers and memory on OS/2, and the begining
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 467
diff changeset
857 {
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
858 int i, count = GetMenuItemCount(menu);
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
859
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
860 for(i=0;i<count;i++)
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
861 {
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
862 MENUITEMINFO mii;
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
863
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
864 mii.cbSize = sizeof(MENUITEMINFO);
1309
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
865 mii.fMask = MIIM_SUBMENU | MIIM_ID;
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
866
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
867 if ( GetMenuItemInfo( menu, i, TRUE, &mii ) )
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
868 {
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
869 /* Free the data associated with the ID */
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
870 if(mii.wID >= 30000)
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
871 {
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
872 char buffer[31] = {0};
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
873
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
874 _snprintf(buffer, 30, "_dw_id%ld", mii.wID);
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
875 dw_window_set_data( DW_HWND_OBJECT, buffer, NULL );
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
876 _snprintf(buffer, 30, "_dw_checkable%ld", mii.wID);
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
877 dw_window_set_data( DW_HWND_OBJECT, buffer, NULL );
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
878 _snprintf(buffer, 30, "_dw_ischecked%ld", mii.wID);
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
879 dw_window_set_data( DW_HWND_OBJECT, buffer, NULL );
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
880 _snprintf(buffer, 30, "_dw_isdisabled%ld", mii.wID);
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
881 dw_window_set_data( DW_HWND_OBJECT, buffer, NULL );
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
882 }
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
883
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
884 /* Check any submenus */
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
885 if( mii.hSubMenu )
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
886 _free_menu_data(mii.hSubMenu);
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
887 }
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
888 }
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
889 dw_signal_disconnect_by_name((HWND)menu, DW_SIGNAL_CLICKED);
468
0a2f13ba2d5c More menu fixes, free signal handlers and memory on OS/2, and the begining
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 467
diff changeset
890 }
0a2f13ba2d5c More menu fixes, free signal handlers and memory on OS/2, and the begining
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 467
diff changeset
891
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
892 /* Convert to our internal color scheme */
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
893 ULONG _internal_color(ULONG color)
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
894 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
895 if(color == DW_CLR_DEFAULT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
896 return DW_RGB_TRANSPARENT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
897 if(color < 18)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
898 return DW_RGB(_red[color], _green[color], _blue[color]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
899 return color;
191
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
900 }
634625c3239d Fixes for dw_color_xxxx_set() to accept OS/2 style colors, and fixed a
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
901
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
902 /* This function returns 1 if the window (widget) handle
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
903 * passed to it is a valid window that can gain input focus.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
904 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
905 int _validate_focus(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
906 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
907 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
908
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
909 if(!handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
910 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
911
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
912 if(!IsWindowEnabled(handle))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
913 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
914
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
915 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
916
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
917 /* These are the window classes which can
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
918 * obtain input focus.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
919 */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
920 if(_tcsnicmp(tmpbuf, EDITCLASSNAME, _tcslen(EDITCLASSNAME)+1)==0 || /* Entryfield */
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
921 _tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1)==0 || /* Button */
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
922 #ifdef TOOLBAR
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
923 _tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0 || /* Toolbar */
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
924 #endif
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
925 _tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0 || /* Combobox */
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
926 _tcsnicmp(tmpbuf, LISTBOXCLASSNAME, _tcslen(LISTBOXCLASSNAME)+1)==0 || /* List box */
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
927 _tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1)==0 || /* Spinbutton */
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
928 _tcsnicmp(tmpbuf, TRACKBAR_CLASS, _tcslen(TRACKBAR_CLASS)+1)==0 || /* Slider */
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
929 _tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW)+1)== 0 || /* Container */
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
930 _tcsnicmp(tmpbuf, WC_TREEVIEW, _tcslen(WC_TREEVIEW)+1)== 0) /* Tree */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
931 return 1;
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
932 /* Special case for the notebook, can get focus and contains other items */
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
933 if(_tcsnicmp(tmpbuf, WC_TABCONTROL, _tcslen(WC_TABCONTROL))==0) /* Notebook */
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
934 return 2;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
935 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
936 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
937
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
938 HWND _normalize_handle(HWND handle)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
939 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
940 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
941
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
942 GetClassName(handle, tmpbuf, 99);
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
943 if(_tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS))==0) /* Spinner */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
944 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
945 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
946
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
947 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
948 return cinfo->buddy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
949 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
950 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME))==0) /* Combobox */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
951 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
952 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
953
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
954 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
955 return cinfo->buddy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
956 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
957 return handle;
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
958 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
959
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
960 #define _DW_DIRECTION_FORWARD -1
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
961 #define _DW_DIRECTION_BACKWARD 1
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
962
1812
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
963 int _focus_check_box(Box *box, HWND handle, int start, int direction, HWND defaultitem);
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
964
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
965 /* Internal comparision function */
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
966 int _focus_comp(int direction, int z, int end)
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
967 {
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
968 if(direction == _DW_DIRECTION_FORWARD)
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
969 return z > -1;
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
970 return z < end;
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
971 }
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
972
1812
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
973 int _focus_notebook(HWND hwnd, HWND handle, int start, int direction, HWND defaultitem)
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
974 {
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
975 NotebookPage **array = (NotebookPage **)dw_window_get_data(hwnd, "_dw_array");
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
976 int pageid = TabCtrl_GetCurSel(hwnd);
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
977
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
978 if(pageid > -1 && array && array[pageid])
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
979 {
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
980 Box *notebox;
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
981
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
982 if(array[pageid]->hwnd)
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
983 {
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
984 notebox = (Box *)GetWindowLongPtr(array[pageid]->hwnd, GWLP_USERDATA);
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
985
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
986 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, direction, defaultitem))
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
987 return 1;
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
988 }
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
989 }
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
990 return 0;
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
991 }
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
992
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
993 /* Handle box focus traversal in either direction */
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
994 int _focus_check_box(Box *box, HWND handle, int start, int direction, HWND defaultitem)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
995 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
996 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
997 static HWND lasthwnd, firsthwnd;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
998 static int finish_searching;
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
999 int beg = (direction == _DW_DIRECTION_FORWARD) ? box->count-1 : 0;
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1000 int end = (direction == _DW_DIRECTION_FORWARD) ? -1 : box->count;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1001
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1002 /* Start is 2 when we have cycled completely and
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1003 * need to set the focus to the last widget we found
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1004 * that was valid.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1005 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1006 if(start == 2)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1007 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1008 if(lasthwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1009 SetFocus(lasthwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1010 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1011 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1012
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1013 /* Start is 1 when we are entering the function
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1014 * for the first time, it is zero when entering
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1015 * the function recursively.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1016 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1017 if(start == 1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1018 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1019 lasthwnd = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1020 finish_searching = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1021 firsthwnd = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1022 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1023
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1024 for(z=beg;_focus_comp(direction, z, end);z+=direction)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1025 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1026 if(box->items[z].type == TYPEBOX)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1027 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1028 Box *thisbox = (Box *)GetWindowLongPtr(box->items[z].hwnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1029
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1030 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0, direction, defaultitem))
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1031 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1032 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1033 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1034 {
1812
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
1035 int type = _validate_focus(box->items[z].hwnd);
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1036
1812
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
1037 /* Special case notebook, can focus and contains items */
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
1038 if(type == 2 && direction == _DW_DIRECTION_FORWARD && _focus_notebook(box->items[z].hwnd, handle, start, direction, defaultitem))
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
1039 return 1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1040 if(box->items[z].hwnd == handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1041 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1042 if(lasthwnd == handle && firsthwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1043 SetFocus(firsthwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1044 else if(lasthwnd == handle && !firsthwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1045 finish_searching = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1046 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1047 SetFocus(lasthwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1048
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1049 /* If we aren't looking for the last handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1050 * return immediately.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1051 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1052 if(!finish_searching)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1053 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1054 }
1812
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
1055 if(type > 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1056 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1057 /* Start is 3 when we are looking for the
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1058 * first valid item in the layout.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1059 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1060 if(start == 3)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1061 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1062 if(!defaultitem || (defaultitem && box->items[z].hwnd == defaultitem))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1063 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1064 SetFocus(_normalize_handle(box->items[z].hwnd));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1065 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1066 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1067 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1068
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1069 lasthwnd = _normalize_handle(box->items[z].hwnd);
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1070
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1071 if(!firsthwnd)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1072 firsthwnd = lasthwnd;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1073 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1074 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1075 {
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1076 /* Handle controls that contain other items */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1077 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1078
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1079 GetClassName(box->items[z].hwnd, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1080
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1081 if(_tcsncmp(tmpbuf, SplitbarClassName, _tcslen(SplitbarClassName)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1082 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1083 /* Then try the bottom or right box */
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1084 HWND mybox = (HWND)dw_window_get_data(box->items[z].hwnd, (direction == _DW_DIRECTION_FORWARD) ? "_dw_bottomright" : "_dw_topleft");
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1085
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1086 if(mybox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1087 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1088 Box *splitbox = (Box *)GetWindowLongPtr(mybox, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1089
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1090 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, direction, defaultitem))
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1091 return 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1092 }
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1093
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1094 /* Try the top or left box */
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1095 mybox = (HWND)dw_window_get_data(box->items[z].hwnd, (direction == _DW_DIRECTION_FORWARD) ? "_dw_topleft" : "_dw_bottomright");
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1096
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1097 if(mybox)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1098 {
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1099 Box *splitbox = (Box *)GetWindowLongPtr(mybox, GWLP_USERDATA);
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1100
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1101 if(splitbox && _focus_check_box(splitbox, handle, start == 3 ? 3 : 0, direction, defaultitem))
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1102 return 1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1103 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1104 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1105 else if(_tcsnicmp(tmpbuf, ScrollClassName, _tcslen(ScrollClassName))==0) /* Scroll Box */
903
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1106 {
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1107 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(box->items[z].hwnd, GWLP_USERDATA);
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1108 Box *scrollbox = (Box *)GetWindowLongPtr(cinfo->combo, GWLP_USERDATA);
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1109
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1110 if(scrollbox && _focus_check_box(scrollbox, handle, start == 3 ? 3 : 0, direction, defaultitem))
903
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1111 return 1;
db26726118ba Fixed scrollbox tab and shift tab focus shifting on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 896
diff changeset
1112 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1113 }
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1114 /* Special case notebook, can focus and contains items */
1812
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
1115 if(type == 2 && direction == _DW_DIRECTION_BACKWARD && _focus_notebook(box->items[z].hwnd, handle, start, direction, defaultitem))
9bbe090d0250 Depending on the tab direction on Windows, the dual purpose notebook
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1811
diff changeset
1116 return 1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1117 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1118 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1119 return 0;
61
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1120 }
4a02842f8074 Added shift-tab and up/down/left/right button support. And added missing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1121
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1122 /* This function finds the first widget in the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1123 * layout and moves the current focus to it.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1124 */
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1125 void _initial_focus(HWND handle)
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1126 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1127 Box *thisbox;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1128 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1129
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1130 if(!handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1131 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1132
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1133 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1134
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1135 if(_tcsnicmp(tmpbuf, ClassName, _tcslen(ClassName)+1)!=0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1136 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1137
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1138
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1139 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1140 thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1141
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1142 if(thisbox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1143 {
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1144 _focus_check_box(thisbox, handle, 3, _DW_DIRECTION_FORWARD, thisbox->defaultitem);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1145 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1146 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1147
301
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
1148 HWND _toplevel_window(HWND handle)
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
1149 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1150 HWND box, lastbox = GetParent(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1151
1803
5ed9f7ea3882 Make sure _toplevel_window() when passed a top-level window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1799
diff changeset
1152 if(!lastbox)
5ed9f7ea3882 Make sure _toplevel_window() when passed a top-level window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1799
diff changeset
1153 lastbox = handle;
5ed9f7ea3882 Make sure _toplevel_window() when passed a top-level window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1799
diff changeset
1154
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1155 /* Find the toplevel window */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1156 while((box = GetParent(lastbox)))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1157 {
1467
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1158 /* If it hasn't been packed yet.. */
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
1159 if(box == DW_HWND_OBJECT)
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
1160 return 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1161 lastbox = box;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1162 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1163 if(lastbox)
1467
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1164 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1165 TCHAR tmpbuf[100] = {0};
1467
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1166
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1167 GetClassName(lastbox, tmpbuf, 99);
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1168
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1169 if(_tcsncmp(tmpbuf, ClassName, _tcslen(ClassName)+1)==0)
1467
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1170 return lastbox;
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1171 }
91bdd9840b9f _toplevel_window() changes for Windows similar to the OS/2 changes...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1464
diff changeset
1172 return 0;
301
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
1173 }
887675ee5b67 More keypress fixes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 299
diff changeset
1174
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1175 /* This function finds the current widget in the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1176 * layout and moves the current focus to the next item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1177 */
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1178 void _shift_focus(HWND handle, int direction)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1179 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1180 Box *thisbox;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1181
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1182 HWND box, lastbox = GetParent(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1183
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1184 /* Find the toplevel window */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1185 while((box = GetParent(lastbox)))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1186 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1187 lastbox = box;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1188 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1189
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1190 thisbox = (Box *)GetWindowLongPtr(lastbox, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1191 if(thisbox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1192 {
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1193 if(_focus_check_box(thisbox, handle, 1, direction, 0) == 0)
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1194 _focus_check_box(thisbox, handle, 2, direction, 0);
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1195 }
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1196 }
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
1197
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1198 /* This function calculates how much space the widgets and boxes require
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1199 * and does expansion as necessary.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1200 */
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1201 static void _resize_box(Box *thisbox, int *depth, int x, int y, int pass)
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1202 {
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1203 /* Current item position */
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1204 int z, currentx = thisbox->pad, currenty = thisbox->pad;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1205 /* Used x, y and padding maximum values...
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1206 * These will be used to find the widest or
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1207 * tallest items in a box.
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1208 */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1209 int uymax = 0, uxmax = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1210 int upymax = 0, upxmax = 0;
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1211
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1212 /* Reset the box sizes */
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1213 thisbox->minwidth = thisbox->minheight = thisbox->usedpadx = thisbox->usedpady = thisbox->pad * 2;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1214
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1215 if(thisbox->grouphwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1216 {
1442
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1217 /* Only calculate the size on the first pass...
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1218 * use the cached values on second.
1408
96460bd4c679 Fixes for groupboxes with no text (or very small text) on Windows not displaying properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1404
diff changeset
1219 */
1442
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1220 if(pass == 1)
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1221 {
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1222 char *text = dw_window_get_text(thisbox->grouphwnd);
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1223
1408
96460bd4c679 Fixes for groupboxes with no text (or very small text) on Windows not displaying properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1404
diff changeset
1224 thisbox->grouppady = 9;
1442
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1225
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1226 if(text)
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1227 {
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1228 if(*text)
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1229 dw_font_text_extents_get(thisbox->grouphwnd, 0, text, NULL, &thisbox->grouppady);
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1230 dw_free(text);
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1231 }
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1232 /* If the string height is less than 9...
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1233 * set it to 9 anyway since that is the minimum.
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1234 */
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1235 if(thisbox->grouppady < 9)
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1236 thisbox->grouppady = 9;
1408
96460bd4c679 Fixes for groupboxes with no text (or very small text) on Windows not displaying properly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1404
diff changeset
1237
1442
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1238 if(thisbox->grouppady)
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1239 thisbox->grouppady += 3;
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1240 else
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1241 thisbox->grouppady = 6;
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1242
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1243 thisbox->grouppadx = 6;
02a329b2b0cd Added groupbox perfomance improvement to Windows and OS/2 that was missed when importing from the Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1441
diff changeset
1244 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1245
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1246 thisbox->minwidth += thisbox->grouppadx;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1247 thisbox->usedpadx += thisbox->grouppadx;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1248 thisbox->minheight += thisbox->grouppady;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1249 thisbox->usedpady += thisbox->grouppady;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1250 }
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1251
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1252 /* Count up all the space for all items in the box */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1253 for(z=0;z<thisbox->count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1254 {
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1255 int itempad, itemwidth, itemheight;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1256
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1257 if(thisbox->items[z].type == TYPEBOX)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1258 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1259 Box *tmp = (Box *)GetWindowLongPtr(thisbox->items[z].hwnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1260
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1261 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1262 {
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1263 /* On the first pass calculate the box contents */
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1264 if(pass == 1)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1265 {
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1266 (*depth)++;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1267
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1268 /* Save the newly calculated values on the box */
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1269 _resize_box(tmp, depth, x, y, pass);
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1270
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1271 /* Duplicate the values in the item list for use below */
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1272 thisbox->items[z].width = tmp->minwidth;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1273 thisbox->items[z].height = tmp->minheight;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1274
1449
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1448
diff changeset
1275 /* If the box has no contents but is expandable... default the size to 1 */
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1448
diff changeset
1276 if(!thisbox->items[z].width && thisbox->items[z].hsize)
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1448
diff changeset
1277 thisbox->items[z].width = 1;
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1448
diff changeset
1278 if(!thisbox->items[z].height && thisbox->items[z].vsize)
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1448
diff changeset
1279 thisbox->items[z].height = 1;
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1448
diff changeset
1280
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1281 (*depth)--;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1282 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1283 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1284 }
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1285
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1286 /* Precalculate these values, since they will
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1287 * be used used repeatedly in the next section.
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1288 */
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1289 itempad = thisbox->items[z].pad * 2;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1290 itemwidth = thisbox->items[z].width + itempad;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1291 itemheight = thisbox->items[z].height + itempad;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1292
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1293 /* Calculate the totals and maximums */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1294 if(thisbox->type == DW_VERT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1295 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1296 if(itemwidth > uxmax)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1297 uxmax = itemwidth;
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1298
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1299 if(thisbox->items[z].hsize != SIZEEXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1300 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1301 if(itemwidth > upxmax)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1302 upxmax = itemwidth;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1303 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1304 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1305 {
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1306 if(itempad > upxmax)
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1307 upxmax = itempad;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1308 }
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1309 thisbox->minheight += itemheight;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1310 if(thisbox->items[z].vsize != SIZEEXPAND)
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1311 thisbox->usedpady += itemheight;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1312 else
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1313 thisbox->usedpady += itempad;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1314 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1315 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1316 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1317 if(itemheight > uymax)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1318 uymax = itemheight;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1319 if(thisbox->items[z].vsize != SIZEEXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1320 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1321 if(itemheight > upymax)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1322 upymax = itemheight;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1323 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1324 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1325 {
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1326 if(itempad > upymax)
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1327 upymax = itempad;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1328 }
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1329 thisbox->minwidth += itemwidth;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1330 if(thisbox->items[z].hsize != SIZEEXPAND)
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1331 thisbox->usedpadx += itemwidth;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1332 else
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1333 thisbox->usedpadx += itempad;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1334 }
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1335 }
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1336
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1337 /* Add the maximums which were calculated in the previous loop */
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1338 thisbox->minwidth += uxmax;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1339 thisbox->minheight += uymax;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1340 thisbox->usedpadx += upxmax;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1341 thisbox->usedpady += upymax;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1342
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1343 /* Move the groupbox start past the group border */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1344 if(thisbox->grouphwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1345 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1346 currentx += 3;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1347 currenty += thisbox->grouppady - 3;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1348 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1349
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1350 /* The second pass is for actual placement. */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1351 if(pass > 1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1352 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1353 for(z=0;z<(thisbox->count);z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1354 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1355 int height = thisbox->items[z].height;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1356 int width = thisbox->items[z].width;
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1357 int itempad = thisbox->items[z].pad * 2;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1358 int thispad = thisbox->pad * 2;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1359
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1360 /* Calculate the new sizes */
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1361 if(thisbox->items[z].hsize == SIZEEXPAND)
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1362 {
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1363 if(thisbox->type == DW_HORZ)
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1364 {
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1365 int expandablex = thisbox->minwidth - thisbox->usedpadx;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1366
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1367 if(expandablex)
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1368 width = (int)(((float)width / (float)expandablex) * (float)(x - thisbox->usedpadx));
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1369 }
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1370 else
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1371 width = x - (itempad + thispad + thisbox->grouppadx);
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1372 }
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1373 if(thisbox->items[z].vsize == SIZEEXPAND)
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1374 {
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1375 if(thisbox->type == DW_VERT)
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1376 {
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1377 int expandabley = thisbox->minheight - thisbox->usedpady;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1378
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1379 if(expandabley)
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1380 height = (int)(((float)height / (float)expandabley) * (float)(y - thisbox->usedpady));
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1381 }
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1382 else
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1383 height = y - (itempad + thispad + thisbox->grouppady);
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1384 }
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1385
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1386 /* If the calculated size is valid... */
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1387 if(width > 0 && height > 0)
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1388 {
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1389 int pad = thisbox->items[z].pad;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1390 HWND handle = thisbox->items[z].hwnd;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1391 TCHAR tmpbuf[100] = {0};
1436
18c1b999dd65 Similar fix for OS/2 and Windows as just committed on Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1434
diff changeset
1392
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1393 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1394
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1395 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1396 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1397 /* Handle special case Combobox */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1398 MoveWindow(handle, currentx + pad, currenty + pad,
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1399 width, height + 400, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1400 }
1723
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1401 #ifdef TOOLBAR
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1402 /* Bitmap Buttons */
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1403 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0)
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1404 {
1731
f7a41d057a50 A much better solution that centering the button in the space on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1730
diff changeset
1405 SendMessage(handle, TB_SETBUTTONSIZE, 0, MAKELPARAM(width, height));
f7a41d057a50 A much better solution that centering the button in the space on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1730
diff changeset
1406
f7a41d057a50 A much better solution that centering the button in the space on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1730
diff changeset
1407 MoveWindow(handle, currentx + pad, currenty + pad, width, height, FALSE);
1723
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1408 }
d55227360864 Center toolbar-based bitmap buttons on Windows during layout since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1722
diff changeset
1409 #endif
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1410 else if(_tcsnicmp(tmpbuf, UPDOWN_CLASS, _tcslen(UPDOWN_CLASS)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1411 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1412 /* Handle special case Spinbutton */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1413 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1414
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1415 MoveWindow(handle, currentx + pad + (width - 20), currenty + pad,
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1416 20, height, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1417
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1418 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1419 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1420 MoveWindow(cinfo->buddy, currentx + pad, currenty + pad,
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1421 width - 20, height, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1422 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1423 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1424 else if(_tcsncmp(tmpbuf, ScrollClassName, _tcslen(ScrollClassName)+1)==0)
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1425 {
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1426 /* Handle special case of scrollbox */
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1427 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1428 int cx, cy, depth = 0;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1429 Box *thisbox = (Box *)GetWindowLongPtr(cinfo->combo, GWLP_USERDATA);
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1430 SCROLLINFO hsi, vsi;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1431 RECT rect;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1432
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1433 vsi.cbSize = hsi.cbSize = sizeof(SCROLLINFO);
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1434 vsi.fMask = hsi.fMask = SIF_POS;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1435
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1436 /* Save the current scroll positions */
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1437 GetScrollInfo(handle, SB_HORZ, &hsi);
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1438 GetScrollInfo(handle, SB_VERT, &vsi);
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1439
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1440 /* Position the scrollbox */
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1441 MoveWindow(handle, currentx + pad, currenty + pad, width, height, FALSE);
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1442
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1443 GetClientRect(handle, &rect);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1444 cx = rect.right;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1445 cy = rect.bottom;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1446
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1447
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1448 /* Get the required space for the box */
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1449 _resize_box(thisbox, &depth, cx, cy, 1);
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1450
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1451 if(cx < thisbox->minwidth)
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1452 {
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1453 cx = thisbox->minwidth;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1454 }
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1455 if(cy < thisbox->minheight)
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1456 {
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1457 cy = thisbox->minheight;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1458 }
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1459
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1460 /* Position the scrolled box */
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1461 vsi.fMask = hsi.fMask = SIF_POS | SIF_RANGE | SIF_PAGE | SIF_DISABLENOSCROLL;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1462 vsi.nMin = hsi.nMin = vsi.nMax = hsi.nMax = 0;
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1463 if(rect.bottom < thisbox->minheight)
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1464 {
1556
4a9c574d5c17 Fixed on Windows showing themed static text on colored boxes when the window is glass.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1550
diff changeset
1465 vsi.nMax = thisbox->minheight - 1;
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1466 vsi.nPage = rect.bottom;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1467 if(vsi.nPos > vsi.nMax)
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1468 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1469 vsi.nPos = vsi.nMax;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1470 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1471 }
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1472 if(rect.right < thisbox->minwidth)
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1473 {
1556
4a9c574d5c17 Fixed on Windows showing themed static text on colored boxes when the window is glass.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1550
diff changeset
1474 hsi.nMax = thisbox->minwidth - 1;
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1475 hsi.nPage = rect.right;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1476 if(hsi.nPos > hsi.nMax)
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1477 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1478 hsi.nPos = hsi.nMax;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1479 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1480 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1481 MoveWindow(cinfo->combo, -hsi.nPos, -vsi.nPos, cx, cy, FALSE);
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1482 SetScrollInfo(handle, SB_HORZ, &hsi, TRUE);
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
1483 SetScrollInfo(handle, SB_VERT, &vsi, TRUE);
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1484
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1485 /* Layout the content of the scrollbox */
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1486 _do_resize(thisbox, cx, cy);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
1487 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1488 else if(_tcsncmp(tmpbuf, SplitbarClassName, _tcslen(SplitbarClassName)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1489 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1490 /* Then try the bottom or right box */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1491 float *percent = (float *)dw_window_get_data(handle, "_dw_percent");
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
1492 int type = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_type"));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1493
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1494 MoveWindow(handle, currentx + pad, currenty + pad,
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1495 width, height, FALSE);
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1496
1449
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1448
diff changeset
1497 if(percent && width > 0 && height > 0)
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1498 _handle_splitbar_resize(handle, *percent, type, width, height);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1499 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1500 else if(_tcsnicmp(tmpbuf, STATICCLASSNAME, _tcslen(STATICCLASSNAME)+1)==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1501 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1502 /* Handle special case Vertically Center static text */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1503 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1504
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1505 if(cinfo && cinfo->vcenter)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1506 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1507 /* We are centered so calculate a new position */
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
1508 TCHAR tmpbuf[1024] = {0}, *thisbuf = tmpbuf;
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1509 int textheight, diff, total = height;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1510
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
1511 GetWindowText(handle, thisbuf, 1023);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1512
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1513 /* Figure out how big the text is */
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
1514 dw_font_text_extents_get(handle, 0, WideToUTF8(thisbuf), 0, &textheight);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1515
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1516 diff = (total - textheight) / 2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1517
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1518 MoveWindow(handle, currentx + pad, currenty + pad + diff,
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1519 width, height - diff, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1520 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1521 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1522 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1523 MoveWindow(handle, currentx + pad, currenty + pad,
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1524 width, height, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1525 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1526 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1527 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1528 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1529 /* Everything else */
1464
e325f98a2792 FIXME: Workaround for items on the top-level not getting WM_PAINT messages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1456
diff changeset
1530 if(*depth)
e325f98a2792 FIXME: Workaround for items on the top-level not getting WM_PAINT messages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1456
diff changeset
1531 MoveWindow(handle, currentx + pad, currenty + pad, width, height, FALSE);
e325f98a2792 FIXME: Workaround for items on the top-level not getting WM_PAINT messages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1456
diff changeset
1532 else /* FIXME: This is a hack to generate WM_PAINT messages for items on the top-level */
e325f98a2792 FIXME: Workaround for items on the top-level not getting WM_PAINT messages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1456
diff changeset
1533 SetWindowPos(handle, HWND_TOP, currentx + pad, currenty + pad, width, height, 0);
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1534
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1535 /* After placing a box... place its components */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1536 if(thisbox->items[z].type == TYPEBOX)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1537 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1538 Box *boxinfo = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1539
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1540 if(boxinfo)
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
1541 {
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1542 /* Move the group border into place */
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1543 if(boxinfo->grouphwnd)
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1544 {
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1545 MoveWindow(boxinfo->grouphwnd, 0, 0,
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1546 width, height, FALSE);
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1547 }
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1548 /* Dive into the box */
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1549 (*depth)++;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1550 _resize_box(boxinfo, depth, width, height, pass);
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1551 (*depth)--;
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
1552 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1553 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1554 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1555
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1556 /* Notebook dialog requires additional processing */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1557 if(_tcsncmp(tmpbuf, WC_TABCONTROL, _tcslen(WC_TABCONTROL))==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1558 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1559 RECT rect;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1560 NotebookPage **array = (NotebookPage **)dw_window_get_data(handle, "_dw_array");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1561 int pageid = TabCtrl_GetCurSel(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1562
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1563 if(pageid > -1 && array && array[pageid])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1564 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1565 GetClientRect(handle,&rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1566 TabCtrl_AdjustRect(handle,FALSE,&rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1567 MoveWindow(array[pageid]->hwnd, rect.left, rect.top,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1568 rect.right - rect.left, rect.bottom-rect.top, FALSE);
1449
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1448
diff changeset
1569 dw_window_redraw(array[pageid]->hwnd);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1570 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1571 }
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
1572 /* So does the List View... handle delayed cursoring */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1573 if(_tcsnicmp(tmpbuf, WC_LISTVIEW, _tcslen(WC_LISTVIEW)+1)==0 && width > 10 && height > 10)
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
1574 {
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
1575 int index = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_cursor"));
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
1576
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
1577 if(index > 0)
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
1578 ListView_EnsureVisible(handle, index, TRUE);
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
1579 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1580
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1581 /* Advance the current position in the box */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1582 if(thisbox->type == DW_HORZ)
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1583 currentx += width + (pad * 2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1584 if(thisbox->type == DW_VERT)
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1585 currenty += height + (pad * 2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1586 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1587 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1588 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1589 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1590
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1591 void _do_resize(Box *thisbox, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1592 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1593 if(x != 0 && y != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1594 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1595 if(thisbox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1596 {
1438
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1597 int depth = 0;
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1598
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1599 /* Calculate space requirements */
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1600 _resize_box(thisbox, &depth, x, y, 1);
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1601
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1602 /* Finally place all the boxes and controls */
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
1603 _resize_box(thisbox, &depth, x, y, 2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1604 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1605 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1606 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1607
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
1608 int _HandleScroller(HWND handle, int bar, int pos, int which)
211
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1609 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1610 SCROLLINFO si;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
1611
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
1612 ZeroMemory( &si, sizeof(si) );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1613 si.cbSize = sizeof(SCROLLINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1614 si.fMask = SIF_ALL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1615
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1616 SendMessage(handle, SBM_GETSCROLLINFO, 0, (LPARAM)&si);
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
1617
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1618 switch(which)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1619 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1620 case SB_THUMBTRACK:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1621 return pos;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1622 /*case SB_PAGEUP:*/
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1623 case SB_PAGELEFT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1624 pos = si.nPos - si.nPage;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1625 if(pos < si.nMin)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1626 pos = si.nMin;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1627 return pos;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1628 /*case SB_PAGEDOWN:*/
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1629 case SB_PAGERIGHT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1630 pos = si.nPos + si.nPage;
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
1631 if(pos > (int)(si.nMax - si.nPage) + 1)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1632 pos = (si.nMax - si.nPage) + 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1633 return pos;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1634 /*case SB_LINEUP:*/
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1635 case SB_LINELEFT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1636 pos = si.nPos - 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1637 if(pos < si.nMin)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1638 pos = si.nMin;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1639 return pos;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
1640 /*case SB_LINEDOWN:*/
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1641 case SB_LINERIGHT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1642 pos = si.nPos + 1;
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
1643 if(pos > (int)(si.nMax - si.nPage) + 1)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1644 pos = (si.nMax - si.nPage) + 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1645 return pos;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1646 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1647 return -1;
211
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1648 }
e57c182cac64 Automatically scroll when getting PAGE and LINE messages, not just
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 209
diff changeset
1649
466
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1650 HMENU _get_owner(HMENU menu)
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1651 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1652 MENUINFO mi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1653
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1654 mi.cbSize = sizeof(MENUINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1655 mi.fMask = MIM_MENUDATA;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1656
912
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
1657 if ( GetMenuInfo( menu, &mi ) )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1658 return (HMENU)mi.dwMenuData;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1659 return (HMENU)0;
466
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1660 }
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1661
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1662 /* Find the desktop window handle */
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1663 HMENU _menu_owner(HMENU handle)
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1664 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1665 HMENU menuowner = 0, lastowner = _get_owner(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1666
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1667 /* Find the toplevel menu */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1668 while((menuowner = _get_owner(lastowner)) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1669 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1670 if(menuowner == (HMENU)1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1671 return lastowner;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1672 lastowner = menuowner;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1673 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1674 return (HMENU)0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1675 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1676
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1677 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1678 * Determine if this is a checkable menu. If it is get the current state
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1679 * and toggle it. Windows doesn't do this automatically :-(
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1680 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1681 static void _dw_toggle_checkable_menu_item( HWND window, int id )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1682 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1683 char buffer[40];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1684 int checkable;
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
1685 sprintf( buffer, "_dw_checkable%d", id );
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
1686 checkable = DW_POINTER_TO_INT(dw_window_get_data(DW_HWND_OBJECT, buffer));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1687 if ( checkable )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1688 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1689 int is_checked;
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
1690 sprintf( buffer, "_dw_ischecked%d", id );
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
1691 is_checked = DW_POINTER_TO_INT(dw_window_get_data(DW_HWND_OBJECT, buffer));
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
1692 is_checked = (is_checked) ? DW_MIS_UNCHECKED : DW_MIS_CHECKED;
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
1693 dw_menu_item_set_state( window, id, is_checked );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1694 }
466
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1695 }
c3dfa117b080 Added new code to make the menu handlers window local instead of global.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 461
diff changeset
1696
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1697 /* The main window procedure for Dynamic Windows, all the resizing code is done here. */
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
1698 LRESULT CALLBACK _wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1699 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1700 int result = -1, taskbar = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1701 SignalHandler *tmp = Root;
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
1702 void (DWSIGNAL *windowfunc)(PVOID);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1703 ULONG origmsg = msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1704
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1705 /* Deal with translating some messages */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1706 if (msg == WM_USER+2)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1707 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1708 taskbar = TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1709 origmsg = msg = (UINT)mp2; /* no else here */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1710 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1711 if (msg == WM_RBUTTONDOWN || msg == WM_MBUTTONDOWN)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1712 msg = WM_LBUTTONDOWN;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1713 else if (msg == WM_RBUTTONUP || msg == WM_MBUTTONUP)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1714 msg = WM_LBUTTONUP;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1715 else if (msg == WM_HSCROLL)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1716 msg = WM_VSCROLL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1717 else if (msg == WM_KEYDOWN) /* && mp1 >= VK_F1 && mp1 <= VK_F24) allow ALL special keys */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1718 msg = WM_CHAR;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1719
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1720 if (result == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1721 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1722 /* Find any callbacks for this function */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1723 while (tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1724 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1725 if (tmp->message == msg || msg == WM_COMMAND || msg == WM_NOTIFY || tmp->message == WM_USER+1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1726 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1727 switch (msg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1728 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1729 case WM_TIMER:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1730 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1731 if (!hWnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1732 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
1733 int (DWSIGNAL *timerfunc)(void *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1734 if (tmp->id == (int)mp1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1735 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1736 if (!timerfunc(tmp->data))
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
1737 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1738 dw_timer_disconnect(tmp->id);
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
1739 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1740 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1741 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1742 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1743 result = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1744 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1745 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1746 case WM_SETFOCUS:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1747 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
1748 int (DWSIGNAL *setfocusfunc)(HWND, void *) = (int (*)(HWND, void *))tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1749
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1750 if(hWnd == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1751 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1752 result = setfocusfunc(tmp->window, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1753 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1754 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1755 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1756 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1757 case WM_SIZE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1758 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
1759 int (DWSIGNAL *sizefunc)(HWND, int, int, void *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1760 if(hWnd == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1761 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1762 result = sizefunc(tmp->window, LOWORD(mp2), HIWORD(mp2), tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1763 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1764 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1765 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1766 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1767 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1768 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
1769 int (DWSIGNAL *buttonfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1770
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1771 if(hWnd == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1772 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1773 int button=0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1774
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1775 switch(origmsg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1776 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1777 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1778 button = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1779 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1780 case WM_RBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1781 button = 2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1782 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1783 case WM_MBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1784 button = 3;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1785 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1786 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1787 if(taskbar)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1788 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1789 POINT ptl;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1790 GetCursorPos(&ptl);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1791 result = buttonfunc(tmp->window, ptl.x, ptl.y, button, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1792 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1793 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1794 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1795 POINTS pts = MAKEPOINTS(mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1796 result = buttonfunc(tmp->window, pts.x, pts.y, button, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1797 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1798 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1799 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1800 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1801 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1802 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1803 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
1804 int (DWSIGNAL *buttonfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1805
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1806 if(hWnd == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1807 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1808 int button=0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1809
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1810 switch(origmsg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1811 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1812 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1813 button = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1814 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1815 case WM_RBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1816 button = 2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1817 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1818 case WM_MBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1819 button = 3;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1820 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1821 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1822 if(taskbar)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1823 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1824 POINT ptl;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1825 GetCursorPos(&ptl);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1826 result = buttonfunc(tmp->window, ptl.x, ptl.y, button, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1827 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1828 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1829 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1830 POINTS pts = MAKEPOINTS(mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1831 result = buttonfunc(tmp->window, pts.x, pts.y, button, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1832 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1833 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1834 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1835 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1836 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1837 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1838 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1839 POINTS pts = MAKEPOINTS(mp2);
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
1840 int (DWSIGNAL *motionfunc)(HWND, int, int, int, void *) = (int (*)(HWND, int, int, int, void *))tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1841
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1842 if(hWnd == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1843 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1844 int keys = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1845
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1846 if (mp1 & MK_LBUTTON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1847 keys = DW_BUTTON1_MASK;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1848 if (mp1 & MK_RBUTTON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1849 keys |= DW_BUTTON2_MASK;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1850 if (mp1 & MK_MBUTTON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1851 keys |= DW_BUTTON3_MASK;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1852
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1853 result = motionfunc(tmp->window, pts.x, pts.y, keys, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1854 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1855 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1856 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1857 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1858 case WM_CHAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1859 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
1860 int (DWSIGNAL *keypressfunc)(HWND, char, int, int, void *, char *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1861
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1862 if(hWnd == tmp->window || _toplevel_window(hWnd) == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1863 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1864 int special = 0;
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1865 char *utf8 = NULL, ch[2] = {0};
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1866 #ifdef UNICODE
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1867 WCHAR uc[2] = { 0 };
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1868
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1869 uc[0] = (WCHAR)mp1;
1842
123d1a900f54 More MINGW cleanups... eliminate a few more warnings and disable the unused-value warning due to unfixable warnings generated by the Win32 macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1839
diff changeset
1870 utf8 = WideToUTF8(&uc[0]);
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1871 #endif
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1872
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1873 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1874 special |= KC_SHIFT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1875 if(GetAsyncKeyState(VK_CONTROL) & 0x8000)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1876 special |= KC_CTRL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1877 if(mp2 & (1 << 29))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1878 special |= KC_ALT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1879
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1880 if(origmsg == WM_CHAR && mp1 < 128)
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1881 ch[0] = (char)mp1;
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1882
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
1883 result = keypressfunc(tmp->window, ch[0], (int)mp1, special, tmp->data, utf8 ? utf8 : ch);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1884 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1885 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1886 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1887 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1888 case WM_CLOSE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1889 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
1890 int (DWSIGNAL *closefunc)(HWND, void *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1891
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1892 if(hWnd == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1893 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1894 result = closefunc(tmp->window, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1895 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1896 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1897 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1898 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1899 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1900 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1901 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1902 DWExpose exp;
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
1903 int (DWSIGNAL *exposefunc)(HWND, DWExpose *, void *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1904
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
1905 if ( hWnd == tmp->window )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1906 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1907 BeginPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1908 exp.x = ps.rcPaint.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1909 exp.y = ps.rcPaint.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1910 exp.width = ps.rcPaint.right - ps.rcPaint.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1911 exp.height = ps.rcPaint.bottom - ps.rcPaint.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1912 result = exposefunc(hWnd, &exp, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1913 EndPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1914 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1915 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1916 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1917 case WM_NOTIFY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1918 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1919 if(tmp->message == TVN_SELCHANGED ||
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1920 tmp->message == NM_RCLICK ||
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1921 tmp->message == TVN_ITEMEXPANDED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1922 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1923 NMTREEVIEW FAR *tem=(NMTREEVIEW FAR *)mp2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1924 NMLISTVIEW FAR *lem=(NMLISTVIEW FAR *)mp2;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1925 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1926
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1927 GetClassName(tem->hdr.hwndFrom, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1928
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1929 if(_tcsnicmp(tmpbuf, WC_TREEVIEW, _tcslen(WC_TREEVIEW))==0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1930 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1931 if(tem->hdr.code == TVN_SELCHANGED && tmp->message == TVN_SELCHANGED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1932 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1933 if(tmp->window == tem->hdr.hwndFrom && !dw_window_get_data(tmp->window, "_dw_select_item"))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1934 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
1935 int (DWSIGNAL *treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1936 TVITEM tvi;
1868
dc3260e1a915 Use the cached text from the tree on Windows instead of caching parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
1937 TCHAR textbuf[1025] = {0}, *textptr = textbuf;
dc3260e1a915 Use the cached text from the tree on Windows instead of caching parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
1938
dc3260e1a915 Use the cached text from the tree on Windows instead of caching parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
1939 tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1940 tvi.hItem = tem->itemNew.hItem;
1868
dc3260e1a915 Use the cached text from the tree on Windows instead of caching parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
1941 tvi.pszText = textbuf;
dc3260e1a915 Use the cached text from the tree on Windows instead of caching parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
1942 tvi.cchTextMax = 1024;
617
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 TreeView_GetItem(tmp->window, &tvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1945
1868
dc3260e1a915 Use the cached text from the tree on Windows instead of caching parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
1946 result = treeselectfunc(tmp->window, tem->itemNew.hItem, WideToUTF8(textptr), tmp->data, (void *)tvi.lParam);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1947
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1948 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1949 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1950 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1951 else if(tem->hdr.code == TVN_ITEMEXPANDED && tmp->message == TVN_ITEMEXPANDED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1952 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1953 if(tmp->window == tem->hdr.hwndFrom && tem->action == TVE_EXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1954 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
1955 int (DWSIGNAL *treeexpandfunc)(HWND, HTREEITEM, void *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1956
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1957 result = treeexpandfunc(tmp->window, tem->itemNew.hItem, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1958 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1959 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1960 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1961 else if(tem->hdr.code == NM_RCLICK && tmp->message == NM_RCLICK)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1962 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1963 if(tmp->window == tem->hdr.hwndFrom)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1964 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
1965 int (DWSIGNAL *containercontextfunc)(HWND, char *, int, int, void *, void *) = tmp->signalfunction;
1653
a7a24a3b8899 Fixes for the latest MinGW (gcc 4.6.2). Only ANSI mode is currently supported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1643
diff changeset
1966 HTREEITEM hti;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1967 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1968 TVHITTESTINFO thi;
1868
dc3260e1a915 Use the cached text from the tree on Windows instead of caching parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
1969 void *itemdata = NULL;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1970 LONG x, y;
1868
dc3260e1a915 Use the cached text from the tree on Windows instead of caching parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
1971 TCHAR textbuf[1025] = {0}, *textptr = textbuf;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1972
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1973 dw_pointer_query_pos(&x, &y);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1974
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1975 thi.pt.x = x;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1976 thi.pt.y = y;
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 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
1979
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1980 hti = TreeView_HitTest(tmp->window, &thi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1981
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1982 if(hti)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1983 {
1868
dc3260e1a915 Use the cached text from the tree on Windows instead of caching parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
1984 tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1985 tvi.hItem = hti;
1868
dc3260e1a915 Use the cached text from the tree on Windows instead of caching parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
1986 tvi.pszText = textbuf;
dc3260e1a915 Use the cached text from the tree on Windows instead of caching parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
1987 tvi.cchTextMax = 1024;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1988
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1989 TreeView_GetItem(tmp->window, &tvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1990 TreeView_SelectItem(tmp->window, hti);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1991
1868
dc3260e1a915 Use the cached text from the tree on Windows instead of caching parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
1992 itemdata = (void *)tvi.lParam;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1993 }
1868
dc3260e1a915 Use the cached text from the tree on Windows instead of caching parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
1994 containercontextfunc(tmp->window, WideToUTF8(textptr), x, y, tmp->data, itemdata);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1995 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1996 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1997 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
1998 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
1999 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
2000 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2001 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
2002 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2003 if(tmp->window == tem->hdr.hwndFrom)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2004 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2005 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2006 int iItem;
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 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
2009
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2010 memset(&lvi, 0, sizeof(LV_ITEM));
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 if(iItem > -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2013 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
2014 int (DWSIGNAL *treeselectfunc)(HWND, HWND, char *, void *, void *) = tmp->signalfunction;
617
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 lvi.iItem = iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2017 lvi.mask = LVIF_PARAM;
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 ListView_GetItem(tmp->window, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2020
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2021 /* 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
2022 if(lvi.lParam < 100)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2023 lvi.lParam = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2024
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2025 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
2026 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2027 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2028 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2029 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2030 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2031 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2032 else if(tmp->message == TCN_SELCHANGE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2033 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2034 NMHDR FAR *tem=(NMHDR FAR *)mp2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2035 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
2036 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
2037 int (DWSIGNAL *switchpagefunc)(HWND, unsigned long, void *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2038 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
2039 result = switchpagefunc(tem->hwndFrom, num, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2040 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2041 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2042 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2043 else if(tmp->message == LVN_COLUMNCLICK)
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 NMLISTVIEW FAR *tem=(NMLISTVIEW FAR *)mp2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2046 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
2047 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
2048 int (DWSIGNAL *columnclickfunc)(HWND, int, void *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2049 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
2050 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2051 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2052 }
1624
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2053 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
2054 {
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2055 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
2056 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
2057 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
2058 int (DWSIGNAL *valuechangefunc)(HWND, int, void *) = tmp->signalfunction;
1624
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2059 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
2060 tmp = NULL;
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2061 }
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2062 }
617
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2065 case WM_COMMAND:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2066 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
2067 int (DWSIGNAL *clickfunc)(HWND, void *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2068 HWND command;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2069 ULONG passthru = (ULONG)LOWORD(mp1);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
2070 ULONG message = (ULONG)HIWORD(mp1);
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
2071
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
2072 command = (HWND)(uintptr_t)passthru;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2073
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2074 if (message == LBN_SELCHANGE || message == CBN_SELCHANGE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2075 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
2076 int (DWSIGNAL *listboxselectfunc)(HWND, int, void *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2077
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2078 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
2079 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2080 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
2081 tmp = NULL;
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 }
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
2084 #ifdef TOOLBAR
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
2085 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
2086 {
1760
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2087 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
2088
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2089 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
2090
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2091 /* 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
2092 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
2093 {
3bbbb5a55cf8 Fix buttons causing double events when toolbar support is enabled on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1754
diff changeset
2094 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
2095 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
2096 }
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
2097 }
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
2098 #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
2099 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
2100 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2101 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
2102
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2103 if (menuowner == hwndmenu || !menuowner)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2104 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2105 _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
2106 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2107 * Call the user supplied callback
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2108 */
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
2109 result = clickfunc((HWND)(uintptr_t)tmp->id, tmp->data);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2110 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2111 }
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2112 } /* this fires for checkable menu items */
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2113 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
2114 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
2115 _dw_toggle_checkable_menu_item( popup ? popup : tmp->window, DW_POINTER_TO_INT(tmp->data) );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2116 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
2117 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2118 }
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2121 case WM_HSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2122 case WM_VSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2123 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2124 TCHAR tmpbuf[100] = {0};
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2125 HWND handle = (HWND)mp2;
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
2126 int (DWSIGNAL *valuechangefunc)(HWND, int, void *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2127
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
2128 if(!GetClassName(handle, tmpbuf, 99))
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
2129 {
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
2130 GetClassName(hWnd, tmpbuf, 99);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
2131 }
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
2132
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2133 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
2134 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2135
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2136 if (handle == tmp->window)
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 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
2139 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
2140 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2141
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2142 if(currentstyle & TBS_VERT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2143 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
2144 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2145 result = valuechangefunc(tmp->window, value, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2146 tmp = NULL;
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 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2149 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
2150 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2151 if(handle == tmp->window)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2152 {
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2153 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
2154 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
2155
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2156 if(value > -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2157 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2158 dw_scrollbar_set_pos(tmp->window, value);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2159 result = valuechangefunc(tmp->window, value, tmp->data);
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 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2162 msg = 0;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2165 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2166 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2167 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2168 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2169 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2170 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2171 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2172 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2173
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2174 /* 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
2175 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2176 {
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
2177 #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
2178 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
2179 {
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
2180 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
2181
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2182 if(_DwmIsCompositionEnabled)
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2183 _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
2184
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2185 /* 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
2186 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
2187 {
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2188 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
2189
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2190 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
2191 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
2192 _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
2193 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2194 }
1515
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2195 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
2196 #endif
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2197 #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
2198 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
2199 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
2200 {
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2201 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
2202 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
2203
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2204 if(!hbrush)
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2205 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
2206
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2207 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
2208 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
2209 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
2210 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2211 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
2212 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2213 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2214 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2215 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2216
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2217 BeginPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2218 EndPaint(hWnd, &ps);
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2221 case WM_SIZE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2222 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2223 static int lastx = -1, lasty = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2224 static HWND lasthwnd = 0;
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 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
2227 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2228 Box *mybox = (Box *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2229
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2230 if(mybox && mybox->count)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2231 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2232 lastx = LOWORD(mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2233 lasty = HIWORD(mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2234 lasthwnd = hWnd;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2235
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2236 ShowWindow(mybox->items[0].hwnd, SW_HIDE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2237 _do_resize(mybox,LOWORD(mp2),HIWORD(mp2));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2238 ShowWindow(mybox->items[0].hwnd, SW_SHOW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2239 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2240 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2241 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2242 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2243 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2244 case WM_USER:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2245 windowfunc = (void *)mp1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2246
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2247 if(windowfunc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2248 windowfunc((void *)mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2249 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2250 case WM_USER+5:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2251 _free_menu_data((HMENU)mp1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2252 DestroyMenu((HMENU)mp1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2253 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2254 case WM_NOTIFY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2255 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2256 NMHDR FAR *tem=(NMHDR FAR *)mp2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2257
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2258 if(tem->code == TCN_SELCHANGING)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2259 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2260 int num=TabCtrl_GetCurSel(tem->hwndFrom);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2261 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
2262
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2263 if(num > -1 && array && array[num])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2264 SetParent(array[num]->hwnd, DW_HWND_OBJECT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2265
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2266 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2267 else if(tem->code == TCN_SELCHANGE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2268 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2269 int num=TabCtrl_GetCurSel(tem->hwndFrom);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2270 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
2271
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2272 if(num > -1 && array && array[num])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2273 SetParent(array[num]->hwnd, tem->hwndFrom);
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 _resize_notebook_page(tem->hwndFrom, num);
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2278 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2279 case WM_HSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2280 case WM_VSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2281 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2282 HWND handle = (HWND)mp2;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2283 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
2284
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2285 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
2286 {
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2287 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
2288
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2289 if(value > -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2290 dw_scrollbar_set_pos(handle, value);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2291 }
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2292 else
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2293 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2294 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
2295
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2296 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
2297 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
2298 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
2299 _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
2300 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2301 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2302 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2303 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2304 case WM_GETMINMAXINFO:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2305 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2306 MINMAXINFO *info = (MINMAXINFO *)mp2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2307 info->ptMinTrackSize.x = 8;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2308 info->ptMinTrackSize.y = 8;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2309 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2310 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2311 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2312 case WM_DESTROY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2313 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2314 HMENU menu = GetMenu(hWnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2315
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2316 if(menu)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2317 _free_menu_data(menu);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2318
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2319 /* Free memory before destroying */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2320 _free_window_memory(hWnd, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2321 EnumChildWindows(hWnd, _free_window_memory, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2322 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2323 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2324 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2325 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2326 HCURSOR cursor;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2327
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2328 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
2329 (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
2330 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2331 SetCursor(cursor);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2332 }
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2335 case WM_CTLCOLORSTATIC:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2336 case WM_CTLCOLORLISTBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2337 case WM_CTLCOLORBTN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2338 case WM_CTLCOLOREDIT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2339 case WM_CTLCOLORMSGBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2340 case WM_CTLCOLORSCROLLBAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2341 case WM_CTLCOLORDLG:
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2342 return _colorwndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2343 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2344 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
2345 {
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
2346 /* 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
2347 _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
2348 /* Then finally return */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2349 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
2350 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
2351 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
2352 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2353
461
12ba7e744560 Fixes timer problems on Windows, however this may break Win95 support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 456
diff changeset
2354 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
2355 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2356 _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
2357 }
12ba7e744560 Fixes timer problems on Windows, however this may break Win95 support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 456
diff changeset
2358
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
2359 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
2360 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2361 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2362 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2363 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2364 case WM_MBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2365 case WM_RBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2366 SetActiveWindow(hWnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2367 SetFocus(hWnd);
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_COMMAND:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2370 case WM_NOTIFY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2371 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2372 _wndproc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2373 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
2374 #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
2375 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
2376 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
2377 {
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2378 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
2379 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
2380
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2381 if(!hbrush)
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2382 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
2383
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
2384 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
2385 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
2386 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
2387 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2388 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
2389 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2390 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2391 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2392 ColorInfo *thiscinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
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 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
2395 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2396 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2397 HDC hdcPaint = BeginPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2398 int success = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2399
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2400 if(thiscinfo && thiscinfo->fore != -1 && thiscinfo->back != -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2401 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2402 /* Handle foreground */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2403 if(thiscinfo->fore > -1 && thiscinfo->fore < 18)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2404 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2405 if(thiscinfo->fore != DW_CLR_DEFAULT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2406 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2407 SetTextColor((HDC)mp1, RGB(_red[thiscinfo->fore],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2408 _green[thiscinfo->fore],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2409 _blue[thiscinfo->fore]));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2410 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2411 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2412 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
2413 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2414 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
2415 DW_GREEN_VALUE(thiscinfo->fore),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2416 DW_BLUE_VALUE(thiscinfo->fore)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2417 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2418 /* Handle background */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2419 if(thiscinfo->back > -1 && thiscinfo->back < 18)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2420 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2421 if(thiscinfo->back != DW_CLR_DEFAULT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2422 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2423 SetBkColor((HDC)mp1, RGB(_red[thiscinfo->back],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2424 _green[thiscinfo->back],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2425 _blue[thiscinfo->back]));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2426 if(thiscinfo->hbrush)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2427 DeleteObject(thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2428 thiscinfo->hbrush = CreateSolidBrush(RGB(_red[thiscinfo->back],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2429 _green[thiscinfo->back],
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2430 _blue[thiscinfo->back]));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2431 SelectObject(hdcPaint, thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2432 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
2433 success = TRUE;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2436 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
2437 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2438 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
2439 DW_GREEN_VALUE(thiscinfo->back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2440 DW_BLUE_VALUE(thiscinfo->back)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2441 if(thiscinfo->hbrush)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2442 DeleteObject(thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2443 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
2444 DW_GREEN_VALUE(thiscinfo->back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2445 DW_BLUE_VALUE(thiscinfo->back)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2446 SelectObject(hdcPaint, thiscinfo->hbrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2447 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
2448 success = TRUE;
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 }
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 EndPaint(hWnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2453 if(success)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2454 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2455 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2456
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2457 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2458 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2459 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2460 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
2461 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2462
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
2463 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
2464 {
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
2465 LRESULT rcode = TRUE;
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2466
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2467 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2468 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2469 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2470 case WM_MBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2471 case WM_RBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2472 SetFocus(hWnd);
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2473 rcode = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2474 break;
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2475 case WM_MOUSEMOVE:
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
2476 /* 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
2477 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
2478 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
2479 case WM_USER+2:
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2480 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2481 case WM_MBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2482 case WM_RBUTTONUP:
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2483 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
2484 break;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2485 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2486 case WM_SIZE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2487 case WM_COMMAND:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2488 case WM_CHAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2489 case WM_KEYDOWN:
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2490 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
2491 break;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2492 default:
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2493 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2494 }
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2495 /* 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
2496 if ( rcode != 0 )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
2497 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
2498 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
2499 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2500
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
2501 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
2502 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2503 ColorInfo *cinfo;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2504
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2505 cinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2506
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2507 if(msg == WM_MOUSEMOVE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2508 _wndproc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2509
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2510 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2511 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2512 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2513 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2514 case WM_LBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2515 case WM_MBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2516 case WM_RBUTTONDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2517 case WM_KEYDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2518 {
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
2519 LRESULT ret;
617
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 if(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2522 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2523 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
2524
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2525 /* 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
2526 * 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
2527 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2528 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2529 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
2530
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2531 SetTimer(hWnd, 100, 100, (TIMERPROC)NULL);
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 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2534 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2535 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2536 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2537 case WM_MBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2538 case WM_RBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2539 case WM_KEYUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2540 {
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
2541 LRESULT ret;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2542
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2543 if(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2544 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2545 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
2546
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2547 /* 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
2548 * 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
2549 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2550 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2551 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
2552
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2553 if(hWnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2554 KillTimer(hWnd, 100);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2555
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2556 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2557 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2558 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2559 case WM_TIMER:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2560 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2561 if(mp1 == 100)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2562 {
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
2563 LRESULT ret;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2564
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2565 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2566 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
2567
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2568 if(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2569 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2570 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
2571
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2572 /* 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
2573 * 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
2574 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2575 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2576 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
2577
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2578 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2579 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2580 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2581 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2582 case WM_USER+10:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2583 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2584 if(cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2585 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2586 TCHAR tempbuf[100] = { 0 };
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2587 long position;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2588
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2589 GetWindowText(cinfo->buddy, tempbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2590
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2591 position = _tstol(tempbuf);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2592
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
2593 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
2594 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2595 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2596 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2597 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2598 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2599
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2600 if(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2601 return DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2602 return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2603 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2604
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2605 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
2606 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
2607 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2608
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2609 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2610
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2611 /* These are the window classes which can
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2612 * obtain input focus.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2613 */
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
2614 if (_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1)==0
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
2615 #ifdef TOOLBAR
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
2616 || _tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
2617 #endif
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
2618 )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2619 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2620 /* Generate click on default item */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2621 SignalHandler *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2622
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2623 /* Find any callbacks for this function */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2624 while (tmp)
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 (tmp->message == WM_COMMAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2627 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2628 /* 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
2629 if (tmp->window == handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2630 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
2631 int (DWSIGNAL *clickfunc)(HWND, void *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2632 clickfunc(tmp->window, tmp->data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2633 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2634 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2635 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2636 if (tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2637 tmp= tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2638 }
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 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2641 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
2642 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2643
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2644 /* 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
2645 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
2646 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2647 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
2648 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2649 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
2650 LRESULT ret = -1;
617
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 cinfo = (ColorInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
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 GetClassName(hWnd, tmpbuf, 99);
1624
c5aab296fba3 Implemented value changed event for spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1623
diff changeset
2655 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
2656 cinfo = &(((Box *)cinfo)->cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2657
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
2658 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
2659 ret = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2660
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2661 if (cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2662 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2663 pOldProc = cinfo->pOldProc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2664
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2665 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2666 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2667 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
2668 if(cinfo->combo)
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2669 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
2670 else
1131
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2671 ret = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2672 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2673 case WM_VSCROLL:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2674 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
2675 ret = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2676 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2677 case WM_KEYDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2678 case WM_KEYUP:
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 (hWnd && (mp1 == VK_UP || mp1 == VK_DOWN))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2681 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2682 if (!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2683 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2684 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
2685
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2686 /* 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
2687 * 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
2688 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2689 if (cinfo && cinfo->buddy && !cinfo->combo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2690 PostMessage(hWnd, WM_USER+10, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2691
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2692 if(msg == WM_KEYDOWN)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2693 SetTimer(hWnd, 101, 100, (TIMERPROC)NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2694 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2695 KillTimer(hWnd, 101);
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_TIMER:
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(mp1 == 101)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2704 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2705 if(!cinfo || !cinfo->pOldProc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2706 ret = DefWindowProc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2707 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
2708
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2709 /* 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
2710 * 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
2711 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2712 if(cinfo && cinfo->buddy && !cinfo->combo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2713 PostMessage(hWnd, WM_USER+10, 0, 0);
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 return ret;
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2719 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
2720 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
2721 if (ret != TRUE && LOWORD(mp1) == '\t')
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2722 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2723 if (GetAsyncKeyState(VK_SHIFT) & 0x8000)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2724 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2725 if (cinfo->combo)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
2726 _shift_focus(cinfo->combo, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2727 else if(cinfo->buddy)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
2728 _shift_focus(cinfo->buddy, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2729 else
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
2730 _shift_focus(hWnd, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2731 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2732 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2733 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2734 if (cinfo->combo)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
2735 _shift_focus(cinfo->combo, _DW_DIRECTION_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2736 else if(cinfo->buddy)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
2737 _shift_focus(cinfo->buddy, _DW_DIRECTION_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2738 else
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
2739 _shift_focus(hWnd, _DW_DIRECTION_FORWARD);
617
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 return FALSE;
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 else if(LOWORD(mp1) == '\r')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2744 {
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2745
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2746 if ( cinfo->clickdefault )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2747 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2748 _click_default(cinfo->clickdefault);
1846
905f8632005b When handling click default, return instead of running the default handler on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1842
diff changeset
2749 return (LRESULT)TRUE;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2750 }
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2751 else
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2752 {
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2753 /*
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2754 * 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
2755 * has a default click set
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2756 */
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2757 HWND tl = _toplevel_window( hWnd );
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2758 ColorInfo *mycinfo = (ColorInfo *)GetWindowLongPtr( tl, GWLP_USERDATA );
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
2759 if ( mycinfo && mycinfo->clickdefault )
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2760 {
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2761 _click_default( mycinfo->clickdefault );
1846
905f8632005b When handling click default, return instead of running the default handler on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1842
diff changeset
2762 return (LRESULT)TRUE;
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2763 }
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
2764 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2765 }
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 /* 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
2768 * 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
2769 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2770 if (cinfo->buddy && !cinfo->combo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2771 {
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
2772 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
2773 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2774 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2775 case WM_USER+10:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2776 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2777 if(cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2778 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2779 long val;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2780
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
2781 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
2782
1621
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
2783 _sntprintf(tmpbuf, 99, TEXT("%ld"), val);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2784 SetWindowText(hWnd, tmpbuf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2785 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2786 }
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_CTLCOLORSTATIC:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2789 case WM_CTLCOLORLISTBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2790 case WM_CTLCOLORBTN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2791 case WM_CTLCOLOREDIT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2792 case WM_CTLCOLORMSGBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2793 case WM_CTLCOLORSCROLLBAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2794 case WM_CTLCOLORDLG:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2795 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2796 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
2797 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
2798 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2799 int thisback = thiscinfo->back;
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2800
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2801 /* Handle foreground */
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2802 if(thiscinfo->fore != DW_CLR_DEFAULT)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2803 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2804 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
2805
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2806 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
2807 DW_GREEN_VALUE(fore),
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2808 DW_BLUE_VALUE(fore)));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2809 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2810 /* Handle background */
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2811 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
2812 {
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2813 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
2814
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2815 if(parentcinfo && parentcinfo->back != -1)
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2816 thisback = parentcinfo->back;
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2817 }
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2818 if(thisback == DW_CLR_DEFAULT)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2819 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2820 HBRUSH hbr = GetSysColorBrush(COLOR_3DFACE);
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2821
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2822 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
2823
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2824 SelectObject((HDC)mp1, hbr);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
2825 return (LONG)(intptr_t)hbr;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2826 }
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2827 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
2828 {
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2829 int back = _internal_color(thisback);
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2830
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2831 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
2832 DW_GREEN_VALUE(back),
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2833 DW_BLUE_VALUE(back)));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2834 if(thiscinfo->hbrush)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2835 DeleteObject(thiscinfo->hbrush);
1427
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2836 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
2837 DW_GREEN_VALUE(back),
7b735226ab94 Simplified the widget color handling code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1425
diff changeset
2838 DW_BLUE_VALUE(back)));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2839 SelectObject((HDC)mp1, thiscinfo->hbrush);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
2840 return (LONG)(intptr_t)thiscinfo->hbrush;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2841 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2842 }
1514
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2843 #ifdef AEROGLASS
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2844 switch(msg)
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2845 {
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2846 case WM_CTLCOLORSTATIC:
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2847 case WM_CTLCOLORBTN:
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2848 case WM_CTLCOLORDLG:
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2849 {
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2850
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
2851 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
2852 (!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
2853 {
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
2854 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
2855 {
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
2856 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
2857 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
2858 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
2859 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
2860 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
2861 return (LONG)thiscinfo->hbrush;
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2862 }
1514
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2863 }
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2864 }
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2865 }
f33dca736917 More work on Windows Aero Glass backgrounds...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1512
diff changeset
2866 #endif
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
2867 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2868 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2869 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2870 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2871
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
2872 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
2873 {
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2874 if(!pOldProc)
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2875 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
2876 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
2877 }
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
2878 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
2879 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2880
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2881 /* 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
2882 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
2883 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
2884 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
2885
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2886 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2887 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2888 case WM_COMMAND:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2889 case WM_NOTIFY:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2890 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2891 _wndproc(hWnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2892 break;
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2893 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
2894 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
2895 {
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
2896 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
2897 int iItems, iTop, i;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2898 COLORREF c;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2899
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2900 /* 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
2901 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
2902 /* 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
2903 GetUpdateRect(hWnd, &rectUpd, FALSE);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2904 /* 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
2905 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
2906 /* number of displayed rows */
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2907 iItems = ListView_GetCountPerPage(hWnd);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2908 /* first visible row */
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2909 iTop = ListView_GetTopIndex(hWnd);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2910
1214
e16e7c51b6c7 Another attempt at fixing alternating row issues on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1213
diff changeset
2911 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
2912 {
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2913 /* 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
2914 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
2915 {
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2916 /* 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
2917 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
2918
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2919 if(c != DW_RGB_TRANSPARENT)
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2920 {
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2921 ListView_SetTextBkColor(hWnd, c);
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2922 /* 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
2923 InvalidateRect(hWnd, &rectDestin, FALSE);
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2924 /* ...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
2925 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
2926 }
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2927 }
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2928 }
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2929 }
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
2930 break;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2931 case WM_LBUTTONDBLCLK:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2932 case WM_CHAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2933 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2934 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2935 int iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2936
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2937 if(LOWORD(mp1) == '\t')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2938 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2939 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
2940 _shift_focus(hWnd, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2941 else
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
2942 _shift_focus(hWnd, _DW_DIRECTION_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2943 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2944 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2945
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2946 if(msg == WM_CHAR && (char)mp1 != '\r')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2947 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2948
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2949 iItem = ListView_GetNextItem(hWnd, -1, LVNI_FOCUSED);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2950
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2951 memset(&lvi, 0, sizeof(LV_ITEM));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2952
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2953 if(iItem > -1)
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 lvi.iItem = iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2956 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2957
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2958 ListView_GetItem(hWnd, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2959 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2960
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2961 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2962 SignalHandler *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2963
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2964 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2965 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2966 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
2967 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
2968 int (DWSIGNAL *containerselectfunc)(HWND, char *, void *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2969
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2970 /* 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
2971 if(lvi.lParam < 100)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2972 lvi.lParam = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2973
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2974 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
2975 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2976 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2977 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2978 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2979 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2980 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2981 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2982 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2983 case WM_CONTEXTMENU:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2984 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2985 SignalHandler *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2986
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2987 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2988 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2989 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
2990 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
2991 int (DWSIGNAL *containercontextfunc)(HWND, char *, int, int, void *, void *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2992 LONG x,y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2993 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2994 int iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2995 LVHITTESTINFO lhi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2996
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2997 dw_pointer_query_pos(&x, &y);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2998
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
2999 lhi.pt.x = x;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3000 lhi.pt.y = y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3001
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3002 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
3003
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3004 iItem = ListView_HitTest(tmp->window, &lhi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3005
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3006 memset(&lvi, 0, sizeof(LV_ITEM));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3007
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3008 if(iItem > -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3009 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3010 lvi.iItem = iItem;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3011 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3012
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3013 ListView_GetItem(tmp->window, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3014 ListView_SetSelectionMark(tmp->window, iItem);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3015 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3016
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3017 /* 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
3018 if(lvi.lParam < 100)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3019 lvi.lParam = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3020
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3021 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
3022 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3023 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3024 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3025 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3026 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3027 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3028 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3029 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3030
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
3031 if(!continfo || !continfo->cinfo.pOldProc)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3032 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
3033 return CallWindowProc(continfo->cinfo.pOldProc, hWnd, msg, mp1, mp2);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3034 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3035
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
3036 LRESULT CALLBACK _simplewndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)
68
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3037 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3038 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
3039 LRESULT ret = -1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3040
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3041 cinfo = (ContainerInfo *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3042
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3043 switch( msg )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3044 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3045 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
3046 ret = _wndproc(hWnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3047 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3048 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
3049 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
3050 if(ret != TRUE && LOWORD(mp1) == '\t')
617
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)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
3053 _shift_focus(hWnd, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3054 else
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
3055 _shift_focus(hWnd, _DW_DIRECTION_FORWARD);
617
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 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3059 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3060
1131
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3061 if(ret != TRUE)
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3062 {
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
3063 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
3064 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
3065 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
3066 }
5d27b8562c6f With subclasses calling _wndproc directly on Windows, save the result...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1119
diff changeset
3067 return ret;
68
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3068 }
8d6100960adf Minor tab changes on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3069
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3070 void _changebox(Box *thisbox, int percent, int type)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3071 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3072 int z;
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 for(z=0;z<thisbox->count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3075 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3076 if(thisbox->items[z].type == TYPEBOX)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3077 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3078 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
3079 _changebox(tmp, percent, type);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3080 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3081 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3082 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3083 if(type == DW_HORZ)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3084 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3085 if(thisbox->items[z].hsize == SIZEEXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3086 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
3087 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3088 else
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(thisbox->items[z].vsize == SIZEEXPAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3091 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
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 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3095 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3096
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3097 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
3098 {
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
3099 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
3100 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
3101
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
3102 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
3103 ShowWindow(handle2, SW_HIDE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3104
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3105 if(type == DW_HORZ)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3106 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3107 int newx = x;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3108 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
3109 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
3110
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3111 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
3112
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3113 MoveWindow(handle1, 0, 0, newx, y, FALSE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3114 _do_resize(tmp, newx - 1, y - 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3115
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3116 tmp = (Box *)GetWindowLongPtr(handle2, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3117
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3118 newx = x - newx - SPLITBAR_WIDTH;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3119
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3120 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
3121 _do_resize(tmp, newx - 1, y - 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3122
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3123 dw_window_set_data(hwnd, "_dw_start", DW_INT_TO_POINTER(newx));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3124 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3125 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3126 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3127 int newy = y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3128 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
3129 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
3130
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3131 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
3132
1450
145edf67013e Fixed accidentally flipping splitbars vertically on Windows in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1449
diff changeset
3133 MoveWindow(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
3134 _do_resize(tmp, x - 1, newy - 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3135
1450
145edf67013e Fixed accidentally flipping splitbars vertically on Windows in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1449
diff changeset
3136 tmp = (Box *)GetWindowLongPtr(handle1, GWLP_USERDATA);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3137
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3138 newy = y - newy - SPLITBAR_WIDTH;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3139
1450
145edf67013e Fixed accidentally flipping splitbars vertically on Windows in that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1449
diff changeset
3140 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
3141 _do_resize(tmp, x - 1, newy - 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3142
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3143 dw_window_set_data(hwnd, "_dw_start", DW_INT_TO_POINTER(newy));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3144 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3145
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3146 ShowWindow(handle1, SW_SHOW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3147 ShowWindow(handle2, SW_SHOW);
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3148 }
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3149
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3150 /* 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
3151 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
3152 {
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3153 switch (msg)
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3154 {
841
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3155 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
3156 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
3157 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3158 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
3159 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
3160 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
3161 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
3162
896
529c27638936 Added missing SIF_PAGE getting SCROLLINFO on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 865
diff changeset
3163 /* 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
3164 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
3165 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
3166
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3167 /* 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
3168 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
3169 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
3170
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3171 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
3172 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3173 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
3174 si = &vsi;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3175 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3176
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3177 switch(which)
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3178 {
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3179 case SB_THUMBTRACK:
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3180 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
3181 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3182 /*case SB_PAGEDOWN:*/
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3183 case SB_PAGELEFT:
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3184 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
3185 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
3186 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
3187 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3188 /*case SB_PAGEUP:*/
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3189 case SB_PAGERIGHT:
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3190 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
3191 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
3192 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
3193 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3194 /*case SB_LINEDOWN:*/
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3195 case SB_LINELEFT:
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3196 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
3197 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
3198 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
3199 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3200 /*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
3201 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
3202 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
3203 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
3204 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
3205 break;
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3206 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3207
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3208 /* 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
3209 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
3210 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
3211 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
3212 }
9be19dbd2ff4 Basic handling for the scrolled widget. Scrollbox now works on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 839
diff changeset
3213 break;
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3214 }
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3215 return DefWindowProc(hwnd, msg, mp1, mp2);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3216 }
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3217
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3218 /* 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
3219 LRESULT CALLBACK _splitwndproc(HWND hwnd, UINT msg, WPARAM mp1, LPARAM mp2)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3220 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3221 switch (msg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3222 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3223 case WM_ACTIVATE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3224 case WM_SETFOCUS:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3225 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3226
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3227 case WM_PAINT:
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 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3230 HDC hdcPaint;
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3231 int type = DW_POINTER_TO_INT(dw_window_get_data(hwnd, "_dw_type"));
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3232 int start = DW_POINTER_TO_INT(dw_window_get_data(hwnd, "_dw_start"));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3233
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3234 BeginPaint(hwnd, &ps);
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 if((hdcPaint = GetDC(hwnd)) != NULL)
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 unsigned long cx, cy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3239 HBRUSH oldBrush = SelectObject(hdcPaint, GetSysColorBrush(COLOR_3DFACE));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3240 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
3241
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3242 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
3243
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3244 if(type == DW_HORZ)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3245 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
3246 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3247 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
3248
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3249 SelectObject(hdcPaint, oldBrush);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3250 DeleteObject(SelectObject(hdcPaint, oldPen));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3251 ReleaseDC(hwnd, hdcPaint);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3252 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3253 EndPaint(hwnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3254 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3255 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3256 case WM_LBUTTONDOWN:
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 SetCapture(hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3259 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3260 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3261 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3262 {
126
72cb88af4490 Finalized splitbar support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 124
diff changeset
3263 if(GetCapture() == hwnd)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3264 ReleaseCapture();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3265 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3266 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3267 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3268 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3269 float *percent = (float *)dw_window_get_data(hwnd, "_dw_percent");
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3270 int type = DW_POINTER_TO_INT(dw_window_get_data(hwnd, "_dw_type"));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3271 int start;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3272
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3273 if(type == DW_HORZ)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3274 SetCursor(LoadCursor(NULL, IDC_SIZEWE));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3275 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3276 SetCursor(LoadCursor(NULL, IDC_SIZENS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3277
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3278 if(GetCapture() == hwnd && percent)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3279 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3280 POINT point;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3281 RECT rect;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3282 static POINT lastpoint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3283
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3284 GetCursorPos(&point);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3285 GetWindowRect(hwnd, &rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3286
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3287 if(memcmp(&point, &lastpoint, sizeof(POINT)))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3288 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3289 if(PtInRect(&rect, point))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3290 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3291 int width = (rect.right - rect.left);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3292 int height = (rect.bottom - rect.top);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3293
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3294 if(type == DW_HORZ)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3295 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3296 start = point.x - rect.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3297 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
3298 *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
3299 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3300 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3301 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3302 start = point.y - rect.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3303 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
3304 *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
3305 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3306 _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
3307 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3308 memcpy(&lastpoint, &point, sizeof(POINT));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3309 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3310 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3311 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3312 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3313 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3314 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
3315 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3316
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3317 /* 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
3318 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
3319 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3320 switch (msg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3321 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3322 case WM_MOUSEMOVE:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3323 _wndproc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3324 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3325 case WM_SETTEXT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3326 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3327 /* 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
3328 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
3329
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3330 InvalidateRgn(hwnd, NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3331 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3332 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3333 case WM_PAINT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3334 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3335 HDC hdcPaint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3336 PAINTSTRUCT ps;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3337 RECT rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3338 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
3339 TCHAR tempbuf[1025] = { 0 };
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3340 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3341 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
3342 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
3343
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3344 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
3345 GetWindowText(hwnd, tempbuf, 1024);
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 hdcPaint = BeginPaint(hwnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3348 if(hfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3349 oldfont = (HFONT)SelectObject(hdcPaint, hfont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3350 rc.top = rc.left = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3351 rc.right = cx;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3352 rc.bottom = cy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3353 DrawStatusText(hdcPaint, &rc, tempbuf, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3354 if(hfont && oldfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3355 SelectObject(hdcPaint, oldfont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3356 if(hfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3357 DeleteObject(hfont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3358 EndPaint(hwnd, &ps);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3359 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3360 return FALSE;
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 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
3363 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3364
1536
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3365 #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
3366 /* 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
3367 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
3368 {
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
3369 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
3370 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
3371
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3372 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
3373 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
3374
1556
4a9c574d5c17 Fixed on Windows showing themed static text on colored boxes when the window is glass.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1550
diff changeset
3375 /* 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
3376 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
3377
1536
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3378 /* 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
3379 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
3380 || !_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
3381 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
3382
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
3383 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
3384
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3385 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
3386 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3387 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
3388 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3389 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
3390 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
3391
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3392 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
3393 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3394 /* 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
3395 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
3396 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
3397 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
3398 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
3399 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
3400
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3401 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
3402
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3403 if(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
3404 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3405 /* 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
3406 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
3407
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3408 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
3409 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3410 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
3411 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
3412 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
3413 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
3414 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
3415
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3416 /* 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
3417 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
3418 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
3419
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3420 /* 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
3421 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
3422 _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
3423
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3424 /* 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
3425 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
3426 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
3427 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
3428
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3429 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
3430
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3431 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
3432 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
3433
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3434 /* 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
3435 if(iLen)
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3436 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3437 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
3438
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3439 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
3440 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3441 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
3442 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
3443 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3444 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
3445
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3446 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
3447 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3448 case SS_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
3449 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
3450 break;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3451 case SS_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
3452 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
3453 break;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3454 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
3455 dwFlags &= ~DT_WORDBREAK;
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3456 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
3457 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3458
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3459 if(dwStyle & SS_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
3460 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3461 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
3462 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
3463 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3464
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3465
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3466 if(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
3467 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
3468 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
3469 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
3470 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
3471 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
3472
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3473 if (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
3474 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
3475
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3476 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
3477 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
3478
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3479 /* 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
3480 _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
3481 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
3482 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3483 }
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
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 /* 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
3487 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
3488 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
3489 _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
3490 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3491 _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
3492 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3493 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3494
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3495 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
3496 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
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 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
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
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 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
3502 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
3503 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
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 #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
3506
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3507 /* Function: _BtProc
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3508 * Abstract: Subclass procedure for buttons
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3509 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3510
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
3511 LRESULT CALLBACK _BtProc(HWND hwnd, ULONG msg, WPARAM mp1, LPARAM mp2)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3512 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3513 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
3514 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
3515 int retval = -1;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3516
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3517 if ( !cinfo )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3518 return DefWindowProc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3519
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3520 /* 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
3521 * window procedure because if a signal
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3522 * handler attached here destroys this
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3523 * window it will then be invalid.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3524 */
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3525 pOldProc = cinfo->pOldProc;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3526
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3527 switch(msg)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3528 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3529 case WM_CTLCOLORSTATIC:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3530 case WM_CTLCOLORLISTBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3531 case WM_CTLCOLORBTN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3532 case WM_CTLCOLOREDIT:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3533 case WM_CTLCOLORMSGBOX:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3534 case WM_CTLCOLORSCROLLBAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3535 case WM_CTLCOLORDLG:
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
3536 return _colorwndproc(hwnd, msg, mp1, mp2);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3537 case WM_SETFOCUS:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3538 _wndproc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3539 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3540 case WM_LBUTTONUP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3541 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3542 SignalHandler *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3543
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3544 /* Find any callbacks for this function */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3545 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3546 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3547 if(tmp->message == WM_COMMAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3548 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
3549 int (DWSIGNAL *clickfunc)(HWND, void *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3550
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3551 /* 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
3552 if(tmp->window == hwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3553 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3554 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
3555
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3556 if(checkbox)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3557 in_checkbox_handler = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3558
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
3559 retval = clickfunc(tmp->window, tmp->data);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3560
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
3561 if(checkbox)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3562 in_checkbox_handler = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3563 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3564 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3565 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3566 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3567 tmp= tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3568 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3569 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3570 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3571 case WM_CHAR:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3572 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3573 /* 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
3574 * 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
3575 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3576 if(LOWORD(mp1) == '\r' || LOWORD(mp1) == ' ')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3577 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3578 SignalHandler *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3579
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3580 /* Find any callbacks for this function */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3581 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3582 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3583 if(tmp->message == WM_COMMAND)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3584 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
3585 int (DWSIGNAL *clickfunc)(HWND, void *) = tmp->signalfunction;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3586
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3587 /* 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
3588 if(tmp->window == hwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3589 {
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
3590 retval = clickfunc(tmp->window, tmp->data);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3591 tmp = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3592 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3593 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3594 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3595 tmp= tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3596 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3597 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3598 if(LOWORD(mp1) == '\t')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3599 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3600 if(GetAsyncKeyState(VK_SHIFT) & 0x8000)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
3601 _shift_focus(hwnd, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3602 else
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
3603 _shift_focus(hwnd, _DW_DIRECTION_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3604 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3605 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3606 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3607 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3608 case WM_KEYDOWN:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3609 if(mp1 == VK_LEFT || mp1 == VK_UP)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
3610 _shift_focus(hwnd, _DW_DIRECTION_BACKWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3611 if(mp1 == VK_RIGHT || mp1 == VK_DOWN)
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
3612 _shift_focus(hwnd, _DW_DIRECTION_FORWARD);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3613 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3614 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3615
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
3616 /* 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
3617 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
3618 _dw_redraw(0, FALSE);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3619 if ( !pOldProc )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3620 return DefWindowProc(hwnd, msg, mp1, mp2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3621 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
3622 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3623
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3624 /* 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
3625 * 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
3626 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3627 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
3628 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3629 RECT rect;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3630 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
3631
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3632 if(array && array[pageid])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3633 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3634 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
3635
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3636 GetClientRect(handle,&rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3637 TabCtrl_AdjustRect(handle,FALSE,&rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3638 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
3639 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
3640 if(box && box->count)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3641 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3642 ShowWindow(box->items[0].hwnd, SW_HIDE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3643 _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
3644 ShowWindow(box->items[0].hwnd, SW_SHOW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3645 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3646
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3647 ShowWindow(array[pageid]->hwnd, SW_SHOWNORMAL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3648 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3649 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3650
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
3651 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
3652 {
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
3653 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
3654
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
3655 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
3656 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
3657 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
3658
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
3659 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
3660 if(text)
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3661 {
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3662 /* 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
3663 * 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
3664 */
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3665 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
3666 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
3667 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
3668
2ccf7eacedf5 Safety checks in dw_bitmapbutton_new*() on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1392
diff changeset
3669 /* 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
3670 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
3671 }
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
3672 }
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
3673
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
3674 #ifndef GDIPLUS
578
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3675 /* 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
3676 */
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3677 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
3678 {
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3679 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
3680 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
3681
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3682 *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
3683 *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
3684
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3685 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
3686 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3687 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
3688 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3689
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3690 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
3691
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3692 /* 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
3693 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
3694 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3695 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
3696 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
3697 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3698 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
3699 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
3700 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3701 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
3702 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3703 *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
3704 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
3705 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3706 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
3707 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3708 *hbitmap = (HBITMAP)LoadImage(NULL, UTF8toWide(file), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3709 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
3710 }
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3711 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
3712 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3713 *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
3714 windowtype = BS_BITMAP;
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3715 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3716 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
3717 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3718 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3719 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3720 /* 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
3721 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
3722 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
3723 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3724 *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
3725 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
3726 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3727 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3728 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3729 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
3730 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
3731 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
3732 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
3733 *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
3734 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
3735 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3736 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3737 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
3738 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
3739 return windowtype;
578
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3740 }
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
3741 #endif
578
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
3742
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3743 /* 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
3744 void _init_thread(void)
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3745 {
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3746 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
3747 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
3748 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
3749 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
3750 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
3751 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
3752
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
3753 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
3754 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
3755 GdipCreateSolidFill(gpfore, &brush);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3756 TlsSetValue(_gpBrush, brush);
1613
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
3757 #endif
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3758 TlsSetValue(_foreground, DW_UINT_TO_POINTER(foreground));
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
3759 TlsSetValue(_background, DW_UINT_TO_POINTER(background));
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3760 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
3761 TlsSetValue(_hBrush, CreateSolidBrush(foreground));
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3762 }
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3763
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3764 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3765 * Initializes the Dynamic Windows engine.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3766 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3767 * newthread: True if this is the only thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3768 * False if there is already a message loop running.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3769 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3770 int API dw_init(int newthread, int argc, char *argv[])
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3771 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3772 WNDCLASS wc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3773 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3774 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
3775 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
3776 #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
3777 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
3778 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3779
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3780 /* 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
3781 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
3782 {
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3783 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
3784
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3785 /* 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
3786 if(!pos)
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3787 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
3788
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3789 if(pos)
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3790 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
3791 }
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
3792 /* 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
3793 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
3794 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
3795
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3796 /* Initialize our thread local storage */
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3797 _foreground = TlsAlloc();
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3798 _background = TlsAlloc();
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3799 _hPen = TlsAlloc();
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3800 _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
3801 #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
3802 _gpPen = TlsAlloc();
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
3803 _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
3804 #endif
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
3805
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3806 icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3807 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
3808
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3809 InitCommonControlsEx(&icc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3810
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3811 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
3812
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3813 /* Register the generic Dynamic Windows class */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3814 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3815 wc.style = CS_DBLCLKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3816 wc.lpfnWndProc = (WNDPROC)_wndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3817 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3818 wc.cbWndExtra = 32;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3819 wc.hbrBackground = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3820 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3821 wc.lpszClassName = ClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3822
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3823 RegisterClass(&wc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3824
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3825 /* Register the splitbar control */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3826 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3827 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
3828 wc.lpfnWndProc = (WNDPROC)_splitwndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3829 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3830 wc.cbWndExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3831 wc.hbrBackground = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3832 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3833 wc.lpszClassName = SplitbarClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3834
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3835 RegisterClass(&wc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3836
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3837 /* Register the scroller control */
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3838 memset(&wc, 0, sizeof(WNDCLASS));
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3839 wc.style = CS_DBLCLKS;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3840 wc.lpfnWndProc = (WNDPROC)_scrollwndproc;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3841 wc.cbClsExtra = 0;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3842 wc.cbWndExtra = 32;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3843 wc.hbrBackground = NULL;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3844 wc.lpszMenuName = NULL;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3845 wc.lpszClassName = ScrollClassName;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3846
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3847 RegisterClass(&wc);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
3848
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3849 /* 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
3850 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3851 wc.style = CS_DBLCLKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3852 wc.lpfnWndProc = (WNDPROC)_framewndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3853 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3854 wc.cbWndExtra = 32;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3855 wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_3DFACE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3856 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3857 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3858 wc.lpszClassName = FRAMECLASSNAME;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3859
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3860 RegisterClass(&wc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3861
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
3862 /* 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
3863 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
3864 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
3865 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
3866 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
3867 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
3868 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
3869 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
3870 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
3871 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
3872
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
3873 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
3874
1856
285bf986e4fd Get HTML support building with MinGW... some warnings need to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1853
diff changeset
3875 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3876 /* Register HTML renderer class */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3877 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3878 wc.lpfnWndProc = (WNDPROC)_browserWindowProc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3879 wc.lpszClassName = BrowserClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3880 wc.style = CS_HREDRAW|CS_VREDRAW;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3881 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
3882 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3883
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3884 /* 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
3885 for(z=0;z<18;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3886 _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
3887
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3888 /* 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
3889 * 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
3890 * of Windows.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3891 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3892 memset(&wc, 0, sizeof(WNDCLASS));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3893 wc.style = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3894 wc.lpfnWndProc = (WNDPROC)_wndproc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3895 wc.cbClsExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3896 wc.cbWndExtra = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3897 wc.hbrBackground = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3898 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3899 wc.lpszMenuName = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3900 wc.lpszClassName = ObjectClassName;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3901
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3902 RegisterClass(&wc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3903
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3904 /* 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
3905 * 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
3906 * 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
3907 * 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
3908 * packed into their correct parent.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3909 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3910
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
3911 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
3912 0, 0, HWND_DESKTOP, NULL, DWInstance, NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3913
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3914 if(!DW_HWND_OBJECT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3915 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3916 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
3917 exit(1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3918 }
1332
c0f29ce1a879 Fixed too broad of an if() in dw_window_destroy on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1331
diff changeset
3919
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
3920 /* 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
3921 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
3922 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
3923
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
3924 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
3925
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
3926 /* 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
3927 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
3928
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3929 /* 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
3930 dwVersion = GetVersion();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3931 dwComctlVer = GetDllVersion(TEXT("comctl32.dll"));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3932
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3933 /* Initialize Security for named events and memory */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3934 InitializeSecurityDescriptor(&_dwsd, SECURITY_DESCRIPTOR_REVISION);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3935 SetSecurityDescriptorDacl(&_dwsd, TRUE, (PACL) NULL, FALSE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3936
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3937 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
3938
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
3939 /*
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3940 * 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
3941 */
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3942 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
3943 {
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3944 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
3945 }
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3946 else
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
3947 {
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
3948 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
3949 }
1251
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3950
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3951 #ifdef GDIPLUS
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3952 /* Setup GDI+ */
7809be48de7d Enable GDI Plus on Windows to see how well it works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1250
diff changeset
3953 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
3954 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
3955 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
3956 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
3957 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
3958 #endif
1628
2571d6b23065 _init_thread() needs to be called after initializing GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1627
diff changeset
3959
2571d6b23065 _init_thread() needs to be called after initializing GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1627
diff changeset
3960 /* 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
3961 _init_thread();
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
3962
1730
3828f3faec8c Had to move uxtheme/SetWindowTheme out of the AERO #ifdefs to get
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1729
diff changeset
3963 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
3964 _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
3965 #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
3966 /* 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
3967 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
3968 {
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
3969 _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
3970 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
3971 _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
3972 _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
3973 _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
3974 _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
3975 _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
3976 _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
3977 _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
3978 }
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3979 /* 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
3980 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
3981 {
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
3982 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
3983 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
3984 }
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
3985 #endif
1550
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
3986 #ifdef RICHEDIT
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
3987 /* 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
3988 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
3989 hrichedit = LoadLibrary("riched32");
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
3990 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
3991 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3992 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3993
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
3994 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
3995
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3996 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3997 * 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
3998 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
3999 void API dw_main(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4000 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4001 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4002
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4003 _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
4004 /* 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
4005 _dw_redraw(0, FALSE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4006
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4007 /* 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
4008 _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
4009
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4010 /* 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
4011 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
4012 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4013 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
4014 _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
4015 else
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 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4018 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4019 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4020 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4021 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4022
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4023 /*
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4024 * 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
4025 */
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4026 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
4027 {
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4028 _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
4029 }
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4030
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
4031 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4032 * 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
4033 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
4034 * 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
4035 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4036 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
4037 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4038 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4039 double start = (double)clock();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4040
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4041 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
4042 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4043 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
4044 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4045 GetMessage(&msg, NULL, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4046 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
4047 _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
4048 else
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 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4051 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4052 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4053 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4054 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4055 Sleep(1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4056 }
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4057 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4058
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4059 /*
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
4060 * 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
4061 */
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4062 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
4063 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4064 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4065
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4066 _dwtid = dw_thread_id();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4067
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4068 if(GetMessage(&msg, NULL, 0, 0))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4069 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4070 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
4071 _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
4072 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4073 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4074 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4075 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4076 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4077 }
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
4078 }
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4079
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
4080 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4081 * Free's memory allocated by dynamic windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4082 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4083 * ptr: Pointer to dynamic windows allocated
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4084 * memory to be free()'d.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4085 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4086 void API dw_free(void *ptr)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4087 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4088 free(ptr);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4089 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4090
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4091 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4092 * Allocates and initializes a dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4093 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4094 * data: User defined data to be passed to functions.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4095 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4096 DWDialog * API dw_dialog_new(void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4097 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4098 DWDialog *tmp = malloc(sizeof(DWDialog));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4099
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4100 tmp->eve = dw_event_new();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4101 dw_event_reset(tmp->eve);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4102 tmp->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4103 tmp->done = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4104 tmp->result = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4105
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4106 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4107 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4108
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4109 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4110 * Accepts a dialog struct and returns the given data to the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4111 * initial called of dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4112 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4113 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4114 * result: Data to be returned by dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4115 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4116 int API dw_dialog_dismiss(DWDialog *dialog, void *result)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4117 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4118 dialog->result = result;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4119 dw_event_post(dialog->eve);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4120 dialog->done = TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4121 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4122 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4123
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4124 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4125 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4126 * called by a signal handler with the given dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4127 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4128 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4129 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4130 void * API dw_dialog_wait(DWDialog *dialog)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4131 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4132 MSG msg;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4133 void *tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4134
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4135 while (GetMessage(&msg,NULL,0,0))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4136 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4137 if(msg.hwnd == NULL && msg.message == WM_TIMER)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4138 _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
4139 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4140 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4141 TranslateMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4142 DispatchMessage(&msg);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4143 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4144 if(dialog->done)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4145 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4146 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4147 dw_event_close(&dialog->eve);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4148 tmp = dialog->result;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4149 free(dialog);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4150 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4151 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4152
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4153 /*
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
4154 * 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
4155 * 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
4156 * 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
4157 * ...: 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
4158 */
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4159 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
4160 {
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4161 va_list args;
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
4162 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
4163
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
4164 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
4165 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
4166 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
4167
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
4168 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
4169 }
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
4170
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
4171 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4172 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4173 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4174 * title: The title of the message box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4175 * format: printf style format string.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4176 * ...: Additional variables for use in the format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4177 */
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 389
diff changeset
4178 int API dw_messagebox(char *title, int flags, char *format, ...)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4179 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4180 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
4181 char outbuf[1025] = { 0 }, *thisbuf = outbuf;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4182 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4183
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4184 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
4185 vsnprintf(outbuf, 1024, format, args);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4186 va_end(args);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4187
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
4188 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
4189 if(rc == IDOK)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4190 return DW_MB_RETURN_OK;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4191 else if(rc == IDYES)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4192 return DW_MB_RETURN_YES;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4193 else if(rc == IDNO)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4194 return DW_MB_RETURN_NO;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4195 else if(rc == IDCANCEL)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4196 return DW_MB_RETURN_CANCEL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4197 else return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4198 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4199
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4200 /*
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4201 * 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
4202 * 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
4203 * 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
4204 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4205 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
4206 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4207 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
4208 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4209
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4210 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4211 * Makes the window topmost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4212 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4213 * 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
4214 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4215 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
4216 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4217 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
4218 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4219
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4220 /*
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4221 * Makes the window bottommost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4222 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4223 * 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
4224 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4225 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
4226 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4227 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
4228 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4229
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4230 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4231 * Makes the window visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4232 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4233 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4234 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4235 int API dw_window_show(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4236 {
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
4237 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
4238 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
4239
5e4ced521696 Changed auto-size behavior on Windows... if no window size is set on a window...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
4240 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
4241
5e4ced521696 Changed auto-size behavior on Windows... if no window size is set on a window...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1472
diff changeset
4242 /* 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
4243 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
4244 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
4245
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
4246 rc = ShowWindow(handle, SW_SHOW);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4247 SetFocus(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4248 _initial_focus(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4249 return rc;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4250 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4251
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4252 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4253 * Makes the window invisible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4254 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4255 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4256 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4257 int API dw_window_hide(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4258 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4259 return ShowWindow(handle, SW_HIDE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4260 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4261
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4262 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4263 * Destroys a window and all of it's children.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4264 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4265 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4266 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4267 int API dw_window_destroy(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4268 {
1371
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4269 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
4270 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
4271
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4272 /* 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
4273 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
4274 {
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4275 char buffer[31] = {0};
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
4276 ULONG id = (ULONG)(uintptr_t)handle;
1371
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4277
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4278 _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
4279 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
4280
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4281 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
4282 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
4283 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
4284 }
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4285
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
4286 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
4287 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
4288
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
4289 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
4290 _free_menu_data(menu);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4291
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
4292 /* 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
4293 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
4294 {
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
4295 dw_box_unpack(handle);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4296 _free_window_memory(handle, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4297 EnumChildWindows(handle, _free_window_memory, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4298 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4299 return DestroyWindow(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4300 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4301
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4302 /* 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
4303 * 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
4304 * 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
4305 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4306 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
4307 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4308 Box *mybox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4309
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4310 if(mybox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4311 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4312 RECT rect;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4313 int istoplevel = (GetParent(handle) == HWND_DESKTOP);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4314
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4315 GetClientRect(handle, &rect);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4316
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4317 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
4318 _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
4319 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
4320 }
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
4321 }
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
4322
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4323 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4324 * Changes a window's parent to newparent.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4325 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4326 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4327 * newparent: The window's new parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4328 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4329 void API dw_window_reparent(HWND handle, HWND newparent)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4330 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4331 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
4332 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4333
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4334 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
4335 {
1621
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4336 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
4337 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
4338 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
4339
1621
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4340 /* 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
4341 if(myFontName)
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4342 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
4343 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
4344 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
4345
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4346 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
4347 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
4348 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
4349 lf.lfWidth = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4350 lf.lfEscapement = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4351 lf.lfOrientation = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4352 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
4353 lf.lfUnderline = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4354 lf.lfStrikeOut = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4355 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
4356 lf.lfCharSet = DEFAULT_CHARSET;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4357 lf.lfOutPrecision = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4358 lf.lfClipPrecision = 0;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4359 lf.lfQuality = DEFAULT_QUALITY;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4360 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
4361 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
4362 *Italic = 0;
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4363 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
4364 *Bold = 0;
0e8c80209c4b Rewrite of _get_logfont on Windows to use library functions and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1620
diff changeset
4365 _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
4366 free(myFontName);
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4367 return lf;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4368 }
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4369
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
4370 /* 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
4371 * 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
4372 */
3d117071a50b Renamed Mac _dw_default_font() to dw_font_set_default() and added it on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1073
diff changeset
4373 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
4374 {
3d117071a50b Renamed Mac _dw_default_font() to dw_font_set_default() and added it on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1073
diff changeset
4375 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
4376 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
4377 }
3d117071a50b Renamed Mac _dw_default_font() to dw_font_set_default() and added it on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1073
diff changeset
4378
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
4379 /* 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
4380 * 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
4381 */
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4382 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
4383 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4384 HFONT hfont = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4385
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4386 if(fontname != DefaultFont && fontname[0])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4387 {
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4388 LOGFONT lf = _get_logfont(hdc, fontname);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4389 hfont = CreateFontIndirect(&lf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4390 }
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
4391 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
4392 hfont = _DupFontHandle(_DefaultFont);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4393 if(!hfont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4394 hfont = GetStockObject(DEFAULT_GUI_FONT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4395 return hfont;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4396 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4397
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4398 /* 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
4399 * 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
4400 */
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4401 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
4402 {
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4403 HDC hdc = GetDC(handle);
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4404 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
4405 ReleaseDC(handle, hdc);
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4406 return hfont;
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4407 }
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
4408
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4409 /*
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
4410 * 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
4411 * 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
4412 * 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
4413 */
3d117071a50b Renamed Mac _dw_default_font() to dw_font_set_default() and added it on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1073
diff changeset
4414 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
4415 {
3d117071a50b Renamed Mac _dw_default_font() to dw_font_set_default() and added it on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1073
diff changeset
4416 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
4417
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
4418 _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
4419 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
4420 {
3d117071a50b Renamed Mac _dw_default_font() to dw_font_set_default() and added it on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1073
diff changeset
4421 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
4422 }
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
4423 }
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
4424
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
4425 /* 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
4426 * 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
4427 */
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4428 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
4429 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4430 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
4431 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
4432
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4433 /* If 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
4434 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
4435 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4436 if(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
4437 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4438 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
4439 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
4440
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4441 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
4442 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4443 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
4444 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
4445 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4446 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4447 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4448 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
4449 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4450
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4451 /* 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
4452 * 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
4453 *
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
4454 * 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
4455 * 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
4456 * 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
4457 * 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
4458 * 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
4459 * 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
4460 * 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
4461 */
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4462 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
4463 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4464 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
4465 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
4466 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
4467 HBITMAP hbm = 0;
1658
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4468 HICON hic = 0;
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4469 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
4470
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4471 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
4472
1660
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4473 /* 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
4474 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
4475 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
4476 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
4477 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
4478
1658
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4479 /* 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
4480 if(hic)
1658
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4481 {
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4482 if(GetIconInfo(hic, &ii))
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4483 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
4484 }
6fe1e91da477 Added DW_POINTER() macro for casting parameters to (void *)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1654
diff changeset
4485
1660
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4486 /* 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
4487 if(!hbm)
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4488 {
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4489 /* 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
4490 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
4491 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
4492 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
4493 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
4494 }
28775ce2d26c Okay second attempt at that Windows 7 icon/bitmap fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1659
diff changeset
4495
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
4496 /* 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
4497 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
4498 {
1448
508dde3dc398 Windows needs a little more extra vertical space for text buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1445
diff changeset
4499 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
4500
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4501 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
4502 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
4503 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
4504 }
1792
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4505 else
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4506 {
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4507 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
4508
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4509 /* If 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
4510 * 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
4511 */
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4512 if(buf)
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4513 {
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4514 if(*buf)
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4515 dw_font_text_extents_get(handle, NULL, 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
4516 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
4517 _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
4518 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
4519 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
4520 }
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
4521 }
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
4522
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
4523 /* Combobox */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4524 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
4525 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4526 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
4527 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
4528 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
4529 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
4530 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
4531 }
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
4532 /* 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
4533 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
4534 _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
4535 _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
4536 {
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4537 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
4538 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
4539 {
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4540 /* 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
4541 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
4542 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
4543 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4544 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
4545 {
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4546 /* 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
4547 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
4548 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
4549 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4550 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4551 /* Spinbuttons */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4552 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
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 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
4555 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
4556 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
4557 }
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4558 #ifdef TOOLBAR
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4559 /* Bitmap Buttons */
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4560 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
4561 {
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4562 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
4563 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
4564
1729
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4565 if(imlist)
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4566 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
4567
1728
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4568 /* 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
4569 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
4570 minsize = 20;
1729
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4571 else
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4572 {
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4573 thiswidth += 4;
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4574 thisheight += 4;
570a03dabdc2 Slight improvement... check the flat flags and adjust the required
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1728
diff changeset
4575 }
1728
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4576
aa2bd0d8bf27 Set the minimum button size to 24x24 instead of 20x20 when toolbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1727
diff changeset
4577 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
4578 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
4579 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
4580 thisheight = minsize;
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4581 }
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
4582 #endif
1570
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4583 /* Listbox */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4584 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
4585 {
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4586 char buf[1025] = {0};
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4587 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
4588 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
4589
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4590 thisheight = 8;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4591
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4592 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
4593 {
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4594 int height, width = 0;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4595
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4596 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
4597
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4598 if(strlen(buf))
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4599 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
4600 else
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4601 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
4602
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4603 width += basicwidth;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4604
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4605 if(width > thiswidth)
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4606 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
4607 thisheight += height;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4608 }
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4609
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4610 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
4611 thiswidth = _DW_SCROLLED_MIN_WIDTH;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4612 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
4613 thisheight = _DW_SCROLLED_MIN_HEIGHT;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4614 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
4615 thisheight = _DW_SCROLLED_MAX_HEIGHT;
d6988022c5cf Implemented listbox sizing on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1566
diff changeset
4616 }
1537
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4617 /* 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
4618 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
4619 _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
4620 {
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
4621 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
4622 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
4623 {
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4624 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
4625 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
4626 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
4627 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
4628
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4629 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
4630 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
4631 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
4632 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
4633 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
4634
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4635 dw_mle_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
4636
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4637 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
4638 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
4639 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
4640 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
4641
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
4642 /* MLE */
1581
a80ec948c3eb Fixed a MinGW warning and updated the readme.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1570
diff changeset
4643 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
4644 {
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4645 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
4646 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
4647 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
4648 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
4649 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
4650 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
4651
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4652 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
4653
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4654 if(!(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
4655 {
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4656 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
4657 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
4658 }
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4659 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
4660 {
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4661 if(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
4662 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
4663 }
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4664 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
4665 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
4666 }
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4667
1c6593b0ce45 Initial scrolled minimum and maximum code on Windows... MLE implemented, container to go.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1537
diff changeset
4668 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
4669 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
4670 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
4671 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
4672 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
4673 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
4674 }
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4675 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
4676 {
a4ecef1980db Added code for returning a size for scrolled widgets on OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1536
diff changeset
4677 /* 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
4678 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
4679 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
4680 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
4681 }
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
4682 }
1542
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4683 /* Container */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4684 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
4685 {
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4686 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
4687
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4688 thiswidth = LOWORD(result);
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4689 thisheight = HIWORD(result);
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4690
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4691 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
4692 thiswidth = _DW_SCROLLED_MAX_WIDTH;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4693 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
4694 thiswidth = _DW_SCROLLED_MIN_WIDTH;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4695 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
4696 thisheight = _DW_SCROLLED_MIN_HEIGHT;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4697 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
4698 thisheight = _DW_SCROLLED_MAX_HEIGHT;
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4699 }
edbc7405ed4d Added code to auto-size container on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1541
diff changeset
4700 /* Tree */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4701 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
4702 {
1566
035bc006afbe Experimental change... halfway between min and max for tree controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1561
diff changeset
4703 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
4704 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
4705 }
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
4706 /* Buttons */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4707 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
4708 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4709 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
4710
1422
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4711 /* 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
4712 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
4713 {
1431
0676561865ac Better extra border values for bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
4714 extrawidth = 5;
0676561865ac Better extra border values for bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1429
diff changeset
4715 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
4716 }
131bedf41332 Initial support for automatic redrawing on Windows and ranged/bitmap auto-calculation support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1415
diff changeset
4717 /* 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
4718 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
4719 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4720 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
4721 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
4722 }
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
4723 /* 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
4724 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
4725 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4726 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
4727 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
4728 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4729 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4730 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
4731 {
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
4732 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
4733 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
4734 }
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
4735
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4736 /* 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
4737 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
4738 *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
4739 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
4740 *height = thisheight + extraheight;
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4741
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4742 /* Free temporary bitmaps */
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4743 if(ii.hbmColor)
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4744 DeleteObject(ii.hbmColor);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4745 if(ii.hbmMask);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
4746 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
4747 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4748
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
4749 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4750 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4751 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4752 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4753 * fontname: Name and size of the font in the form "size.fontname"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4754 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4755 int API dw_window_set_font(HWND handle, char *fontname)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4756 {
1039
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4757 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
4758 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
4759 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
4760
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4761 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
4762
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4763 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
4764 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
4765 {
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4766 /* groupbox */
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4767 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
4768 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
4769 {
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4770 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
4771 }
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4772 }
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
4773
1039
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4774 /* 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
4775 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
4776 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
4777
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
4778 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
4779 {
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4780 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
4781 {
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4782 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
4783 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
4784 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
4785 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
4786 }
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4787 else
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4788 {
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4789 cinfo = 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
4790 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
4791
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
4792 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
4793
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4794 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
4795 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
4796 }
860d6e73f8bb Attempt at fixing dw_window_set/get_font() on Groupboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1036
diff changeset
4797 }
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
4798 /* 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
4799 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
4800 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4801 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
4802
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4803 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
4804 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
4805 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
4806
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4807 /* 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
4808 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
4809 {
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
4810 _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
4811 /* 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
4812 _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
4813 }
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
4814 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
4815 }
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
4816 return DW_ERROR_UNKNOWN;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4817 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4818
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4819 /* 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
4820 * Parameters:
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4821 * currfont: current font
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4822 * Returns:
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4823 * 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
4824 */
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4825 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
4826 {
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4827 CHOOSEFONT cf = { 0 };
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4828 LOGFONT lf = { 0 };
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4829 char *str = NULL;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4830 char *bold = "";
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4831 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
4832
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4833 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
4834 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
4835
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4836 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
4837 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
4838 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
4839
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4840 if(ChooseFont(&cf))
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4841 {
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
4842 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
4843 if ( str )
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4844 {
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4845 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
4846 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
4847
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4848 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
4849 bold = " Bold";
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4850 if ( lf.lfItalic )
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4851 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
4852 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
4853 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
4854 _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
4855 }
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4856 }
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4857 return str;
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4858 }
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4859
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4860 /*
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4861 * 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
4862 * Parameters:
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4863 * handle: The window (widget) handle.
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4864 * 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
4865 */
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4866 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
4867 {
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4868 HFONT oldfont = NULL;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4869 char *str = NULL;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4870 char *bold = "";
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4871 char *italic = "";
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4872 LOGFONT lf = { 0 };
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4873 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
4874 TCHAR tmpbuf[100] = {0};
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4875
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4876 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 )
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4878 {
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4879 /* groupbox */
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4880 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
4881 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
4882 {
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4883 handle = thisbox->grouphwnd;
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4884 }
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4885 }
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
4886 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
4887 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
4888 {
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
4889 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
4890 if ( str )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4891 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4892 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
4893 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
4894
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4895 if ( lf.lfWeight > FW_MEDIUM )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4896 bold = " Bold";
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4897 if ( lf.lfItalic )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4898 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
4899 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
4900 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
4901 _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
4902 }
1051
6919854298fd Added dw_font_choose() on Windows for 2.1.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1042
diff changeset
4903 }
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4904 if ( oldfont )
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4905 DeleteObject( oldfont );
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4906 return str;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4907 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4908
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4909 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4910 * Sets the colors used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4911 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4912 * 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
4913 * 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
4914 * back: Background color in RGB format.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4915 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4916 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4917 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4918 ColorInfo *cinfo;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4919 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
4920 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4921
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4922 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4923
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4924 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4925
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4926 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
4927 {
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
4928 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
4929 cinfo->back = back = _internal_color(back);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4930
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4931 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
4932 DW_GREEN_VALUE(fore),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4933 DW_BLUE_VALUE(fore)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4934 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
4935 DW_GREEN_VALUE(back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4936 DW_BLUE_VALUE(back)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4937 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
4938 DW_GREEN_VALUE(back),
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4939 DW_BLUE_VALUE(back)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4940 InvalidateRgn(handle, NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4941 return TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4942 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
4943 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
4944 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4945 /* groupbox */
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4946 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
4947 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
4948 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4949 thisbox->cinfo.fore = fore;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4950 thisbox->cinfo.back = back;
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4951 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
4952 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4953
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4954 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4955 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4956 cinfo->fore = fore;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4957 cinfo->back = back;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4958 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4959 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4960 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4961 cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4962
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4963 cinfo->fore = fore;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4964 cinfo->back = back;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4965
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4966 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4967 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4968 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4969 InvalidateRgn(handle, NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4970 return TRUE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4971 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4972
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4973 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4974 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4975 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4976 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4977 * border: Size of the window border in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4978 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4979 int API dw_window_set_border(HWND handle, int border)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4980 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4981 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4982 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4983
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4984 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4985 * Captures the mouse input to this window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4986 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4987 * handle: Handle to receive mouse input.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4988 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4989 void API dw_window_capture(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4990 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4991 SetCapture(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4992 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4993
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4994 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4995 * Releases previous mouse capture.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4996 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
4997 void API dw_window_release(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4998 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
4999 ReleaseCapture();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5000 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5001
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5002 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5003 * 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
5004 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5005 * 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
5006 * 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
5007 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
5008 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
5009 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5010 HCURSOR cursor = pointertype < 65536 ? LoadCursor(NULL, MAKEINTRESOURCE(pointertype)) : (HCURSOR)(intptr_t)pointertype;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5011
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5012 if(!pointertype)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5013 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
5014 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5015 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5016 dw_window_set_data(handle, "_dw_cursor", DW_POINTER(cursor));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5017 SetCursor(cursor);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5018 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5019 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5020
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5021 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5022 * Create a new Window Frame.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5023 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5024 * owner: The Owner's window handle or HWND_DESKTOP.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5025 * 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
5026 * flStyle: Style flags, see the DW reference.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5027 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5028 HWND API dw_window_new(HWND hwndOwner, char *title, ULONG flStyle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5029 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5030 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5031 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
5032 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
5033 #ifdef AEROGLASS
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5034 MARGINS mar = {-1};
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
5035
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
5036 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
5037 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
5038 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5039
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5040 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
5041 newbox->vsize = newbox->hsize = SIZEEXPAND;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5042 newbox->cinfo.fore = newbox->cinfo.back = -1;
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 if(!(flStyle & WS_CAPTION))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5045 flStyle |= WS_POPUPWINDOW;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5046
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
5047 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
5048 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
5049 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5050 hwndframe = CreateWindowEx(flStyleEx, ClassName, UTF8toWide(title), (flStyle | WS_CLIPCHILDREN) & 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
5051 0, 0, hwndOwner, NULL, DWInstance, NULL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5052 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5053 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5054 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5055 flStyleEx |= WS_EX_TOOLWINDOW;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5056
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5057 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
5058 0, 0, hwndOwner, NULL, DWInstance, NULL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5059 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5060 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5061
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5062 if(hwndOwner)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5063 SetParent(hwndframe, hwndOwner);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5064
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5065 #ifdef AEROGLASS
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5066 /* 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
5067 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
5068 {
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
5069 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
5070 _DwmExtendFrameIntoClientArea(hwndframe, &mar);
1516
03c0eca3aaba Glass window improvement on Windows... mostly usable...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1515
diff changeset
5071 }
1512
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5072 #endif
50d972da558e Added experimental Aero translucent backgrounds on Windows 7 and Vista.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1508
diff changeset
5073
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5074 return hwndframe;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5075 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5076
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5077 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5078 * Create a new Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5079 * 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
5080 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5081 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5082 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5083 HWND API dw_box_new(int type, int pad)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5084 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5085 Box *newbox = calloc(sizeof(Box), 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5086 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5087
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5088 newbox->pad = pad;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5089 newbox->type = type;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5090 newbox->count = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5091 newbox->grouphwnd = (HWND)NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5092 newbox->cinfo.fore = newbox->cinfo.back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5093
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5094 hwndframe = CreateWindow(FRAMECLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5095 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5096 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
5097 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5098 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5099 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5100 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5101 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5102
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5103 newbox->cinfo.pOldProc = SubclassWindow(hwndframe, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5104 newbox->cinfo.fore = newbox->cinfo.back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5105
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5106 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)newbox);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5107 return hwndframe;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5108 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5109
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5110 /*
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5111 * 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
5112 * Parameters:
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5113 * 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
5114 * 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
5115 */
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5116 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
5117 {
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5118 ColorInfo *cinfo = calloc(sizeof(ColorInfo), 1);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5119 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
5120 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
5121 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
5122
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5123 cinfo->fore = cinfo->back = -1;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5124
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5125 hwndframe = CreateWindow(ScrollClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5126 NULL,
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5127 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
5128 0,0,0,0,
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5129 DW_HWND_OBJECT,
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5130 NULL,
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5131 DWInstance,
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5132 NULL);
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5133
839
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5134 cinfo->buddy = box;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5135 cinfo->combo = tmpbox;
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5136 SetParent(tmpbox, hwndframe);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5137 SetWindowLongPtr(hwndframe, GWLP_USERDATA, (LONG_PTR)cinfo);
ccfa5173659f Initial implementation of scrollboxes on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 833
diff changeset
5138 return hwndframe;
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5139 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5140
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5141 /*
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5142 * 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
5143 * Parameters:
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5144 * 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
5145 * 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
5146 */
833
53b677d126dc Scrollbox cleanups on Windows and added stubs on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 832
diff changeset
5147 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
5148 {
842
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5149 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
5150 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
5151
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5152 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
5153 {
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5154 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
5155 }
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5156
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5157 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
5158 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
5159
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5160 /* 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
5161 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
5162 {
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5163 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
5164 }
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5165 return si.nPos;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5166 }
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5167
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5168 /*
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5169 * 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
5170 * Parameters:
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5171 * 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
5172 * 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
5173 */
833
53b677d126dc Scrollbox cleanups on Windows and added stubs on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 832
diff changeset
5174 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
5175 {
842
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5176 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
5177 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
5178
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5179 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
5180 {
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5181 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
5182 }
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5183
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5184 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
5185 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
5186
843
d51e958aad95 Updates to the comments about scrollboxes and removing them from incomplete status.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 842
diff changeset
5187 /* 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
5188 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
5189 {
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5190 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
5191 }
89dd3e442e7e Implemented dw_scrollbox_get_pos() and dw_scrollbox_get_range() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 841
diff changeset
5192 return si.nMax;
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
5193 }
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5194 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5195 * Create a new Group Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5196 * 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
5197 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5198 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5199 * title: Text to be displayined in the group outline.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5200 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5201 HWND API dw_groupbox_new(int type, int pad, char *title)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5202 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5203 Box *newbox = calloc(sizeof(Box), 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5204 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5205
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5206 newbox->pad = pad;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5207 newbox->type = type;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5208 newbox->count = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5209 newbox->cinfo.fore = newbox->cinfo.back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5210
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5211 hwndframe = CreateWindow(FRAMECLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5212 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5213 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
5214 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5215 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5216 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5217 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5218 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5219
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5220 newbox->grouphwnd = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5221 UTF8toWide(title),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5222 WS_CHILD | BS_GROUPBOX |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5223 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
5224 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5225 hwndframe,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5226 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5227 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5228 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5229
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5230 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
5231 dw_window_set_font(hwndframe, DefaultFont);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5232 return hwndframe;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5233 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5234
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5235 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5236 * 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
5237 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5238 * 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
5239 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5240 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
5241 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5242 CLIENTCREATESTRUCT ccs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5243 HWND hwndframe;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5244
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5245 ccs.hWindowMenu = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5246 ccs.idFirstChild = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5247
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5248 hwndframe = CreateWindow(TEXT("MDICLIENT"),
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5249 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5250 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
5251 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5252 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5253 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5254 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5255 &ccs);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5256 return hwndframe;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5257 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5258
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5259 /*
584
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5260 * 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
5261 * Parameters:
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5262 * 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
5263 */
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5264 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
5265 {
1856
285bf986e4fd Get HTML support building with MinGW... some warnings need to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1853
diff changeset
5266 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5267 return CreateWindow(BrowserClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5268 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5269 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
5270 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5271 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5272 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5273 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5274 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
5275 #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
5276 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
5277 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
5278 #endif
584
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5279 }
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5280
1856
285bf986e4fd Get HTML support building with MinGW... some warnings need to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1853
diff changeset
5281 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5282 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
5283 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
5284 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
5285 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5286
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5287 /*
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5288 * 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
5289 * Parameters:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5290 * 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
5291 * 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
5292 */
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5293 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
5294 {
1856
285bf986e4fd Get HTML support building with MinGW... some warnings need to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1853
diff changeset
5295 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5296 _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
5297 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5298 }
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5299
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5300 /*
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5301 * 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
5302 * Parameters:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5303 * 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
5304 * 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
5305 * be rendered.
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5306 * Returns:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5307 * 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
5308 */
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5309 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
5310 {
1856
285bf986e4fd Get HTML support building with MinGW... some warnings need to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1853
diff changeset
5311 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5312 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
5313 #else
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5314 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
5315 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5316 }
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5317
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5318 /*
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5319 * 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
5320 * Parameters:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5321 * 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
5322 * 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
5323 * 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
5324 * Returns:
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5325 * 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
5326 */
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5327 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
5328 {
1856
285bf986e4fd Get HTML support building with MinGW... some warnings need to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1853
diff changeset
5329 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5330 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
5331 #else
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5332 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
5333 #endif
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5334 }
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
5335
584
420c6c94abc7 Added dw_html_* functionality for embedding HTML pages in Dynamic Windows
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 583
diff changeset
5336 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5337 * Create a bitmap object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5338 * 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
5339 * id: An ID to be used with dw_window_from_id or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5340 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5341 HWND API dw_bitmap_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5342 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5343 return CreateWindow(STATICCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5344 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
5345 SS_BITMAP | SS_CENTERIMAGE | WS_VISIBLE |
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5346 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
5347 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5348 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5349 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5350 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5351 NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5352 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5353
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5354 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5355 * Create a notebook object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5356 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5357 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5358 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5359 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5360 HWND API dw_notebook_new(ULONG id, int top)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5361 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5362 ULONG flags = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5363 HWND tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5364 NotebookPage **array = calloc(256, sizeof(NotebookPage *));
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
5365 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5366
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5367 if(!top)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5368 flags = TCS_BOTTOM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5369
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5370 tmp = CreateWindow(WC_TABCONTROL,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5371 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5372 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
5373 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5374 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5375 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5376 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5377 NULL);
1811
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
5378 cinfo->fore = cinfo->back = -1;
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
5379 cinfo->pOldProc = SubclassWindow(tmp, _simplewndproc);
e7ed7bbea3a4 Rewrite of the focus shifting code on Windows, eliminate duplicated code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1810
diff changeset
5380 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
5381 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
5382 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5383 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5384 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5385
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5386 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5387 * Create a menu object to be popped up.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5388 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5389 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5390 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5391 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5392 HMENUI API dw_menu_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5393 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5394 return (HMENUI)CreatePopupMenu();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5395 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5396
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5397 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5398 * Create a menubar on a window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5399 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5400 * location: Handle of a window frame to be attached to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5401 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5402 HMENUI API dw_menubar_new(HWND location)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5403 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5404 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
5405 MENUINFO mi;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5406
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5407 tmp = (HMENUI)CreateMenu();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5408
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
5409 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
5410 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
5411 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
5412
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
5413 SetMenuInfo( (HMENU)tmp, &mi );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5414
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5415 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
5416
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5417 SetMenu(location, (HMENU)tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5418 return location;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5419 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5420
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5421 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5422 * Destroys a menu created with dw_menubar_new or dw_menu_new.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5423 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5424 * menu: Handle of a menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5425 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5426 void API dw_menu_destroy(HMENUI *menu)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5427 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5428 if(menu)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5429 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5430 HMENU mymenu = (HMENU)*menu;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5431
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5432 if(IsWindow((HWND)mymenu) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5433 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
5434 if(IsMenu(mymenu))
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5435 DestroyMenu(mymenu);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5436 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5437 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5438
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
5439 /* 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
5440 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
5441 {
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
5442 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
5443
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5444 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
5445 {
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5446 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
5447 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
5448 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
5449 }
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
5450 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
5451 }
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
5452
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5453 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5454 * Adds a menuitem or submenu to an existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5455 * Parameters:
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5456 * menu: The handle to the existing menu.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5457 * title: The title text on the menu item to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5458 * id: An ID to be used for message passing.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5459 * end: If TRUE memu is positioned at the end of the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5460 * 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
5461 * flags: Extended attributes to set on the menu.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5462 * submenu: Handle to an existing menu to be a submenu or NULL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5463 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5464 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
5465 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5466 MENUITEMINFO mii;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5467 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
5468 char buffer[31] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5469 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
5470 char *menutitle = title;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5471
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5472 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5473 * 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
5474 * for the menubar
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5475 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5476 if (IsWindow(menux) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5477 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
5478
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5479 memset( &mii, 0, sizeof(mii) );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5480 mii.cbSize = sizeof(MENUITEMINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5481 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
5482
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5483 /* 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
5484 if (title)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5485 {
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
5486 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
5487
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
5488 strcpy(tmp, title);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5489
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5490 while(*tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5491 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5492 if(*tmp == '~')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5493 *tmp = '&';
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5494 tmp++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5495 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5496 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5497
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
5498 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
5499 {
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5500 /* 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
5501 * 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
5502 */
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5503 if(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
5504 {
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5505 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
5506
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5507 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
5508 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
5509
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5510 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
5511 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
5512 }
18a31ab94e3d Added DW_MENU_AUTO and DW_MENU_POPUP flags that can be passed to dw_menu_append_item() in the id field.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1303
diff changeset
5513 /* 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
5514 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
5515 {
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
5516 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
5517
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5518 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
5519 {
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
5520 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
5521 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
5522 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
5523 }
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
5524 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
5525 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
5526 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5527 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
5528 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5529 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5530 mii.fType = MFT_SEPARATOR;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5531
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5532 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5533 * Handle flags
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5534 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5535 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
5536 if ( is_checked )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5537 mii.fState |= MFS_CHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5538 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5539 mii.fState |= MFS_UNCHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5540 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
5541 if ( is_disabled )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5542 mii.fState |= MFS_DISABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5543 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5544 mii.fState |= MFS_ENABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5545
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5546 mii.wID = id;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5547 if (IsMenu((HMENU)submenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5548 mii.hSubMenu = (HMENU)submenu;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5549 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5550 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
5551 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
5552 mii.cch = (UINT)_tcslen(mii.dwTypeData);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5553
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5554 InsertMenuItem(mymenu, 65535, TRUE, &mii);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5555
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
5556 _snprintf(buffer, 30, "_dw_id%ld", id);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5557 dw_window_set_data( DW_HWND_OBJECT, buffer, DW_POINTER(mymenu) );
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
5558 _snprintf(buffer, 30, "_dw_checkable%ld", id);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5559 dw_window_set_data( DW_HWND_OBJECT, buffer, DW_INT_TO_POINTER(check) );
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
5560 _snprintf(buffer, 30, "_dw_ischecked%ld", id);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5561 dw_window_set_data( DW_HWND_OBJECT, buffer, DW_INT_TO_POINTER(is_checked) );
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
5562 _snprintf(buffer, 30, "_dw_isdisabled%ld", id);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5563 dw_window_set_data( DW_HWND_OBJECT, buffer, DW_INT_TO_POINTER(is_disabled) );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5564
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
5565 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
5566 {
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5567 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
5568
0c39705ddd4a Removed a bunch of code that had been used to support Win95/NT/98/ME which are now unsupported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 907
diff changeset
5569 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
5570 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
5571 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
5572
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
5573 SetMenuInfo( (HMENU)submenu, &mi );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5574 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5575
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5576 if (IsWindow(menux) && !IsMenu((HMENU)menux))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5577 DrawMenuBar(menux);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5578 return (HWND)(uintptr_t)id;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5579 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5580
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5581 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5582 * 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
5583 * Deprecated: use dw_menu_item_set_state()
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5584 * Parameters:
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5585 * menu: The handle to the existing menu.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5586 * id: Menuitem id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5587 * check: TRUE for checked FALSE for not checked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5588 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5589 void API dw_menu_item_set_check(HMENUI menux, unsigned long id, int check)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5590 {
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5591 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
5592 HMENU mymenu = (HMENU)menux;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5593 char buffer[30];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5594
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5595 if (IsWindow(menux) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5596 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
5597
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 * 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
5600 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5601 memset( &mii, 0, sizeof(mii) );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5602 GetMenuItemInfo( mymenu, id, FALSE, &mii);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5603
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5604 mii.cbSize = sizeof(MENUITEMINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5605 mii.fMask = MIIM_STATE | MIIM_CHECKMARKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5606 if (check)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5607 mii.fState |= MFS_CHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5608 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5609 mii.fState |= MFS_UNCHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5610 SetMenuItemInfo( mymenu, id, FALSE, &mii );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5611 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5612 * Keep our internal state consistent
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5613 */
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
5614 _snprintf( buffer, 30, "_dw_ischecked%ld", id );
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5615 dw_window_set_data( DW_HWND_OBJECT, buffer, DW_INT_TO_POINTER(check) );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5616 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5618 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5619 * Sets the state of a menu item.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5620 * Parameters:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5621 * menu: The handle to the existing menu.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5622 * id: Menuitem id.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5623 * flags: DW_MIS_ENABLED/DW_MIS_DISABLED
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5624 * DW_MIS_CHECKED/DW_MIS_UNCHECKED
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5625 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5626 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
5627 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5628 MENUITEMINFO mii;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5629 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
5630 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
5631 int check;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5632 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
5633
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5634 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
5635 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
5636
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
5637 _snprintf( buffer1, 30, "_dw_ischecked%ld", id );
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5638 check = DW_POINTER_TO_INT(dw_window_get_data( DW_HWND_OBJECT, buffer1 ));
1306
dbd507f42947 Added dw_debug() logging function which will output a message to the debugging console.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1305
diff changeset
5639 _snprintf( buffer2, 30, "_dw_isdisabled%ld", id );
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5640 disabled = DW_POINTER_TO_INT(dw_window_get_data( DW_HWND_OBJECT, buffer2 ));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5641
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5642 memset( &mii, 0, sizeof(mii) );
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5643
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5644 mii.cbSize = sizeof(MENUITEMINFO);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5645 mii.fMask = MIIM_STATE | MIIM_CHECKMARKS;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5646 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
5647 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5648 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5649 * 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
5650 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5651 if ( state & DW_MIS_CHECKED )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5652 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5653 mii.fState |= MFS_CHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5654 check = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5655 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5656 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5657 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5658 mii.fState |= MFS_UNCHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5659 check = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5660 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5661 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5662 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5663 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5664 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5665 * ...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
5666 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5667 if ( check )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5668 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5669 mii.fState |= MFS_CHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5670 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5671 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5672 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5673 mii.fState |= MFS_UNCHECKED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5674 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5675 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5676 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
5677 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5678 if ( state & DW_MIS_DISABLED )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5679 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5680 mii.fState |= MFS_DISABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5681 disabled = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5682 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5683 else
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 mii.fState |= MFS_ENABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5686 disabled = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5687 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5688 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5689 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5690 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5691 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5692 * ...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
5693 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5694 if ( disabled )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5695 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5696 mii.fState |= MFS_DISABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5697 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5698 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5699 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5700 mii.fState |= MFS_ENABLED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5701 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5702 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
5703 SetMenuItemInfo( mymenu, id, FALSE, &mii );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5704 /*
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5705 * Keep our internal checked state consistent
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5706 */
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5707 dw_window_set_data( DW_HWND_OBJECT, buffer1, DW_INT_TO_POINTER(check) );
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5708 dw_window_set_data( DW_HWND_OBJECT, buffer2, DW_INT_TO_POINTER(disabled) );
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5709 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5710
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5711 /*
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5712 * Deletes the menu item specified
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5713 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5714 * 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
5715 * 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
5716 * Returns:
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
5717 * 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
5718 */
896347a9be19 Initial versions of dw_menu_delete_item() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1370
diff changeset
5719 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
5720 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5721 HMENU mymenu = (HMENU)menux;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5722
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
5723 if ( IsWindow(menux) && !IsMenu(mymenu) )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5724 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
5725
1377
b6249d66404c Cleanup signal handlers when calling dw_menu_delete_item() on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1371
diff changeset
5726 if ( 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
5727 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
5728
1377
b6249d66404c Cleanup signal handlers when calling dw_menu_delete_item() on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1371
diff changeset
5729 /* 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
5730 if(id >= 30000)
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5731 dw_signal_disconnect_by_window((HWND)(uintptr_t)id);
1377
b6249d66404c Cleanup signal handlers when calling dw_menu_delete_item() on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1371
diff changeset
5732
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
5733 /* 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
5734 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
5735 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
5736 return DW_ERROR_NONE;
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5737 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
5738
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5739 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5740 * Pops up a context menu at given x and y coordinates.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5741 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5742 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5743 * parent: Handle to the window initiating the popup.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5744 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5745 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5746 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5747 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5748 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5749 if(menu)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5750 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5751 HMENU mymenu = (HMENU)*menu;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5752
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5753 if(IsWindow(*menu) && !IsMenu(mymenu))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5754 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
5755
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5756 popup = parent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5757 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
5758 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
5759 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5760 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5761
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5762
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5763 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5764 * Create a container object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5765 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5766 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5767 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5768 */
350
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
5769 HWND API dw_container_new(ULONG id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5770 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5771 HWND tmp = CreateWindow(WC_LISTVIEW,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5772 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5773 WS_VISIBLE | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5774 (multi ? 0 : LVS_SINGLESEL) |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5775 LVS_REPORT | LVS_SHOWSELALWAYS |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5776 LVS_SHAREIMAGELISTS | WS_BORDER |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5777 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
5778 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5779 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5780 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5781 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5782 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5783 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
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(!cinfo)
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 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5788 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5789 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5790
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
5791 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _containerwndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5792 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
5793 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
5794
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5795 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5796 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
5797 /* 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
5798 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
5799 {
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
5800 /* 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
5801 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
5802 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5803 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5804 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5805
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5806 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5807 * 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
5808 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5809 * 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
5810 * 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
5811 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5812 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
5813 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5814 HWND tmp = CreateWindow(WC_TREEVIEW,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5815 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5816 WS_VISIBLE | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5817 TVS_HASLINES | TVS_SHOWSELALWAYS |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5818 TVS_HASBUTTONS | TVS_LINESATROOT |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5819 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
5820 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5821 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5822 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5823 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5824 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5825 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5826 TreeView_SetItemHeight(tmp, 16);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5827
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5828 if(!cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5829 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5830 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5831 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5832 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5833
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
5834 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _simplewndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5835 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
5836 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
5837
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5838 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5839 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5840 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
5841 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5842
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5843 /*
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5844 * 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
5845 * 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
5846 * 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
5847 * 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
5848 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5849 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
5850 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5851 POINT ptl;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5852
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5853 GetCursorPos(&ptl);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5854 if(x && y)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5855 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5856 *x = ptl.x;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5857 *y = ptl.y;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5858 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5859 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5860
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5861 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5862 * 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
5863 * 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
5864 * 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
5865 * 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
5866 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5867 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
5868 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5869 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
5870 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5871
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5872 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5873 * Create a new static text window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5874 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5875 * 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
5876 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5877 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5878 HWND API dw_text_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5879 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5880 HWND tmp = CreateWindow(STATICCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5881 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
5882 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
5883 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
5884 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5885 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5886 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5887 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5888 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
5889 #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
5890 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
5891
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
5892 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
5893
a71ec02f3b70 Attempt on Windows using DrawThemeTextEx to nicely display text widgets on glass backgrounds.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1535
diff changeset
5894 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
5895 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
5896 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5897 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
5898 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
5899 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5900 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5901
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5902 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5903 * 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
5904 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5905 * 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
5906 * 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
5907 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5908 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
5909 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5910 HWND tmp = CreateWindow(StatusbarClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5911 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
5912 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
5913 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5914 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5915 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5916 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5917 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5918 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5919 return tmp;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5920 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5921
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
5922 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5923 * Create a new Multiline Editbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5924 * 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
5925 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5926 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5927 HWND API dw_mle_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5928 {
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
5929
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5930 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
5931 hrichedit ? RICHEDIT_CLASS : EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5932 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5933 WS_VISIBLE | WS_BORDER |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5934 WS_VSCROLL | ES_MULTILINE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5935 ES_WANTRETURN | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5936 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
5937 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5938 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5939 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5940 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5941 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5942 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5943
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5944 if(!cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5945 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5946 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5947 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5948 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5949
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
5950 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _simplewndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5951 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
5952 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
5953
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5954 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5955 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5956 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5957 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5958
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5959 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5960 * Create a new Entryfield window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5961 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5962 * 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
5963 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5964 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5965 HWND API dw_entryfield_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5966 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5967 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
5968 EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5969 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5970 ES_WANTRETURN | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5971 WS_BORDER | ES_AUTOHSCROLL |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5972 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
5973 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5974 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
5975 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5976 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5977 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5978 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5979
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5980 cinfo->back = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5981
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5982 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5983 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5984 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5985 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5986 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5987
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5988 /*
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5989 * Create a new Entryfield passwird window (widget) to be packed.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5990 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5991 * 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
5992 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5993 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
5994 HWND API dw_entryfield_password_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5995 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
5996 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
5997 EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
5998 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
5999 ES_WANTRETURN | WS_CHILD |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6000 ES_PASSWORD | WS_BORDER | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6001 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
6002 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6003 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6004 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6005 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6006 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6007 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6008
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6009 cinfo->back = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6010
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6011 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6012 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6013 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6014 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6015 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6016
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6017 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
6018 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6019 ColorInfo *cinfo = (ColorInfo *)lp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6020
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6021 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6022 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6023 cinfo->buddy = handle;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6024 cinfo->pOldProc = SubclassWindow(handle, _colorwndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6025 SetWindowLongPtr(handle, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6026 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6027 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
6028 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6029
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6030 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6031 * Create a new Combobox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6032 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6033 * 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
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_combobox_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6037 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6038 HWND tmp = CreateWindow(COMBOBOXCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6039 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6040 WS_CHILD | CBS_DROPDOWN | WS_VSCROLL |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6041 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
6042 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6043 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6044 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6045 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6046 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6047 ColorInfo *cinfo = (ColorInfo *)calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6048 ColorInfo *cinfo2 = (ColorInfo *)calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6049
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6050 if(!cinfo || !cinfo2)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6051 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6052 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6053 free(cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6054 if(cinfo2)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6055 free(cinfo2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6056 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6057 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6058 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6059
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6060 cinfo2->fore = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6061 cinfo2->back = cinfo->back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6062 cinfo2->combo = cinfo->combo = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6063 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
6064 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
6065
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6066 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6067 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
6068 SetWindowText(tmp, UTF8toWide(text));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6069 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6070 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6071
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6072 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6073 * Create a new button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6074 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6075 * 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
6076 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6077 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6078 HWND API dw_button_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6079 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6080 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
6081
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6082 HWND tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6083 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
6084 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
6085 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
6086 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
6087 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6088 (HMENU)(uintptr_t)id,
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6089 DWInstance,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6090 NULL);
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6091 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6092 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
6093
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6094 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
6095 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
6096 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6097 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6098
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6099 #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
6100 /* 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
6101 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
6102 {
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6103 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
6104 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
6105 {
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6106 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
6107 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
6108
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6109 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
6110 {
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6111 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
6112 {
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6113 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
6114 /* 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
6115 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
6116
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6117 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
6118 }
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6119 }
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6120 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
6121 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
6122 }
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
6123 }
2e0f87ec24fe Create a separate disabled image list with washed out and grayscale bitmaps on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1724
diff changeset
6124
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6125 /* 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
6126 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
6127 {
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6128 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
6129 HIMAGELIST imlist, dimlist;
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6130 BITMAP bmi = { 0 };
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6131 TBBUTTON tbButtons[] = {
1857
417176df4755 Add TOOLBAR define with MinGW by default... fix warnings...generated
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1856
diff changeset
6132 { MAKELONG(0, 0), id, TBSTATE_ENABLED, TBSTYLE_BUTTON}
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6133 };
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6134
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6135 /* 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
6136 if(hbitmap)
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6137 {
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6138 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
6139 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
6140 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
6141 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
6142 _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
6143 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
6144 DeleteObject(hbitmap);
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6145 }
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6146 else if(icon)
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6147 {
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6148 ICONINFO iconinfo;
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6149
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6150 GetIconInfo(icon, &iconinfo);
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6151 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
6152 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
6153 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
6154 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
6155 _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
6156 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
6157 DeleteObject(iconinfo.hbmColor);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6158 DeleteObject(iconinfo.hbmMask);
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6159 DestroyIcon(icon);
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6160 }
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6161 else
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6162 return 0;
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6163
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6164 /* Create the toolbar */
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6165 tmp = CreateWindowEx(0L, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | TBSTYLE_AUTOSIZE | CCS_NORESIZE |
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6166 CCS_NOPARENTALIGN | CCS_NODIVIDER, 0, 0, 100, 30, DW_HWND_OBJECT, (HMENU)(uintptr_t)id, DWInstance, NULL);
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6167
1727
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6168 /* 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
6169 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
6170 _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
6171
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6172 /* 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
6173 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
6174 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
6175 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
6176 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
6177 SendMessage(tmp, TB_SETDISABLEDIMAGELIST, 0, (LPARAM)dimlist);
1838
ca304f28de3b Fix 64bit crashes on Windows when building with Visual Studio 2012.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1826
diff changeset
6178 SendMessage(tmp, TB_ADDBUTTONS, 1, (LPARAM) &tbButtons);
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6179
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6180 _create_tooltip(tmp, text);
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6181 return tmp;
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6182 }
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
6183 #endif
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6184
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6185 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6186 * Create a new bitmap button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6187 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6188 * text: Bubble help text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6189 * id: An ID of a bitmap in the resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6190 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6191 HWND API dw_bitmapbutton_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6192 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6193 HWND tmp;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6194 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
6195 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
6196 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
6197 #ifdef TOOLBAR
1857
417176df4755 Add TOOLBAR define with MinGW by default... fix warnings...generated
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1856
diff changeset
6198 if((tmp = _create_toolbar(text, id, icon, hbitmap)))
1727
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6199 {
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6200 cinfo->fore = cinfo->back = -1;
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
6201 cinfo->pOldProc = SubclassWindow(tmp, _simplewndproc);
1727
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6202 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
6203 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
6204 }
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
6205 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6206
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6207 tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6208 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6209 WS_CHILD | BS_PUSHBUTTON |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6210 WS_VISIBLE | WS_CLIPCHILDREN |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6211 (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
6212 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6213 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6214 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6215 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6216 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6217
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6218 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6219 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
6220
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6221 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
6222
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
6223 _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
6224
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6225 if(icon)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6226 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6227 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
6228 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6229 else if(hbitmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6230 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6231 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
6232 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6233 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6234 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6235
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6236 /*
281
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6237 * 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
6238 * Parameters:
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6239 * 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
6240 * 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
6241 * 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
6242 * DW pick the appropriate file extension.
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6243 * (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
6244 */
507
c607eb385e58 Added missing calling conventions. Thanks Bastian for pointing this out.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 506
diff changeset
6245 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
6246 {
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6247 HWND tmp;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6248 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6249 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
6250 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
6251 int windowtype = 0;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6252
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6253 if (!cinfo)
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6254 return 0;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6255
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
6256 #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
6257 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
6258 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
6259 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
6260 {
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
6261 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
6262 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
6263 }
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
6264 #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
6265 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
6266 #endif
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6267
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6268 #ifdef TOOLBAR
1857
417176df4755 Add TOOLBAR define with MinGW by default... fix warnings...generated
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1856
diff changeset
6269 if((tmp = _create_toolbar(text, id, hicon, hbitmap)))
1727
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6270 {
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6271 cinfo->fore = cinfo->back = -1;
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
6272 cinfo->pOldProc = SubclassWindow(tmp, _simplewndproc);
1727
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6273 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
6274 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
6275 }
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
6276 #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
6277 tmp = CreateWindow( BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6278 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
6279 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
6280 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
6281 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6282 (HMENU)(uintptr_t)id,
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6283 DWInstance,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6284 NULL);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6285
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6286 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6287 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
6288
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6289 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6290
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
6291 _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
6292
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
6293 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
6294 {
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
6295 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
6296 }
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
6297 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
6298 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6299 SendMessage(tmp, BM_SETIMAGE,(WPARAM) IMAGE_BITMAP, (LPARAM) hbitmap);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6300 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6301 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
6302 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6303
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6304 /*
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6305 * 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
6306 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6307 * 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
6308 * 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
6309 * 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
6310 * (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
6311 * 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
6312 */
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6313 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
6314 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6315 HWND tmp;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6316 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
6317 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
6318 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
6319 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
6320 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
6321 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
6322
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6323 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
6324 return 0;
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6325
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
6326 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
6327 if ( file != NULL )
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6328 {
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6329 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
6330 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
6331 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6332 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
6333 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
6334 #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
6335 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
6336 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
6337 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
6338 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
6339 #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
6340 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
6341 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
6342 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
6343 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
6344 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
6345 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
6346 }
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
6347 #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
6348 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6349 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6350 {
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
6351 _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
6352 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
6353 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
6354 }
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
6355 _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
6356 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
6357 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6358
1722
d9849833e535 Toolbar based bitmap buttons are now functional on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1721
diff changeset
6359 #ifdef TOOLBAR
1857
417176df4755 Add TOOLBAR define with MinGW by default... fix warnings...generated
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1856
diff changeset
6360 if((tmp = _create_toolbar(text, id, hicon, hbitmap)))
1727
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6361 {
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6362 cinfo->fore = cinfo->back = -1;
1810
c110191e3775 Added tab handling to the toolbar control on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1804
diff changeset
6363 cinfo->pOldProc = SubclassWindow(tmp, _simplewndproc);
1727
38a0e75bc59c Since toolbars need to have a bitmap to add a button, if toolbar based buttons
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1726
diff changeset
6364 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
6365 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
6366 }
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
6367 #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
6368 tmp = CreateWindow( BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6369 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
6370 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
6371 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
6372 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
6373 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
6374 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6375 (HMENU)(uintptr_t)id,
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6376 DWInstance,
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6377 NULL );
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6378
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6379 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6380 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
6381
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6382 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
6383
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
6384 _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
6385
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
6386 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
6387 {
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
6388 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
6389 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6390 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
6391 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6392 SendMessage( tmp, BM_SETIMAGE, (WPARAM) IMAGE_BITMAP, (LPARAM) hbitmap);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6393 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
6394 return tmp;
281
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6395 }
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6396
2f038ef90a36 Implemented dw_bitmapbutton_new_from_file() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
6397 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6398 * Create a new spinbutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6399 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6400 * 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
6401 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6402 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6403 HWND API dw_spinbutton_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6404 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6405 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
6406 EDITCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6407 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6408 WS_CHILD | WS_BORDER | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6409 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
6410 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6411 DW_HWND_OBJECT,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6412 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6413 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6414 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6415 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6416 UPDOWN_CLASS,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6417 NULL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6418 WS_CHILD | UDS_ALIGNRIGHT | WS_BORDER |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6419 UDS_ARROWKEYS | UDS_SETBUDDYINT |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6420 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
6421 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6422 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6423 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6424 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6425 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6426 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6427
1025
3573878d1239 Make sure the initial spinbutton limits on Windows match the other platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1006
diff changeset
6428 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
6429 SendMessage(tmp, UDM_SETBUDDY, (WPARAM)buddy, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6430 cinfo->back = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6431 cinfo->buddy = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6432
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6433 cinfo->pOldProc = SubclassWindow(buddy, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6434 SetWindowLongPtr(buddy, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6435
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6436 cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6437 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
6438 /* 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
6439 * 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
6440 * 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
6441 */
e8e7f048f0b8 Removed spinbutton workaround on Vista and higher... still needed for XP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1115
diff changeset
6442 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
6443 {
e8e7f048f0b8 Removed spinbutton workaround on Vista and higher... still needed for XP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1115
diff changeset
6444 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
6445 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6446
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6447 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6448 dw_window_set_font(buddy, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6449 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6450 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6451
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6452 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6453 * Create a new radiobutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6454 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6455 * 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
6456 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6457 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6458 HWND API dw_radiobutton_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6459 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6460 HWND tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6461 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6462 WS_CHILD | BS_AUTORADIOBUTTON |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6463 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
6464 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6465 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6466 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6467 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6468 NULL);
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6469 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
6470 cinfo->fore = cinfo->back = -1;
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6471 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
6472 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
6473 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
6474 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
6475 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
6476 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6477
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6478
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6479 /*
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6480 * 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
6481 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
6482 * 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
6483 * 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
6484 * 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
6485 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6486 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
6487 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6488 HWND tmp = CreateWindow(TRACKBAR_CLASS,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6489 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6490 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6491 (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
6492 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6493 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6494 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6495 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6496 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6497 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6498
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6499 cinfo->back = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6500
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6501 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6502 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
1838
ca304f28de3b Fix 64bit crashes on Windows when building with Visual Studio 2012.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1826
diff changeset
6503 SendMessage(tmp, TBM_SETRANGE, (WPARAM)FALSE, MAKELPARAM(0, increments-1));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6504 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6505 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6506
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6507 /*
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6508 * 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
6509 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6510 * 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
6511 * 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
6512 * 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
6513 */
511
80dbd5a1f403 Removed the increments parameter from dw_scrollbar_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 510
diff changeset
6514 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
6515 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6516 HWND tmp = CreateWindow(SCROLLBARCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6517 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6518 WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6519 (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
6520 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6521 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6522 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6523 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6524 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6525 ColorInfo *cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6526
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6527 cinfo->back = cinfo->fore = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6528
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6529 cinfo->pOldProc = SubclassWindow(tmp, _colorwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6530 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6531 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
6532 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
6533 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6534
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
6535 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 32
diff changeset
6536 * Create a new percent bar window (widget) to be packed.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6537 * 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
6538 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6539 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6540 HWND API dw_percent_new(ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6541 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6542 return CreateWindow(PROGRESS_CLASS,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6543 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6544 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
6545 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6546 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6547 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6548 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6549 NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6550 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6551
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6552 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6553 * Create a new checkbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6554 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6555 * 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
6556 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6557 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6558 HWND API dw_checkbox_new(char *text, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6559 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
6560 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
6561 HWND tmp = CreateWindow(BUTTONCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6562 UTF8toWide(text),
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6563 WS_CHILD | BS_AUTOCHECKBOX |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6564 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
6565 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6566 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6567 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6568 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6569 NULL);
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
6570 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
6571 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
6572 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
6573 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
6574 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
6575 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6576 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6577
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6578 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6579 * Create a new listbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6580 * 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
6581 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6582 * multi: Multiple select TRUE or FALSE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6583 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6584 HWND API dw_listbox_new(ULONG id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6585 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6586 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6587 LISTBOXCLASSNAME,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6588 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6589 WS_VISIBLE | LBS_NOINTEGRALHEIGHT |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6590 WS_CHILD | LBS_HASSTRINGS |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6591 LBS_NOTIFY | WS_BORDER | WS_CLIPCHILDREN |
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6592 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
6593 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6594 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6595 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6596 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6597 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6598 ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6599
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6600 if(!cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6601 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6602 DestroyWindow(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6603 return NULL;
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
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
6606 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
6607 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
6608 cinfo->cinfo.pOldProc = SubclassWindow(tmp, _containerwndproc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6609
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6610 SetWindowLongPtr(tmp, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6611 dw_window_set_font(tmp, DefaultFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6612 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6613 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6614
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6615 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6616 * Sets the icon used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6617 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6618 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6619 * id: An ID to be used to specify the icon.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6620 */
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
6621 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
6622 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6623 int iicon = DW_POINTER_TO_INT(icon);
975
52cd98b7e45c Changed to using HANDLE as the base type for HICN on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 970
diff changeset
6624 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
6625
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6626 SendMessage(handle, WM_SETICON,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6627 (WPARAM) IMAGE_ICON,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6628 (LPARAM) hicon);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6629 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6630
1820
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6631 /* Internal function to set bitmap for the next two functions */
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6632 void _dw_window_set_bitmap(HWND handle, HICON icon, HBITMAP hbitmap)
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6633 {
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6634 HBITMAP oldbitmap = 0;
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6635 HANDLE oldicon = 0;
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6636 TCHAR tmpbuf[100] = {0};
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6637
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6638 if (!icon && !hbitmap)
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6639 return;
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6640
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6641 GetClassName(handle, tmpbuf, 99);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6642
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6643 if(_tcsnicmp(tmpbuf, BUTTONCLASSNAME, _tcslen(BUTTONCLASSNAME)+1)==0)
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6644 {
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6645 oldbitmap = (HBITMAP)SendMessage(handle, BM_GETIMAGE, IMAGE_BITMAP, 0);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6646 oldicon = (HICON)SendMessage(handle, BM_GETIMAGE, IMAGE_ICON, 0);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6647 SendMessage(handle, BM_SETIMAGE,
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6648 (icon ? (WPARAM)IMAGE_ICON : (WPARAM)IMAGE_BITMAP),
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6649 (icon ? (LPARAM)icon : (LPARAM)hbitmap));
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6650 }
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6651 #ifdef TOOLBAR
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6652 /* Bitmap Buttons */
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6653 else if(_tcsnicmp(tmpbuf, TOOLBARCLASSNAME, _tcslen(TOOLBARCLASSNAME)+1) == 0)
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6654 {
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6655 HIMAGELIST imlist = (HIMAGELIST)SendMessage(handle, TB_GETIMAGELIST, 0, 0);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6656 HIMAGELIST dimlist = (HIMAGELIST)SendMessage(handle, TB_GETDISABLEDIMAGELIST, 0, 0);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6657 BITMAP bmi = { 0 };
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6658
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6659 if(hbitmap)
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6660 {
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6661 GetObject(hbitmap, sizeof(BITMAP), &bmi);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6662 ImageList_Replace(imlist, 0, hbitmap, NULL);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6663 _to_grayscale(hbitmap, bmi.bmWidth, bmi.bmHeight);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6664 ImageList_Replace(dimlist, 0, hbitmap, NULL);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6665 DeleteObject(hbitmap);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6666 }
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6667 else if(icon)
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6668 {
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6669 ICONINFO iconinfo;
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6670
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6671 GetIconInfo(icon, &iconinfo);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6672 GetObject(iconinfo.hbmColor, sizeof(BITMAP), &bmi);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6673 ImageList_ReplaceIcon(imlist, 0, icon);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6674 _to_grayscale(iconinfo.hbmColor, bmi.bmWidth, bmi.bmHeight);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6675 ImageList_Replace(dimlist, 0, iconinfo.hbmColor, iconinfo.hbmMask);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6676 DeleteObject(iconinfo.hbmColor);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6677 DeleteObject(iconinfo.hbmMask);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6678 DestroyIcon(icon);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6679 }
1826
10c59bb2c47f On Windows invalidate the bitmap button after changing the bitmap to force a redraw.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1822
diff changeset
6680 InvalidateRect(handle, NULL, FALSE);
1820
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6681 }
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6682 #endif
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6683 else
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6684 {
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6685 oldbitmap = (HBITMAP)SendMessage(handle, STM_GETIMAGE, IMAGE_BITMAP, 0);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6686 oldicon = (HICON)SendMessage(handle, STM_GETIMAGE, IMAGE_ICON, 0);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6687 SendMessage(handle, STM_SETIMAGE,
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6688 (icon ? (WPARAM)IMAGE_ICON : (WPARAM)IMAGE_BITMAP),
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6689 (icon ? (LPARAM)icon : (LPARAM)hbitmap));
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6690 }
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6691
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6692 if(oldbitmap)
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6693 DeleteObject(oldbitmap);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6694 if(oldicon)
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6695 DeleteObject(oldicon);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6696
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6697 /* If we changed the bitmap... */
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6698 {
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6699 Item *item = _box_item(handle);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6700
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6701 /* Check to see if any of the sizes need to be recalculated */
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6702 if(item && (item->origwidth == -1 || item->origheight == -1))
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6703 {
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6704 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6705 /* Queue a redraw on the top-level window */
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6706 _dw_redraw(_toplevel_window(handle), TRUE);
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6707 }
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6708 }
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6709 }
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6710
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6711 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6712 * Sets the bitmap used for a given static window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6713 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6714 * 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
6715 * 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
6716 * (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
6717 * 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
6718 * 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
6719 * 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
6720 */
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 277
diff changeset
6721 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
6722 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
6723 HBITMAP hbitmap = 0;
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
6724 HANDLE icon = 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6725
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6726 if(id)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6727 {
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
6728 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
6729 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
6730 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6731 else if(filename)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6732 {
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
6733 #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
6734 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
6735 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6736 _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
6737 #endif
1820
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6738 }
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6739
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6740 _dw_window_set_bitmap(handle, icon, hbitmap);
578
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
6741 }
e4c5b03c7ce8 Add support for .ico files to dw_window_set_icon()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 573
diff changeset
6742
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6743 /*
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6744 * 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
6745 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6746 * 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
6747 * 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
6748 * (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
6749 * 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
6750 * 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
6751 * 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
6752 * 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
6753 */
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6754 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
6755 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6756 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
6757 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
6758 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
6759 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
6760
1717
8228b3cf8f37 Same fix on Windows as I just committed on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6761 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
6762 {
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
6763 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
6764 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
6765 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6766 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
6767 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
6768 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6769 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
6770 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
6771 #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
6772 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
6773 #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
6774 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
6775 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
6776 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
6777 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
6778 #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
6779 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6780 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6781 {
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
6782 _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
6783 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
6784 return;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6785 }
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
6786 _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
6787 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
6788 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6789 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
6790 return;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6791 }
1717
8228b3cf8f37 Same fix on Windows as I just committed on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6792 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
6793 {
8228b3cf8f37 Same fix on Windows as I just committed on OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1704
diff changeset
6794 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
6795 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
6796 }
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6797
1820
ece7befa9f3d Initial rewrite of dw_window_set_bitmap() to work on bitmap buttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1812
diff changeset
6798 _dw_window_set_bitmap(handle, icon, hbitmap);
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6799 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
6800
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6801
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6802 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6803 * Sets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6804 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6805 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6806 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6807 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6808 void API dw_window_set_text(HWND handle, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6809 {
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6810 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
6811 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
6812
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6813 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6814
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6815 SetWindowText(handle, wtext);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6816
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6817 /* Combobox */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6818 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
6819 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
6820 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
6821 {
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6822 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
6823 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
6824 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
6825 }
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6826 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
6827 {
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6828 /* groupbox */
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6829 thisbox = (Box *)GetWindowLongPtr( handle, GWLP_USERDATA );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6830 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
6831 SetWindowText( thisbox->grouphwnd, wtext );
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
6832 }
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
6833 /* 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
6834 {
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
6835 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
6836
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
6837 /* 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
6838 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
6839 {
1792
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6840 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
6841
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6842 _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
6843
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6844 /* 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
6845 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
6846 (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
6847 {
b0bdec1b820c Similar fixes to the Mac one on OS/2 and Windows....
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1790
diff changeset
6848 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
6849 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
6850 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
6851 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
6852 /* 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
6853 _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
6854 }
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
6855 }
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
6856 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6857 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6858
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6859 /*
1389
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6860 * 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
6861 * Parameters:
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6862 * 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
6863 * 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
6864 */
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6865 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
6866 {
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
6867 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
6868
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
6869 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
6870 _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
6871 _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
6872 }
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6873
0512fbb08abf Added dw_window_set_tooltip() for adding bubble help to most controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1387
diff changeset
6874 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6875 * Gets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6876 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6877 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6878 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6879 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6880 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6881 char * API dw_window_get_text(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6882 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6883 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
6884 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
6885 int len;
1028
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6886
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6887 GetClassName(handle, tmpbuf, 99);
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
6888
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6889 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
6890 {
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6891 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
6892
1028
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6893 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
6894 handle = cinfo->buddy;
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6895 else
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6896 return NULL;
4d49504d76dd Fix dw_window_get/set_text() on spinbuttons on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1025
diff changeset
6897 }
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
6898
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6899 /* 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
6900 * and fill it with the current text.
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6901 */
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
6902 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
6903 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
6904 GetWindowText(handle, tempbuf, len);
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6905
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6906 /* 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
6907 * 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
6908 */
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
6909 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
6910 retbuf = _strdup(retbuf);
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
6911 return retbuf;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6912 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6913
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6914 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6915 * Disables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6916 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6917 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6918 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6919 void API dw_window_disable(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6920 {
1303
ca02c24e80c9 Experimental change to menu code on Windows to allow dw_window_enable/disable to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1297
diff changeset
6921 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
6922 {
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
6923 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
6924 HMENU mymenu;
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6925 ULONG id = (ULONG)(uintptr_t)handle;
1303
ca02c24e80c9 Experimental change to menu code on Windows to allow dw_window_enable/disable to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1297
diff changeset
6926
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
6927 _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
6928 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
6929
ca02c24e80c9 Experimental change to menu code on Windows to allow dw_window_enable/disable to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1297
diff changeset
6930 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
6931 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
6932 }
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
6933 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
6934 EnableWindow(handle, FALSE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6935 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6936
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6937 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6938 * Enables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6939 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6940 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6941 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6942 void API dw_window_enable(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6943 {
1303
ca02c24e80c9 Experimental change to menu code on Windows to allow dw_window_enable/disable to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1297
diff changeset
6944 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
6945 {
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
6946 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
6947 HMENU mymenu;
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
6948 ULONG id = (ULONG)(uintptr_t)handle;
1303
ca02c24e80c9 Experimental change to menu code on Windows to allow dw_window_enable/disable to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1297
diff changeset
6949
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
6950 _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
6951 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
6952
ca02c24e80c9 Experimental change to menu code on Windows to allow dw_window_enable/disable to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1297
diff changeset
6953 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
6954 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
6955 }
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
6956 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6957 EnableWindow(handle, TRUE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6958 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6959
247
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6960 static HWND _dw_wfid_hwnd = NULL;
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6961
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6962 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
6963 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6964 if(GetWindowLong(handle, GWL_ID) == lParam)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6965 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6966 _dw_wfid_hwnd = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6967 return FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6968 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6969 return TRUE;
247
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6970 }
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6971
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6972 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6973 * Gets the child window handle with specified ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6974 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6975 * handle: Handle to the parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6976 * id: Integer ID of the child.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6977 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
6978 HWND API dw_window_from_id(HWND handle, int id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6979 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6980 _dw_wfid_hwnd = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
6981 EnumChildWindows(handle, _wfid, (LPARAM)id);
247
c097ffe6cfeb Implemented dw_window_from_id() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 243
diff changeset
6982 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
6983 }
248
0f9a185deeb6 Minor change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 247
diff changeset
6984
1084
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
6985 /* 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
6986 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
6987 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
6988 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
6989 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
6990
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
6991 /*
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
6992 * If 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
6993 * 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
6994 */
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
6995 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
6996 {
1084
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
6997 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
6998 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
6999 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7000
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7001 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
7002
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
7003 /* 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
7004 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
7005 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7006 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
7007 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
7008 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7009 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
7010 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
7011 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7012 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7013 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
7014 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
7015 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
7016 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7017 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
7018 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
7019
1077
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7020 /* 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
7021 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
7022 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
7023 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
7024 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
7025 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
7026 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
7027
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7028 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
7029
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7030 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
7031 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7032 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
7033 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
7034 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
7035 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
7036 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7037
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7038 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
7039
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7040 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
7041 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
7042 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
7043 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
7044
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7045 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
7046 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
7047 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
7048 {
1618
428148fd0976 Switch to UNICODE builds by default on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1617
diff changeset
7049 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
7050 {
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
7051 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
7052 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
7053 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
7054 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
7055 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
7056 }
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
7057 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
7058 {
a26edf086082 Windows Aero work towards making it enabled on the fly... also attempt at making controls opaque.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1514
diff changeset
7059 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
7060 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
7061 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
7062 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
7063
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
7064 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
7065 }
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
7066 }
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7067
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7068 tmpitem[index].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
7069 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
7070 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
7071 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
7072 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
7073 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
7074
22ba64e357de Initial versions of code to figure out control sizes for Windows and OS/2...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1409
diff changeset
7075 /* 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
7076 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
7077 _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
7078
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7079 thisbox->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
7080
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7081 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
7082 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
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 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
7085
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7086 SetParent(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
7087 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
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 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
7090
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7091 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
7092 {
34f1d6f5f1c3 Added function dw_box_pack_at_index() on Windows, Mac and OS/2. And an example usage in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1075
diff changeset
7093 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
7094 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
7095 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
7096 }
34f1d6f5f1c3 Added function dw_box_pack_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 }
1726
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7098 #ifdef TOOLBAR
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7099 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
7100 {
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
7101 #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
7102 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
7103 #endif
1726
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7104 {
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7105 /* 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
7106 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
7107 }
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7108 }
a02ce34692f0 Enable toolbar double buffering during packing on Windows if the window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1725
diff changeset
7109 #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
7110 /* 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
7111 _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
7112 }
34f1d6f5f1c3 Added function dw_box_pack_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 }
34f1d6f5f1c3 Added function dw_box_pack_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
34f1d6f5f1c3 Added function dw_box_pack_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 /*
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7116 * 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
7117 * Parameters:
1679
e19b93a8229b More comment cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1673
diff changeset
7118 * 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
7119 * Returns:
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7120 * 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
7121 */
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
7122 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
7123 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7124 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
7125
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7126 if(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
7127 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7128 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
7129
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7130 /* If 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
7131 * 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
7132 */
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7133 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
7134 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7135 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
7136 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
7137
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7138 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
7139 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
7140
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7141 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
7142 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7143 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
7144 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
7145 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7146
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7147 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
7148 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
7149
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7150 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
7151 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7152 tmpitem = 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
7153
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7154 /* 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
7155 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
7156 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7157 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
7158 }
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7159 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
7160 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7161 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
7162 }
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7163 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7164
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7165 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
7166 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
7167 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
7168 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
7169 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
7170 else
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7171 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
7172
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7173 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
7174 /* 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
7175 _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
7176 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
7177 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7178 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7179 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
7180 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7181
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7182 /*
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7183 * 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
7184 * Parameters:
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7185 * box: 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
7186 * 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
7187 * Returns:
1679
e19b93a8229b More comment cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1673
diff changeset
7188 * 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
7189 */
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
7190 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
7191 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7192 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
7193
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7194 /* 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
7195 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
7196 {
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7197 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
7198 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
7199 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
7200
1766
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7201 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
7202 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7203 tmpitem = 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
7204
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7205 /* 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
7206 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
7207 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7208 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
7209 }
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7210 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
7211 {
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7212 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
7213 }
1667
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
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7216 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
7217 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
7218 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
7219 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
7220 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
7221 else
47e503ecc812 Ported clang/Xcode fixes to Windows and OS/2 just in case.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1765
diff changeset
7222 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
7223
1667
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7224 /* 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
7225 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
7226 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
7227 /* 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
7228 _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
7229 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
7230 }
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
7231 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
7232 }
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7233
9dbd2984c1e5 Initial implementation of dw_box_remove() and dw_box_remove_at_index()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1663
diff changeset
7234 /*
1084
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7235 * 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
7236 * Parameters:
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7237 * 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
7238 * 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
7239 * 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
7240 * 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
7241 * 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
7242 * 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
7243 * 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
7244 * 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
7245 */
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7246 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
7247 {
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7248 _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
7249 }
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7250
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7251 /*
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7252 * Pack windows (widgets) into a box from the start (or top).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7253 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7254 * 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
7255 * item: Window handle of the item to pack.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7256 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7257 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7258 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7259 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7260 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7261 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7262 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
7263 {
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
7264 /* 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
7265 * 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
7266 */
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7267 _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
7268 }
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7269
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7270 /*
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7271 * 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
7272 * Parameters:
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7273 * 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
7274 * 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
7275 * 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
7276 * 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
7277 * 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
7278 * 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
7279 * 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
7280 */
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7281 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
7282 {
fa219e997fb8 Merge all 3 box packing functions into one internal function on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1077
diff changeset
7283 _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
7284 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7285
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7286 /*
1443
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7287 * 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
7288 * 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
7289 */
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7290 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
7291 {
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7292 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
7293
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7294 if(thisbox)
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7295 {
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7296 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
7297 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
7298 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
7299 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
7300 RECT rc = { 0 } ;
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7301
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7302 /* Calculate space requirements */
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7303 _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
7304
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7305 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
7306 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
7307
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7308 /* 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
7309 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
7310
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7311 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
7312 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
7313 }
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7314 }
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7315
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7316 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7317 * Sets the size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7318 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7319 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7320 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7321 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7322 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
7323 void API dw_window_set_size(HWND handle, ULONG width, ULONG height)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7324 {
1443
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7325 /* 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
7326 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
7327 _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
7328
bde7ebced556 Initial layout engine 2.0 for Windows and OS/2...Plus some updates for the Mac code...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1436
diff changeset
7329 /* 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
7330 SetWindowPos(handle, (HWND)NULL, 0, 0, width, height, SWP_NOZORDER | SWP_NOMOVE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7331 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7332
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7333 /*
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
7334 * 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
7335 * 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
7336 * 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
7337 * 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
7338 * 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
7339 */
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
7340 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
7341 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7342 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
7343
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7344 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
7345
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7346 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
7347 {
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7348 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
7349
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7350 /* 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
7351 _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
7352
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7353 /* 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
7354 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
7355 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
7356 }
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7357 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
7358 {
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7359 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
7360
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7361 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
7362 {
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7363 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
7364
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7365 /* 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
7366 _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
7367
783a464afab2 Added window and box support to dw_window_get_preferred_size() on OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1528
diff changeset
7368 /* 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
7369 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
7370 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
7371 }
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
7372 }
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
7373 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
7374 _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
7375 }
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
7376
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
7377 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7378 * Returns the width of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7379 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7380 int API dw_screen_width(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7381 {
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7382 return GetSystemMetrics(SM_CXSCREEN);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7383 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7384
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7385 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7386 * Returns the height of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7387 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7388 int API dw_screen_height(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7389 {
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7390 return GetSystemMetrics(SM_CYSCREEN);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7391 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7392
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7393 /* 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
7394 unsigned long API dw_color_depth_get(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7395 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7396 int bpp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7397 HDC hdc = GetDC(HWND_DESKTOP);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7398
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7399 bpp = GetDeviceCaps(hdc, BITSPIXEL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7400
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7401 ReleaseDC(HWND_DESKTOP, hdc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7402
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7403 return bpp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7404 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7405
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7406 /*
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7407 * 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
7408 * 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
7409 * Parameters:
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7410 * 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
7411 * 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
7412 * 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
7413 */
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7414 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
7415 {
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7416 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
7417 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
7418 }
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7419
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7420 /* 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
7421 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
7422 {
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7423 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
7424 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
7425
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7426 /* 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
7427 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
7428 {
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7429 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
7430
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7431 /* Handle 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
7432 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
7433 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
7434 /* 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
7435 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
7436 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
7437 /* 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
7438 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
7439 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
7440 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
7441 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
7442
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7443 /* 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
7444 *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
7445 *y = newy;
1493
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7446
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7447 /* Adjust the values to avoid Taskbar if requested */
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7448 if((horz | vert) & DW_GRAV_OBSTACLES)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7449 {
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7450 POINT pt = { 0, 0 };
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7451 HMONITOR mon = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7452 MONITORINFO mi;
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7453
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7454 mi.cbSize = sizeof(MONITORINFO);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7455
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7456 GetMonitorInfo(mon, &mi);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7457
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7458 if(horz & DW_GRAV_OBSTACLES)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7459 {
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7460 if((horz & 0xf) == DW_GRAV_LEFT)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7461 *x += (mi.rcWork.left - mi.rcMonitor.left);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7462 else if((horz & 0xf) == DW_GRAV_RIGHT)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7463 *x -= (mi.rcMonitor.right - mi.rcWork.right);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7464 }
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7465 if(vert & DW_GRAV_OBSTACLES)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7466 {
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7467 if((vert & 0xf) == DW_GRAV_TOP)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7468 *y += (mi.rcWork.top - mi.rcMonitor.top);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7469 else if((vert & 0xf) == DW_GRAV_BOTTOM)
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7470 *y -= (mi.rcMonitor.bottom - mi.rcWork.bottom);
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7471 }
ac43d9a9eee7 Initial obstacles support on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1487
diff changeset
7472 }
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7473 }
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7474 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7475
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7476 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7477 * Sets the position of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7478 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7479 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7480 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7481 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7482 */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7483 void API dw_window_set_pos(HWND handle, long x, long y)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7484 {
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7485 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
7486 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
7487
f8b4d6075cac Added auto-size support during dw_window_set_pos() on OS/2, Mac and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1493
diff changeset
7488 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
7489
f8b4d6075cac Added auto-size support during dw_window_set_pos() on OS/2, Mac and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1493
diff changeset
7490 /* 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
7491 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
7492 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
7493
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7494 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
7495 _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
7496 SetWindowPos(handle, (HWND)NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7497 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7498
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7499 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7500 * Sets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7501 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7502 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7503 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7504 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7505 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7506 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7507 */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7508 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
7509 {
1443
66999ff50174 Fix auto-sizing top-level windows with menus on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1442
diff changeset
7510 /* 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
7511 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
7512 _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
7513
1472
1794caee0758 Initial versions of dw_window_set_gravity for Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1467
diff changeset
7514 _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
7515 /* 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
7516 SetWindowPos(handle, (HWND)NULL, x, y, width, height, SWP_NOZORDER | SWP_NOACTIVATE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7517 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7518
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7519 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7520 * Gets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7521 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7522 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7523 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7524 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7525 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7526 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7527 */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7528 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
7529 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7530 WINDOWPLACEMENT wp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7531
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7532 wp.length = sizeof(WINDOWPLACEMENT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7533
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7534 GetWindowPlacement(handle, &wp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7535 if( wp.showCmd == SW_SHOWMAXIMIZED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7536 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7537 if(x)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7538 *x=0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7539 if(y)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7540 *y=0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7541 if(width)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7542 *width=dw_screen_width();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7543 if(height)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7544 *height=dw_screen_height();
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7545 }
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
7546 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7547 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7548 if(x)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7549 *x = wp.rcNormalPosition.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7550 if(y)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7551 *y = wp.rcNormalPosition.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7552 if(width)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7553 *width = wp.rcNormalPosition.right - wp.rcNormalPosition.left;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7554 if(height)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7555 *height = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7556 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7557 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7558
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7559 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7560 * Sets the style of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7561 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7562 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7563 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7564 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7565 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7566 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7567 {
1314
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7568 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
7569 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
7570 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
7571
1790
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7572 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
7573 return;
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7574
1314
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7575 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
7576 {
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7577 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
7578 HMENU mymenu;
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
7579 ULONG id = (ULONG)(uintptr_t)handle;
1314
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7580
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7581 _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
7582 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
7583
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7584 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
7585 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
7586 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
7587 }
c969db49606e Initial commit allowing dw_window_set_style() to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1310
diff changeset
7588
1535
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7589 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
7590
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
7591 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
7592 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7593
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7594 #ifdef TOOLBAR
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7595 /* Bitmap Buttons */
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7596 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
7597 {
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7598 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
7599
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7600 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
7601 {
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7602 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
7603
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
7604 /* 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
7605 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
7606 _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
7607
1721
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7608 return;
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7609 }
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7610 }
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7611 #endif
8c98c8525918 Improved but still non-functional bitmapbutton/toolbar implementation on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1720
diff changeset
7612
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7613 tmp = currentstyle | mask;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7614 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
7615 tmp |= style & mask;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7616
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
7617 /* 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
7618 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
7619 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
7620 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
7621 {
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7622 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
7623 #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
7624 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
7625 {
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
7626 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
7627
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7628 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
7629 {
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7630 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
7631
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7632 /* 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
7633 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
7634 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
7635 _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
7636 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7637 else
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7638 {
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7639 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
7640
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7641 /* 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
7642 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
7643 _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
7644 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7645 }
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7646 #endif
2913bb58f439 Added DW_FCF_COMPOSITED frame creation flag, used only on Windows currently...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1532
diff changeset
7647 }
1790
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7648 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
7649 {
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7650 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
7651 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
7652 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
7653
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7654 /* 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
7655 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
7656 tmp ^= thismask;
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7657 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
7658
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7659 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
7660 {
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7661 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
7662 {
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7663 if(cinfo)
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7664 cinfo->vcenter = 1;
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7665 else
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7666 {
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7667 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
7668 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
7669 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
7670
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7671 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
7672 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
7673 }
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7674 }
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7675 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
7676 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
7677 }
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7678 /* 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
7679 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
7680 tmp &= ~(0xFL);
209c57a14b09 Rewrite dw_window_set_style() on Windows to properly handle the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1784
diff changeset
7681 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
7682 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
7683 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
7684 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
7685 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
7686 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
7687 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7688
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7689 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
7690 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7691
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7692 /* 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
7693 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
7694 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7695 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7696
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7697 for(z=0;z<256;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7698 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7699 if(array[z] && array[z]->realid == pageid)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7700 return z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7701 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7702 return -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7703 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7704
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7705 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7706 * Adds a new page to specified notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7707 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7708 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7709 * flags: Any additional page creation flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7710 * front: If TRUE page is added at the beginning.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7711 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7712 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7713 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7714 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
7715
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7716 if(array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7717 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7718 int z, refid = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7719
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7720 for(z=0;z<256;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7721 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7722 if(_findnotebookid(array, z) == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7723 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7724 refid = z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7725 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7726 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7727 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7728
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7729 if(refid == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7730 return -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7731
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7732 for(z=0;z<256;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7733 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7734 if(!array[z])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7735 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7736 array[z] = calloc(1, sizeof(NotebookPage));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7737 array[z]->realid = refid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7738 array[z]->item.mask = TCIF_TEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7739 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
7740 array[z]->item.pszText = TEXT("");
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7741 TabCtrl_InsertItem(handle, z, &(array[z]->item));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7742 return refid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7743 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7744 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7745 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7746 return -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7747 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7748
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7749 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7750 * Sets the text on the specified notebook tab.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7751 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7752 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7753 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7754 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7755 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7756 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
7757 {
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7758
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7759 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
7760 int pageid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7761
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7762 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7763 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7764
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7765 pageid = _findnotebookid(array, pageidx);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7766
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7767 if(pageid > -1 && array[pageid])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7768 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7769 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
7770 array[pageid]->item.pszText = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7771 TabCtrl_SetItem(handle, pageid, &(array[pageid]->item));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7772 _resize_notebook_page(handle, pageid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7773 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7774 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7775
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7776 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7777 * Sets the text on the specified notebook tab status area.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7778 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7779 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7780 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7781 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7782 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7783 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7784 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7785 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7786
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7787 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7788 * Packs the specified box into the notebook page.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7789 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7790 * handle: Handle to the notebook to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7791 * pageid: Page ID in the notebook which is being packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7792 * page: Box handle to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7793 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7794 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
7795 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7796 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
7797 int pageid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7798
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7799 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7800 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7801
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7802 pageid = _findnotebookid(array, pageidx);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7803
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7804 if(pageid > -1 && array[pageid])
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 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
7807
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7808 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
7809 if(array[pageid]->hwnd)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7810 dw_window_destroy(array[pageid]->hwnd);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7811 array[pageid]->hwnd = tmpbox;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7812 if(pageidx == dw_notebook_page_get(handle))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7813 {
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
7814 ShowWindow(tmpbox, SW_HIDE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7815 SetParent(tmpbox, handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7816 _resize_notebook_page(handle, pageid);
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 }
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7819 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7820
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7821 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7822 * 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
7823 * 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
7824 * 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
7825 * 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
7826 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7827 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
7828 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7829 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
7830 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
7831 HWND pagehwnd = 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7832
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7833 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7834 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7835
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7836 pageid = _findnotebookid(array, pageidx);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7837
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7838 if(pageid < 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7839 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7840
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7841 if(array[pageid])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7842 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7843 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
7844 pagehwnd = array[pageid]->hwnd;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7845 free(array[pageid]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7846 array[pageid] = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7847 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7848
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7849 TabCtrl_DeleteItem(handle, pageid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7850
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7851 /* Shift the pages over 1 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7852 for(z=pageid;z<255;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7853 array[z] = array[z+1];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7854 array[255] = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7855
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7856 for(z=0;z<256;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7857 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7858 if(array[z])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7859 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7860 newid = z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7861 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7862 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7863 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7864 if(newid > -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7865 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7866 SetParent(array[newid]->hwnd, handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7867 _resize_notebook_page(handle, newid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7868 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
7869 }
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
7870 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
7871 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
7872 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7873
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7874 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7875 * 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
7876 * 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
7877 * 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
7878 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
7879 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
7880 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7881 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
7882 int physid = TabCtrl_GetCurSel(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7883
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7884 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
7885 return array[physid]->realid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7886 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
7887 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7888
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7889 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7890 * 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
7891 * 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
7892 * 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
7893 * 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
7894 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7895 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
7896 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7897 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
7898 int pageid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7899
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7900 if(!array)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7901 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7902
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7903 pageid = _findnotebookid(array, pageidx);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7904
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7905 if(pageid > -1 && pageid < 256)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7906 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7907 int oldpage = TabCtrl_GetCurSel(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7908
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7909 if(oldpage > -1 && array && array[oldpage])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7910 SetParent(array[oldpage]->hwnd, DW_HWND_OBJECT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7911
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7912 TabCtrl_SetCurSel(handle, pageid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7913
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7914 SetParent(array[pageid]->hwnd, handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7915 _resize_notebook_page(handle, pageid);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7916 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7917 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7918
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7919 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7920 * Appends the specified text to the listbox's (or combobox) entry list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7921 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7922 * handle: Handle to the listbox to be appended to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7923 * text: Text to append into listbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7924 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7925 void API dw_listbox_append(HWND handle, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7926 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7927 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7928
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7929 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7930
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7931 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
7932 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7933 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
7934 0, (LPARAM)UTF8toWide(text));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7935 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7936 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7937 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
7938 0, (LPARAM)UTF8toWide(text));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7939 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7940
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7941 /*
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7942 * 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
7943 * Parameters:
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7944 * 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
7945 * text: Text strings to append into listbox.
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7946 * count: Number of text strings to append
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7947 */
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7948 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
7949 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7950 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7951 int listbox_type;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7952 int i;
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 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7955
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7956 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
7957 listbox_type = CB_ADDSTRING;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7958 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7959 listbox_type = LB_ADDSTRING;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7960
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7961 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
7962 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
7963 }
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7964
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7965 /*
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7966 * 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
7967 * Parameters:
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7968 * handle: Handle to the listbox to be appended to.
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7969 * text: Text to append into listbox.
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7970 * pos: 0 based position to insert text
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7971 */
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7972 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
7973 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7974 TCHAR tmpbuf[100] = {0};
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7975
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7976 GetClassName(handle, tmpbuf, 99);
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7977
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7978 if(_tcsnicmp(tmpbuf, COMBOBOXCLASSNAME, _tcslen(COMBOBOXCLASSNAME)+1)==0)
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7979 SendMessage(handle,
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7980 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
7981 pos, (LPARAM)UTF8toWide(text));
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7982 else
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7983 SendMessage(handle,
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7984 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
7985 pos, (LPARAM)UTF8toWide(text));
643
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7986 }
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7987
9ab89d89e6b4 Add dw_listview_insert()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 635
diff changeset
7988 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7989 * Clears the listbox's (or combobox) list of all entries.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7990 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7991 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7992 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
7993 void API dw_listbox_clear(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7994 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7995 TCHAR tmpbuf[100] = {0};
617
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 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
7998
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
7999 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
8000 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8001 char *buf = dw_window_get_text(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8002
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8003 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8004 CB_RESETCONTENT, 0L, 0L);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8005
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8006 if(buf)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8007 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8008 dw_window_set_text(handle, buf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8009 free(buf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8010 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8011 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8012 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8013 SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8014 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
8015 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8016
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8017 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8018 * 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
8019 * 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
8020 * 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
8021 * 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
8022 * 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
8023 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8024 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
8025 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8026 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8027
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8028 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8029
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8030 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
8031 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8032 SendMessage(handle, CB_DELETESTRING, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8033 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
8034 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8035 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8036 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8037 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
8038 SendMessage(handle, LB_DELETESTRING, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8039 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
8040 SendMessage(handle, LB_SETCURSEL, (WPARAM)sel, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8041 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
8042 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8043 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8044
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8045 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8046 * Copies the given index item's text into buffer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8047 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8048 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8049 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8050 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8051 * length: Length of the buffer (including NULL).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8052 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8053 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
8054 {
1622
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8055 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
8056 unsigned int len;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8057
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
8058 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
8059
33d7cf373938 After looking at that last commit I realized what I was doing was
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1622
diff changeset
8060 if(!buffer || !length)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8061 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8062
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8063 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8064
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8065 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
8066 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8067 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
8068
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
8069 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
8070 {
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8071 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
8072 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
8073 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8074 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8075 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8076 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8077 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
8078
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
8079 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
8080 {
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8081 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
8082 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
8083 }
fb3c9d7509dd Fix dw_listbox_get_text() to work in Unicode mode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1621
diff changeset
8084 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8085 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8086
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8087 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8088 * Returns the index to the item in the list currently selected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8089 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8090 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8091 */
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
8092 int API dw_listbox_selected(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8093 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8094 TCHAR tmpbuf[100] = {0};
617
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 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8097
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8098 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
8099 return (unsigned int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8100 CB_GETCURSEL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8101 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8102
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8103 return (unsigned int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8104 LB_GETCURSEL,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8105 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8106 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8107
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8108 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8109 * Returns the index to the current selected item or -1 when done.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8110 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8111 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8112 * where: Either the previous return or -1 to restart.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8113 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8114 int API dw_listbox_selected_multi(HWND handle, int where)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8115 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8116 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
8117 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8118
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8119 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8120
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8121 /* 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
8122 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
8123 return -1;
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 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
8126 if(count > 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8127 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8128 array = malloc(sizeof(int)*count);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8129 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
8130
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8131 if(where == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8132 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8133 int ret = array[0];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8134 free(array);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8135 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8136 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8137 for(z=0;z<count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8138 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8139 if(array[z] == where && (z+1) < count)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8140 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8141 int ret = array[z+1];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8142 free(array);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8143 return ret;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8144 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8145 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8146 free(array);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8147 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8148 return -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8149 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8150
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8151 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8152 * Sets the selection state of a given index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8153 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8154 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8155 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8156 * state: TRUE if selected FALSE if unselected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8157 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8158 void API dw_listbox_select(HWND handle, int index, int state)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8159 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8160 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8161
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8162 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8163
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8164 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
8165 SendMessage(handle, CB_SETCURSEL, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8166 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8167 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8168 SendMessage(handle, LB_SETCURSEL, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8169 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
8170 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8171 _wndproc(handle, WM_COMMAND, (WPARAM)(LBN_SELCHANGE << 16), (LPARAM)handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8172 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8173
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8174 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8175 * Deletes the item with given index from the list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8176 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8177 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8178 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8179 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8180 void API dw_listbox_delete(HWND handle, int index)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8181 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8182 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8183
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8184 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8185
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8186 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
8187 SendMessage(handle, CB_DELETESTRING, (WPARAM)index, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8188 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8189 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
8190 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8191
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8192 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8193 * 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
8194 * 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
8195 * 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
8196 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8197 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
8198 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8199 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8200
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8201 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8202
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8203 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
8204 return (int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8205 CB_GETCOUNT,0L, 0L);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8206
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8207 return (int)SendMessage(handle,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8208 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
8209 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8210
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8211 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8212 * 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
8213 * 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
8214 * 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
8215 * 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
8216 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8217 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
8218 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8219 TCHAR tmpbuf[100] = {0};
617
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 GetClassName(handle, tmpbuf, 99);
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 /* 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
8224 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
8225 return;
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 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
8228 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
8229
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8230 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8231 * Adds text to an MLE box and returns the current point.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8232 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8233 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8234 * buffer: Text buffer to be imported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8235 * startpoint: Point to start entering text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8236 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8237 unsigned int API dw_mle_import(HWND handle, char *buffer, int startpoint)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8238 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8239 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
8240 TCHAR *tmpbuf, *srcbuf = UTF8toWide(buffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8241
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8242 if(startpoint < 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8243 startpoint = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8244
1641
cdbf4cc929fc Fixed issue with dw_mle_import() in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1633
diff changeset
8245 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
8246 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
8247
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8248 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
8249
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8250 if(len)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8251 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8252 TCHAR *dest, *start;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8253 int copylen = len - startpoint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8254
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8255 GetWindowText(handle, tmpbuf, len+1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8256
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
8257 dest = &tmpbuf[startpoint+textlen];
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8258 start = &tmpbuf[startpoint];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8259
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8260 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
8261 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
8262 }
1641
cdbf4cc929fc Fixed issue with dw_mle_import() in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1633
diff changeset
8263 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
8264
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8265 SetWindowText(handle, tmpbuf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8266
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8267 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
8268 return (startpoint + textlen);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8269 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8270
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8271 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8272 * Grabs text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8273 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8274 * 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
8275 * buffer: Text buffer to be exported. MUST allow for trailing nul character.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8276 * startpoint: Point to start grabbing text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8277 * length: Amount of text to be grabbed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8278 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8279 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8280 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8281 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
8282 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
8283
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8284 if(len)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8285 GetWindowText(handle, tmpbuf, len+1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8286
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8287 buffer[0] = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8288
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8289 if(startpoint < len)
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 max = MIN(length, len - startpoint);
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 memcpy(buffer, WideToUTF8(&tmpbuf[startpoint]), max);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8294 buffer[max] = '\0';
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8295 }
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 free(tmpbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8298 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8299
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8300 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8301 * Obtains information about an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8302 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8303 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8304 * bytes: A pointer to a variable to return the total bytes.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8305 * lines: A pointer to a variable to return the number of lines.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8306 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8307 void API dw_mle_get_size(HWND handle, unsigned long *bytes, unsigned long *lines)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8308 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8309 if(bytes)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8310 *bytes = GetWindowTextLength(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8311 if(lines)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8312 *lines = (unsigned long)SendMessage(handle, EM_GETLINECOUNT, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8313 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8314
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8315 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8316 * Deletes text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8317 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8318 * handle: Handle to the MLE to be deleted from.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8319 * startpoint: Point to start deleting text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8320 * length: Amount of text to be deleted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8321 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8322 void API dw_mle_delete(HWND handle, int startpoint, int length)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8323 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8324 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
8325 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
8326
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8327 GetWindowText(handle, tmpbuf, len+1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8328
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8329 if(startpoint + length < len)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8330 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8331 _tcscpy(&tmpbuf[startpoint], &tmpbuf[startpoint+length]);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8332
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8333 SetWindowText(handle, tmpbuf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8334 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8335
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8336 free(tmpbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8337 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8338
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8339 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8340 * Clears all text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8341 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8342 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8343 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8344 void API dw_mle_clear(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8345 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8346 SetWindowText(handle, TEXT(""));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8347 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8348
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8349 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8350 * Sets the visible line of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8351 * 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
8352 * handle: Handle to the MLE.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8353 * line: Line to be visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8354 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8355 void API dw_mle_set_visible(HWND handle, int line)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8356 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8357 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
8358 dw_mle_set_cursor(handle, point);
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 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8362 * Sets the editablity of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8363 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8364 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8365 * 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
8366 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8367 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
8368 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8369 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
8370 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8371
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8372 /*
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8373 * Sets the word wrap state of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8374 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8375 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8376 * 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
8377 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8378 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
8379 {
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
8380 /* 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
8381 * horizontal scrollbar it word wraps.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8382 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8383 if(state)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8384 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
8385 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8386 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
8387 /* 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
8388 if(hrichedit)
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8389 {
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8390 if(state)
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8391 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
8392 else
78a2e6a51285 Added basic rich edit control support for MLEs on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1542
diff changeset
8393 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
8394 }
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8395 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8396
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
8397 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8398 * Sets the current cursor position of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8399 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8400 * handle: Handle to the MLE to be positioned.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8401 * point: Point to position cursor.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8402 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8403 void API dw_mle_set_cursor(HWND handle, int point)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8404 {
1838
ca304f28de3b Fix 64bit crashes on Windows when building with Visual Studio 2012.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1826
diff changeset
8405 SendMessage(handle, EM_SETSEL, 0, MAKELPARAM(point,point));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8406 SendMessage(handle, EM_SCROLLCARET, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8407 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8408
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8409 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8410 * Finds text in an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8411 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8412 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8413 * text: Text to search for.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8414 * point: Start point of search.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8415 * flags: Search specific flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8416 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8417 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8418 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8419 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
8420 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
8421 TCHAR *searchtext = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8422 int z, textlen, retval = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8423
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8424 GetWindowText(handle, tmpbuf, len+1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8425
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
8426 textlen = (int)strlen(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8427
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8428 if(flags & DW_MLE_CASESENSITIVE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8429 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8430 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
8431 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8432 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
8433 retval = z + textlen;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8434 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8435 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8436 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8437 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8438 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
8439 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8440 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
8441 retval = z + textlen;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8442 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8443 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8444
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8445 if(retval)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8446 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8447 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
8448 SendMessage(handle, EM_SCROLLCARET, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8449 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8450
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8451 free(tmpbuf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8452
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8453 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8454 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8455
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8456 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8457 * Stops redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8458 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8459 * handle: Handle to the MLE to freeze.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8460 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8461 void API dw_mle_freeze(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8462 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8463 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8464
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8465 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8466 * Resumes redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8467 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8468 * handle: Handle to the MLE to thaw.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8469 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8470 void API dw_mle_thaw(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8471 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8472 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8473
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8474 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 32
diff changeset
8475 * Sets the percent bar position.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8476 * 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
8477 * 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
8478 * position: Position of the percent bar withing the range.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8479 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8480 void API dw_percent_set_pos(HWND handle, unsigned int position)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8481 {
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
8482 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
8483 {
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8484 /* 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
8485 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
8486 {
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8487 /* 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
8488 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
8489 /* 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
8490 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
8491 }
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8492 else
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8493 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
8494 }
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8495 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
8496 {
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8497 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
8498 {
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8499 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
8500
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8501 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
8502 {
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8503 /* 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
8504 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
8505 /* 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
8506 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
8507 }
76262040ed5f Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1170
diff changeset
8508 }
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
8509 /* 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
8510 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
8511 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8512 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8513
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8514 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8515 * 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
8516 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8517 * 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
8518 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8519 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
8520 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8521 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
8522 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8523
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8524 if(currentstyle & TBS_VERT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8525 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
8526 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
8527 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8528
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8529 /*
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8530 * 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
8531 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8532 * 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
8533 * 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
8534 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8535 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
8536 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8537 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
8538 ULONG currentstyle = GetWindowLong(handle, GWL_STYLE);
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 if(currentstyle & TBS_VERT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8541 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
8542 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8543 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
8544 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8545
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8546 /*
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8547 * 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
8548 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8549 * 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
8550 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8551 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
8552 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8553 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
8554 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8555
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8556 /*
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8557 * 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
8558 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8559 * 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
8560 * 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
8561 */
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8562 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
8563 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
8564 dw_window_set_data(handle, "_dw_scrollbar_value", DW_UINT_TO_POINTER(position));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8565 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
8566 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8567
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8568 /*
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8569 * 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
8570 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8571 * 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
8572 * 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
8573 * 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
8574 */
098ed34d41fb The basics of the new scrollbar code on Windows, and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 201
diff changeset
8575 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
8576 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8577 SCROLLINFO si;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8578
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8579 si.cbSize = sizeof(SCROLLINFO);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8580 si.fMask = SIF_RANGE | SIF_PAGE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8581 si.nMin = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8582 si.nMax = range - 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8583 si.nPage = visible;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8584 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
8585 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8586
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
8587 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8588 * Sets the spinbutton value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8589 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8590 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8591 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8592 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8593 void API dw_spinbutton_set_pos(HWND handle, long position)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8594 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8595 TCHAR tmpbuf[101] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8596 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8597
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8598 _sntprintf(tmpbuf, 100, TEXT("%ld"), position);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8599
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8600 if(cinfo && cinfo->buddy)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8601 SetWindowText(cinfo->buddy, tmpbuf);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8602
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
8603 SendMessage(handle, UDM_SETPOS32, 0, (LPARAM)position);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8604 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8605
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8606 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8607 * Sets the spinbutton limits.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8608 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8609 * 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
8610 * 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
8611 * position: Current value of the spinbutton.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8612 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8613 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8614 {
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
8615 SendMessage(handle, UDM_SETRANGE32, (WPARAM)lower,(LPARAM)upper);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8616 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8617
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8618 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8619 * Sets the entryfield character limit.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8620 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8621 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8622 * limit: Number of characters the entryfield will take.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8623 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8624 void API dw_entryfield_set_limit(HWND handle, ULONG limit)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8625 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8626 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
8627 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8628
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8629 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8630 * Returns the current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8631 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8632 * handle: Handle to the spinbutton to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8633 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8634 long API dw_spinbutton_get_pos(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8635 {
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
8636 return (long)SendMessage(handle, UDM_GETPOS32, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8637 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8638
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8639 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8640 * Returns the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8641 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8642 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8643 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8644 int API dw_checkbox_get(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8645 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8646 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
8647 return (in_checkbox_handler ? FALSE : TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8648 return (in_checkbox_handler ? TRUE : FALSE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8649 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8650
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
8651 /* 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
8652 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
8653 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8654 TCHAR tmpbuf[100] = {0};
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8655
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8656 GetClassName(handle, tmpbuf, 99);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8657
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8658 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
8659 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
8660 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
8661 SendMessage(handle, BM_SETCHECK, 0, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8662 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8663 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
8664 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8665 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8666 * Sets the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8667 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8668 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8669 * value: TRUE for checked, FALSE for unchecked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8670 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8671 void API dw_checkbox_set(HWND handle, int value)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8672 {
1392
943266c86aed Refactoring OS/2 and Windows code... eliminating BubbleButton...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1389
diff changeset
8673 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
8674 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8675 HWND parent = GetParent(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8676
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8677 if(parent)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8678 EnumChildWindows(parent, _uncheck_radios, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8679 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8680 SendMessage(handle, BM_SETCHECK, (WPARAM)value, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8681 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8682
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8683 /*
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8684 * 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
8685 * Parameters:
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8686 * 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
8687 * 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
8688 * title: The text title of the entry.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8689 * icon: Handle to coresponding icon.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8690 * parent: Parent handle or 0 if root.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8691 * itemdata: Item specific data.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8692 */
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
8693 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
8694 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8695 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8696 TVINSERTSTRUCT tvins;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8697 HTREEITEM hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8698
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8699 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
8700 tvi.pszText = UTF8toWide(title);
1868
dc3260e1a915 Use the cached text from the tree on Windows instead of caching parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
8701 tvi.lParam = (LPARAM)itemdata;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8702 tvi.cchTextMax = (int)_tcslen(tvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8703 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
8704
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8705 tvins.item = tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8706 tvins.hParent = parent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8707 tvins.hInsertAfter = item ? item : TVI_FIRST;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8708
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8709 hti = TreeView_InsertItem(handle, &tvins);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8710
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8711 return hti;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8712 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8713
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 59
diff changeset
8714 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8715 * 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
8716 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8717 * 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
8718 * 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
8719 * 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
8720 * 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
8721 * 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
8722 */
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
8723 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
8724 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8725 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8726 TVINSERTSTRUCT tvins;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8727 HTREEITEM hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8728
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8729 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
8730 tvi.pszText = UTF8toWide(title);
1868
dc3260e1a915 Use the cached text from the tree on Windows instead of caching parameters...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1861
diff changeset
8731 tvi.lParam = (LPARAM)itemdata;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
8732 tvi.cchTextMax = (int)_tcslen(tvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8733 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
8734
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8735 tvins.item = tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8736 tvins.hParent = parent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8737 tvins.hInsertAfter = TVI_LAST;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8738
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8739 hti = TreeView_InsertItem(handle, &tvins);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8740
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8741 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
8742 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8743
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
8744 /*
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
8745 * 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
8746 * 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
8747 * 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
8748 * 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
8749 * 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
8750 * 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
8751 */
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
8752 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
8753 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8754 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8755
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8756 tvi.mask = TVIF_HANDLE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8757 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8758
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8759 if(TreeView_GetItem(handle, &tvi))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8760 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8761 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
8762 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
8763 tvi.cchTextMax = (int)_tcslen(tvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8764 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
8765 tvi.hItem = (HTREEITEM)item;
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 TreeView_SetItem(handle, &tvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8768 }
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
8769 }
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
8770
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
8771 /*
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
8772 * 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
8773 * 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
8774 * 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
8775 * 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
8776 * 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
8777 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
8778 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
8779 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8780 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8781 void **ptrs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8782
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8783 tvi.mask = TVIF_HANDLE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8784 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8785
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8786 if(TreeView_GetItem(handle, &tvi))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8787 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8788 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8789 ptrs[1] = itemdata;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8790 }
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
8791 }
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
8792
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
8793 /*
317
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8794 * 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
8795 * Parameters:
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8796 * 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
8797 * 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
8798 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8799 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
8800 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8801 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8802 void **ptrs;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8803
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
8804 tvi.mask = TVIF_HANDLE | TVIF_PARAM;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8805 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8806
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8807 if(TreeView_GetItem(handle, &tvi))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8808 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8809 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8810 return ptrs[1];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8811 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8812 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
8813 }
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8814
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
8815 /*
481
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8816 * 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
8817 * Parameters:
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8818 * 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
8819 * 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
8820 */
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8821 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
8822 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8823 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8824
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8825 tvi.mask = TVIF_HANDLE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8826 tvi.hItem = item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8827
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8828 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
8829 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
8830 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
8831 }
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8832
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8833 /*
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8834 * 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
8835 * Parameters:
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8836 * 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
8837 * 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
8838 */
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8839 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
8840 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8841 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
8842 }
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8843
97c2c560f829 Implemented the new tree functions and signal on Windows and exported the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 473
diff changeset
8844 /*
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
8845 * 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
8846 * 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
8847 * 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
8848 * 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
8849 */
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
8850 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
8851 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8852 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
8853 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8854
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
8855 /* 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
8856 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
8857 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8858 HTREEITEM hti;
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 hti = TreeView_GetChild(handle, node);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8861
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8862 while(hti)
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 HTREEITEM lastitem = hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8865
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8866 hti = TreeView_GetNextSibling(handle, hti);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8867 dw_tree_item_delete(handle, lastitem);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8868 }
291
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
8869 }
70480069392b Fixed memory leak in the tree control on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 284
diff changeset
8870
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
8871 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8872 * Removes all nodes from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8873 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8874 * 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
8875 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8876 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
8877 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8878 HTREEITEM hti = TreeView_GetRoot(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8879
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8880 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
8881 while(hti)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8882 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8883 HTREEITEM lastitem = hti;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8884
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8885 _dw_tree_item_delete_recursive(handle, hti);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8886 hti = TreeView_GetNextSibling(handle, hti);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8887 dw_tree_item_delete(handle, lastitem);
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 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
8890 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8891
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8892 /*
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
8893 * 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
8894 * 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
8895 * 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
8896 * 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
8897 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8898 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
8899 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8900 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
8901 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8902
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8903 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8904 * 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
8905 * 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
8906 * 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
8907 * 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
8908 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8909 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
8910 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8911 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
8912 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8913
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8914 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8915 * Removes a node from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8916 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8917 * 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
8918 * item: Handle to node to be deleted.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8919 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 509
diff changeset
8920 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
8921 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8922 TVITEM tvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8923 void **ptrs=NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8924
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8925 if(item == TVI_ROOT || !item)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8926 return;
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))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8932 ptrs = (void **)tvi.lParam;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8933
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8934 _dw_tree_item_delete_recursive(handle, item);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8935 TreeView_DeleteItem(handle, item);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8936 if(ptrs)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8937 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
8938 }
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8939
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
8940 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8941 * Sets up the container columns.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8942 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8943 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8944 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8945 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8946 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8947 * 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
8948 * (only used on OS/2 but must be >= 0 on all)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8949 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
8950 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
8951 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8952 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8953 int z, l = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8954 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
8955 LVCOLUMN lvc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8956
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8957 if(separator == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8958 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8959 tempflags[0] = DW_CFA_RESERVED;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8960 l = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8961 }
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 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
8964 tempflags[count + l] = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8965 cinfo->flags = tempflags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8966 cinfo->columns = count + l;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8967
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8968
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8969 for(z=0;z<count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8970 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8971 if(titles[z])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8972 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8973 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
8974 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
8975 lvc.cchTextMax = (int)_tcslen(lvc.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8976 if(flags[z] & DW_CFA_RIGHT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8977 lvc.fmt = LVCFMT_RIGHT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8978 else if(flags[z] & DW_CFA_CENTER)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8979 lvc.fmt = LVCFMT_CENTER;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8980 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8981 lvc.fmt = LVCFMT_LEFT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8982 lvc.cx = 75;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8983 lvc.iSubItem = count;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8984 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
8985 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8986 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
8987 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
8988 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8989 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8990
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8991 /*
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
8992 * 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
8993 * Parameters:
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
8994 * 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
8995 * 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
8996 */
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
8997 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
8998 {
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
8999 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
9000
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
9001 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
9002 }
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9003
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9004 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9005 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9006 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9007 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9008 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9009 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9010 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9011 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9012 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9013 {
1744
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9014 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
9015 LV_COLUMN lvc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9016
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9017 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
9018 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
9019 lvc.cchTextMax = 8;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9020 lvc.fmt = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9021 if(!count)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9022 lvc.cx = 300;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9023 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9024 lvc.cx = 150;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9025 lvc.iSubItem = count;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9026 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
9027 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
9028 if(coltitle)
535e8c19a13d Added dw_filesystem_set_column_title() function to aid in localization.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1732
diff changeset
9029 {
1749
ff9a51706715 Added optional keypress callback optional utf8 parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1744
diff changeset
9030 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
9031 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
9032 }
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
9033 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9034 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9035
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9036 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9037 * Obtains an icon from a module (or header in GTK).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9038 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9039 * module: Handle to module (DLL) in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9040 * id: A unsigned long id int the resources on OS/2 and
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9041 * Windows, on GTK this is converted to a pointer
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9042 * to an embedded XPM.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9043 */
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
9044 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
9045 {
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
9046 return (HICN)LoadIcon(DWInstance, MAKEINTRESOURCE(id));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9047 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9048
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9049 /*
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
9050 * 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
9051 * 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
9052 * 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
9053 * 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
9054 * (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
9055 */
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
9056 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
9057 {
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
9058 #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
9059 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
9060 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9061 char *file = malloc(strlen(filename) + 5);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9062 HANDLE icon;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9063
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9064 if(!file)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9065 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9066
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9067 strcpy(file, filename);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9068
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9069 /* 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
9070 if(access(file, 04) != 0)
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 /* Try with .bmp extention */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9073 strcat(file, ".ico");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9074 if(access(file, 04) != 0)
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 free(file);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9077 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9078 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9079 }
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
9080 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
9081 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
9082 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
9083 #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
9084 }
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
9085
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
9086 /*
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9087 * 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
9088 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9089 * 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
9090 * 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
9091 * (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
9092 */
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
9093 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
9094 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
9095 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
9096 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
9097 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
9098
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9099 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
9100 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
9101 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
9102 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
9103 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9104 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
9105 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
9106 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9107 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
9108 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
9109 #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
9110 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
9111 #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
9112 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
9113 #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
9114 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9115 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9116 {
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
9117 _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
9118 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
9119 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
9120 }
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
9121 _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
9122 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
9123 }
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
9124 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
9125 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9126
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
9127 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9128 * Frees a loaded resource in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9129 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9130 * handle: Handle to icon returned by dw_icon_load().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9131 */
671
c60a4f6cfae8 Implemented icon support on the Mac. In the process created a new HICN type.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 648
diff changeset
9132 void API dw_icon_free(HICN handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9133 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9134 DestroyIcon((HICON)handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9135 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9136
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9137 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9138 * Allocates memory used to populate a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9139 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9140 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9141 * rowcount: The number of items to be populated.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9142 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9143 void * API dw_container_alloc(HWND handle, int rowcount)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9144 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9145 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9146 int z, item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9147
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9148 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
9149 lvi.iSubItem = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9150 /* Insert at the end */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9151 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
9152 lvi.pszText = TEXT("");
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9153 lvi.cchTextMax = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9154 lvi.iImage = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9155
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9156 ShowWindow(handle, SW_HIDE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9157 item = ListView_InsertItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9158 for(z=1;z<rowcount;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9159 ListView_InsertItem(handle, &lvi);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9160 dw_window_set_data(handle, "_dw_insertitem", DW_INT_TO_POINTER(item));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9161 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
9162 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9163
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9164 /* 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
9165 * 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
9166 */
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9167 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
9168 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9169 int z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9170 static HWND lasthwnd = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9171
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
9172 /* 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
9173 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
9174 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
9175
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9176 if(!hSmall || !hLarge)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9177 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9178 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
9179 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
9180 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9181 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
9182 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9183 if(!lookup[z])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9184 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9185 lookup[z] = hicon;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9186 ImageList_AddIcon(hSmall, hicon);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9187 ImageList_AddIcon(hLarge, hicon);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9188 if(type)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9189 {
1842
123d1a900f54 More MINGW cleanups... eliminate a few more warnings and disable the unused-value warning due to unfixable warnings generated by the Win32 macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1839
diff changeset
9190 TreeView_SetImageList(handle, hSmall, TVSIL_NORMAL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9191 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9192 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9193 {
1842
123d1a900f54 More MINGW cleanups... eliminate a few more warnings and disable the unused-value warning due to unfixable warnings generated by the Win32 macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1839
diff changeset
9194 ListView_SetImageList(handle, hSmall, LVSIL_SMALL);
123d1a900f54 More MINGW cleanups... eliminate a few more warnings and disable the unused-value warning due to unfixable warnings generated by the Win32 macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1839
diff changeset
9195 ListView_SetImageList(handle, hLarge, LVSIL_NORMAL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9196 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9197 lasthwnd = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9198 return z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9199 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9200
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9201 if(hicon == lookup[z])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9202 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9203 if(lasthwnd != handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9204 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9205 if(type)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9206 {
1842
123d1a900f54 More MINGW cleanups... eliminate a few more warnings and disable the unused-value warning due to unfixable warnings generated by the Win32 macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1839
diff changeset
9207 TreeView_SetImageList(handle, hSmall, TVSIL_NORMAL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9208 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9209 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9210 {
1842
123d1a900f54 More MINGW cleanups... eliminate a few more warnings and disable the unused-value warning due to unfixable warnings generated by the Win32 macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1839
diff changeset
9211 ListView_SetImageList(handle, hSmall, LVSIL_SMALL);
123d1a900f54 More MINGW cleanups... eliminate a few more warnings and disable the unused-value warning due to unfixable warnings generated by the Win32 macros.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1839
diff changeset
9212 ListView_SetImageList(handle, hLarge, LVSIL_NORMAL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9213 }
1532
6c55d68fd08a Fixed some warnings building with MinGW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1531
diff changeset
9214 lasthwnd = handle;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9215 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9216 return z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9217 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9218 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9219 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
9220 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9221
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9222 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9223 * 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
9224 * 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
9225 * 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
9226 * 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
9227 * 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
9228 * 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
9229 * 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
9230 */
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
9231 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
9232 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9233 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
9234 int item = 0;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9235
832
37cdfec6d3fa Fix for dw_filesystem_set_file() not working as designed on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 819
diff changeset
9236 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
9237 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9238 item = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_insertitem"));
832
37cdfec6d3fa Fix for dw_filesystem_set_file() not working as designed on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 819
diff changeset
9239 }
37cdfec6d3fa Fix for dw_filesystem_set_file() not working as designed on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 819
diff changeset
9240
37cdfec6d3fa Fix for dw_filesystem_set_file() not working as designed on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 819
diff changeset
9241 lvi.iItem = row + item;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9242 lvi.iSubItem = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9243 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
9244 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
9245 lvi.cchTextMax = (int)_tcslen(lvi.pszText);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9246 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
9247
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9248 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
9249 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9250
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9251 /*
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9252 * 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
9253 * 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
9254 * 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
9255 * 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
9256 * 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
9257 * 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
9258 * 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
9259 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9260 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
9261 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9262 dw_container_set_item(handle, pointer, column + 1, row, data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9263 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9264
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9265 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9266 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9267 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9268 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9269 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9270 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9271 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9272 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9273 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9274 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
9275 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9276 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9277 ULONG *flags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9278 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
9279 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
9280 int item = 0;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9281
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
9282 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
9283 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9284 item = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_insertitem"));
819
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9285 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9286
1500
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9287 if(!cinfo || !cinfo->flags)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9288 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9289
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9290 flags = cinfo->flags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9291
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9292 lvi.mask = LVIF_DI_SETITEM | LVIF_TEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9293 lvi.iItem = row + item;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9294 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
9295 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
9296 lvi.cchTextMax = 0;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9297
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9298 if(flags[column] & DW_CFA_BITMAPORICON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9299 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9300 lvi.mask = LVIF_DI_SETITEM | LVIF_IMAGE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9301 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
9302
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9303 if(data)
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9304 {
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9305 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
9306
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9307 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
9308 }
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9309 else
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9310 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
9311 }
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9312 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
9313 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9314 char *tmp = *((char **)data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9315
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9316 if(!tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9317 tmp = "";
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9318
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9319 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
9320 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
9321 }
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9322 else if(flags[column] & DW_CFA_ULONG && data)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9323 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9324 ULONG tmp = *((ULONG *)data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9325
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9326 _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
9327
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9328 lvi.cchTextMax = (int)_tcslen(textbuffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9329 }
1500
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9330 else if(flags[column] & DW_CFA_DATE && data)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9331 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9332 struct tm curtm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9333 CDATE cdate = *((CDATE *)data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9334
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9335 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
9336
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9337 /* 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
9338 * Visual Studio 2008. -Brian
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9339 */
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9340 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
9341 {
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9342 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
9343 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
9344 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
9345 _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
9346 }
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9347
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9348 lvi.cchTextMax = (int)_tcslen(textbuffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9349 }
1500
97002721c4ca Allow passing NULL to the container set item functions on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1498
diff changeset
9350 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
9351 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9352 struct tm curtm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9353 CTIME ctime = *((CTIME *)data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9354
771
5cca4ebcca9a When destroying a spinbutton, destroy the correct window
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 770
diff changeset
9355 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
9356 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
9357 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
9358
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9359 _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
9360
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
9361 lvi.cchTextMax = (int)_tcslen(textbuffer);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9362 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9363
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9364 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
9365 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9366
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9367 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9368 * 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
9369 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9370 * 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
9371 * 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
9372 * 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
9373 * 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
9374 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9375 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
9376 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9377 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
9378 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9379
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9380 /*
503
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9381 * 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
9382 * Parameters:
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9383 * 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
9384 * 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
9385 * 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
9386 * 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
9387 */
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9388 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
9389 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9390 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
9391 }
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9392
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9393 /*
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9394 * 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
9395 * Parameters:
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9396 * 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
9397 * 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
9398 * 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
9399 * 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
9400 * 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
9401 */
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
9402 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
9403 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9404 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
9405 }
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9406
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 502
diff changeset
9407 /*
508
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9408 * 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
9409 * Parameters:
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9410 * 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
9411 * 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
9412 */
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9413 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
9414 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9415 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9416 ULONG *flags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9417 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9418
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9419 if(!cinfo || !cinfo->flags)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9420 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9421
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9422 flags = cinfo->flags;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9423
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9424 if(flags[column] & DW_CFA_BITMAPORICON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9425 rc = DW_CFA_BITMAPORICON;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9426 else if(flags[column] & DW_CFA_STRING)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9427 rc = DW_CFA_STRING;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9428 else if(flags[column] & DW_CFA_ULONG)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9429 rc = DW_CFA_ULONG;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9430 else if(flags[column] & DW_CFA_DATE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9431 rc = DW_CFA_DATE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9432 else if(flags[column] & DW_CFA_TIME)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9433 rc = DW_CFA_TIME;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9434 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9435 rc = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9436 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
9437 }
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9438
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9439 /*
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9440 * 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
9441 * Parameters:
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9442 * 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
9443 * 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
9444 */
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9445 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
9446 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9447 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
9448 }
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9449
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 507
diff changeset
9450 /*
1208
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9451 * 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
9452 * Parameters:
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9453 * 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
9454 * 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
9455 * 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
9456 * 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
9457 * 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
9458 */
1291
b99b0b2c2826 Renamed dw_container_set_row_bg() to dw_container_set_stripe().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1275
diff changeset
9459 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
9460 {
1212
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9461 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
9462 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
9463 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
9464 temp = _internal_color(evencolor);
0712ee0f311e Grr flippin' tabs again!
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1292
diff changeset
9465 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
9466
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9467 /* Drop out on error */
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9468 if(!cinfo)
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9469 return;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9470
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9471 /* 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
9472 if(oddcolor != DW_RGB_TRANSPARENT)
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9473 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
9474 else
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9475 cinfo->odd = oddcolor;
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9476
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9477 if(evencolor != DW_RGB_TRANSPARENT)
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9478 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
9479 else
5271d5cb27ac Implemented dw_container_set_row_bg() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1211
diff changeset
9480 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
9481 }
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9482
53547c9c99a2 Added dw_container_set_row_bg() stubs on the remaining platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1190
diff changeset
9483 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9484 * 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
9485 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9486 * 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
9487 * 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
9488 * 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
9489 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9490 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
9491 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9492 ListView_SetColumnWidth(handle, column, width);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9493 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9494
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
9495 /* 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
9496 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
9497 {
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
9498 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
9499 int item = 0;
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9500
819
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9501 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
9502 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9503 item = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_insertitem"));
819
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9504 }
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9505
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9506 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
9507 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
9508 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
9509 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
9510
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9511 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
9512 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
9513
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9514 }
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9515
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9516 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9517 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9518 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9519 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9520 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9521 * title: String title of the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9522 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9523 void API dw_container_set_row_title(void *pointer, int row, char *title)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9524 {
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9525 _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
9526 }
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
9527
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
9528 /*
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
9529 * 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
9530 * 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
9531 * 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
9532 * 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
9533 * 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
9534 */
2dd7638a7719 Fix for some dw_container_change_item() misbehavior... was functioning the same as dw_container_set_item().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 771
diff changeset
9535 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
9536 {
863
b405182033a0 Removed leftover code from _HandleScroller copied incorrectly when debugging.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 862
diff changeset
9537 _dw_container_set_row_title(handle, NULL, row, title);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9538 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9539
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9540 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9541 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9542 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9543 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9544 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9545 * rowcount: The number of rows to be inserted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9546 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9547 void API dw_container_insert(HWND handle, void *pointer, int rowcount)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9548 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9549 ShowWindow(handle, SW_SHOW);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9550 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9551
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9552 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9553 * Removes all rows from a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9554 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9555 * 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
9556 * 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
9557 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9558 void API dw_container_clear(HWND handle, int redraw)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9559 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9560 ListView_DeleteAllItems(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9561 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9562
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9563 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9564 * 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
9565 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9566 * 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
9567 * 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
9568 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9569 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
9570 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9571 int z, _index = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_index"));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9572
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9573 for(z=0;z<rowcount;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9574 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9575 ListView_DeleteItem(handle, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9576 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9577 if(rowcount > _index)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9578 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
9579 else
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9580 dw_window_set_data(handle, "_dw_index", DW_INT_TO_POINTER((_index - rowcount)));
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9581 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9582
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9583 /*
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9584 * 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
9585 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9586 * 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
9587 * 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
9588 * 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
9589 * 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
9590 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9591 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
9592 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9593 switch(direction)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9594 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9595 case DW_SCROLL_TOP:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9596 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
9597 break;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9598 case DW_SCROLL_BOTTOM:
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9599 ListView_Scroll(handle, 0, 10000000);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9600 break;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9601 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9602 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9603
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
9604 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9605 * Starts a new query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9606 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9607 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9608 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9609 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9610 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9611 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9612 char * API dw_container_query_start(HWND handle, unsigned long flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9613 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9614 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9615 int _index = ListView_GetNextItem(handle, -1, flags);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9616
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9617 if(_index == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9618 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9619
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9620 memset(&lvi, 0, sizeof(LV_ITEM));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9621
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9622 lvi.iItem = _index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9623 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9624
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9625 ListView_GetItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9626
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9627 dw_window_set_data(handle, "_dw_index", DW_INT_TO_POINTER(_index));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9628 return (char *)lvi.lParam;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9629 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9630
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9631 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9632 * Continues an existing query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9633 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9634 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9635 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9636 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9637 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9638 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9639 char * API dw_container_query_next(HWND handle, unsigned long flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9640 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9641 LV_ITEM lvi;
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9642 int _index = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_index"));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9643
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9644 _index = ListView_GetNextItem(handle, _index, flags);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9645
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9646 if(_index == -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9647 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9648
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9649 memset(&lvi, 0, sizeof(LV_ITEM));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9650
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9651 lvi.iItem = _index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9652 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9653
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9654 ListView_GetItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9655
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9656 dw_window_set_data(handle, "_dw_index", DW_INT_TO_POINTER(_index));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9657 return (char *)lvi.lParam;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9658 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9659
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9660 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9661 * 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
9662 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9663 * 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
9664 * 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
9665 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9666 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
9667 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9668 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
9669 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
9670
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9671 while ( index != -1 )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9672 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9673 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9674
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9675 memset(&lvi, 0, sizeof(LV_ITEM));
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 lvi.iItem = index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9678 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9679
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9680 ListView_GetItem( handle, &lvi );
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9681
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
9682 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
9683 {
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
9684 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
9685
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9686 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
9687 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
9688 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
9689 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
9690 ListView_EnsureVisible( handle, index, TRUE );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9691 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9692 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9693
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
9694 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
9695 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9696 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9697
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9698 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9699 * 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
9700 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9701 * 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
9702 * 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
9703 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9704 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
9705 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9706 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
9707 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
9708
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9709 while(index != -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9710 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9711 LV_ITEM lvi;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9712
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9713 memset(&lvi, 0, sizeof(LV_ITEM));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9714
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9715 lvi.iItem = index;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9716 lvi.mask = LVIF_PARAM;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9717
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9718 ListView_GetItem(handle, &lvi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9719
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
9720 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
9721 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9722 int _index = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_index"));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9723
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9724 if(index < _index)
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9725 dw_window_set_data(handle, "_dw_index", DW_INT_TO_POINTER((_index - 1)));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9726
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9727 ListView_DeleteItem(handle, index);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9728 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9729 }
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9730
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9731 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
9732 }
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9733 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9734
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
9735 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9736 * 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
9737 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9738 * 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
9739 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9740 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
9741 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9742 ContainerInfo *cinfo = (ContainerInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9743 if(cinfo && cinfo->columns == 1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9744 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9745 ListView_SetColumnWidth(handle, 0, LVSCW_AUTOSIZE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9746 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9747 else if(cinfo && cinfo->columns > 1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9748 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9749 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
9750 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
9751 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
9752 int index;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9753
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9754 /* Initialize with sizes of column labels */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9755 for(z=0;z<cinfo->columns;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9756 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9757 if(flags[z] & DW_CFA_BITMAPORICON)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9758 columns[z] = 5;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9759 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9760 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9761 LVCOLUMN lvc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9762
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9763 lvc.mask = LVCF_TEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9764 lvc.cchTextMax = 1023;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9765 lvc.pszText = text;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9766
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9767 if(ListView_GetColumn(handle, z, &lvc))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9768 columns[z] = ListView_GetStringWidth(handle, lvc.pszText);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9769
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9770 if(flags[z] & DW_CFA_RESERVED)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9771 columns[z] += 20;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9772 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9773 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9774
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9775 index = ListView_GetNextItem(handle, -1, LVNI_ALL);
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 /* Query all the item texts */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9778 while(index != -1)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9779 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9780 for(z=0;z<cinfo->columns;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9781 {
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
9782 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
9783
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9784 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
9785 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
9786
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9787 /* 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
9788 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
9789 width += 20;
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9790
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9791 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
9792 columns[z] = width;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9793 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9794
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9795 index = ListView_GetNextItem(handle, index, LVNI_ALL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9796 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9797
1387
db27c6e139a3 Fixed dw_container_optimize() on Windows was not calculating things correctly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1386
diff changeset
9798 /* 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
9799 * 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
9800 * 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
9801 */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9802 for(z=0;z<cinfo->columns;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9803 ListView_SetColumnWidth(handle, z, columns[z] + 16);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9804
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9805 free(columns);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9806 free(text);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9807 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9808 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9809
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 68
diff changeset
9810 /*
487
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9811 * 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
9812 * Parameters:
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9813 * 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
9814 * 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
9815 * 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
9816 */
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
9817 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
9818 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9819 NOTIFYICONDATA tnid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9820
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9821 tnid.cbSize = sizeof(NOTIFYICONDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9822 tnid.hWnd = handle;
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9823 tnid.uID = (UINT)(uintptr_t)icon;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9824 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
9825 tnid.uCallbackMessage = WM_USER+2;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9826 tnid.hIcon = (HICON)icon;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9827 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
9828 _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
9829 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9830 tnid.szTip[0] = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9831
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9832 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
9833 }
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9834
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9835 /*
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9836 * 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
9837 * Parameters:
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9838 * 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
9839 * 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
9840 */
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
9841 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
9842 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9843 NOTIFYICONDATA tnid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9844
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9845 tnid.cbSize = sizeof(NOTIFYICONDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9846 tnid.hWnd = handle;
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9847 tnid.uID = (UINT)(uintptr_t)icon;
617
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 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
9850 }
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9851
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 481
diff changeset
9852 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9853 * Creates a rendering context widget (window) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9854 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9855 * id: An id to be used with dw_window_from_id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9856 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9857 * A handle to the widget or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9858 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9859 HWND API dw_render_new(unsigned long id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9860 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9861 Box *newbox = calloc(sizeof(Box), 1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9862 HWND tmp = CreateWindow(ObjectClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
9863 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9864 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
9865 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9866 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9867 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9868 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9869 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9870 newbox->pad = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9871 newbox->type = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9872 newbox->count = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9873 newbox->grouphwnd = (HWND)NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9874 newbox->cinfo.pOldProc = SubclassWindow(tmp, _rendwndproc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9875 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
9876 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
9877 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9878 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9879
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9880 /* Sets the current foreground drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9881 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9882 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9883 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9884 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9885 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9886 void API dw_color_foreground_set(unsigned long value)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9887 {
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9888 HPEN hPen = TlsGetValue(_hPen);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9889 HBRUSH hBrush = TlsGetValue(_hBrush);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9890 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
9891 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
9892 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
9893 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
9894 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
9895 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9896
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9897 value = _internal_color(value);
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9898 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
9899 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
9900 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
9901
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
9902 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
9903 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
9904 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
9905 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
9906 #endif
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
9907
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9908 DeleteObject(hPen);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9909 DeleteObject(hBrush);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9910 TlsSetValue(_foreground, (LPVOID)(uintptr_t)foreground);
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9911 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
9912 TlsSetValue(_hBrush, CreateSolidBrush(foreground));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9913 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9914
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9915 /* Sets the current background drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9916 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9917 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9918 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9919 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9920 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9921 void API dw_color_background_set(unsigned long value)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9922 {
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9923 COLORREF background;
617
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 value = _internal_color(value);
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9926 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
9927
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9928 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
9929 TlsSetValue(_background, (LPVOID)DW_RGB_TRANSPARENT);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9930 else
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
9931 TlsSetValue(_background, (LPVOID)(uintptr_t)background);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9932 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9933
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9934 /* 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
9935 * Parameters:
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9936 * value: current color
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9937 * Returns:
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9938 * The selected color or the current color if cancelled.
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9939 */
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9940 unsigned long API dw_color_choose(unsigned long value)
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9941 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9942 CHOOSECOLOR cc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9943 unsigned long newcolor;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9944 COLORREF acrCustClr[16] = {0};
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9945
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9946 value = _internal_color(value);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9947 if(value == DW_RGB_TRANSPARENT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9948 newcolor = DW_RGB_TRANSPARENT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9949 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9950 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
9951 ZeroMemory(&cc, sizeof(CHOOSECOLOR));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9952 cc.lStructSize = sizeof(CHOOSECOLOR);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9953 cc.rgbResult = newcolor;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9954 cc.hwndOwner = HWND_DESKTOP;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9955 cc.lpCustColors = (LPDWORD)acrCustClr;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9956 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9957 if (ChooseColor(&cc) == TRUE)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9958 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
9959 return newcolor;
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9960 }
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9961
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9962 /* Draw a point on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9963 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9964 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9965 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9966 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9967 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9968 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
9969 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9970 {
1682
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
9971 #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
9972 /* 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
9973 * 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
9974 */
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
9975 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
9976 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9977 HDC hdcPaint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9978
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9979 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9980 hdcPaint = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9981 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9982 hdcPaint = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9983 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9984 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9985
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
9986 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
9987 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
9988 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
9989 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9990 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9991
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9992 /* Draw a line on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9993 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9994 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9995 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9996 * x1: First X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9997 * y1: First Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9998 * x2: Second X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9999 * y2: Second Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10000 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10001 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
10002 {
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10003 #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
10004 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
10005 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
10006
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10007 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
10008 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
10009 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
10010 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
10011 else
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10012 return;
fd3b7784ab53 Initial commit for GDI+ anti-aliased drawing. Code currently does not work,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1602
diff changeset
10013
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10014 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
10015 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
10016 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
10017 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10018 HDC hdcPaint;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10019 HPEN oldPen;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10020
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10021 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10022 hdcPaint = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10023 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10024 hdcPaint = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10025 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10026 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10027
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10028 oldPen = SelectObject(hdcPaint, TlsGetValue(_hPen));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10029 MoveToEx(hdcPaint, x1, y1, NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10030 LineTo(hdcPaint, x2, y2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10031 SelectObject(hdcPaint, oldPen);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10032 /* For some reason Win98 (at least) fails
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10033 * 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
10034 */
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10035 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
10036 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10037 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
10038 #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
10039 }
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
10040
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10041 /* 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
10042 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
10043 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10044 POINT *points;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10045 int i;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10046
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10047 /*
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10048 * 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
10049 * 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
10050 * 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
10051 */
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10052 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
10053
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10054 if(points)
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10055 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10056 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
10057 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10058 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
10059 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
10060 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10061 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
10062 && 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
10063 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10064 /* 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
10065 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
10066 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
10067 /* ... 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
10068 (*npoints)++;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10069 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10070 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10071 return points;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10072 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10073
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10074 /* 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
10075 * Parameters:
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10076 * handle: Handle to the window.
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10077 * 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
10078 * 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
10079 * number of points
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10080 * x[]: X coordinates.
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10081 * y[]: Y coordinates.
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10082 */
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
10083 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
10084 {
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
10085 POINT *points = NULL;
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10086
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10087 /* Sanity check */
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10088 if(npoints < 1)
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10089 return;
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10090
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10091 #ifdef GDIPLUS
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10092 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10093 GpGraphics *graphics = NULL;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10094
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10095 if(handle)
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10096 GdipCreateFromHWND(handle, &graphics);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10097 else if(pixmap)
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10098 GdipCreateFromHDC(pixmap->hdc, &graphics);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10099 else
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10100 return;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10101
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10102 /* 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
10103 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
10104 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
10105
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10106 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
10107 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10108 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
10109 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10110 GpBrush *brush = TlsGetValue(_gpBrush);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10111
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10112 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
10113 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10114 else
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10115 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10116 GpPen *pen = TlsGetValue(_gpPen);
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10117
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10118 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
10119 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10120 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10121 GdipDeleteGraphics(graphics);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10122 }
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10123 #else
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10124 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10125 HDC hdcPaint;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10126
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10127 if ( handle )
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10128 hdcPaint = GetDC( handle );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10129 else if ( pixmap )
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10130 hdcPaint = pixmap->hdc;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10131 else
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10132 return;
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10133
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10134 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
10135 {
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10136 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
10137 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
10138
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10139 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
10140 Polygon( hdcPaint, points, npoints );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10141 else
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10142 Polyline( hdcPaint, points, npoints );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10143
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10144 SelectObject( hdcPaint, oldBrush );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10145 SelectObject( hdcPaint, oldPen );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10146 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10147
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10148 if ( !pixmap )
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10149 ReleaseDC( handle, hdcPaint );
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10150 }
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10151 #endif
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10152 if(points)
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10153 free(points);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10154 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10155
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
10156 /* 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
10157 * 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
10158 * 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
10159 * 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
10160 * 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
10161 * 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
10162 * 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
10163 * 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
10164 * 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
10165 */
1275
0b34e2cf0706 Updated dw_draw_rect and dw_draw_polygon to accept flags the same way as dw_draw_arc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1270
diff changeset
10166 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
10167 {
1682
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
10168 #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
10169 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
10170
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10171 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10172 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
10173 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
10174 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
10175 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10176 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10177
1682
ea749fb90f7e Some more GDI+ changes... implement dw_draw_point() using dw_draw_rect().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1681
diff changeset
10178 /* 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
10179 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
10180 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
10181
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10182 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
10183 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10184 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
10185
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10186 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
10187 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10188 else
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10189 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10190 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
10191
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10192 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
10193 }
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10194 GdipDeleteGraphics(graphics);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10195 #else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10196 HDC hdcPaint;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10197 RECT Rect;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10198
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10199 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10200 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
10201 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
10202 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
10203 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10204 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10205
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10206 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
10207 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
10208 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
10209 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10210 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
10211 if(!pixmap)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10212 ReleaseDC(handle, hdcPaint);
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10213 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10214 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10215
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10216 /* 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
10217 * Parameters:
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10218 * 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
10219 * 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
10220 * 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
10221 * 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
10222 * 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
10223 * 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
10224 * 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
10225 * 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
10226 * 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
10227 * 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
10228 */
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10229 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
10230 {
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10231 #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
10232 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
10233 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
10234
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10235 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10236 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
10237 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
10238 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
10239 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10240 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10241
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10242 /* 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
10243 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
10244 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
10245
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10246 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
10247 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10248 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
10249 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10250 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
10251
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10252 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
10253 }
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
10254 else
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10255 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
10256 }
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
10257 else
1681
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10258 {
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10259 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
10260 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
10261 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
10262 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
10263 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
10264 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
10265 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
10266
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10267 /* 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
10268 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
10269 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
10270 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
10271
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10272 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
10273 }
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10274 GdipDeleteGraphics(graphics);
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10275 #else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10276 HDC hdcPaint;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10277 HBRUSH oldBrush;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10278 HPEN oldPen;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10279 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
10280 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
10281 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
10282 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
10283
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10284 if(handle)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10285 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
10286 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
10287 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
10288 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10289 return;
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10290
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10291 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
10292 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
10293 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10294 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
10295 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
10296 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
10297 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
10298 else
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10299 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
10300 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
10301 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
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(!pixmap)
e02101d1b8ba Decided to move to all GDI+ drawing when GDIPLUS is defined...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1680
diff changeset
10304 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
10305 #endif
1261
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10306 }
61d0c5f84644 Initial attempt at adding dw_draw_arc() support on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1257
diff changeset
10307
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10308 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10309 /* 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
10310 * 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
10311 */
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10312 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
10313 {
1684
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10314 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
10315 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
10316 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
10317 {
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10318 if(mult)
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10319 {
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10320 if(x)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10321 *x *= ratiox;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10322 if(y)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10323 *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
10324 }
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10325 else
31dd366acfc8 Fixed calculating the GDI+ ratio based on the DPI on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1683
diff changeset
10326 {
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10327 if(x)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10328 *x /= ratiox;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10329 if(y)
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10330 *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
10331 }
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10332 }
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10333 }
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10334 #endif
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10335
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10336 /* Draw text on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10337 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10338 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10339 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10340 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10341 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10342 * text: Text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10343 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10344 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
10345 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10346 HDC hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10347 int mustdelete = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10348 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
10349 ColorInfo *cinfo = NULL;
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10350 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
10351 TCHAR *wtext = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10352
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10353 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10354 hdc = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10355 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10356 hdc = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10357 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10358 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10359
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10360 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10361 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
10362 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
10363 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
10364 else if(pixmap->handle)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10365 cinfo = (ColorInfo *)GetWindowLongPtr(pixmap->handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10366
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10367 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10368 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10369 hFont = _acquire_font(handle, cinfo->fontname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10370 mustdelete = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10371 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10372
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
10373 background = (COLORREF)(uintptr_t)TlsGetValue(_background);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10374 if(hFont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10375 oldFont = SelectObject(hdc, hFont);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
10376 SetTextColor(hdc, (COLORREF)(uintptr_t)TlsGetValue(_foreground));
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10377 if(background == DW_RGB_TRANSPARENT)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10378 SetBkMode(hdc, TRANSPARENT);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10379 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10380 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10381 SetBkMode(hdc, OPAQUE);
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
10382 SetBkColor(hdc, background);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10383 }
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10384 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10385 _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
10386 #endif
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10387 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
10388 if(oldFont)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10389 SelectObject(hdc, oldFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10390 if(mustdelete)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10391 DeleteObject(hFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10392 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10393 ReleaseDC(handle, hdc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10394 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10395
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
10396 /* 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
10397 * 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
10398 * 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
10399 * 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
10400 * 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
10401 * 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
10402 * 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
10403 */
514
08d770271709 More function name changes for Rexx/DW compatibility.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 513
diff changeset
10404 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
10405 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10406 HDC hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10407 int mustdelete = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10408 HFONT hFont = NULL, oldFont;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10409 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
10410 TCHAR *wtext = UTF8toWide(text);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10411
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10412 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10413 hdc = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10414 else if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10415 hdc = pixmap->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10416 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10417 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10418
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
10419 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
10420 {
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
10421 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
10422 }
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
10423 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10424 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10425 ColorInfo *cinfo;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10426
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10427 if(handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10428 cinfo = (ColorInfo *)GetWindowLongPtr(handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10429 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10430 cinfo = (ColorInfo *)GetWindowLongPtr(pixmap->handle, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10431
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10432 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10433 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10434 hFont = _acquire_font(handle, cinfo->fontname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10435 mustdelete = 1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10436 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10437 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10438 oldFont = SelectObject(hdc, hFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10439
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
10440 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
10441
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10442 if(width)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10443 *width = sz.cx;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10444
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10445 if(height)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10446 *height = sz.cy;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10447
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10448 #ifdef GDIPLUS
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10449 _convert_dpi(hdc, width, height, FALSE);
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10450 #endif
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
10451
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10452 SelectObject(hdc, oldFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10453 if(mustdelete)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10454 DeleteObject(hFont);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10455 if(!pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10456 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
10457 }
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
10458
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10459 /* Call this after drawing to the screen to make sure
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10460 * anything you have drawn is visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10461 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10462 void API dw_flush(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10463 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10464 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10465
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10466 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10467 * Creates a pixmap with given parameters.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10468 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10469 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10470 * width: Width of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10471 * height: Height of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10472 * depth: Color depth of the pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10473 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10474 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10475 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10476 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
10477 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10478 HPIXMAP pixmap;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10479 HDC hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10480
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10481 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10482 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10483
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10484 hdc = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10485
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10486 pixmap->width = width; pixmap->height = height;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10487
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10488 pixmap->handle = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10489 pixmap->hbm = CreateCompatibleBitmap(hdc, width, height);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10490 pixmap->hdc = CreateCompatibleDC(hdc);
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10491 pixmap->transcolor = DW_RGB_TRANSPARENT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10492
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10493 SelectObject(pixmap->hdc, pixmap->hbm);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10494
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10495 ReleaseDC(handle, hdc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10496
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10497 return pixmap;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10498 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10499
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
10500 #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
10501 /* 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
10502 * 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
10503 * 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
10504 */
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
10505 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
10506 {
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10507 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
10508 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
10509 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
10510 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
10511 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
10512
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10513 /* 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
10514 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
10515 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
10516
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10517 /* 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
10518 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
10519 {
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10520 /* Couldn't read the file header */
967
c8490b0d8577 Minor formatting fix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 966
diff changeset
10521 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
10522 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
10523 }
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10524
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
10525 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
10526 {
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10527 /* 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
10528 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
10529 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
10530 }
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10531
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10532 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
10533 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
10534 {
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10535 /* 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
10536 fclose(fp);
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10537 return 0;
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10538 }
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10539
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10540 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
10541 {
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10542 /* 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
10543 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
10544 }
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10545 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
10546 fclose(fp);
d90222530bb9 Added code to detect the actual color depth of loaded bitmap files on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 961
diff changeset
10547 return 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
10548 }
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
10549 #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
10550
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10551 /*
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10552 * Creates a pixmap from a file.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10553 * Parameters:
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10554 * 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
10555 * 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
10556 * DW pick the appropriate file extension.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10557 * (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
10558 * Returns:
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10559 * 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
10560 */
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10561 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
10562 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10563 HPIXMAP pixmap;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10564 BITMAP bm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10565 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
10566 #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
10567 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
10568 #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
10569
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10570 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
10571 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
10572
ed2119fc210d Initial commit of GDI+ image loader for Windows to allow use of other image formats...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1243
diff changeset
10573 #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
10574 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
10575 #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
10576 file = _alloca(strlen(filename) + 5);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10577 strcpy(file, filename);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10578
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10579 /* 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
10580 if(access(file, 04) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10581 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10582 /* Try with .bmp extention */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10583 strcat(file, ".bmp");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10584 if(access(file, 04) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10585 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10586 free(pixmap);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10587 free(file);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10588 return NULL;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10591
1732
03a76c4185a8 Fixes for building on Windows 2000. Use VS2008 and disabled GDIPLUS/AEROGLASS.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1731
diff changeset
10592 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
10593 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
10594 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10595
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10596 pixmap->handle = handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10597
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10598 if ( !pixmap->hbm )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10599 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10600 free(pixmap);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10601 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10602 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
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 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
10605
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10606 pixmap->hdc = CreateCompatibleDC( hdc );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10607 GetObject( pixmap->hbm, sizeof(bm), &bm );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10608 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
10609 SelectObject( pixmap->hdc, pixmap->hbm );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10610 ReleaseDC( handle, hdc );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10611 pixmap->transcolor = DW_RGB_TRANSPARENT;
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10612
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10613 return pixmap;
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10614 }
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10615
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 238
diff changeset
10616 /*
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10617 * 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
10618 * Parameters:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10619 * 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
10620 * 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
10621 * (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
10622 * 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
10623 * Returns:
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10624 * 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
10625 */
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10626 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
10627 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10628 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
10629 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
10630 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
10631 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
10632 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
10633
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10634 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
10635 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10636 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
10637 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10638
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10639 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
10640
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10641 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
10642
1090
b905fd8e7fd1 Use _tempnam() on Windows instead of tmpnam() for dw_*_from_data() functions.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1084
diff changeset
10643 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
10644 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
10645 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10646 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
10647 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
10648 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10649 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
10650 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
10651 #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
10652 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
10653 #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
10654 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
10655 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
10656 #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
10657 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10658 else
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10659 {
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
10660 _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
10661 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
10662 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
10663 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
10664 }
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
10665 _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
10666 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
10667 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10668
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10669 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
10670 {
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10671 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
10672 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
10673 return NULL;
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10674 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10675
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10676 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
10677
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10678 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
10679
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10680 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
10681
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10682 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
10683
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10684 ReleaseDC( handle, hdc );
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10685 pixmap->transcolor = DW_RGB_TRANSPARENT;
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10686
614
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10687 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
10688 }
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10689
0ab21b3b1d52 Attempt auto resizing of window based on widget sizes; not very successful.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 612
diff changeset
10690 /*
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10691 * 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
10692 */
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10693 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
10694 {
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
10695 if ( pixmap && pixmap->depth < 32)
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10696 {
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10697 pixmap->transcolor = _internal_color(color);
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10698 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10699 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10700
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10701 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10702 * Creates a pixmap from internal resource graphic specified by id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10703 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10704 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10705 * id: Resource ID associated with requested pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10706 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10707 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10708 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10709 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10710 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10711 HPIXMAP pixmap;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10712 BITMAP bm;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10713 HDC hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10714
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10715 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10716 return NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10717
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10718 hdc = GetDC(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10719
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10720 pixmap->hbm = LoadBitmap(DWInstance, MAKEINTRESOURCE(id));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10721 pixmap->hdc = CreateCompatibleDC(hdc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10722
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10723 GetObject(pixmap->hbm, sizeof(BITMAP), (void *)&bm);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10724
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10725 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
10726 pixmap->depth = bm.bmBitsPixel;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10727
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10728 SelectObject(pixmap->hdc, pixmap->hbm);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10729
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10730 ReleaseDC(handle, hdc);
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10731 pixmap->transcolor = DW_RGB_TRANSPARENT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10732
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10733 return pixmap;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10734 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10735
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10736 /*
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
10737 * 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
10738 * 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
10739 * 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
10740 * 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
10741 * 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
10742 * 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
10743 * 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
10744 * 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
10745 * 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
10746 */
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10747 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
10748 {
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10749 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
10750 {
1238
700ce342aab8 Divided _acquire_font() into two parts on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1231
diff changeset
10751 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
10752
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10753 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
10754 {
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10755 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
10756 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
10757 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
10758 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
10759 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
10760 }
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10761 }
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10762 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
10763 }
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10764
091ed7c20b3f Implemented dw_pixmap_set_font() on Windows. Added to export files on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1143
diff changeset
10765 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10766 * Destroys an allocated pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10767 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10768 * pixmap: Handle to a pixmap returned by
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10769 * dw_pixmap_new..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10770 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10771 void API dw_pixmap_destroy(HPIXMAP pixmap)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10772 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10773 if(pixmap)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10774 {
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
10775 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
10776 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
10777 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
10778 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
10779 free(pixmap);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10780 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10781 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10782
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10783 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10784 * Copies from one item to another.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10785 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10786 * dest: Destination window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10787 * destp: Destination pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10788 * xdest: X coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10789 * ydest: Y coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10790 * width: Width of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10791 * height: Height of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10792 * src: Source window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10793 * srcp: Source pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10794 * xsrc: X coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10795 * ysrc: Y coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10796 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10797 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
10798 {
1243
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10799 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
10800 }
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10801
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10802 /*
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10803 * 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
10804 * Parameters:
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10805 * 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
10806 * 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
10807 * 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
10808 * 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
10809 * 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
10810 * 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
10811 * 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
10812 * 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
10813 * 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
10814 * 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
10815 * 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
10816 * 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
10817 * Returns:
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10818 * 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
10819 */
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10820 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
10821 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10822 HDC hdcdest;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10823 HDC hdcsrc;
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10824 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
10825 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
10826
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10827 /* Do some sanity checks */
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10828 if ( dest )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10829 hdcdest = GetDC( dest );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10830 else if ( destp )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10831 hdcdest = destp->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10832 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
10833 return DW_ERROR_GENERAL;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10834
634
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10835 if ( src )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10836 hdcsrc = GetDC( src );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10837 else if ( srcp )
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10838 hdcsrc = srcp->hdc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10839 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
10840 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
10841
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10842 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
10843 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
10844
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10845 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
10846 {
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10847 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
10848 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
10849 }
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10850
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10851 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10852 /* 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
10853 _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
10854 _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
10855 _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
10856 _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
10857 #endif
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
10858
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10859 /* 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
10860 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
10861 {
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10862 /* Don't do anything */
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10863 }
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10864 /* 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
10865 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
10866 {
1243
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10867 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
10868 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10869 else
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10870 {
960
841b66d2d1b9 Added initial support for transparent pixmap/bitmaps on Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 926
diff changeset
10871 /* 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
10872 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
10873 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
10874 else
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10875 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
10876 }
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10877 if ( !destp )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10878 ReleaseDC( dest, hdcdest );
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10879 if ( !srcp )
c6a216c8174f Support for setting transparent colour for bitmaps
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 630
diff changeset
10880 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
10881
c191a562c14a Added new dw_pixmap_stretch_bitblt() function on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1238
diff changeset
10882 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10883 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10884
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
10885 /* 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
10886 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
10887 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10888 int *info = (int *)data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10889
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10890 if(data)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10891 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10892 Beep(info[0], info[1]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10893 free(data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10894 }
527
e0ea29c3d1eb Fixed dw_window_pointer() so it works on Windows. Tried to fix the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 526
diff changeset
10895 }
e0ea29c3d1eb Fixed dw_window_pointer() so it works on Windows. Tried to fix the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 526
diff changeset
10896
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10897 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10898 * Emits a beep.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10899 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10900 * freq: Frequency.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10901 * dur: Duration.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10902 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10903 void API dw_beep(int freq, int dur)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10904 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10905 int *info = malloc(sizeof(int) * 2);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10906
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10907 if(info)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10908 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10909 info[0] = freq;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10910 info[1] = dur;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10911
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10912 _beginthread(_beepthread, 100, (void *)info);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10913 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10914 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10915
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10916 /* Open a shared library and return a handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10917 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10918 * name: Base name of the shared library.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10919 * handle: Pointer to a module handle,
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10920 * will be filled in with the handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10921 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10922 int API dw_module_load(char *name, HMOD *handle)
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10923 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10924 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
10925 return DW_ERROR_UNKNOWN;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10926
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
10927 *handle = LoadLibrary(UTF8toWide(name));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10928 return (NULL == *handle);
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10929 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10930
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10931 /* Queries the address of a symbol within open handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10932 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10933 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10934 * name: Name of the symbol you want the address of.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10935 * func: A pointer to a function pointer, to obtain
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10936 * the address.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10937 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10938 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
10939 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10940 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
10941 return DW_ERROR_UNKNOWN;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10942
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10943 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
10944 return DW_ERROR_UNKNOWN;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10945
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10946 *func = (void*)GetProcAddress(handle, name);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10947 return (NULL == *func);
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10948 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10949
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10950 /* Frees the shared library previously opened.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10951 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10952 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10953 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10954 int API dw_module_close(HMOD handle)
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10955 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10956 return FreeLibrary(handle);
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10957 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
10958
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10959 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10960 * Returns the handle to an unnamed mutex semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10961 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10962 HMTX API dw_mutex_new(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10963 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10964 return (HMTX)CreateMutex(NULL, FALSE, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10965 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10966
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10967 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10968 * Closes a semaphore created by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10969 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10970 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10971 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10972 void API dw_mutex_close(HMTX mutex)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10973 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10974 CloseHandle((HANDLE)mutex);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10975 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10976
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10977 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10978 * Tries to gain access to the semaphore, if it can't it blocks.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10979 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10980 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10981 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
10982 void API dw_mutex_lock(HMTX mutex)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10983 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10984 if(_dwtid == dw_thread_id())
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10985 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10986 int rc = WaitForSingleObject((HANDLE)mutex, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10987
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10988 while(rc == WAIT_TIMEOUT)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10989 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10990 dw_main_sleep(1);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10991 rc = WaitForSingleObject((HANDLE)mutex, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10992 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10993 }
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 61
diff changeset
10994 else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
10995 WaitForSingleObject((HANDLE)mutex, INFINITE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10996 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10997
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10998 /*
1158
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
10999 * 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
11000 * Parameters:
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11001 * 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
11002 * Returns:
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11003 * 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
11004 */
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11005 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
11006 {
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11007 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
11008 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
11009 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
11010 }
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11011
f86f556ff29d Added dw_mutex_trylock() that functions like dw_mutex_lock() except
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1155
diff changeset
11012 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11013 * Reliquishes the access to the semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11014 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11015 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11016 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11017 void API dw_mutex_unlock(HMTX mutex)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11018 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11019 ReleaseMutex((HANDLE)mutex);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11020 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11021
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11022 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11023 * Returns the handle to an unnamed event semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11024 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11025 HEV API dw_event_new(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11026 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
11027 return CreateEvent(NULL, TRUE, FALSE, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11028 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11029
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11030 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11031 * Resets a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11032 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11033 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11034 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11035 int API dw_event_reset(HEV eve)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11036 {
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
11037 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
11038 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
11039 return DW_ERROR_GENERAL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11040 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11041
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11042 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11043 * Posts a semaphore created by dw_event_new(). Causing all threads
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11044 * waiting on this event in dw_event_wait to continue.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11045 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11046 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11047 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11048 int API dw_event_post(HEV eve)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11049 {
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
11050 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
11051 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
11052 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
11053 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11054
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11055 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11056 * Waits on a semaphore created by dw_event_new(), until the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11057 * event gets posted or until the timeout expires.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11058 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11059 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11060 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11061 int API dw_event_wait(HEV eve, unsigned long timeout)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11062 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11063 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11064
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
11065 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
11066 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
11067 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
11068 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
11069 return DW_ERROR_TIMEOUT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11070 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
11071 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
11072 return DW_ERROR_GENERAL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11073 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11074
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11075 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11076 * Closes a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11077 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11078 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11079 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11080 int API dw_event_close(HEV *eve)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11081 {
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
11082 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
11083 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
11084 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
11085 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11086
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11087 /* 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
11088 * 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
11089 * 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
11090 * 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
11091 * 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
11092 * 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
11093 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11094 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
11095 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11096 SECURITY_ATTRIBUTES sa;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11097
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11098 sa.nLength = sizeof( SECURITY_ATTRIBUTES);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11099 sa.lpSecurityDescriptor = &_dwsd;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11100 sa.bInheritHandle = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11101
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11102 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
11103 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11104
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11105 /* 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
11106 * 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
11107 * 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
11108 * 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
11109 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11110 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
11111 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11112 return 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
11113 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11114
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11115 /* 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
11116 * 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
11117 * 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
11118 * 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
11119 * 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
11120 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11121 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
11122 {
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
11123 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
11124 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
11125 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
11126 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11127
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11128 /* 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
11129 * 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
11130 * 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
11131 * 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
11132 * 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
11133 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11134 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
11135 {
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
11136 if(SetEvent(eve))
1170
4b94c9f5ddeb Missing return on Windows... surprised this compiled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1160
diff changeset
11137 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
11138 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
11139 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11140
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11141 /* 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
11142 * 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
11143 * 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
11144 * 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
11145 * 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
11146 * 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
11147 * 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
11148 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11149 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
11150 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11151 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11152
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
11153 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
11154 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
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 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
11157 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
11158 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
11159 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
11160 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
11161 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11162
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11163 /* 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
11164 * 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
11165 * 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
11166 * 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
11167 * 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
11168 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11169 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
11170 {
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
11171 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
11172 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
11173 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
11174 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11175
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11176 /*
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11177 * 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
11178 * 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
11179 * 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
11180 * 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
11181 * 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
11182 * 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
11183 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11184 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
11185 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11186 SECURITY_ATTRIBUTES sa;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11187 HSHM handle;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11188
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11189 sa.nLength = sizeof(SECURITY_ATTRIBUTES);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11190 sa.lpSecurityDescriptor = &_dwsd;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11191 sa.bInheritHandle = FALSE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11192
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11193 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
11194
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11195 if(!handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11196 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11197
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11198 *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
11199
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11200 if(!*dest)
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 CloseHandle(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11203 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11204 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11205
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11206 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
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 /*
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 * 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
11211 * 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
11212 * 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
11213 * 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
11214 * 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
11215 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11216 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
11217 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11218 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
11219
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11220 if(!handle)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11221 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11222
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11223 *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
11224
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11225 if(!*dest)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11226 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11227 CloseHandle(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11228 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11229 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11230
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11231 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
11232 }
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
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 /*
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 * 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
11236 * 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
11237 * 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
11238 * 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
11239 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 555
diff changeset
11240 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
11241 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11242 UnmapViewOfFile(ptr);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11243 CloseHandle(handle);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11244 return 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11245 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11246
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11247 /*
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11248 * Encapsulate thread creation on Win32.
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11249 */
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11250 void _dwthreadstart(void *data)
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11251 {
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11252 void (* threadfunc)(void *) = NULL;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11253 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
11254 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
11255 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
11256 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
11257 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
11258 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
11259 #endif
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11260
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11261 _init_thread();
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11262
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11263 threadfunc = (void (*)(void *))tmp[0];
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11264 threadfunc(tmp[1]);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11265
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11266 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
11267 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
11268 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
11269 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
11270 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
11271 #ifdef GDIPLUS
1631
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
11272 if((brush = TlsGetValue(_gpBrush)))
0e6c2aeed041 Got anti-aliased drawing working with GDI+ on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1630
diff changeset
11273 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
11274 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
11275 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
11276 #endif
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11277 }
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11278
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11279 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11280 * Creates a new thread with a starting point of func.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11281 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11282 * func: Function which will be run in the new thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11283 * data: Parameter(s) passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11284 * stack: Stack size of new thread (OS/2 and Windows only).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11285 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11286 DWTID API dw_thread_new(void *func, void *data, int stack)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11287 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
11288 #if defined(__CYGWIN__)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11289 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
11290 #else
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11291 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
11292
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11293 tmp[0] = func;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11294 tmp[1] = data;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11295
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11296 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
11297 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11298 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11299
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11300 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11301 * Ends execution of current thread immediately.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11302 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11303 void API dw_thread_end(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11304 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
11305 #if !defined(__CYGWIN__)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11306 _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
11307 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11308 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11309
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11310 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11311 * Returns the current thread's ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11312 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11313 DWTID API dw_thread_id(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11314 {
58
5c66a108aa47 Fixed example test app at the bottom of the source to use new dw_init
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
11315 #if defined(__CYGWIN__)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11316 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
11317 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11318 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
11319 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11320 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11321
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11322 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11323 * Cleanly terminates a DW session, should be signal handler safe.
1861
c836603d3f14 Add dw_shutdown() function which does the same thing as dw_exit() ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1858
diff changeset
11324 */
c836603d3f14 Add dw_shutdown() function which does the same thing as dw_exit() ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1858
diff changeset
11325 void API dw_shutdown(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11326 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11327 OleUninitialize();
1528
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
11328 #ifdef AEROGLASS
5facb5380944 Added dw_main_quit() function for exiting the dw_main() loop.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1521
diff changeset
11329 /* 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
11330 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
11331 #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
11332 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
11333 DestroyWindow(hwndTooltip);
1861
c836603d3f14 Add dw_shutdown() function which does the same thing as dw_exit() ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1858
diff changeset
11334 }
c836603d3f14 Add dw_shutdown() function which does the same thing as dw_exit() ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1858
diff changeset
11335
c836603d3f14 Add dw_shutdown() function which does the same thing as dw_exit() ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1858
diff changeset
11336 /*
c836603d3f14 Add dw_shutdown() function which does the same thing as dw_exit() ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1858
diff changeset
11337 * Cleanly terminates a DW session, should be signal handler safe.
c836603d3f14 Add dw_shutdown() function which does the same thing as dw_exit() ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1858
diff changeset
11338 * Parameters:
c836603d3f14 Add dw_shutdown() function which does the same thing as dw_exit() ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1858
diff changeset
11339 * exitcode: Exit code reported to the operating system.
c836603d3f14 Add dw_shutdown() function which does the same thing as dw_exit() ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1858
diff changeset
11340 */
c836603d3f14 Add dw_shutdown() function which does the same thing as dw_exit() ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1858
diff changeset
11341 void API dw_exit(int exitcode)
c836603d3f14 Add dw_shutdown() function which does the same thing as dw_exit() ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1858
diff changeset
11342 {
c836603d3f14 Add dw_shutdown() function which does the same thing as dw_exit() ...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1858
diff changeset
11343 dw_shutdown();
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11344 exit(exitcode);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11345 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11346
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11347 /*
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11348 * Creates a splitbar window (widget) with given parameters.
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11349 * Parameters:
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 281
diff changeset
11350 * type: Value can be DW_VERT or DW_HORZ.
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11351 * topleft: Handle to the window to be top or left.
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11352 * bottomright: Handle to the window to be bottom or right.
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11353 * Returns:
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11354 * A handle to a splitbar window or NULL on failure.
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11355 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11356 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id)
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11357 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11358 HWND tmp = CreateWindow(SplitbarClassName,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
11359 NULL,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11360 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
11361 0,0,0,0,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11362 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11363 (HMENU)(uintptr_t)id,
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11364 DWInstance,
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11365 NULL);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11366
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11367 if(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11368 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11369 HWND tmpbox = dw_box_new(DW_VERT, 0);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11370 float *percent = (float *)malloc(sizeof(float));
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11371
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11372 dw_box_pack_start(tmpbox, topleft, 1, 1, TRUE, TRUE, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11373 SetParent(tmpbox, tmp);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11374 dw_window_set_data(tmp, "_dw_topleft", DW_POINTER(tmpbox));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11375
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11376 tmpbox = dw_box_new(DW_VERT, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11377 dw_box_pack_start(tmpbox, bottomright, 1, 1, TRUE, TRUE, 0);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11378 SetParent(tmpbox, tmp);
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11379 dw_window_set_data(tmp, "_dw_bottomright", DW_POINTER(tmpbox));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11380 *percent = 50.0;
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11381 dw_window_set_data(tmp, "_dw_percent", DW_POINTER(percent));
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11382 dw_window_set_data(tmp, "_dw_type", DW_INT_TO_POINTER(type));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11383 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11384 return tmp;
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11385 }
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11386
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11387 /*
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11388 * Sets the position of a splitbar (pecentage).
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11389 * Parameters:
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11390 * handle: The handle to the splitbar returned by dw_splitbar_new().
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11391 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11392 void API dw_splitbar_set(HWND handle, float percent)
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11393 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11394 float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent");
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11395 int type = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_type"));
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11396 unsigned long width, height;
124
edf615d8266e Use float instead of int for percent on Windows. And a minor safety check
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
11397
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11398 if(mypercent)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11399 *mypercent = percent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11400
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11401 dw_window_get_pos_size(handle, NULL, NULL, &width, &height);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11402
1449
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1448
diff changeset
11403 if(width > 0 && height > 0)
632346743f46 Fixed dw_window_redraw() on Windows not recalculating notebook page contents if the notebook size didn't change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1448
diff changeset
11404 _handle_splitbar_resize(handle, percent, type, width, height);
118
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11405 }
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11406
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11407 /*
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11408 * Gets the position of a splitbar (pecentage).
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11409 * Parameters:
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11410 * handle: The handle to the splitbar returned by dw_splitbar_new().
c170181668b7 Initial new splitbar code on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 111
diff changeset
11411 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11412 float API dw_splitbar_get(HWND handle)
124
edf615d8266e Use float instead of int for percent on Windows. And a minor safety check
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
11413 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11414 float *percent = (float *)dw_window_get_data(handle, "_dw_percent");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11415
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11416 if(percent)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11417 return *percent;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11418 return 0.0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11419 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11420
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11421 /*
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11422 * Creates a calendar window (widget) with given parameters.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11423 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11424 * type: Value can be DW_VERT or DW_HORZ.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11425 * topleft: Handle to the window to be top or left.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11426 * bottomright: Handle to the window to be bottom or right.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11427 * Classname: SysMonthCal32
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11428 * Returns:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11429 * A handle to a calendar window or NULL on failure.
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11430 */
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11431 HWND API dw_calendar_new(unsigned long id)
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11432 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11433 RECT rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11434 MONTHDAYSTATE mds[3];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11435 HWND tmp = CreateWindowEx(WS_EX_CLIENTEDGE,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11436 MONTHCAL_CLASS,
1614
702de58e9ef8 Initial UTF8 support for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1613
diff changeset
11437 NULL,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11438 WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | MCS_DAYSTATE,
1370
e705051d841c Test change on Windows to allow dw_container_cursor() to work on unsized containers.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1367
diff changeset
11439 0,0,0,0,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11440 DW_HWND_OBJECT,
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11441 (HMENU)(uintptr_t)id,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11442 DWInstance,
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11443 NULL);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11444 if ( tmp )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11445 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11446 // Get the size required to show an entire month.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11447 MonthCal_GetMinReqRect(tmp, &rc);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11448 // Resize the control now that the size values have been obtained.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11449 SetWindowPos(tmp, NULL, 0, 0,
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11450 rc.right, rc.bottom,
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11451 SWP_NOZORDER | SWP_NOMOVE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11452 mds[0] = mds[1] = mds[2] = (MONTHDAYSTATE)0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11453 MonthCal_SetDayState(tmp,3,mds);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11454 return tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11455 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11456 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11457 return NULL;
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11458 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11459
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11460 /*
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11461 * Sets the current date of a calendar
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11462 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11463 * handle: The handle to the calendar returned by dw_calendar_new().
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11464 * year: The year to set the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11465 * month: The month to set the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11466 * day: The day to set the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11467 */
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11468 void API dw_calendar_set_date(HWND handle, unsigned int year, unsigned int month, unsigned int day)
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11469 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11470 MONTHDAYSTATE mds[3];
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11471 SYSTEMTIME date;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11472 date.wYear = year;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11473 date.wMonth = month;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11474 date.wDay = day;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11475 if ( MonthCal_SetCurSel( handle, &date ) )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11476 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11477 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11478 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11479 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11480 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11481 mds[0] = mds[1] = mds[2] = (MONTHDAYSTATE)0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11482 MonthCal_SetDayState(handle,3,mds);
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11483 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11484
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11485 /*
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11486 * Gets the date from the calendar
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11487 * Parameters:
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11488 * handle: The handle to the calendar returned by dw_calendar_new().
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11489 * year: Pointer to the year to get the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11490 * month: Pointer to the month to get the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11491 * day: Pointer to the day to get the date to
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11492 */
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11493 void API dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day)
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11494 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11495 SYSTEMTIME date;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11496 if ( MonthCal_GetCurSel( handle, &date ) )
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11497 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11498 *year = date.wYear;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11499 *month = date.wMonth;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11500 *day = date.wDay;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11501 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11502 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11503 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11504 *year = *month = *day = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11505 }
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11506 }
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11507
1799
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11508 /* Internal function to set the focus from the window thread */
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11509 void _dw_set_focus(HWND handle)
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11510 {
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11511 SetFocus(handle);
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11512 }
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11513
593
d3871f747160 Add calendar widget.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 589
diff changeset
11514 /*
1795
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11515 * Sets the current focus item for a window/dialog.
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11516 * Parameters:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11517 * handle: Handle to the dialog item to be focused.
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11518 * Remarks:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11519 * This is for use after showing the window/dialog.
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11520 */
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11521 void API dw_window_set_focus(HWND handle)
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11522 {
1799
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11523 if(_dwtid == (DWTID)-1)
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11524 SetFocus(handle);
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11525 else
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
11526 dw_window_function(handle, (void *)_dw_set_focus, handle);
1795
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11527 }
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11528
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11529 /*
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11530 * Sets the default focus item for a window/dialog.
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11531 * Parameters:
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11532 * window: Toplevel window or dialog.
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11533 * defaultitem: Handle to the dialog item to be default.
1795
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11534 * Remarks:
9304241b7b33 Added new dw_window_set_focus() function and attempted to fix...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1792
diff changeset
11535 * This is for use before showing the window/dialog.
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11536 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11537 void API dw_window_default(HWND window, HWND defaultitem)
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11538 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11539 Box *thisbox = (Box *)GetWindowLongPtr(window, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11540
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11541 if(thisbox)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11542 thisbox->defaultitem = defaultitem;
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11543 }
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11544
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
11545 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11546 * Sets window to click the default dialog item when an ENTER is pressed.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11547 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11548 * window: Window (widget) to look for the ENTER press.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11549 * next: Window (widget) to move to next (or click)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11550 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11551 void API dw_window_click_default(HWND window, HWND next)
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11552 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11553 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11554
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11555 if (cinfo)
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11556 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11557 cinfo->clickdefault = next;
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11558 }
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11559 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11560
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
11561 /*
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11562 * Gets the contents of the default clipboard as text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11563 * Parameters:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11564 * None.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11565 * Returns:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11566 * Pointer to an allocated string of text or NULL if clipboard empty or contents could not
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11567 * be converted to text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11568 */
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11569 char * API dw_clipboard_get_text(void)
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11570 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11571 HANDLE handle;
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11572 char *ret = NULL;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11573 TCHAR *tmp;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11574 #ifdef UNICODE
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11575 int type = CF_UNICODETEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11576 #else
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11577 int type = CF_TEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11578 #endif
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11579
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11580 if ( !OpenClipboard( NULL ) )
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11581 return ret;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11582
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11583 if ( ( handle = GetClipboardData(type) ) == NULL )
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11584 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11585 CloseClipboard();
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11586 return ret;
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11587 }
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11588
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11589 if ( (tmp = GlobalLock(handle)) && _tcslen(tmp) )
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11590 {
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11591 ret = _strdup(WideToUTF8(tmp));
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11592 GlobalUnlock(handle);
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11593 }
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11594 CloseClipboard();
969
69f620df0c47 Step 1 in modernization of the Win32 module.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 968
diff changeset
11595 return ret;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11596 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11597
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11598 /*
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11599 * Sets the contents of the default clipboard to the supplied text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11600 * Parameters:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11601 * Text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11602 */
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11603 void API dw_clipboard_set_text( char *str, int len )
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11604 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11605 HGLOBAL ptr1;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11606 LPTSTR ptr2;
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11607 TCHAR *buf;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11608 #ifdef UNICODE
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11609 int type = CF_UNICODETEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11610 char *src = calloc(len + 1, 1);
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11611
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11612 memcpy(src, str, len);
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11613 buf = UTF8toWide(src);
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11614 free(src);
1762
b472a892ce1f Added code to plug several resource leaks on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1761
diff changeset
11615 len = (int)_tcslen(buf);
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11616 #else
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11617 int type = CF_TEXT;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11618
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11619 buf = str;
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11620 #endif
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11621
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11622 if ( !OpenClipboard( NULL ) )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11623 return;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11624
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11625 ptr1 = GlobalAlloc( GMEM_MOVEABLE|GMEM_DDESHARE, (len + 1) * sizeof(TCHAR) );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11626
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11627 if ( !ptr1 )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11628 return;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11629
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11630 ptr2 = GlobalLock( ptr1 );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11631
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11632 memcpy(ptr2, buf, (len + 1) * sizeof(TCHAR));
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11633 GlobalUnlock( ptr1 );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11634 EmptyClipboard();
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11635
1754
eeec5ceec7a5 Enable unicode cut and paste on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1750
diff changeset
11636 SetClipboardData( type, ptr1 );
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11637
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11638 CloseClipboard();
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11639 GlobalFree( ptr1 );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11640 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11641
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 611
diff changeset
11642 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11643 * Returns some information about the current operating environment.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11644 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11645 * env: Pointer to a DWEnv struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11646 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11647 void API dw_environment_query(DWEnv *env)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11648 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11649 if(!env)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11650 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11651
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11652 /* Get the Windows version. */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11653
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11654 env->MajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11655 env->MinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11656
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11657 /* Get the build number for Windows NT/Windows 2000. */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11658
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11659 env->MinorBuild = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11660
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11661 if (dwVersion < 0x80000000)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11662 {
716
67f2e890b9df Added "Windows Vista" and "Windows 7" to the operating system names reported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
11663 if(env->MajorVersion == 5 && env->MinorVersion == 0)
67f2e890b9df Added "Windows Vista" and "Windows 7" to the operating system names reported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
11664 strcpy(env->osName, "Windows 2000");
67f2e890b9df Added "Windows Vista" and "Windows 7" to the operating system names reported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
11665 else if(env->MajorVersion == 5 && env->MinorVersion > 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11666 strcpy(env->osName, "Windows XP");
716
67f2e890b9df Added "Windows Vista" and "Windows 7" to the operating system names reported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
11667 else if(env->MajorVersion == 6 && env->MinorVersion == 0)
67f2e890b9df Added "Windows Vista" and "Windows 7" to the operating system names reported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
11668 strcpy(env->osName, "Windows Vista");
1629
d97e3f7f4e47 Add Windows 8 string to the environment query.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1628
diff changeset
11669 else if(env->MajorVersion == 6 && env->MinorVersion == 1)
716
67f2e890b9df Added "Windows Vista" and "Windows 7" to the operating system names reported.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 672
diff changeset
11670 strcpy(env->osName, "Windows 7");
1629
d97e3f7f4e47 Add Windows 8 string to the environment query.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1628
diff changeset
11671 else if(env->MajorVersion == 6 && env->MinorVersion > 1)
d97e3f7f4e47 Add Windows 8 string to the environment query.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1628
diff changeset
11672 strcpy(env->osName, "Windows 8");
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11673 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11674 strcpy(env->osName, "Windows NT");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11675
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11676 env->MajorBuild = (DWORD)(HIWORD(dwVersion));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11677 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11678 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11679 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11680 strcpy(env->osName, "Windows 95/98/ME");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11681 env->MajorBuild = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11682 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11683
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11684 strcpy(env->buildDate, __DATE__);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11685 strcpy(env->buildTime, __TIME__);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11686 env->DWMajorVersion = DW_MAJOR_VERSION;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11687 env->DWMinorVersion = DW_MINOR_VERSION;
1160
924c8087a755 Attempt to use the subversion revision number as the sub version number.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1158
diff changeset
11688 #ifdef VER_REV
924c8087a755 Attempt to use the subversion revision number as the sub version number.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1158
diff changeset
11689 env->DWSubVersion = VER_REV;
924c8087a755 Attempt to use the subversion revision number as the sub version number.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1158
diff changeset
11690 #else
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11691 env->DWSubVersion = DW_SUB_VERSION;
1160
924c8087a755 Attempt to use the subversion revision number as the sub version number.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1158
diff changeset
11692 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11693 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11694
1294
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11695 /* Helper to make sure all /s are \s */
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11696 void _to_dos(TCHAR *dst, TCHAR *src)
1294
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11697 {
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11698 int x = 0;
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11699
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11700 while(src[x])
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11701 {
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11702 if(src[x] == TEXT('/'))
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11703 dst[x] = TEXT('\\');
1294
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11704 else
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11705 dst[x] = src[x];
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11706 x++;
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11707 }
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11708 dst[x] = 0;
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11709 }
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11710
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11711 #define BROWSEBUFSIZE 1000
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11712
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11713 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11714 * Opens a file dialog and queries user selection.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11715 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11716 * title: Title bar text for dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11717 * defpath: The default path of the open dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11718 * ext: Default file extention.
449
787cc1e27897 Add support for directory browsing under Win32. DW_DIRECTORY_OPEN can be
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 448
diff changeset
11719 * flags: DW_FILE_OPEN or DW_FILE_SAVE or DW_DIRECTORY_OPEN.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11720 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11721 * NULL on error. A malloced buffer containing
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11722 * the file path on success.
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
11723 *
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11724 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11725 char * API dw_file_browse(char *title, char *defpath, char *ext, int flags)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11726 {
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11727 OPENFILENAME of = {0};
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11728 TCHAR filenamebuf[BROWSEBUFSIZE+1] = {0}, *fbuf = filenamebuf;
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11729 TCHAR filterbuf[BROWSEBUFSIZE+1] = {0};
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11730 TCHAR *exten = UTF8toWide(ext);
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11731 TCHAR *dpath = UTF8toWide(defpath);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11732 int rc;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11733
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11734 if ( flags == DW_DIRECTORY_OPEN )
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11735 {
913
81059acce901 If we aren't building a DLL use the simple folder browser and don't include the HTML browser...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 912
diff changeset
11736 /* If we aren't building a DLL, use the more simple browser */
81059acce901 If we aren't building a DLL use the simple folder browser and don't include the HTML browser...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 912
diff changeset
11737 #ifndef BUILD_DLL
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11738 BROWSEINFO bi = {0};
1362
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11739 TCHAR szDir[MAX_PATH];
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11740 LPITEMIDLIST pidl;
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11741 LPMALLOC pMalloc;
412af8059331 Attempt to get it building with Mingw again... builds but crashes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1358
diff changeset
11742
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11743 if (SUCCEEDED(SHGetMalloc(&pMalloc)))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11744 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11745 bi.hwndOwner = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11746 bi.pszDisplayName = 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11747 bi.pidlRoot = 0;
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1694
diff changeset
11748 bi.lpszTitle = UTF8toWide(title);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11749 bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11750 bi.lpfn = NULL; /*BrowseCallbackProc*/
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11751
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11752 pidl = SHBrowseForFolder(&bi);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11753 if (pidl)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11754 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11755 if (SHGetPathFromIDList(pidl,szDir))
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11756 {
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11757 _tcsncpy(filenamebuf,szDir,BROWSEBUFSIZE);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11758 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11759
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11760 /* In C++: pMalloc->Free(pidl); pMalloc->Release(); */
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11761 pMalloc->lpVtbl->Free(pMalloc,pidl);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11762 pMalloc->lpVtbl->Release(pMalloc);
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1694
diff changeset
11763 return _strdup(WideToUTF8(filenamebuf));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11764 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11765 }
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11766 #else
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11767 if ( XBrowseForFolder( NULL,
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1694
diff changeset
11768 (LPCTSTR)dpath,
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11769 -1,
1704
873304f581be Fix Unicode issues with the directory browser on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1694
diff changeset
11770 (LPCTSTR)UTF8toWide(title),
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11771 (LPTSTR)filenamebuf,
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11772 BROWSEBUFSIZE,
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11773 FALSE ) )
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11774 {
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
11775 return _strdup( WideToUTF8(fbuf) );
630
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11776 }
6e84e055d981 Attempt to make click_default work properly.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 628
diff changeset
11777 #endif
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11778 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11779 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11780 {
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11781 DWORD att = defpath ? GetFileAttributes(UTF8toWide(defpath)) : INVALID_FILE_ATTRIBUTES;
1294
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11782
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11783 if (ext)
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11784 {
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11785 /*
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11786 * The following mess is because sprintf() trunates at first \0
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11787 * and format of filter is eg: "c files (*.c)\0*.c\0All Files\0*.*\0\0"
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11788 */
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11789 int len;
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11790 TCHAR *ptr = filterbuf;
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11791 TCHAR *start = filterbuf;
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11792
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11793 len = _sntprintf( ptr, BROWSEBUFSIZE - (ptr - start), TEXT("%s Files (*.%s)"), exten, exten );
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11794 ptr = ptr + len + 1; /* past first \0 */
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11795 len = _sntprintf( ptr, BROWSEBUFSIZE - (ptr - start), TEXT("*.%s"), exten );
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11796 ptr = ptr + len + 1; /* past next \0 */
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11797 len = _sntprintf( ptr, BROWSEBUFSIZE - (ptr - start), TEXT("All Files") );
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11798 ptr = ptr + len + 1; /* past next \0 */
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11799 len = _sntprintf( ptr, BROWSEBUFSIZE - (ptr - start), TEXT("*.*") );
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11800 }
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11801
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11802 memset( &of, 0, sizeof(OPENFILENAME) );
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11803
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11804 of.lStructSize = sizeof(OPENFILENAME);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11805 of.hwndOwner = HWND_DESKTOP;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11806 of.hInstance = DWInstance;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11807 of.lpstrTitle = UTF8toWide(title);
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11808 of.lpstrInitialDir = TEXT(".");
1294
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11809 if(att != INVALID_FILE_ATTRIBUTES && (att & FILE_ATTRIBUTE_DIRECTORY))
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11810 of.lpstrInitialDir = dpath;
1294
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11811 else if(defpath)
1662
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11812 _to_dos(filenamebuf, dpath);
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11813 of.lpstrFile = filenamebuf;
620df4222086 Fixes for dw_file_browse() on Windows in Unicode mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1660
diff changeset
11814 of.lpstrFilter = filterbuf;
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11815 of.nFilterIndex = 1;
1765
15414cbe857f Fix warnings with Visual C largely in debug mode.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1763
diff changeset
11816 of.nMaxFile = BROWSEBUFSIZE;
1294
4bc8b6ffbe1e Code changes to enable default filename on Windows with dw_file_browse().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1293
diff changeset
11817 /*of.lpstrDefExt = ext;*/
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11818 of.Flags = OFN_NOCHANGEDIR;
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11819
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11820 if (flags & DW_FILE_SAVE)
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11821 {
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11822 of.Flags |= OFN_OVERWRITEPROMPT;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11823 rc = GetSaveFileName(&of);
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11824 }
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11825 else
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11826 {
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11827 of.Flags |= OFN_FILEMUSTEXIST;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11828 rc = GetOpenFileName(&of);
628
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11829 }
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11830
7d93356f250a Fixed dw_file_browse(); filters now work on extension passed in.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 617
diff changeset
11831 if (rc)
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11832 return _strdup(WideToUTF8(of.lpstrFile));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11833 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11834 return NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11835 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11836
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11837 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11838 * Execute and external program in a seperate session.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11839 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11840 * program: Program name with optional path.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11841 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11842 * params: An array of pointers to string arguements.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11843 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11844 * -1 on error.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11845 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11846 int API dw_exec(char *program, int type, char **params)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11847 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11848 char **newparams;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11849 int retcode, count = 0, z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11850
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11851 while(params[count])
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11852 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11853 count++;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11854 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11855
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11856 newparams = (char **)malloc(sizeof(char *) * (count+1));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11857
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11858 for(z=0;z<count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11859 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11860 newparams[z] = malloc(strlen(params[z])+3);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11861 strcpy(newparams[z], "\"");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11862 strcat(newparams[z], params[z]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11863 strcat(newparams[z], "\"");
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11864 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11865 newparams[count] = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11866
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
11867 /* Why does this return intptr_t ... can the PID exceed an integer value? */
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
11868 retcode = (int)_spawnvp(P_NOWAIT, program, (const char * const *)newparams);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11869
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11870 for(z=0;z<count;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11871 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11872 free(newparams[z]);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11873 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11874 free(newparams);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11875
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11876 return retcode;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11877 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11878
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11879 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11880 * Loads a web browser pointed at the given URL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11881 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11882 * url: Uniform resource locator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11883 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
11884 int API dw_browse(char *url)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11885 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11886 char *browseurl = url;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11887 int retcode;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11888
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11889 if(strlen(url) > 7 && strncmp(url, "file://", 7) == 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11890 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11891 int len, z;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11892
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11893 browseurl = &url[7];
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
11894 len = (int)strlen(browseurl);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11895
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11896 for(z=0;z<len;z++)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11897 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11898 if(browseurl[z] == '|')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11899 browseurl[z] = ':';
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11900 if(browseurl[z] == '/')
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11901 browseurl[z] = '\\';
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11902 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11903 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11904
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
11905 retcode = DW_POINTER_TO_INT(ShellExecute(NULL, TEXT("open"), UTF8toWide(browseurl), NULL, NULL, SW_SHOWNORMAL));
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
11906 if(retcode<33 && retcode != 2)
1115
03cd2f3e929d Fixed a documentation and template error regarding dw_browse() return code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1090
diff changeset
11907 return DW_ERROR_UNKNOWN;
03cd2f3e929d Fixed a documentation and template error regarding dw_browse() return code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1090
diff changeset
11908 return DW_ERROR_NONE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11909 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11910
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11911 typedef struct _dwprint
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11912 {
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11913 PRINTDLG pd;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11914 DOCINFO di;
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
11915 int (DWSIGNAL *drawfunc)(HPRINT, HPIXMAP, int, void *);
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11916 void *drawdata;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11917 unsigned long flags;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11918 } DWPrint;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11919
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11920 /*
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11921 * Creates a new print object.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11922 * Parameters:
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
11923 * jobname: Name of the print job to show in the queue.
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11924 * flags: Flags to initially configure the print object.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11925 * pages: Number of pages to print.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11926 * drawfunc: The pointer to the function to be used as the callback.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11927 * drawdata: User data to be passed to the handler function.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11928 * Returns:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11929 * A handle to the print object or NULL on failure.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11930 */
1152
58b5374355ab Added print jobname parameter to dw_print_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1147
diff changeset
11931 HPRINT API dw_print_new(char *jobname, unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata)
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11932 {
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11933 DWPrint *print;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11934
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11935 if(!drawfunc || !(print = calloc(1, sizeof(DWPrint))))
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11936 return NULL;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11937
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11938 print->drawfunc = drawfunc;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11939 print->drawdata = drawdata;
1139
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11940 print->pd.lStructSize = sizeof(PRINTDLG);
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11941 print->pd.hwndOwner = HWND_DESKTOP;
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11942 print->pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC;
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11943 print->pd.nCopies = 1;
1140
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
11944 print->pd.nFromPage = 1;
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
11945 print->pd.nToPage = pages;
1139
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11946 print->pd.nMinPage = 1;
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11947 print->pd.nMaxPage = pages;
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11948
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11949 if(!PrintDlg(&(print->pd)))
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11950 {
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11951 free(print);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11952 return NULL;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11953 }
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11954
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11955 print->di.cbSize = sizeof(DOCINFO);
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
11956 print->di.lpszDocName = jobname ? UTF8toWide(jobname) : TEXT("Dynamic Windows Print Job");
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11957 return print;
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11958 }
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11959
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11960 /*
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11961 * Runs the print job, causing the draw page callbacks to fire.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11962 * Parameters:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11963 * print: Handle to the print object returned by dw_print_new().
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11964 * flags: Flags to run the print job.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11965 * Returns:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11966 * DW_ERROR_UNKNOWN on error or DW_ERROR_NONE on success.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11967 */
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11968 int API dw_print_run(HPRINT print, unsigned long flags)
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
11969 {
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11970 DWPrint *p = print;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11971 HPIXMAP pixmap;
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11972 int x, width, height, result = DW_ERROR_UNKNOWN;
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11973
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11974 if(!p)
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1140
diff changeset
11975 return result;
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11976
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11977 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1140
diff changeset
11978 return result;
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11979
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11980 width = GetDeviceCaps(p->pd.hDC, HORZRES);
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11981 height = GetDeviceCaps(p->pd.hDC, VERTRES);
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11982
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11983 pixmap->hbm = CreateCompatibleBitmap(p->pd.hDC, width, height);
1140
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
11984 pixmap->hdc = p->pd.hDC;
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11985 pixmap->transcolor = DW_RGB_TRANSPARENT;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11986
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
11987 #ifdef GDIPLUS
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
11988 /* Convert the size based on the DPI */
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11989 _convert_dpi(pixmap->hdc, &width, &height, FALSE);
1683
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
11990 #endif
19c34a1c1489 Added code to do DPI conversion on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1682
diff changeset
11991
1694
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11992 pixmap->width = width;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11993 pixmap->height = height;
31f16da1052a Fix warnings building with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1684
diff changeset
11994
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11995 SelectObject(pixmap->hdc, pixmap->hbm);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11996
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11997 /* Start the job */
1139
65b750569a0a *sigh* formatting cleanups from that last commit.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1138
diff changeset
11998 StartDoc(p->pd.hDC, &(p->di));
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
11999
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12000 /* Cycle through each page */
1140
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
12001 for(x=p->pd.nFromPage-1; x<p->pd.nToPage && p->drawfunc; x++)
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12002 {
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12003 StartPage(p->pd.hDC);
1140
1c63bf62e0b0 Fix for issues in printing pages on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1139
diff changeset
12004 p->drawfunc(print, pixmap, x, p->drawdata);
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12005 EndPage(p->pd.hDC);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12006 }
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1140
diff changeset
12007 if(p->drawfunc)
1338
b23ae7d9f729 AbortDoc() needs to be issued instead of EndDoc() to cancel printing on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1336
diff changeset
12008 {
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1140
diff changeset
12009 result = DW_ERROR_NONE;
1338
b23ae7d9f729 AbortDoc() needs to be issued instead of EndDoc() to cancel printing on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1336
diff changeset
12010 EndDoc(p->pd.hDC);
b23ae7d9f729 AbortDoc() needs to be issued instead of EndDoc() to cancel printing on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1336
diff changeset
12011 }
b23ae7d9f729 AbortDoc() needs to be issued instead of EndDoc() to cancel printing on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1336
diff changeset
12012 else
b23ae7d9f729 AbortDoc() needs to be issued instead of EndDoc() to cancel printing on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1336
diff changeset
12013 AbortDoc(p->pd.hDC);
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12014 /* Free memory */
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12015 dw_pixmap_destroy(pixmap);
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12016 free(p);
1143
b1b23de965d7 Fixed using a pointer after being free()ed on Windows and Mac.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1140
diff changeset
12017 return result;
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12018 }
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12019
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12020 /*
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12021 * Cancels the print job, typically called from a draw page callback.
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12022 * Parameters:
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12023 * print: Handle to the print object returned by dw_print_new().
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12024 */
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12025 void API dw_print_cancel(HPRINT print)
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12026 {
1138
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12027 DWPrint *p = print;
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12028
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12029 if(p)
caeae1ff0289 Initial implementation of the print object on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1137
diff changeset
12030 p->drawfunc = NULL;
1137
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12031 }
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12032
e24e5a13ff2c Added code to test the new print functions in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1132
diff changeset
12033 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12034 * Returns a pointer to a static buffer which containes the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12035 * current user directory. Or the root directory (C:\ on
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12036 * OS/2 and Windows).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12037 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12038 char * API dw_user_dir(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12039 {
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
12040 static char _user_dir[1024] = {0};
907
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12041
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12042 if(!_user_dir[0])
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12043 {
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12044 HANDLE hToken = 0;
1036
c2013f1ef354 Remove creation of bold default font at startup.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1028
diff changeset
12045
907
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12046 /* Use the Windows API to get the user's profile directory */
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12047 if(OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12048 {
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12049 DWORD BufSize = 1024;
1663
a76fb5f1a6c8 Fixes for building in Unicode mode with MinGW on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1662
diff changeset
12050 TCHAR TmpBuf[1024], *Buf = TmpBuf;
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
12051
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
12052 GetUserProfileDirectory(hToken, Buf, &BufSize);
907
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12053 CloseHandle(hToken);
1617
f8d1da63fb77 Add code to allow building DW.DLL as Unicode on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1614
diff changeset
12054 strncpy(_user_dir, WideToUTF8(Buf), 1023);
907
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12055 }
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12056 /* If it fails set it to the root directory */
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12057 if(!_user_dir[0])
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12058 {
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12059 strcpy(_user_dir, "C:\\");
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12060 }
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12061 }
3e393a9375c4 Implemented _dw_user_dir() using GetUserProfileDirectory() on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 903
diff changeset
12062 return _user_dir;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12063 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12064
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12065 /*
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12066 * Returns a pointer to a static buffer which containes the
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12067 * private application data directory.
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12068 */
1384
156e32814c83 Cleanup of the previous commits and added Unix support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1381
diff changeset
12069 char * API dw_app_dir(void)
1381
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12070 {
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12071 return _dw_exec_dir;
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12072 }
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12073
3ba4853d5b78 Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1380
diff changeset
12074 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12075 * Call a function from the window (widget)'s context.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12076 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12077 * handle: Window handle of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12078 * function: Function pointer to be called.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12079 * data: Pointer to the data to be passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12080 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12081 void API dw_window_function(HWND handle, void *function, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12082 {
1799
165f6ffa8176 Attempted fix at dw_window_set_focus() from non-main threads on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1796
diff changeset
12083 SendMessage(_toplevel_window(handle), WM_USER, (WPARAM)function, (LPARAM)data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12084 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12085
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12086 /* Functions for managing the user data lists that are associated with
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12087 * a given window handle. Used in dw_window_set_data() and
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12088 * dw_window_get_data().
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12089 */
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
12090 UserData *_find_userdata(UserData **root, char *varname)
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12091 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12092 UserData *tmp = *root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12093
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12094 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12095 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
12096 if(_stricmp(tmp->varname, varname) == 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12097 return tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12098 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12099 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12100 return NULL;
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12101 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12102
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
12103 int _new_userdata(UserData **root, char *varname, void *data)
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
12104 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12105 UserData *new = _find_userdata(root, varname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12106
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12107 if(new)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12108 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12109 new->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12110 return TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12111 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12112 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12113 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12114 new = malloc(sizeof(UserData));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12115 if(new)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12116 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
12117 new->varname = _strdup(varname);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12118 new->data = data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12119
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12120 new->next = NULL;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12121
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12122 if (!*root)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12123 *root = new;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12124 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12125 {
1303
ca02c24e80c9 Experimental change to menu code on Windows to allow dw_window_enable/disable to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1297
diff changeset
12126 UserData *prev = *root, *tmp = prev->next;
ca02c24e80c9 Experimental change to menu code on Windows to allow dw_window_enable/disable to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1297
diff changeset
12127
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12128 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12129 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12130 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12131 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12132 }
1303
ca02c24e80c9 Experimental change to menu code on Windows to allow dw_window_enable/disable to work on menu item handles.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1297
diff changeset
12133 prev->next = new;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12134 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12135 return TRUE;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12136 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12137 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12138 return FALSE;
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12139 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12140
180
4207e64d4689 Fixing leaks on Windows and OS/2.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 177
diff changeset
12141 int _remove_userdata(UserData **root, char *varname, int all)
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12142 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12143 UserData *prev = NULL, *tmp = *root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12144
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12145 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12146 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
12147 if(all || _stricmp(tmp->varname, varname) == 0)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12148 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12149 if(!prev)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12150 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12151 *root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12152 free(tmp->varname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12153 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12154 if(!all)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12155 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12156 tmp = *root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12157 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12158 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12159 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12160 /* If all is true we should
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12161 * never get here.
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12162 */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12163 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12164 free(tmp->varname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12165 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12166 return 0;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12167 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12168 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12169 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12170 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12171 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12172 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12173 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12174 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12175 return 0;
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12176 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12177
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12178 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12179 * Add a named user data item to a window handle.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12180 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12181 * window: Window handle of signal to be called back.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12182 * dataname: A string pointer identifying which signal to be hooked.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12183 * data: User data to be passed to the handler function.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12184 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12185 void API dw_window_set_data(HWND window, char *dataname, void *data)
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12186 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12187 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12188
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12189 if(!cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12190 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12191 if(!dataname)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12192 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12193
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12194 cinfo = calloc(1, sizeof(ColorInfo));
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12195 cinfo->fore = cinfo->back = -1;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12196 SetWindowLongPtr(window, GWLP_USERDATA, (LONG_PTR)cinfo);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12197 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12198
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12199 if(cinfo)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12200 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12201 if(data)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12202 _new_userdata(&(cinfo->root), dataname, data);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12203 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12204 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12205 if(dataname)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12206 _remove_userdata(&(cinfo->root), dataname, FALSE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12207 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12208 _remove_userdata(&(cinfo->root), NULL, TRUE);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12209 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12210 }
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12211 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12212
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12213 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12214 * Gets a named user data item to a window handle.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12215 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12216 * window: Window handle of signal to be called back.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12217 * dataname: A string pointer identifying which signal to be hooked.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12218 * data: User data to be passed to the handler function.
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12219 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12220 void * API dw_window_get_data(HWND window, char *dataname)
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12221 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12222 ColorInfo *cinfo = (ColorInfo *)GetWindowLongPtr(window, GWLP_USERDATA);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12223
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12224 if(cinfo && cinfo->root && dataname)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12225 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12226 UserData *ud = _find_userdata(&(cinfo->root), dataname);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12227 if(ud)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12228 return ud->data;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12229 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12230 return NULL;
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12231 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 89
diff changeset
12232
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12233 /*
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12234 * Add a callback to a timer event.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12235 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12236 * interval: Milliseconds to delay between calls.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12237 * sigfunc: The pointer to the function to be used as the callback.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12238 * data: User data to be passed to the handler function.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12239 * Returns:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12240 * Timer ID for use with dw_timer_disconnect(), 0 on error.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12241 */
200
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
12242 int API dw_timer_connect(int interval, void *sigfunc, void *data)
446dd8cea477 Removed window parameter on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 197
diff changeset
12243 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12244 if(sigfunc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12245 {
1601
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
12246 /* Warning: This seems to return UINT_PTR on some systems...
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
12247 * which may exceed the storage of int that our API uses.
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
12248 */
71e0a3ad07f7 Enable level 3 warnings in DEBUG mode with Visual C to show deprecation warnings.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1581
diff changeset
12249 int timerid = (int)SetTimer(NULL, 0, interval, _TimerProc);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12250
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12251 if(timerid)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12252 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12253 _new_signal(WM_TIMER, NULL, timerid, sigfunc, NULL, data);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12254 return timerid;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12255 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12256 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12257 return 0;
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12258 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12259
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12260 /*
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12261 * Removes timer callback.
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12262 * Parameters:
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12263 * id: Timer ID returned by dw_timer_connect().
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12264 */
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12265 void API dw_timer_disconnect(int id)
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12266 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12267 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12268
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12269 /* 0 is an invalid timer ID */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12270 if(!id)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12271 return;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12272
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12273 KillTimer(NULL, id);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12274
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12275 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12276 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12277 if(tmp->id == id)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12278 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12279 if(prev)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12280 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12281 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12282 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12283 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12284 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12285 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12286 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12287 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12288 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12289 tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12290 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12291 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12292 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12293 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12294 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12295 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12296 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12297 }
197
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12298 }
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12299
f3718165f0b2 Implemented scrollbars and timers on Windows, and added scrollbar to the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 194
diff changeset
12300 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12301 * Add a callback to a window event.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12302 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12303 * window: Window handle of signal to be called back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12304 * signame: A string pointer identifying which signal to be hooked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12305 * sigfunc: The pointer to the function to be used as the callback.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12306 * data: User data to be passed to the handler function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12307 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12308 void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12309 {
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12310 dw_signal_connect_data(window, signame, sigfunc, NULL, data);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12311 }
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12312
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12313 /*
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12314 * Add a callback to a window event with a closure callback.
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12315 * Parameters:
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12316 * window: Window handle of signal to be called back.
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12317 * signame: A string pointer identifying which signal to be hooked.
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12318 * sigfunc: The pointer to the function to be used as the callback.
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12319 * discfunc: The pointer to the function called when this handler is removed.
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12320 * data: User data to be passed to the handler function.
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12321 */
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12322 void API dw_signal_connect_data(HWND window, char *signame, void *sigfunc, void *discfunc, void *data)
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12323 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12324 ULONG message = 0, id = 0;
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 if (window && signame && sigfunc)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12327 {
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
12328 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
12329 window = _normalize_handle(window);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12330
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12331 if ((message = _findsigmessage(signame)) != 0)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12332 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12333 /* Handle special case of the menu item */
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12334 if (message == WM_COMMAND && window < (HWND)65536)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12335 {
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
12336 char buffer[16];
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12337 HWND owner;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12338
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12339 _snprintf(buffer, 15, "_dw_id%d", (int)(intptr_t)window);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12340 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
12341
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
12342 /* 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
12343 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
12344
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12345 if (owner)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12346 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12347 id = (ULONG)(uintptr_t)window;
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12348 window = owner;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12349 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12350 }
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12351 _new_signal(message, window, id, sigfunc, discfunc, data);
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12352 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12353 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12354 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12355
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12356 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12357 * Removes callbacks for a given window with given name.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12358 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12359 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12360 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12361 void API dw_signal_disconnect_by_name(HWND window, char *signame)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
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 ULONG message;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12365
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12366 if(!window || !signame || (message = _findsigmessage(signame)) == 0)
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 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12370 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12371 if(((window < (HWND)65536 && (int)(intptr_t)window == tmp->id) || tmp->window == window) && tmp->message == message)
1309
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
12372 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
12373 void (DWSIGNAL *discfunc)(HWND, void *) = (void (*)(HWND, void *))tmp->discfunction;
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12374
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12375 if(discfunc)
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12376 {
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12377 discfunc(tmp->window, tmp->data);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12378 }
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12379
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12380 if(prev)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12381 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12382 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12383 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12384 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12385 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12386 else
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 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12389 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12390 tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12391 }
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 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12394 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12395 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12396 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12397 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12398 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12399 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12400
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12401 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12402 * Removes all callbacks for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12403 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12404 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12405 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12406 void API dw_signal_disconnect_by_window(HWND window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12407 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12408 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12409
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12410 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12411 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12412 if((window < (HWND)65536 && (int)(intptr_t)window == tmp->id) || tmp->window == window)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12413 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
12414 void (DWSIGNAL *discfunc)(HWND, void *) = (void (*)(HWND, void *))tmp->discfunction;
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12415
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12416 if(discfunc)
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12417 {
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12418 discfunc(tmp->window, tmp->data);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12419 }
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12420
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12421 if(prev)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12422 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12423 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12424 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12425 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12426 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12427 else
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 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12430 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12431 tmp = Root;
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 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12434 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12435 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12436 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12437 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12438 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12439 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12440 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12441
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12442 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12443 * Removes all callbacks for a given window with specified data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12444 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12445 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12446 * data: Pointer to the data to be compared against.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12447 */
177
e3dd5c765775 Fixes for Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 173
diff changeset
12448 void API dw_signal_disconnect_by_data(HWND window, void *data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12449 {
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12450 SignalHandler *prev = NULL, *tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12451
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12452 while(tmp)
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12453 {
1839
22225eb286e5 Fixes for building with MINGW64 (specifically http://tdm-gcc.tdragon.net/).
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1838
diff changeset
12454 if(((window < (HWND)65536 && (int)(intptr_t)window == tmp->id) || tmp->window == window) && tmp->data == data)
1309
e73c41653de8 Added support on OS/2 and Windows for looking for signal handlers with menu IDs...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1306
diff changeset
12455 {
1858
952a41463240 Make sure callbacks have their calling convention specified explicitly on Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1857
diff changeset
12456 void (DWSIGNAL *discfunc)(HWND, void *) = (void (*)(HWND, void *))tmp->discfunction;
1853
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12457
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12458 if(discfunc)
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12459 {
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12460 discfunc(tmp->window, tmp->data);
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12461 }
4790589f52a9 Initial commit for new dw_signal_connect_data() function...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1846
diff changeset
12462
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
12463 if(prev)
617
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12464 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12465 prev->next = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12466 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12467 tmp = prev->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12468 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12469 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12470 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12471 Root = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12472 free(tmp);
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12473 tmp = Root;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12474 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12475 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12476 else
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12477 {
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12478 prev = tmp;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12479 tmp = tmp->next;
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12480 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12481 }
4d1d9aeb0bbc Add rudimentary internal logging for debug
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 614
diff changeset
12482 }
1784
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12483
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12484 /*
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12485 * 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
12486 * Parameters:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12487 * 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
12488 * Returns:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12489 * 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
12490 * 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
12491 */
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12492 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
12493 {
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12494 #ifdef UNICODE
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12495 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
12496 #else
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12497 return NULL;
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12498 #endif
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12499 }
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12500
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12501 /*
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12502 * 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
12503 * Parameters:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12504 * 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
12505 * Returns:
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12506 * 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
12507 * 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
12508 */
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12509 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
12510 {
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12511 #ifdef UNICODE
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12512 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
12513 #else
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12514 return NULL;
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12515 #endif
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12516 }
86ace55df07b Added UTF8/Wide conversion functions on OS/2 and Windows...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 1769
diff changeset
12517