2013-07-28 22:08:34 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Our WinMain() functions, and Win32-specific stuff to set up our windows
|
|
|
|
// and otherwise handle our interface to the operating system. Everything
|
|
|
|
// outside win32/... should be standard C++ and gl.
|
|
|
|
//
|
|
|
|
// Copyright 2008-2013 Jonathan Westhues.
|
|
|
|
//-----------------------------------------------------------------------------
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
#include "solvespace.h"
|
|
|
|
#include <time.h>
|
2008-02-09 13:52:01 +00:00
|
|
|
#include <shellapi.h>
|
Replaced RGB-color integers with dedicated data structure
RGB colors were represented using a uint32_t with the red, green and blue
values stuffed into the lower three octets (i.e. 0x00BBGGRR), like
Microsoft's COLORREF. This approach did not lend itself to type safety,
however, so this change replaces it with an RgbColor class that provides
the same infomation plus a handful of useful methods to work with it. (Note
that sizeof(RgbColor) == sizeof(uint32_t), so this change should not lead
to memory bloat.)
Some of the new methods/fields replace what were previously macro calls;
e.g. RED(c) is now c.red, REDf(c) is now c.redF(). The .Equals() method is
now used instead of == to compare colors.
RGB colors still need to be represented as packed integers in file I/O and
preferences, so the methods .FromPackedInt() and .ToPackedInt() are
provided. Also implemented are Cnf{Freeze,Thaw}Color(), type-safe wrappers
around Cnf{Freeze,Thaw}Int() that facilitate I/O with preferences.
(Cnf{Freeze,Thaw}Color() are defined outside of the system-dependent code
to minimize the footprint of the latter; because the same can be done with
Cnf{Freeze,Thaw}Bool(), those are also moved out of the system code with
this commit.)
Color integers were being OR'ed with 0x80000000 in some places for two
distinct purposes: One, to indicate use of a default color in
glxFillMesh(); this has been replaced by use of the .UseDefault() method.
Two, to indicate to TextWindow::Printf() that the format argument of a
"%Bp"/"%Fp" specifier is an RGB color rather than a color "code" from
TextWindow::bgColors[] or TextWindow::fgColors[] (as the specifier can
accept either); instead, we define a new flag "z" (as in "%Bz" or "%Fz") to
indicate an RGBcolor pointer, leaving "%Bp"/"%Fp" to indicate a color code
exclusively.
(This also allows TextWindow::meta[][].bg to be a char instead of an int,
partly compensating for the new .bgRgb field added immediately after.)
In array declarations, RGB colors could previously be specified as 0 (often
in a terminating element). As that no longer works, we define NULL_COLOR,
which serves much the same purpose for RgbColor variables as NULL serves
for pointers.
2013-10-16 20:00:58 +00:00
|
|
|
#undef RGB // our definition clashes with Microsoft's
|
|
|
|
#define RGB(r, g, b) ((COLORREF)0)
|
2008-03-25 10:02:13 +00:00
|
|
|
#include <commctrl.h>
|
2008-04-18 11:11:48 +00:00
|
|
|
#include <commdlg.h>
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2013-09-20 19:25:14 +00:00
|
|
|
#ifdef HAVE_SPACEWARE_INPUT
|
|
|
|
# include <si/si.h>
|
|
|
|
# include <si/siapp.h>
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
# undef uint32_t // thanks but no thanks
|
2013-09-20 19:25:14 +00:00
|
|
|
#endif
|
2009-07-20 19:05:33 +00:00
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
#define FREEZE_SUBKEY "SolveSpace"
|
|
|
|
#include "freeze.h"
|
|
|
|
|
2008-05-27 06:36:59 +00:00
|
|
|
// For the edit controls
|
|
|
|
#define EDIT_WIDTH 220
|
|
|
|
#define EDIT_HEIGHT 21
|
2008-03-25 10:02:13 +00:00
|
|
|
|
|
|
|
HINSTANCE Instance;
|
|
|
|
|
2008-04-01 10:48:44 +00:00
|
|
|
HWND TextWnd;
|
2008-03-25 10:02:13 +00:00
|
|
|
HWND TextWndScrollBar;
|
2008-05-27 06:36:59 +00:00
|
|
|
HWND TextEditControl;
|
2010-04-26 07:52:49 +00:00
|
|
|
HGLRC TextGl;
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-04-01 10:48:44 +00:00
|
|
|
HWND GraphicsWnd;
|
2010-04-26 07:52:49 +00:00
|
|
|
HGLRC GraphicsGl;
|
2008-04-21 10:12:04 +00:00
|
|
|
HWND GraphicsEditControl;
|
2008-04-01 10:48:44 +00:00
|
|
|
struct {
|
|
|
|
int x, y;
|
|
|
|
} LastMousePos;
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2008-05-28 10:10:31 +00:00
|
|
|
char RecentFile[MAX_RECENT][MAX_PATH];
|
|
|
|
HMENU SubMenus[100];
|
|
|
|
HMENU RecentOpenMenu, RecentImportMenu;
|
|
|
|
|
2009-09-23 10:59:59 +00:00
|
|
|
HMENU ContextMenu, ContextSubmenu;
|
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
int ClientIsSmallerBy;
|
|
|
|
|
2010-04-26 07:52:49 +00:00
|
|
|
HFONT FixedFont;
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2013-09-20 19:25:14 +00:00
|
|
|
#ifdef HAVE_SPACEWARE_INPUT
|
2009-07-20 19:05:33 +00:00
|
|
|
// The 6-DOF input device.
|
|
|
|
SiHdl SpaceNavigator = SI_NO_HANDLE;
|
2013-09-20 19:25:14 +00:00
|
|
|
#endif
|
2009-07-20 19:05:33 +00:00
|
|
|
|
2010-01-16 09:22:44 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Routines to display message boxes on screen. Do our own, instead of using
|
|
|
|
// MessageBox, because that is not consistent from version to version and
|
|
|
|
// there's word wrap problems.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
HWND MessageWnd, OkButton;
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
bool MessageDone;
|
2013-08-26 18:58:35 +00:00
|
|
|
const char *MessageString;
|
2010-01-16 09:22:44 +00:00
|
|
|
|
|
|
|
static LRESULT CALLBACK MessageProc(HWND hwnd, UINT msg, WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
2008-04-12 15:17:58 +00:00
|
|
|
{
|
2010-01-16 09:22:44 +00:00
|
|
|
switch (msg) {
|
|
|
|
case WM_COMMAND:
|
|
|
|
if((HWND)lParam == OkButton && wParam == BN_CLICKED) {
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
MessageDone = true;
|
2010-01-16 09:22:44 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_CLOSE:
|
|
|
|
case WM_DESTROY:
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
MessageDone = true;
|
2010-01-16 09:22:44 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_PAINT: {
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
HDC hdc = BeginPaint(hwnd, &ps);
|
|
|
|
int row = 0, col = 0, i;
|
|
|
|
SelectObject(hdc, FixedFont);
|
Replaced RGB-color integers with dedicated data structure
RGB colors were represented using a uint32_t with the red, green and blue
values stuffed into the lower three octets (i.e. 0x00BBGGRR), like
Microsoft's COLORREF. This approach did not lend itself to type safety,
however, so this change replaces it with an RgbColor class that provides
the same infomation plus a handful of useful methods to work with it. (Note
that sizeof(RgbColor) == sizeof(uint32_t), so this change should not lead
to memory bloat.)
Some of the new methods/fields replace what were previously macro calls;
e.g. RED(c) is now c.red, REDf(c) is now c.redF(). The .Equals() method is
now used instead of == to compare colors.
RGB colors still need to be represented as packed integers in file I/O and
preferences, so the methods .FromPackedInt() and .ToPackedInt() are
provided. Also implemented are Cnf{Freeze,Thaw}Color(), type-safe wrappers
around Cnf{Freeze,Thaw}Int() that facilitate I/O with preferences.
(Cnf{Freeze,Thaw}Color() are defined outside of the system-dependent code
to minimize the footprint of the latter; because the same can be done with
Cnf{Freeze,Thaw}Bool(), those are also moved out of the system code with
this commit.)
Color integers were being OR'ed with 0x80000000 in some places for two
distinct purposes: One, to indicate use of a default color in
glxFillMesh(); this has been replaced by use of the .UseDefault() method.
Two, to indicate to TextWindow::Printf() that the format argument of a
"%Bp"/"%Fp" specifier is an RGB color rather than a color "code" from
TextWindow::bgColors[] or TextWindow::fgColors[] (as the specifier can
accept either); instead, we define a new flag "z" (as in "%Bz" or "%Fz") to
indicate an RGBcolor pointer, leaving "%Bp"/"%Fp" to indicate a color code
exclusively.
(This also allows TextWindow::meta[][].bg to be a char instead of an int,
partly compensating for the new .bgRgb field added immediately after.)
In array declarations, RGB colors could previously be specified as 0 (often
in a terminating element). As that no longer works, we define NULL_COLOR,
which serves much the same purpose for RgbColor variables as NULL serves
for pointers.
2013-10-16 20:00:58 +00:00
|
|
|
SetTextColor(hdc, 0x000000);
|
2010-01-16 09:22:44 +00:00
|
|
|
SetBkMode(hdc, TRANSPARENT);
|
|
|
|
for(i = 0; MessageString[i]; i++) {
|
|
|
|
if(MessageString[i] == '\n') {
|
|
|
|
col = 0;
|
|
|
|
row++;
|
|
|
|
} else {
|
2010-04-26 07:52:49 +00:00
|
|
|
TextOut(hdc, col*SS.TW.CHAR_WIDTH + 10,
|
|
|
|
row*SS.TW.LINE_HEIGHT + 10,
|
|
|
|
&(MessageString[i]), 1);
|
2010-01-16 09:22:44 +00:00
|
|
|
col++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EndPaint(hwnd, &ps);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
2008-02-09 13:52:01 +00:00
|
|
|
}
|
2008-06-25 05:14:49 +00:00
|
|
|
|
2010-01-16 09:22:44 +00:00
|
|
|
return 1;
|
2008-04-12 15:17:58 +00:00
|
|
|
}
|
|
|
|
|
2010-01-16 09:22:44 +00:00
|
|
|
HWND CreateWindowClient(DWORD exStyle, char *className, char *windowName,
|
|
|
|
DWORD style, int x, int y, int width, int height, HWND parent,
|
|
|
|
HMENU menu, HINSTANCE instance, void *param)
|
2008-02-09 13:52:01 +00:00
|
|
|
{
|
2010-01-16 09:22:44 +00:00
|
|
|
HWND h = CreateWindowEx(exStyle, className, windowName, style, x, y,
|
|
|
|
width, height, parent, menu, instance, param);
|
|
|
|
|
|
|
|
RECT r;
|
|
|
|
GetClientRect(h, &r);
|
|
|
|
width = width - (r.right - width);
|
|
|
|
height = height - (r.bottom - height);
|
|
|
|
|
|
|
|
SetWindowPos(h, HWND_TOP, x, y, width, height, 0);
|
|
|
|
|
|
|
|
return h;
|
2008-02-09 13:52:01 +00:00
|
|
|
}
|
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
void DoMessageBox(const char *str, int rows, int cols, bool error)
|
2008-02-09 13:52:01 +00:00
|
|
|
{
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
EnableWindow(GraphicsWnd, false);
|
|
|
|
EnableWindow(TextWnd, false);
|
2010-01-16 09:22:44 +00:00
|
|
|
HWND h = GetForegroundWindow();
|
|
|
|
|
|
|
|
// Register the window class for our dialog.
|
|
|
|
WNDCLASSEX wc;
|
|
|
|
memset(&wc, 0, sizeof(wc));
|
|
|
|
wc.cbSize = sizeof(wc);
|
|
|
|
wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW | CS_OWNDC;
|
|
|
|
wc.lpfnWndProc = (WNDPROC)MessageProc;
|
|
|
|
wc.hInstance = Instance;
|
|
|
|
wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;
|
|
|
|
wc.lpszClassName = "MessageWnd";
|
|
|
|
wc.lpszMenuName = NULL;
|
|
|
|
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
|
|
|
wc.hIcon = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000),
|
|
|
|
IMAGE_ICON, 32, 32, 0);
|
|
|
|
wc.hIconSm = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000),
|
|
|
|
IMAGE_ICON, 16, 16, 0);
|
|
|
|
RegisterClassEx(&wc);
|
|
|
|
|
|
|
|
// Create the window.
|
|
|
|
MessageString = str;
|
|
|
|
RECT r;
|
|
|
|
GetWindowRect(GraphicsWnd, &r);
|
|
|
|
char *title = error ? "SolveSpace - Error" : "SolveSpace - Message";
|
2010-04-26 07:52:49 +00:00
|
|
|
int width = cols*SS.TW.CHAR_WIDTH + 20,
|
|
|
|
height = rows*SS.TW.LINE_HEIGHT + 60;
|
2010-01-16 09:22:44 +00:00
|
|
|
MessageWnd = CreateWindowClient(0, "MessageWnd", title,
|
|
|
|
WS_OVERLAPPED | WS_SYSMENU,
|
|
|
|
r.left + 100, r.top + 100, width, height, NULL, NULL, Instance, NULL);
|
|
|
|
|
|
|
|
OkButton = CreateWindowEx(0, WC_BUTTON, "OK",
|
|
|
|
WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON,
|
2010-04-26 07:52:49 +00:00
|
|
|
(width - 70)/2, rows*SS.TW.LINE_HEIGHT + 20,
|
2010-01-16 09:22:44 +00:00
|
|
|
70, 25, MessageWnd, NULL, Instance, NULL);
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
SendMessage(OkButton, WM_SETFONT, (WPARAM)FixedFont, true);
|
2010-01-16 09:22:44 +00:00
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
ShowWindow(MessageWnd, true);
|
2010-01-16 09:22:44 +00:00
|
|
|
SetFocus(OkButton);
|
|
|
|
|
|
|
|
MSG msg;
|
|
|
|
DWORD ret;
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
MessageDone = false;
|
2013-08-26 20:54:04 +00:00
|
|
|
while((ret = GetMessage(&msg, NULL, 0, 0)) != 0 && !MessageDone) {
|
2010-01-16 09:22:44 +00:00
|
|
|
if((msg.message == WM_KEYDOWN &&
|
|
|
|
(msg.wParam == VK_RETURN ||
|
|
|
|
msg.wParam == VK_ESCAPE)) ||
|
|
|
|
(msg.message == WM_KEYUP &&
|
|
|
|
(msg.wParam == VK_SPACE)))
|
|
|
|
{
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
MessageDone = true;
|
2010-01-16 09:22:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageString = NULL;
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
EnableWindow(TextWnd, true);
|
|
|
|
EnableWindow(GraphicsWnd, true);
|
2010-01-16 09:22:44 +00:00
|
|
|
SetForegroundWindow(GraphicsWnd);
|
|
|
|
DestroyWindow(MessageWnd);
|
2008-02-09 13:52:01 +00:00
|
|
|
}
|
|
|
|
|
2013-08-26 18:58:35 +00:00
|
|
|
void AddContextMenuItem(const char *label, int id)
|
2009-09-23 10:59:59 +00:00
|
|
|
{
|
|
|
|
if(!ContextMenu) ContextMenu = CreatePopupMenu();
|
|
|
|
|
|
|
|
if(id == CONTEXT_SUBMENU) {
|
|
|
|
AppendMenu(ContextMenu, MF_STRING | MF_POPUP,
|
|
|
|
(UINT_PTR)ContextSubmenu, label);
|
|
|
|
ContextSubmenu = NULL;
|
|
|
|
} else {
|
|
|
|
HMENU m = ContextSubmenu ? ContextSubmenu : ContextMenu;
|
|
|
|
if(id == CONTEXT_SEPARATOR) {
|
|
|
|
AppendMenu(m, MF_SEPARATOR, 0, "");
|
|
|
|
} else {
|
|
|
|
AppendMenu(m, MF_STRING, id, label);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateContextSubmenu(void)
|
|
|
|
{
|
|
|
|
ContextSubmenu = CreatePopupMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
int ShowContextMenu(void)
|
|
|
|
{
|
|
|
|
POINT p;
|
|
|
|
GetCursorPos(&p);
|
|
|
|
int r = TrackPopupMenu(ContextMenu,
|
|
|
|
TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_TOPALIGN,
|
|
|
|
p.x, p.y, 0, GraphicsWnd, NULL);
|
|
|
|
|
|
|
|
DestroyMenu(ContextMenu);
|
|
|
|
ContextMenu = NULL;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2009-01-02 10:38:36 +00:00
|
|
|
void CALLBACK TimerCallback(HWND hwnd, UINT msg, UINT_PTR id, DWORD time)
|
|
|
|
{
|
2009-01-04 12:52:11 +00:00
|
|
|
// The timer is periodic, so needs to be killed explicitly.
|
|
|
|
KillTimer(GraphicsWnd, 1);
|
2009-01-02 10:38:36 +00:00
|
|
|
SS.GW.TimerCallback();
|
2010-05-03 05:04:42 +00:00
|
|
|
SS.TW.TimerCallback();
|
2009-01-02 10:38:36 +00:00
|
|
|
}
|
|
|
|
void SetTimerFor(int milliseconds)
|
|
|
|
{
|
|
|
|
SetTimer(GraphicsWnd, 1, milliseconds, TimerCallback);
|
|
|
|
}
|
|
|
|
|
2010-04-26 07:52:49 +00:00
|
|
|
static void GetWindowSize(HWND hwnd, int *w, int *h)
|
2009-01-02 10:38:36 +00:00
|
|
|
{
|
2010-04-26 07:52:49 +00:00
|
|
|
RECT r;
|
|
|
|
GetClientRect(hwnd, &r);
|
|
|
|
*w = r.right - r.left;
|
|
|
|
*h = r.bottom - r.top;
|
2009-01-02 10:38:36 +00:00
|
|
|
}
|
2010-04-26 07:52:49 +00:00
|
|
|
void GetGraphicsWindowSize(int *w, int *h)
|
2009-01-02 10:38:36 +00:00
|
|
|
{
|
2010-04-26 07:52:49 +00:00
|
|
|
GetWindowSize(GraphicsWnd, w, h);
|
2009-01-02 10:38:36 +00:00
|
|
|
}
|
2010-05-03 05:04:42 +00:00
|
|
|
void GetTextWindowSize(int *w, int *h)
|
|
|
|
{
|
|
|
|
GetWindowSize(TextWnd, w, h);
|
|
|
|
}
|
2008-02-09 13:52:01 +00:00
|
|
|
|
2013-08-26 18:58:35 +00:00
|
|
|
void OpenWebsite(const char *url) {
|
2008-02-09 13:52:01 +00:00
|
|
|
ShellExecute(GraphicsWnd, "open", url, NULL, NULL, SW_SHOWNORMAL);
|
|
|
|
}
|
|
|
|
|
2008-06-03 18:48:47 +00:00
|
|
|
void ExitNow(void) {
|
|
|
|
PostQuitMessage(0);
|
|
|
|
}
|
|
|
|
|
2008-06-11 04:22:52 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Helpers so that we can read/write registry keys from the platform-
|
|
|
|
// independent code.
|
|
|
|
//-----------------------------------------------------------------------------
|
2013-08-26 18:58:35 +00:00
|
|
|
void CnfFreezeString(const char *str, const char *name)
|
2008-06-11 04:22:52 +00:00
|
|
|
{ FreezeStringF(str, FREEZE_SUBKEY, name); }
|
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
void CnfFreezeInt(uint32_t v, const char *name)
|
|
|
|
{ FreezeDWORDF((DWORD)v, FREEZE_SUBKEY, name); }
|
2008-06-11 04:22:52 +00:00
|
|
|
|
2013-08-26 18:58:35 +00:00
|
|
|
void CnfFreezeFloat(float v, const char *name)
|
2008-07-08 07:41:29 +00:00
|
|
|
{ FreezeDWORDF(*((DWORD *)&v), FREEZE_SUBKEY, name); }
|
|
|
|
|
2013-08-26 18:58:35 +00:00
|
|
|
void CnfThawString(char *str, int maxLen, const char *name)
|
2008-06-11 04:22:52 +00:00
|
|
|
{ ThawStringF(str, maxLen, FREEZE_SUBKEY, name); }
|
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
uint32_t CnfThawInt(uint32_t v, const char *name)
|
|
|
|
{ return (uint32_t)ThawDWORDF((DWORD)v, FREEZE_SUBKEY, name); }
|
2008-06-11 04:22:52 +00:00
|
|
|
|
2013-08-26 18:58:35 +00:00
|
|
|
float CnfThawFloat(float v, const char *name) {
|
2008-07-08 07:41:29 +00:00
|
|
|
DWORD d = ThawDWORDF(*((DWORD *)&v), FREEZE_SUBKEY, name);
|
|
|
|
return *((float *)&d);
|
|
|
|
}
|
|
|
|
|
2013-08-26 18:58:35 +00:00
|
|
|
void SetWindowTitle(const char *str) {
|
2008-07-08 08:02:22 +00:00
|
|
|
SetWindowText(GraphicsWnd, str);
|
|
|
|
}
|
|
|
|
|
2010-04-26 07:52:49 +00:00
|
|
|
void SetMousePointerToHand(bool yes) {
|
|
|
|
SetCursor(LoadCursor(NULL, yes ? IDC_HAND : IDC_ARROW));
|
|
|
|
}
|
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
static void PaintTextWnd(HDC hdc)
|
|
|
|
{
|
2010-04-26 07:52:49 +00:00
|
|
|
wglMakeCurrent(GetDC(TextWnd), TextGl);
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2010-05-03 05:04:42 +00:00
|
|
|
SS.TW.Paint();
|
2010-04-26 07:52:49 +00:00
|
|
|
SwapBuffers(GetDC(TextWnd));
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2010-04-26 07:52:49 +00:00
|
|
|
// Leave the graphics window context active, except when we're painting
|
|
|
|
// this text window.
|
|
|
|
wglMakeCurrent(GetDC(GraphicsWnd), GraphicsGl);
|
|
|
|
}
|
2008-04-09 09:35:09 +00:00
|
|
|
|
2010-04-26 07:52:49 +00:00
|
|
|
void MoveTextScrollbarTo(int pos, int maxPos, int page)
|
|
|
|
{
|
2008-03-25 10:02:13 +00:00
|
|
|
SCROLLINFO si;
|
|
|
|
memset(&si, 0, sizeof(si));
|
|
|
|
si.cbSize = sizeof(si);
|
|
|
|
si.fMask = SIF_DISABLENOSCROLL | SIF_ALL;
|
|
|
|
si.nMin = 0;
|
2010-04-26 07:52:49 +00:00
|
|
|
si.nMax = maxPos;
|
|
|
|
si.nPos = pos;
|
|
|
|
si.nPage = page;
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
SetScrollInfo(TextWndScrollBar, SB_CTL, &si, true);
|
2008-03-26 09:18:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HandleTextWindowScrollBar(WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2010-04-26 07:52:49 +00:00
|
|
|
int maxPos, minPos, pos;
|
|
|
|
GetScrollRange(TextWndScrollBar, SB_CTL, &minPos, &maxPos);
|
|
|
|
pos = GetScrollPos(TextWndScrollBar, SB_CTL);
|
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
switch(LOWORD(wParam)) {
|
2010-04-26 07:52:49 +00:00
|
|
|
case SB_LINEUP: pos--; break;
|
|
|
|
case SB_PAGEUP: pos -= 4; break;
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2010-04-26 07:52:49 +00:00
|
|
|
case SB_LINEDOWN: pos++; break;
|
|
|
|
case SB_PAGEDOWN: pos += 4; break;
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2010-04-26 07:52:49 +00:00
|
|
|
case SB_TOP: pos = 0; break;
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2010-04-26 07:52:49 +00:00
|
|
|
case SB_BOTTOM: pos = maxPos; break;
|
2008-03-26 09:18:12 +00:00
|
|
|
|
|
|
|
case SB_THUMBTRACK:
|
2010-04-26 07:52:49 +00:00
|
|
|
case SB_THUMBPOSITION: pos = HIWORD(wParam); break;
|
2008-03-26 09:18:12 +00:00
|
|
|
}
|
2010-04-26 07:52:49 +00:00
|
|
|
|
|
|
|
SS.TW.ScrollbarEvent(pos);
|
2008-03-25 10:02:13 +00:00
|
|
|
}
|
|
|
|
|
2009-07-20 19:05:33 +00:00
|
|
|
static void MouseWheel(int thisDelta) {
|
|
|
|
static int DeltaAccum;
|
|
|
|
int delta = 0;
|
|
|
|
// Handle mouse deltas of less than 120 (like from an un-detented mouse
|
|
|
|
// wheel) correctly, even though no one ever uses those.
|
|
|
|
DeltaAccum += thisDelta;
|
|
|
|
while(DeltaAccum >= 120) {
|
|
|
|
DeltaAccum -= 120;
|
|
|
|
delta += 120;
|
|
|
|
}
|
|
|
|
while(DeltaAccum <= -120) {
|
|
|
|
DeltaAccum += 120;
|
|
|
|
delta -= 120;
|
|
|
|
}
|
|
|
|
if(delta == 0) return;
|
|
|
|
|
2008-08-15 04:55:03 +00:00
|
|
|
POINT pt;
|
|
|
|
GetCursorPos(&pt);
|
|
|
|
HWND hw = WindowFromPoint(pt);
|
|
|
|
|
|
|
|
// Make the mousewheel work according to which window the mouse is
|
|
|
|
// over, not according to which window is active.
|
|
|
|
bool inTextWindow;
|
|
|
|
if(hw == TextWnd) {
|
|
|
|
inTextWindow = true;
|
|
|
|
} else if(hw == GraphicsWnd) {
|
|
|
|
inTextWindow = false;
|
|
|
|
} else if(GetForegroundWindow() == TextWnd) {
|
|
|
|
inTextWindow = true;
|
|
|
|
} else {
|
|
|
|
inTextWindow = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(inTextWindow) {
|
|
|
|
int i;
|
|
|
|
for(i = 0; i < abs(delta/40); i++) {
|
|
|
|
HandleTextWindowScrollBar(delta > 0 ? SB_LINEUP : SB_LINEDOWN, 0);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SS.GW.MouseScroll(LastMousePos.x, LastMousePos.y, delta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
LRESULT CALLBACK TextWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (msg) {
|
2008-04-27 09:31:56 +00:00
|
|
|
case WM_ERASEBKGND:
|
|
|
|
break;
|
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
case WM_CLOSE:
|
|
|
|
case WM_DESTROY:
|
2008-06-03 18:28:41 +00:00
|
|
|
SolveSpace::MenuFile(GraphicsWindow::MNU_EXIT);
|
2008-03-25 10:02:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_PAINT: {
|
2010-04-26 07:52:49 +00:00
|
|
|
// Actually paint the text window, with gl.
|
|
|
|
PaintTextWnd(GetDC(TextWnd));
|
|
|
|
// And then just make Windows happy.
|
2008-03-25 10:02:13 +00:00
|
|
|
PAINTSTRUCT ps;
|
|
|
|
HDC hdc = BeginPaint(hwnd, &ps);
|
|
|
|
EndPaint(hwnd, &ps);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_SIZING: {
|
|
|
|
RECT *r = (RECT *)lParam;
|
|
|
|
int hc = (r->bottom - r->top) - ClientIsSmallerBy;
|
2010-04-26 07:52:49 +00:00
|
|
|
int extra = hc % (SS.TW.LINE_HEIGHT/2);
|
2008-03-25 10:02:13 +00:00
|
|
|
switch(wParam) {
|
|
|
|
case WMSZ_BOTTOM:
|
|
|
|
case WMSZ_BOTTOMLEFT:
|
|
|
|
case WMSZ_BOTTOMRIGHT:
|
|
|
|
r->bottom -= extra;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WMSZ_TOP:
|
|
|
|
case WMSZ_TOPLEFT:
|
|
|
|
case WMSZ_TOPRIGHT:
|
|
|
|
r->top += extra;
|
|
|
|
break;
|
|
|
|
}
|
2010-04-26 07:52:49 +00:00
|
|
|
int tooNarrow = (SS.TW.MIN_COLS*SS.TW.CHAR_WIDTH) -
|
|
|
|
(r->right - r->left);
|
2008-04-11 12:47:14 +00:00
|
|
|
if(tooNarrow >= 0) {
|
|
|
|
switch(wParam) {
|
|
|
|
case WMSZ_RIGHT:
|
|
|
|
case WMSZ_BOTTOMRIGHT:
|
|
|
|
case WMSZ_TOPRIGHT:
|
|
|
|
r->right += tooNarrow;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WMSZ_LEFT:
|
|
|
|
case WMSZ_BOTTOMLEFT:
|
|
|
|
case WMSZ_TOPLEFT:
|
|
|
|
r->left -= tooNarrow;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-03-25 10:02:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-05-03 05:04:42 +00:00
|
|
|
case WM_MOUSELEAVE:
|
|
|
|
SS.TW.MouseLeave();
|
|
|
|
break;
|
|
|
|
|
2008-03-28 10:00:37 +00:00
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
case WM_MOUSEMOVE: {
|
2010-05-03 05:04:42 +00:00
|
|
|
// We need this in order to get the WM_MOUSELEAVE
|
|
|
|
TRACKMOUSEEVENT tme;
|
|
|
|
ZERO(&tme);
|
|
|
|
tme.cbSize = sizeof(tme);
|
|
|
|
tme.dwFlags = TME_LEAVE;
|
|
|
|
tme.hwndTrack = TextWnd;
|
|
|
|
TrackMouseEvent(&tme);
|
|
|
|
|
|
|
|
// And process the actual message
|
2008-03-28 10:00:37 +00:00
|
|
|
int x = LOWORD(lParam);
|
|
|
|
int y = HIWORD(lParam);
|
2010-07-21 05:04:03 +00:00
|
|
|
SS.TW.MouseEvent(msg == WM_LBUTTONDOWN, wParam & MK_LBUTTON, x, y);
|
2008-03-28 10:00:37 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-04-01 10:48:44 +00:00
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
case WM_SIZE: {
|
|
|
|
RECT r;
|
|
|
|
GetWindowRect(TextWndScrollBar, &r);
|
|
|
|
int sw = r.right - r.left;
|
|
|
|
GetClientRect(hwnd, &r);
|
|
|
|
MoveWindow(TextWndScrollBar, r.right - sw, r.top, sw,
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
(r.bottom - r.top), true);
|
2008-05-27 06:36:59 +00:00
|
|
|
// If the window is growing, then the scrollbar position may
|
|
|
|
// be moving, so it's as if we're dragging the scrollbar.
|
2013-08-26 20:09:15 +00:00
|
|
|
HandleTextWindowScrollBar((WPARAM)-1, -1);
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
InvalidateRect(TextWnd, NULL, false);
|
2008-03-25 10:02:13 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-08-15 04:55:03 +00:00
|
|
|
case WM_MOUSEWHEEL:
|
|
|
|
MouseWheel(GET_WHEEL_DELTA_WPARAM(wParam));
|
2008-02-10 14:06:54 +00:00
|
|
|
break;
|
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
case WM_VSCROLL:
|
|
|
|
HandleTextWindowScrollBar(wParam, lParam);
|
|
|
|
break;
|
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
default:
|
|
|
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
static bool ProcessKeyDown(WPARAM wParam)
|
2008-04-12 15:17:58 +00:00
|
|
|
{
|
2008-04-21 10:12:04 +00:00
|
|
|
if(GraphicsEditControlIsVisible() && wParam != VK_ESCAPE) {
|
|
|
|
if(wParam == VK_RETURN) {
|
|
|
|
char s[1024];
|
|
|
|
memset(s, 0, sizeof(s));
|
|
|
|
SendMessage(GraphicsEditControl, WM_GETTEXT, 900, (LPARAM)s);
|
|
|
|
SS.GW.EditControlDone(s);
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
return true;
|
2008-04-21 10:12:04 +00:00
|
|
|
} else {
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
return false;
|
2008-04-21 10:12:04 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-27 06:36:59 +00:00
|
|
|
if(TextEditControlIsVisible() && wParam != VK_ESCAPE) {
|
|
|
|
if(wParam == VK_RETURN) {
|
|
|
|
char s[1024];
|
|
|
|
memset(s, 0, sizeof(s));
|
|
|
|
SendMessage(TextEditControl, WM_GETTEXT, 900, (LPARAM)s);
|
|
|
|
SS.TW.EditControlDone(s);
|
|
|
|
} else {
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
return false;
|
2008-05-27 06:36:59 +00:00
|
|
|
}
|
|
|
|
}
|
2008-04-21 10:12:04 +00:00
|
|
|
|
2008-04-12 15:17:58 +00:00
|
|
|
int c;
|
|
|
|
switch(wParam) {
|
2009-09-28 10:01:34 +00:00
|
|
|
case VK_OEM_PLUS: c = '+'; break;
|
|
|
|
case VK_OEM_MINUS: c = '-'; break;
|
|
|
|
case VK_ESCAPE: c = 27; break;
|
|
|
|
case VK_OEM_1: c = ';'; break;
|
2009-09-29 11:35:19 +00:00
|
|
|
case VK_OEM_3: c = '`'; break;
|
2009-09-28 10:01:34 +00:00
|
|
|
case VK_OEM_4: c = '['; break;
|
|
|
|
case VK_OEM_6: c = ']'; break;
|
|
|
|
case VK_OEM_5: c = '\\'; break;
|
2009-09-29 11:35:19 +00:00
|
|
|
case VK_OEM_PERIOD: c = '.'; break;
|
2009-09-28 10:01:34 +00:00
|
|
|
case VK_SPACE: c = ' '; break;
|
|
|
|
case VK_DELETE: c = 127; break;
|
|
|
|
case VK_TAB: c = '\t'; break;
|
|
|
|
|
|
|
|
case VK_BROWSER_BACK:
|
2013-09-18 20:41:23 +00:00
|
|
|
case VK_BACK: c = '\b'; break;
|
2008-04-12 15:17:58 +00:00
|
|
|
|
2009-01-02 04:06:47 +00:00
|
|
|
case VK_F1:
|
|
|
|
case VK_F2:
|
|
|
|
case VK_F3:
|
|
|
|
case VK_F4:
|
|
|
|
case VK_F5:
|
|
|
|
case VK_F6:
|
|
|
|
case VK_F7:
|
|
|
|
case VK_F8:
|
|
|
|
case VK_F9:
|
|
|
|
case VK_F10:
|
|
|
|
case VK_F11:
|
2013-08-26 20:09:15 +00:00
|
|
|
case VK_F12: c = ((int)wParam - VK_F1) + 0xf1; break;
|
2009-01-02 04:06:47 +00:00
|
|
|
|
2008-07-10 07:26:41 +00:00
|
|
|
// These overlap with some character codes that I'm using, so
|
|
|
|
// don't let them trigger by accident.
|
|
|
|
case VK_F16:
|
|
|
|
case VK_INSERT:
|
|
|
|
case VK_EXECUTE:
|
|
|
|
case VK_APPS:
|
|
|
|
case VK_LWIN:
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
case VK_RWIN: return false;
|
2008-07-10 07:26:41 +00:00
|
|
|
|
2008-04-12 15:17:58 +00:00
|
|
|
default:
|
2013-08-26 20:09:15 +00:00
|
|
|
c = (int)wParam;
|
2008-04-12 15:17:58 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-09-20 17:54:57 +00:00
|
|
|
if(GetAsyncKeyState(VK_SHIFT) & 0x8000) c |= GraphicsWindow::SHIFT_MASK;
|
|
|
|
if(GetAsyncKeyState(VK_CONTROL) & 0x8000) c |= GraphicsWindow::CTRL_MASK;
|
2008-04-12 15:17:58 +00:00
|
|
|
|
2013-09-20 18:01:31 +00:00
|
|
|
switch(c) {
|
|
|
|
case GraphicsWindow::SHIFT_MASK | '.': c = '>'; break;
|
|
|
|
}
|
|
|
|
|
2008-04-12 15:17:58 +00:00
|
|
|
for(int i = 0; SS.GW.menu[i].level >= 0; i++) {
|
|
|
|
if(c == SS.GW.menu[i].accel) {
|
|
|
|
(SS.GW.menu[i].fn)((GraphicsWindow::MenuId)SS.GW.menu[i].id);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
if(SS.GW.KeyDown(c)) return true;
|
2009-09-28 10:01:34 +00:00
|
|
|
|
2008-04-12 15:17:58 +00:00
|
|
|
// No accelerator; process the key as normal.
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
return false;
|
2008-04-12 15:17:58 +00:00
|
|
|
}
|
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
void ShowTextWindow(bool visible)
|
2008-04-27 05:00:12 +00:00
|
|
|
{
|
|
|
|
ShowWindow(TextWnd, visible ? SW_SHOWNOACTIVATE : SW_HIDE);
|
|
|
|
}
|
|
|
|
|
2010-04-26 07:52:49 +00:00
|
|
|
static void CreateGlContext(HWND hwnd, HGLRC *glrc)
|
|
|
|
{
|
|
|
|
HDC hdc = GetDC(hwnd);
|
2008-05-16 04:54:47 +00:00
|
|
|
|
2008-03-27 09:53:51 +00:00
|
|
|
PIXELFORMATDESCRIPTOR pfd;
|
2009-03-14 20:01:20 +00:00
|
|
|
int pixelFormat;
|
2008-03-27 09:53:51 +00:00
|
|
|
|
|
|
|
memset(&pfd, 0, sizeof(pfd));
|
|
|
|
pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
|
|
|
|
pfd.nVersion = 1;
|
|
|
|
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |
|
|
|
|
PFD_DOUBLEBUFFER;
|
|
|
|
pfd.dwLayerMask = PFD_MAIN_PLANE;
|
2008-04-11 11:13:47 +00:00
|
|
|
pfd.iPixelType = PFD_TYPE_RGBA;
|
2008-07-09 06:41:42 +00:00
|
|
|
pfd.cColorBits = 32;
|
|
|
|
pfd.cDepthBits = 24;
|
2008-03-27 09:53:51 +00:00
|
|
|
pfd.cAccumBits = 0;
|
|
|
|
pfd.cStencilBits = 0;
|
|
|
|
|
|
|
|
pixelFormat = ChoosePixelFormat(hdc, &pfd);
|
|
|
|
if(!pixelFormat) oops();
|
|
|
|
|
|
|
|
if(!SetPixelFormat(hdc, pixelFormat, &pfd)) oops();
|
|
|
|
|
2010-04-26 07:52:49 +00:00
|
|
|
*glrc = wglCreateContext(hdc);
|
|
|
|
wglMakeCurrent(hdc, *glrc);
|
2008-03-27 09:53:51 +00:00
|
|
|
}
|
|
|
|
|
2008-06-12 07:31:41 +00:00
|
|
|
void PaintGraphics(void)
|
|
|
|
{
|
2010-05-03 05:04:42 +00:00
|
|
|
SS.GW.Paint();
|
2008-05-16 04:54:47 +00:00
|
|
|
SwapBuffers(GetDC(GraphicsWnd));
|
2008-04-18 11:11:48 +00:00
|
|
|
}
|
2010-04-26 07:52:49 +00:00
|
|
|
void InvalidateGraphics(void)
|
|
|
|
{
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
InvalidateRect(GraphicsWnd, NULL, false);
|
2010-04-26 07:52:49 +00:00
|
|
|
}
|
2008-05-16 04:54:47 +00:00
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
int32_t GetMilliseconds(void)
|
2008-04-18 11:11:48 +00:00
|
|
|
{
|
2008-06-01 09:46:02 +00:00
|
|
|
LARGE_INTEGER t, f;
|
|
|
|
QueryPerformanceCounter(&t);
|
|
|
|
QueryPerformanceFrequency(&f);
|
|
|
|
LONGLONG d = t.QuadPart/(f.QuadPart/1000);
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
return (int32_t)d;
|
2008-04-18 11:11:48 +00:00
|
|
|
}
|
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
int64_t GetUnixTime(void)
|
2009-06-10 06:57:27 +00:00
|
|
|
{
|
|
|
|
__time64_t ret;
|
|
|
|
_time64(&ret);
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
return (int64_t)ret;
|
2009-06-10 06:57:27 +00:00
|
|
|
}
|
|
|
|
|
2008-04-11 12:47:14 +00:00
|
|
|
void InvalidateText(void)
|
|
|
|
{
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
InvalidateRect(TextWnd, NULL, false);
|
2008-04-11 12:47:14 +00:00
|
|
|
}
|
2008-03-27 09:53:51 +00:00
|
|
|
|
2008-05-27 06:36:59 +00:00
|
|
|
static void ShowEditControl(HWND h, int x, int y, char *s) {
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
MoveWindow(h, x, y, EDIT_WIDTH, EDIT_HEIGHT, true);
|
2008-05-27 06:36:59 +00:00
|
|
|
ShowWindow(h, SW_SHOW);
|
2010-04-26 07:52:49 +00:00
|
|
|
if(s) {
|
|
|
|
SendMessage(h, WM_SETTEXT, 0, (LPARAM)s);
|
|
|
|
SendMessage(h, EM_SETSEL, 0, strlen(s));
|
|
|
|
SetFocus(h);
|
|
|
|
}
|
2008-05-27 06:36:59 +00:00
|
|
|
}
|
2010-07-12 07:51:12 +00:00
|
|
|
void ShowTextEditControl(int x, int y, char *s)
|
2008-05-27 06:36:59 +00:00
|
|
|
{
|
2010-04-26 07:52:49 +00:00
|
|
|
if(GraphicsEditControlIsVisible()) return;
|
2008-05-27 06:36:59 +00:00
|
|
|
|
2010-07-12 07:51:12 +00:00
|
|
|
ShowEditControl(TextEditControl, x, y, s);
|
2008-05-27 06:36:59 +00:00
|
|
|
}
|
|
|
|
void HideTextEditControl(void)
|
|
|
|
{
|
|
|
|
ShowWindow(TextEditControl, SW_HIDE);
|
|
|
|
}
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
bool TextEditControlIsVisible(void)
|
2008-05-27 06:36:59 +00:00
|
|
|
{
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
return IsWindowVisible(TextEditControl) ? true : false;
|
2008-05-27 06:36:59 +00:00
|
|
|
}
|
2008-04-21 10:12:04 +00:00
|
|
|
void ShowGraphicsEditControl(int x, int y, char *s)
|
|
|
|
{
|
2010-04-26 07:52:49 +00:00
|
|
|
if(GraphicsEditControlIsVisible()) return;
|
2008-05-27 06:36:59 +00:00
|
|
|
|
2008-04-21 10:12:04 +00:00
|
|
|
RECT r;
|
|
|
|
GetClientRect(GraphicsWnd, &r);
|
|
|
|
x = x + (r.right - r.left)/2;
|
|
|
|
y = (r.bottom - r.top)/2 - y;
|
|
|
|
|
|
|
|
// (x, y) are the bottom left, but the edit control is placed by its
|
|
|
|
// top left corner
|
2008-04-22 13:14:15 +00:00
|
|
|
y -= 20;
|
2008-04-21 10:12:04 +00:00
|
|
|
|
2008-05-27 06:36:59 +00:00
|
|
|
ShowEditControl(GraphicsEditControl, x, y, s);
|
2008-04-21 10:12:04 +00:00
|
|
|
}
|
|
|
|
void HideGraphicsEditControl(void)
|
|
|
|
{
|
|
|
|
ShowWindow(GraphicsEditControl, SW_HIDE);
|
|
|
|
}
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
bool GraphicsEditControlIsVisible(void)
|
2008-04-21 10:12:04 +00:00
|
|
|
{
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
return IsWindowVisible(GraphicsEditControl) ? true : false;
|
2008-04-21 10:12:04 +00:00
|
|
|
}
|
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
LRESULT CALLBACK GraphicsWndProc(HWND hwnd, UINT msg, WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (msg) {
|
2008-03-27 09:53:51 +00:00
|
|
|
case WM_ERASEBKGND:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_SIZE:
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
InvalidateRect(GraphicsWnd, NULL, false);
|
2008-03-27 09:53:51 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_PAINT: {
|
2010-04-26 07:52:49 +00:00
|
|
|
// Actually paint the window, with gl.
|
2008-05-16 04:54:47 +00:00
|
|
|
PaintGraphics();
|
2010-04-26 07:52:49 +00:00
|
|
|
// And make Windows happy.
|
2008-03-27 09:53:51 +00:00
|
|
|
PAINTSTRUCT ps;
|
|
|
|
HDC hdc = BeginPaint(hwnd, &ps);
|
|
|
|
EndPaint(hwnd, &ps);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-01-02 10:38:36 +00:00
|
|
|
case WM_MOUSELEAVE:
|
|
|
|
SS.GW.MouseLeave();
|
|
|
|
break;
|
|
|
|
|
2008-03-27 09:53:51 +00:00
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
case WM_LBUTTONDOWN:
|
2008-04-22 10:53:42 +00:00
|
|
|
case WM_LBUTTONUP:
|
2008-04-21 10:12:04 +00:00
|
|
|
case WM_LBUTTONDBLCLK:
|
2008-07-06 07:56:24 +00:00
|
|
|
case WM_RBUTTONDOWN:
|
2009-09-23 10:59:59 +00:00
|
|
|
case WM_RBUTTONUP:
|
2008-03-27 09:53:51 +00:00
|
|
|
case WM_MBUTTONDOWN: {
|
|
|
|
int x = LOWORD(lParam);
|
|
|
|
int y = HIWORD(lParam);
|
|
|
|
|
2009-01-02 10:38:36 +00:00
|
|
|
// We need this in order to get the WM_MOUSELEAVE
|
|
|
|
TRACKMOUSEEVENT tme;
|
|
|
|
ZERO(&tme);
|
|
|
|
tme.cbSize = sizeof(tme);
|
|
|
|
tme.dwFlags = TME_LEAVE;
|
|
|
|
tme.hwndTrack = GraphicsWnd;
|
|
|
|
TrackMouseEvent(&tme);
|
|
|
|
|
|
|
|
// Convert to xy (vs. ij) style coordinates, with (0, 0) at center
|
2008-03-27 09:53:51 +00:00
|
|
|
RECT r;
|
|
|
|
GetClientRect(GraphicsWnd, &r);
|
|
|
|
x = x - (r.right - r.left)/2;
|
|
|
|
y = (r.bottom - r.top)/2 - y;
|
|
|
|
|
2008-04-01 10:48:44 +00:00
|
|
|
LastMousePos.x = x;
|
|
|
|
LastMousePos.y = y;
|
|
|
|
|
2008-03-27 09:53:51 +00:00
|
|
|
if(msg == WM_LBUTTONDOWN) {
|
|
|
|
SS.GW.MouseLeftDown(x, y);
|
2008-04-22 10:53:42 +00:00
|
|
|
} else if(msg == WM_LBUTTONUP) {
|
|
|
|
SS.GW.MouseLeftUp(x, y);
|
2008-04-21 10:12:04 +00:00
|
|
|
} else if(msg == WM_LBUTTONDBLCLK) {
|
|
|
|
SS.GW.MouseLeftDoubleClick(x, y);
|
2008-07-06 07:56:24 +00:00
|
|
|
} else if(msg == WM_MBUTTONDOWN || msg == WM_RBUTTONDOWN) {
|
|
|
|
SS.GW.MouseMiddleOrRightDown(x, y);
|
2009-09-23 10:59:59 +00:00
|
|
|
} else if(msg == WM_RBUTTONUP) {
|
|
|
|
SS.GW.MouseRightUp(x, y);
|
2008-03-27 09:53:51 +00:00
|
|
|
} else if(msg == WM_MOUSEMOVE) {
|
|
|
|
SS.GW.MouseMoved(x, y,
|
|
|
|
!!(wParam & MK_LBUTTON),
|
|
|
|
!!(wParam & MK_MBUTTON),
|
|
|
|
!!(wParam & MK_RBUTTON),
|
|
|
|
!!(wParam & MK_SHIFT),
|
|
|
|
!!(wParam & MK_CONTROL));
|
|
|
|
} else {
|
|
|
|
oops();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-08-15 04:55:03 +00:00
|
|
|
case WM_MOUSEWHEEL:
|
|
|
|
MouseWheel(GET_WHEEL_DELTA_WPARAM(wParam));
|
2008-04-01 10:48:44 +00:00
|
|
|
break;
|
2008-08-15 04:55:03 +00:00
|
|
|
|
2008-04-12 15:17:58 +00:00
|
|
|
case WM_COMMAND: {
|
2008-04-21 10:12:04 +00:00
|
|
|
if(HIWORD(wParam) == 0) {
|
|
|
|
int id = LOWORD(wParam);
|
2008-05-28 10:10:31 +00:00
|
|
|
if((id >= RECENT_OPEN && id < (RECENT_OPEN + MAX_RECENT))) {
|
|
|
|
SolveSpace::MenuFile(id);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if((id >= RECENT_IMPORT && id < (RECENT_IMPORT + MAX_RECENT))) {
|
|
|
|
Group::MenuGroup(id);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
int i;
|
|
|
|
for(i = 0; SS.GW.menu[i].level >= 0; i++) {
|
2008-04-21 10:12:04 +00:00
|
|
|
if(id == SS.GW.menu[i].id) {
|
|
|
|
(SS.GW.menu[i].fn)((GraphicsWindow::MenuId)id);
|
|
|
|
break;
|
|
|
|
}
|
2008-04-12 15:17:58 +00:00
|
|
|
}
|
2008-05-28 10:10:31 +00:00
|
|
|
if(SS.GW.menu[i].level < 0) oops();
|
2008-04-12 15:17:58 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-03-27 09:53:51 +00:00
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
case WM_CLOSE:
|
|
|
|
case WM_DESTROY:
|
2008-06-03 18:28:41 +00:00
|
|
|
SolveSpace::MenuFile(GraphicsWindow::MNU_EXIT);
|
2008-03-25 10:02:13 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-04-18 11:11:48 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Common dialog routines, to open or save a file.
|
|
|
|
//-----------------------------------------------------------------------------
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
bool GetOpenFile(char *file, const char *defExtension, const char *selPattern)
|
2008-04-18 11:11:48 +00:00
|
|
|
{
|
|
|
|
OPENFILENAME ofn;
|
|
|
|
|
|
|
|
memset(&ofn, 0, sizeof(ofn));
|
|
|
|
ofn.lStructSize = sizeof(ofn);
|
|
|
|
ofn.hInstance = Instance;
|
|
|
|
ofn.hwndOwner = GraphicsWnd;
|
|
|
|
ofn.lpstrFilter = selPattern;
|
|
|
|
ofn.lpstrDefExt = defExtension;
|
|
|
|
ofn.lpstrFile = file;
|
|
|
|
ofn.nMaxFile = MAX_PATH;
|
|
|
|
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
|
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
EnableWindow(GraphicsWnd, false);
|
|
|
|
EnableWindow(TextWnd, false);
|
2008-06-25 05:14:49 +00:00
|
|
|
|
2008-04-18 11:11:48 +00:00
|
|
|
BOOL r = GetOpenFileName(&ofn);
|
2008-06-25 05:14:49 +00:00
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
EnableWindow(TextWnd, true);
|
|
|
|
EnableWindow(GraphicsWnd, true);
|
2008-04-18 11:11:48 +00:00
|
|
|
SetForegroundWindow(GraphicsWnd);
|
2008-06-25 05:14:49 +00:00
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
return r ? true : false;
|
2008-04-18 11:11:48 +00:00
|
|
|
}
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
bool GetSaveFile(char *file, const char *defExtension, const char *selPattern)
|
2008-04-18 11:11:48 +00:00
|
|
|
{
|
|
|
|
OPENFILENAME ofn;
|
|
|
|
|
|
|
|
memset(&ofn, 0, sizeof(ofn));
|
|
|
|
ofn.lStructSize = sizeof(ofn);
|
|
|
|
ofn.hInstance = Instance;
|
|
|
|
ofn.hwndOwner = GraphicsWnd;
|
|
|
|
ofn.lpstrFilter = selPattern;
|
|
|
|
ofn.lpstrDefExt = defExtension;
|
|
|
|
ofn.lpstrFile = file;
|
|
|
|
ofn.nMaxFile = MAX_PATH;
|
|
|
|
ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
|
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
EnableWindow(GraphicsWnd, false);
|
|
|
|
EnableWindow(TextWnd, false);
|
2008-06-25 05:14:49 +00:00
|
|
|
|
2008-04-18 11:11:48 +00:00
|
|
|
BOOL r = GetSaveFileName(&ofn);
|
2008-06-25 05:14:49 +00:00
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
EnableWindow(TextWnd, true);
|
|
|
|
EnableWindow(GraphicsWnd, true);
|
2008-04-18 11:11:48 +00:00
|
|
|
SetForegroundWindow(GraphicsWnd);
|
2008-06-25 05:14:49 +00:00
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
return r ? true : false;
|
2008-04-18 11:11:48 +00:00
|
|
|
}
|
|
|
|
int SaveFileYesNoCancel(void)
|
|
|
|
{
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
EnableWindow(GraphicsWnd, false);
|
|
|
|
EnableWindow(TextWnd, false);
|
2008-06-25 05:14:49 +00:00
|
|
|
|
|
|
|
int r = MessageBox(GraphicsWnd,
|
2008-04-18 11:11:48 +00:00
|
|
|
"The program has changed since it was last saved.\r\n\r\n"
|
|
|
|
"Do you want to save the changes?", "SolveSpace",
|
|
|
|
MB_YESNOCANCEL | MB_ICONWARNING);
|
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
EnableWindow(TextWnd, true);
|
|
|
|
EnableWindow(GraphicsWnd, true);
|
2008-06-25 05:14:49 +00:00
|
|
|
SetForegroundWindow(GraphicsWnd);
|
|
|
|
|
2013-09-18 20:49:32 +00:00
|
|
|
switch(r) {
|
|
|
|
case IDYES: return SAVE_YES;
|
|
|
|
case IDNO: return SAVE_NO;
|
|
|
|
case IDCANCEL: return SAVE_CANCEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
oops();
|
|
|
|
return SAVE_CANCEL;
|
2008-06-25 05:14:49 +00:00
|
|
|
}
|
2008-06-30 09:09:17 +00:00
|
|
|
|
|
|
|
void LoadAllFontFiles(void)
|
|
|
|
{
|
|
|
|
WIN32_FIND_DATA wfd;
|
|
|
|
char dir[MAX_PATH];
|
|
|
|
GetWindowsDirectory(dir, MAX_PATH - 30);
|
|
|
|
strcat(dir, "\\fonts\\*.ttf");
|
|
|
|
|
|
|
|
HANDLE h = FindFirstFile(dir, &wfd);
|
|
|
|
|
|
|
|
while(h != INVALID_HANDLE_VALUE) {
|
|
|
|
TtfFont tf;
|
|
|
|
ZERO(&tf);
|
|
|
|
|
|
|
|
char fullPath[MAX_PATH];
|
2013-08-26 20:09:15 +00:00
|
|
|
GetWindowsDirectory(fullPath, MAX_PATH - (30 + (UINT)strlen(wfd.cFileName)));
|
2008-06-30 09:09:17 +00:00
|
|
|
strcat(fullPath, "\\fonts\\");
|
|
|
|
strcat(fullPath, wfd.cFileName);
|
|
|
|
|
|
|
|
strcpy(tf.fontFile, fullPath);
|
|
|
|
SS.fonts.l.Add(&tf);
|
|
|
|
|
|
|
|
if(!FindNextFile(h, &wfd)) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
static void MenuById(int id, bool yes, bool check)
|
2008-04-14 10:28:32 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int subMenu = -1;
|
|
|
|
|
|
|
|
for(i = 0; SS.GW.menu[i].level >= 0; i++) {
|
|
|
|
if(SS.GW.menu[i].level == 0) subMenu++;
|
|
|
|
|
|
|
|
if(SS.GW.menu[i].id == id) {
|
|
|
|
if(subMenu < 0) oops();
|
2013-09-19 06:35:56 +00:00
|
|
|
if(subMenu >= arraylen(SubMenus)) oops();
|
2008-04-14 10:28:32 +00:00
|
|
|
|
2008-04-18 07:06:37 +00:00
|
|
|
if(check) {
|
|
|
|
CheckMenuItem(SubMenus[subMenu], id,
|
|
|
|
yes ? MF_CHECKED : MF_UNCHECKED);
|
|
|
|
} else {
|
|
|
|
EnableMenuItem(SubMenus[subMenu], id,
|
|
|
|
yes ? MF_ENABLED : MF_GRAYED);
|
|
|
|
}
|
2008-04-14 10:28:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
oops();
|
|
|
|
}
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
void CheckMenuById(int id, bool checked)
|
2008-04-18 07:06:37 +00:00
|
|
|
{
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
MenuById(id, checked, true);
|
2008-04-18 07:06:37 +00:00
|
|
|
}
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
void RadioMenuById(int id, bool selected)
|
2013-09-19 04:59:18 +00:00
|
|
|
{
|
|
|
|
// Windows does not natively support radio-button menu items
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
MenuById(id, selected, true);
|
2013-09-19 04:59:18 +00:00
|
|
|
}
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
void EnableMenuById(int id, bool enabled)
|
2008-04-18 07:06:37 +00:00
|
|
|
{
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
MenuById(id, enabled, false);
|
2008-04-18 07:06:37 +00:00
|
|
|
}
|
2008-05-28 10:10:31 +00:00
|
|
|
static void DoRecent(HMENU m, int base)
|
|
|
|
{
|
|
|
|
while(DeleteMenu(m, 0, MF_BYPOSITION))
|
|
|
|
;
|
|
|
|
int i, c = 0;
|
|
|
|
for(i = 0; i < MAX_RECENT; i++) {
|
|
|
|
char *s = RecentFile[i];
|
|
|
|
if(*s) {
|
|
|
|
AppendMenu(m, MF_STRING, base+i, s);
|
|
|
|
c++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(c == 0) AppendMenu(m, MF_STRING | MF_GRAYED, 0, "(no recent files)");
|
|
|
|
}
|
|
|
|
void RefreshRecentMenus(void)
|
|
|
|
{
|
|
|
|
DoRecent(RecentOpenMenu, RECENT_OPEN);
|
|
|
|
DoRecent(RecentImportMenu, RECENT_IMPORT);
|
|
|
|
}
|
2008-04-14 10:28:32 +00:00
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
HMENU CreateGraphicsWindowMenus(void)
|
|
|
|
{
|
|
|
|
HMENU top = CreateMenu();
|
2013-08-26 19:36:00 +00:00
|
|
|
HMENU m = 0;
|
2008-03-26 09:18:12 +00:00
|
|
|
|
|
|
|
int i;
|
|
|
|
int subMenu = 0;
|
|
|
|
|
|
|
|
for(i = 0; SS.GW.menu[i].level >= 0; i++) {
|
2013-09-20 19:01:00 +00:00
|
|
|
char label[100] = { '\0' };
|
|
|
|
if(SS.GW.menu[i].label) {
|
|
|
|
char accelbuf[40];
|
|
|
|
const char *sep =
|
|
|
|
MakeAcceleratorLabel(SS.GW.menu[i].accel, accelbuf) ?
|
|
|
|
"\t" : "";
|
|
|
|
sprintf(label, "%s%s%s", SS.GW.menu[i].label, sep, accelbuf);
|
|
|
|
}
|
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
if(SS.GW.menu[i].level == 0) {
|
|
|
|
m = CreateMenu();
|
2013-09-20 19:01:00 +00:00
|
|
|
AppendMenu(top, MF_STRING | MF_POPUP, (UINT_PTR)m, label);
|
2008-03-26 09:18:12 +00:00
|
|
|
if(subMenu >= arraylen(SubMenus)) oops();
|
|
|
|
SubMenus[subMenu] = m;
|
|
|
|
subMenu++;
|
2008-05-28 10:10:31 +00:00
|
|
|
} else if(SS.GW.menu[i].level == 1) {
|
2013-09-20 17:40:17 +00:00
|
|
|
if(SS.GW.menu[i].id == GraphicsWindow::MNU_OPEN_RECENT) {
|
|
|
|
RecentOpenMenu = CreateMenu();
|
|
|
|
AppendMenu(m, MF_STRING | MF_POPUP,
|
2013-09-20 19:01:00 +00:00
|
|
|
(UINT_PTR)RecentOpenMenu, label);
|
2013-09-20 17:40:17 +00:00
|
|
|
} else if(SS.GW.menu[i].id == GraphicsWindow::MNU_GROUP_RECENT) {
|
|
|
|
RecentImportMenu = CreateMenu();
|
|
|
|
AppendMenu(m, MF_STRING | MF_POPUP,
|
2013-09-20 19:01:00 +00:00
|
|
|
(UINT_PTR)RecentImportMenu, label);
|
2013-09-20 17:40:17 +00:00
|
|
|
} else if(SS.GW.menu[i].label) {
|
2013-09-20 19:01:00 +00:00
|
|
|
AppendMenu(m, MF_STRING, SS.GW.menu[i].id, label);
|
2008-03-26 09:18:12 +00:00
|
|
|
} else {
|
|
|
|
AppendMenu(m, MF_SEPARATOR, SS.GW.menu[i].id, "");
|
|
|
|
}
|
2008-05-28 10:10:31 +00:00
|
|
|
} else oops();
|
2008-03-26 09:18:12 +00:00
|
|
|
}
|
2008-05-28 10:10:31 +00:00
|
|
|
RefreshRecentMenus();
|
2008-03-26 09:18:12 +00:00
|
|
|
|
|
|
|
return top;
|
|
|
|
}
|
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
static void CreateMainWindows(void)
|
|
|
|
{
|
|
|
|
WNDCLASSEX wc;
|
|
|
|
|
|
|
|
memset(&wc, 0, sizeof(wc));
|
|
|
|
wc.cbSize = sizeof(wc);
|
2008-03-26 09:18:12 +00:00
|
|
|
|
|
|
|
// The graphics window, where the sketch is drawn and shown.
|
2008-03-25 10:02:13 +00:00
|
|
|
wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW | CS_OWNDC |
|
|
|
|
CS_DBLCLKS;
|
2008-03-26 09:18:12 +00:00
|
|
|
wc.lpfnWndProc = (WNDPROC)GraphicsWndProc;
|
2008-03-27 09:53:51 +00:00
|
|
|
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
2008-03-26 09:18:12 +00:00
|
|
|
wc.lpszClassName = "GraphicsWnd";
|
2008-03-25 10:02:13 +00:00
|
|
|
wc.lpszMenuName = NULL;
|
|
|
|
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
2008-07-18 09:50:52 +00:00
|
|
|
wc.hIcon = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000),
|
|
|
|
IMAGE_ICON, 32, 32, 0);
|
|
|
|
wc.hIconSm = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000),
|
|
|
|
IMAGE_ICON, 16, 16, 0);
|
2008-03-25 10:02:13 +00:00
|
|
|
if(!RegisterClassEx(&wc)) oops();
|
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
HMENU top = CreateGraphicsWindowMenus();
|
2008-04-12 14:12:26 +00:00
|
|
|
GraphicsWnd = CreateWindowEx(0, "GraphicsWnd",
|
2009-06-14 04:36:38 +00:00
|
|
|
"SolveSpace (not yet saved)",
|
2008-03-25 10:02:13 +00:00
|
|
|
WS_OVERLAPPED | WS_THICKFRAME | WS_CLIPCHILDREN | WS_MAXIMIZEBOX |
|
2008-03-27 09:53:51 +00:00
|
|
|
WS_MINIMIZEBOX | WS_SYSMENU | WS_SIZEBOX | WS_CLIPSIBLINGS,
|
2008-05-27 09:59:19 +00:00
|
|
|
50, 50, 900, 600, NULL, top, Instance, NULL);
|
2008-03-26 09:18:12 +00:00
|
|
|
if(!GraphicsWnd) oops();
|
|
|
|
|
2008-04-21 10:12:04 +00:00
|
|
|
GraphicsEditControl = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
|
|
|
|
WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS,
|
|
|
|
50, 50, 100, 21, GraphicsWnd, NULL, Instance, NULL);
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
SendMessage(GraphicsEditControl, WM_SETFONT, (WPARAM)FixedFont, true);
|
2008-04-21 10:12:04 +00:00
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
// The text window, with a comand line and some textual information
|
|
|
|
// about the sketch.
|
2008-04-11 12:47:14 +00:00
|
|
|
wc.style &= ~CS_DBLCLKS;
|
2008-03-26 09:18:12 +00:00
|
|
|
wc.lpfnWndProc = (WNDPROC)TextWndProc;
|
|
|
|
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
|
|
|
wc.lpszClassName = "TextWnd";
|
2008-03-28 10:00:37 +00:00
|
|
|
wc.hCursor = NULL;
|
2008-03-26 09:18:12 +00:00
|
|
|
if(!RegisterClassEx(&wc)) oops();
|
|
|
|
|
|
|
|
// We get the desired Alt+Tab behaviour by specifying that the text
|
|
|
|
// window is a child of the graphics window.
|
|
|
|
TextWnd = CreateWindowEx(0,
|
2010-05-03 05:04:42 +00:00
|
|
|
"TextWnd", "SolveSpace - Browser", WS_THICKFRAME | WS_CLIPCHILDREN,
|
2008-05-27 09:59:19 +00:00
|
|
|
650, 500, 420, 300, GraphicsWnd, (HMENU)NULL, Instance, NULL);
|
2008-03-25 10:02:13 +00:00
|
|
|
if(!TextWnd) oops();
|
|
|
|
|
|
|
|
TextWndScrollBar = CreateWindowEx(0, WC_SCROLLBAR, "", WS_CHILD |
|
|
|
|
SBS_VERT | SBS_LEFTALIGN | WS_VISIBLE | WS_CLIPSIBLINGS,
|
|
|
|
200, 100, 100, 100, TextWnd, NULL, Instance, NULL);
|
|
|
|
// Force the scrollbar to get resized to the window,
|
|
|
|
TextWndProc(TextWnd, WM_SIZE, 0, 0);
|
|
|
|
|
2008-05-27 06:36:59 +00:00
|
|
|
TextEditControl = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
|
|
|
|
WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS,
|
|
|
|
50, 50, 100, 21, TextWnd, NULL, Instance, NULL);
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
SendMessage(TextEditControl, WM_SETFONT, (WPARAM)FixedFont, true);
|
2008-05-27 06:36:59 +00:00
|
|
|
|
2010-04-26 07:52:49 +00:00
|
|
|
// Now that all our windows exist, set up gl contexts.
|
|
|
|
CreateGlContext(TextWnd, &TextGl);
|
|
|
|
CreateGlContext(GraphicsWnd, &GraphicsGl);
|
2008-03-25 10:02:13 +00:00
|
|
|
|
|
|
|
RECT r, rc;
|
|
|
|
GetWindowRect(TextWnd, &r);
|
|
|
|
GetClientRect(TextWnd, &rc);
|
|
|
|
ClientIsSmallerBy = (r.bottom - r.top) - (rc.bottom - rc.top);
|
|
|
|
}
|
|
|
|
|
2013-09-20 19:25:14 +00:00
|
|
|
#ifdef HAVE_SPACEWARE_INPUT
|
2009-07-20 19:05:33 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Test if a message comes from the SpaceNavigator device. If yes, dispatch
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
// it appropriately and return true. Otherwise, do nothing and return false.
|
2009-07-20 19:05:33 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
static bool ProcessSpaceNavigatorMsg(MSG *msg) {
|
|
|
|
if(SpaceNavigator == SI_NO_HANDLE) return false;
|
2009-07-20 19:05:33 +00:00
|
|
|
|
|
|
|
SiGetEventData sged;
|
|
|
|
SiSpwEvent sse;
|
|
|
|
|
|
|
|
SiGetEventWinInit(&sged, msg->message, msg->wParam, msg->lParam);
|
|
|
|
int ret = SiGetEvent(SpaceNavigator, 0, &sged, &sse);
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
if(ret == SI_NOT_EVENT) return false;
|
2009-07-20 19:05:33 +00:00
|
|
|
// So the device is a SpaceNavigator event, or a SpaceNavigator error.
|
|
|
|
|
|
|
|
if(ret == SI_IS_EVENT) {
|
|
|
|
if(sse.type == SI_MOTION_EVENT) {
|
|
|
|
// The Z axis translation and rotation are both
|
|
|
|
// backwards in the default mapping.
|
2009-07-26 01:29:56 +00:00
|
|
|
double tx = sse.u.spwData.mData[SI_TX]*1.0,
|
|
|
|
ty = sse.u.spwData.mData[SI_TY]*1.0,
|
|
|
|
tz = -sse.u.spwData.mData[SI_TZ]*1.0,
|
2009-07-20 19:05:33 +00:00
|
|
|
rx = sse.u.spwData.mData[SI_RX]*0.001,
|
|
|
|
ry = sse.u.spwData.mData[SI_RY]*0.001,
|
|
|
|
rz = -sse.u.spwData.mData[SI_RZ]*0.001;
|
|
|
|
SS.GW.SpaceNavigatorMoved(tx, ty, tz, rx, ry, rz,
|
|
|
|
!!(GetAsyncKeyState(VK_SHIFT) & 0x8000));
|
|
|
|
} else if(sse.type == SI_BUTTON_EVENT) {
|
|
|
|
int button;
|
|
|
|
button = SiButtonReleased(&sse);
|
|
|
|
if(button == SI_APP_FIT_BUTTON) SS.GW.SpaceNavigatorButtonUp();
|
|
|
|
}
|
|
|
|
}
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
return true;
|
2009-07-20 19:05:33 +00:00
|
|
|
}
|
2013-09-20 19:25:14 +00:00
|
|
|
#endif // HAVE_SPACEWARE_INPUT
|
2009-07-20 19:05:33 +00:00
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Entry point into the program.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|
|
|
LPSTR lpCmdLine, INT nCmdShow)
|
|
|
|
{
|
|
|
|
Instance = hInstance;
|
|
|
|
|
2008-04-21 10:12:04 +00:00
|
|
|
InitCommonControls();
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
// A monospaced font
|
2010-04-26 07:52:49 +00:00
|
|
|
FixedFont = CreateFont(SS.TW.CHAR_HEIGHT, SS.TW.CHAR_WIDTH, 0, 0,
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
FW_REGULAR, false,
|
|
|
|
false, false, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
2008-03-25 10:02:13 +00:00
|
|
|
DEFAULT_QUALITY, FF_DONTCARE, "Lucida Console");
|
|
|
|
if(!FixedFont)
|
|
|
|
FixedFont = (HFONT)GetStockObject(SYSTEM_FONT);
|
|
|
|
|
2008-04-21 10:12:04 +00:00
|
|
|
// Create the root windows: one for control, with text, and one for
|
|
|
|
// the graphics
|
|
|
|
CreateMainWindows();
|
|
|
|
|
|
|
|
ThawWindowPos(TextWnd);
|
|
|
|
ThawWindowPos(GraphicsWnd);
|
|
|
|
|
2009-06-14 04:36:38 +00:00
|
|
|
ShowWindow(TextWnd, SW_SHOWNOACTIVATE);
|
|
|
|
ShowWindow(GraphicsWnd, SW_SHOW);
|
|
|
|
|
|
|
|
glClearColor(0, 0, 0, 1);
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
SwapBuffers(GetDC(GraphicsWnd));
|
|
|
|
glClearColor(0, 0, 0, 1);
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT);
|
|
|
|
SwapBuffers(GetDC(GraphicsWnd));
|
|
|
|
|
2009-04-20 07:30:09 +00:00
|
|
|
// Create the heaps for all dynamic memory (AllocTemporary, MemAlloc)
|
|
|
|
InitHeaps();
|
2008-04-13 14:28:35 +00:00
|
|
|
|
2008-06-16 08:35:05 +00:00
|
|
|
// A filename may have been specified on the command line; if so, then
|
|
|
|
// strip any quotation marks, and make it absolute.
|
|
|
|
char file[MAX_PATH] = "";
|
|
|
|
if(strlen(lpCmdLine)+1 < MAX_PATH) {
|
|
|
|
char *s = lpCmdLine;
|
|
|
|
while(*s == ' ' || *s == '"') s++;
|
|
|
|
strcpy(file, s);
|
|
|
|
s = strrchr(file, '"');
|
|
|
|
if(s) *s = '\0';
|
|
|
|
}
|
|
|
|
if(*file != '\0') {
|
2008-06-25 05:14:49 +00:00
|
|
|
GetAbsoluteFilename(file);
|
2008-06-16 08:35:05 +00:00
|
|
|
}
|
2009-07-20 19:05:33 +00:00
|
|
|
|
2013-09-20 19:25:14 +00:00
|
|
|
#ifdef HAVE_SPACEWARE_INPUT
|
2009-07-20 19:05:33 +00:00
|
|
|
// Initialize the SpaceBall, if present. Test if the driver is running
|
|
|
|
// first, to avoid a long timeout if it's not.
|
|
|
|
HWND swdc = FindWindow("SpaceWare Driver Class", NULL);
|
|
|
|
if(swdc != NULL) {
|
|
|
|
SiOpenData sod;
|
|
|
|
SiInitialize();
|
|
|
|
SiOpenWinInit(&sod, GraphicsWnd);
|
|
|
|
SpaceNavigator =
|
|
|
|
SiOpen("GraphicsWnd", SI_ANY_DEVICE, SI_NO_MASK, SI_EVENT, &sod);
|
|
|
|
SiSetUiMode(SpaceNavigator, SI_UI_NO_CONTROLS);
|
|
|
|
}
|
2013-09-20 19:25:14 +00:00
|
|
|
#endif
|
2008-06-16 08:35:05 +00:00
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
// Call in to the platform-independent code, and let them do their init
|
2008-06-25 05:14:49 +00:00
|
|
|
SS.Init(file);
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
// And now it's the message loop. All calls in to the rest of the code
|
|
|
|
// will be from the wndprocs.
|
|
|
|
MSG msg;
|
|
|
|
DWORD ret;
|
2013-08-26 20:54:04 +00:00
|
|
|
while((ret = GetMessage(&msg, NULL, 0, 0)) != 0) {
|
2013-09-20 19:25:14 +00:00
|
|
|
#ifdef HAVE_SPACEWARE_INPUT
|
2009-07-20 19:05:33 +00:00
|
|
|
// Is it a message from the six degree of freedom input device?
|
|
|
|
if(ProcessSpaceNavigatorMsg(&msg)) goto done;
|
2013-09-20 19:25:14 +00:00
|
|
|
#endif
|
2009-07-20 19:05:33 +00:00
|
|
|
|
|
|
|
// A message from the keyboard, which should be processed as a keyboard
|
|
|
|
// accelerator?
|
2008-04-12 15:17:58 +00:00
|
|
|
if(msg.message == WM_KEYDOWN) {
|
2008-06-03 18:28:41 +00:00
|
|
|
if(ProcessKeyDown(msg.wParam)) goto done;
|
|
|
|
}
|
|
|
|
if(msg.message == WM_SYSKEYDOWN && msg.hwnd == TextWnd) {
|
|
|
|
// If the user presses the Alt key when the text window has focus,
|
|
|
|
// then that should probably go to the graphics window instead.
|
|
|
|
SetForegroundWindow(GraphicsWnd);
|
2008-04-12 15:17:58 +00:00
|
|
|
}
|
2009-07-20 19:05:33 +00:00
|
|
|
|
|
|
|
// None of the above; so just a normal message to process.
|
2008-03-25 10:02:13 +00:00
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
2008-06-03 18:28:41 +00:00
|
|
|
done:
|
|
|
|
SS.DoLater();
|
2008-03-25 10:02:13 +00:00
|
|
|
}
|
2008-05-28 10:10:31 +00:00
|
|
|
|
2013-09-20 19:25:14 +00:00
|
|
|
#ifdef HAVE_SPACEWARE_INPUT
|
2009-07-20 19:05:33 +00:00
|
|
|
if(swdc != NULL) {
|
|
|
|
if(SpaceNavigator != SI_NO_HANDLE) SiClose(SpaceNavigator);
|
|
|
|
SiTerminate();
|
|
|
|
}
|
2013-09-20 19:25:14 +00:00
|
|
|
#endif
|
2009-07-20 19:05:33 +00:00
|
|
|
|
2008-05-28 10:10:31 +00:00
|
|
|
// Write everything back to the registry
|
2008-03-26 09:18:12 +00:00
|
|
|
FreezeWindowPos(TextWnd);
|
|
|
|
FreezeWindowPos(GraphicsWnd);
|
2013-09-19 04:33:12 +00:00
|
|
|
|
|
|
|
// Free the memory we've used; anything that remains is a leak.
|
|
|
|
SK.Clear();
|
|
|
|
SS.Clear();
|
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
return 0;
|
|
|
|
}
|