mirror of
https://github.com/reactos/reactos.git
synced 2025-04-20 12:29:56 +00:00
[MSPAINT]
restructuring: - put window class initialization where it belongs - add separate window procedure for the scroll box class svn path=/trunk/; revision=62117
This commit is contained in:
parent
26da1ec606
commit
a9583308c4
16 changed files with 311 additions and 204 deletions
|
@ -8,6 +8,7 @@ list(APPEND SOURCE
|
|||
mouse.c
|
||||
palette.c
|
||||
registry.c
|
||||
scrollbox.c
|
||||
selection.c
|
||||
sizebox.c
|
||||
textedit.c
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "precomp.h"
|
||||
|
||||
#include "winproc.h"
|
||||
#include "scrollbox.h"
|
||||
#include "palette.h"
|
||||
#include "toolsettings.h"
|
||||
#include "selection.h"
|
||||
|
@ -139,13 +140,6 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
|||
HWND hwnd; /* This is the handle for our window */
|
||||
MSG messages; /* Here messages to the application are saved */
|
||||
|
||||
WNDCLASSEX wclScroll;
|
||||
WNDCLASSEX wincl;
|
||||
WNDCLASSEX wclPal;
|
||||
WNDCLASSEX wclSettings;
|
||||
WNDCLASSEX wclSelection;
|
||||
WNDCLASSEX wclTextEdit;
|
||||
|
||||
TCHAR progtitle[1000];
|
||||
TCHAR resstr[100];
|
||||
HMENU menu;
|
||||
|
@ -192,113 +186,17 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
|||
|
||||
hProgInstance = hThisInstance;
|
||||
|
||||
/* Necessary */
|
||||
/* initialize common controls library */
|
||||
InitCommonControls();
|
||||
|
||||
/* initializing and registering the window class used for the main window */
|
||||
wincl.hInstance = hThisInstance;
|
||||
wincl.lpszClassName = _T("WindowsApp");
|
||||
wincl.lpfnWndProc = WindowProcedure;
|
||||
wincl.style = CS_DBLCLKS;
|
||||
wincl.cbSize = sizeof(WNDCLASSEX);
|
||||
wincl.hIcon = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDI_APPICON));
|
||||
wincl.hIconSm = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDI_APPICON));
|
||||
wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wincl.lpszMenuName = NULL;
|
||||
wincl.cbClsExtra = 0;
|
||||
wincl.cbWndExtra = 0;
|
||||
wincl.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
|
||||
RegisterClassEx (&wincl);
|
||||
|
||||
/* initializing and registering the window class used for the scroll box */
|
||||
wclScroll.hInstance = hThisInstance;
|
||||
wclScroll.lpszClassName = _T("Scrollbox");
|
||||
wclScroll.lpfnWndProc = WindowProcedure;
|
||||
wclScroll.style = 0;
|
||||
wclScroll.cbSize = sizeof(WNDCLASSEX);
|
||||
wclScroll.hIcon = NULL;
|
||||
wclScroll.hIconSm = NULL;
|
||||
wclScroll.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wclScroll.lpszMenuName = NULL;
|
||||
wclScroll.cbClsExtra = 0;
|
||||
wclScroll.cbWndExtra = 0;
|
||||
wclScroll.hbrBackground = GetSysColorBrush(COLOR_APPWORKSPACE);
|
||||
RegisterClassEx (&wclScroll);
|
||||
|
||||
/* initializing and registering the window class used for the palette window */
|
||||
wclPal.hInstance = hThisInstance;
|
||||
wclPal.lpszClassName = _T("Palette");
|
||||
wclPal.lpfnWndProc = PalWinProc;
|
||||
wclPal.style = CS_DBLCLKS;
|
||||
wclPal.cbSize = sizeof(WNDCLASSEX);
|
||||
wclPal.hIcon = NULL;
|
||||
wclPal.hIconSm = NULL;
|
||||
wclPal.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wclPal.lpszMenuName = NULL;
|
||||
wclPal.cbClsExtra = 0;
|
||||
wclPal.cbWndExtra = 0;
|
||||
wclPal.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
|
||||
RegisterClassEx (&wclPal);
|
||||
|
||||
/* initializing and registering the window class for the settings window */
|
||||
wclSettings.hInstance = hThisInstance;
|
||||
wclSettings.lpszClassName = _T("ToolSettings");
|
||||
wclSettings.lpfnWndProc = SettingsWinProc;
|
||||
wclSettings.style = CS_DBLCLKS;
|
||||
wclSettings.cbSize = sizeof(WNDCLASSEX);
|
||||
wclSettings.hIcon = NULL;
|
||||
wclSettings.hIconSm = NULL;
|
||||
wclSettings.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wclSettings.lpszMenuName = NULL;
|
||||
wclSettings.cbClsExtra = 0;
|
||||
wclSettings.cbWndExtra = 0;
|
||||
wclSettings.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
|
||||
RegisterClassEx (&wclSettings);
|
||||
|
||||
/* initializing and registering the window class for the selection frame */
|
||||
wclSelection.hInstance = hThisInstance;
|
||||
wclSelection.lpszClassName = _T("Selection");
|
||||
wclSelection.lpfnWndProc = SelectionWinProc;
|
||||
wclSelection.style = CS_DBLCLKS;
|
||||
wclSelection.cbSize = sizeof(WNDCLASSEX);
|
||||
wclSelection.hIcon = NULL;
|
||||
wclSelection.hIconSm = NULL;
|
||||
wclSelection.hCursor = LoadCursor(NULL, IDC_SIZEALL);
|
||||
wclSelection.lpszMenuName = NULL;
|
||||
wclSelection.cbClsExtra = 0;
|
||||
wclSelection.cbWndExtra = 0;
|
||||
wclSelection.hbrBackground = NULL;
|
||||
RegisterClassEx (&wclSelection);
|
||||
|
||||
/* initializing and registering the window class for the size boxes */
|
||||
wclSettings.hInstance = hThisInstance;
|
||||
wclSettings.lpszClassName = _T("Sizebox");
|
||||
wclSettings.lpfnWndProc = SizeboxWinProc;
|
||||
wclSettings.style = CS_DBLCLKS;
|
||||
wclSettings.cbSize = sizeof(WNDCLASSEX);
|
||||
wclSettings.hIcon = NULL;
|
||||
wclSettings.hIconSm = NULL;
|
||||
wclSettings.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wclSettings.lpszMenuName = NULL;
|
||||
wclSettings.cbClsExtra = 0;
|
||||
wclSettings.cbWndExtra = 0;
|
||||
wclSettings.hbrBackground = GetSysColorBrush(COLOR_HIGHLIGHT);
|
||||
RegisterClassEx (&wclSettings);
|
||||
|
||||
/* initializing and registering the window class used for the text editor */
|
||||
wclTextEdit.hInstance = hThisInstance;
|
||||
wclTextEdit.lpszClassName = _T("TextEdit");
|
||||
wclTextEdit.lpfnWndProc = TextEditWinProc;
|
||||
wclTextEdit.style = CS_DBLCLKS;
|
||||
wclTextEdit.cbSize = sizeof(WNDCLASSEX);
|
||||
wclTextEdit.hIcon = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDI_APPICON));
|
||||
wclTextEdit.hIconSm = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDI_APPICON));
|
||||
wclTextEdit.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wclTextEdit.lpszMenuName = NULL;
|
||||
wclTextEdit.cbClsExtra = 0;
|
||||
wclTextEdit.cbWndExtra = 0;
|
||||
wclTextEdit.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
|
||||
RegisterClassEx (&wclTextEdit);
|
||||
/* register application defined window classes */
|
||||
RegisterWclMain();
|
||||
RegisterWclScrollbox();
|
||||
RegisterWclPal();
|
||||
RegisterWclSettings();
|
||||
RegisterWclSelection();
|
||||
RegisterWclSizebox();
|
||||
RegisterWclTextEdit();
|
||||
|
||||
LoadString(hThisInstance, IDS_DEFAULTFILENAME, filename, SIZEOF(filename));
|
||||
LoadString(hThisInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr));
|
||||
|
@ -307,12 +205,12 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
|||
|
||||
/* create main window */
|
||||
hwnd =
|
||||
CreateWindowEx(0, _T("WindowsApp"), progtitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 544,
|
||||
CreateWindowEx(0, _T("MainWindow"), progtitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 544,
|
||||
375, HWND_DESKTOP, NULL, hThisInstance, NULL);
|
||||
hMainWnd = hwnd;
|
||||
|
||||
hwndMiniature =
|
||||
CreateWindowEx(WS_EX_PALETTEWINDOW, _T("WindowsApp"), miniaturetitle,
|
||||
CreateWindowEx(WS_EX_PALETTEWINDOW, _T("MainWindow"), miniaturetitle,
|
||||
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, 180, 200, 120, 100, hwnd,
|
||||
NULL, hThisInstance, NULL);
|
||||
|
||||
|
@ -337,7 +235,7 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
|||
hThisInstance, NULL);
|
||||
|
||||
hToolBoxContainer =
|
||||
CreateWindowEx(0, _T("WindowsApp"), _T(""), WS_CHILD | WS_VISIBLE, 2, 2, 52, 350, hwnd, NULL,
|
||||
CreateWindowEx(0, _T("MainWindow"), _T(""), WS_CHILD | WS_VISIBLE, 2, 2, 52, 350, hwnd, NULL,
|
||||
hThisInstance, NULL);
|
||||
/* creating the 16 bitmap radio buttons and setting the bitmap */
|
||||
|
||||
|
@ -417,7 +315,7 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
|||
|
||||
/* creating the window inside the scroll box, on which the image in hDrawingDC's bitmap is drawn */
|
||||
hImageArea =
|
||||
CreateWindowEx(0, _T("Scrollbox"), _T(""), WS_CHILD | WS_VISIBLE, 3, 3, imgXRes, imgYRes, hScrlClient,
|
||||
CreateWindowEx(0, _T("MainWindow"), _T(""), WS_CHILD | WS_VISIBLE, 3, 3, imgXRes, imgYRes, hScrlClient,
|
||||
NULL, hThisInstance, NULL);
|
||||
|
||||
hDC = GetDC(hImageArea);
|
||||
|
|
|
@ -9,9 +9,30 @@
|
|||
/* INCLUDES *********************************************************/
|
||||
|
||||
#include "precomp.h"
|
||||
#include "palette.h"
|
||||
|
||||
/* FUNCTIONS ********************************************************/
|
||||
|
||||
void
|
||||
RegisterWclPal()
|
||||
{
|
||||
WNDCLASSEX wclPal;
|
||||
/* initializing and registering the window class used for the palette window */
|
||||
wclPal.hInstance = hProgInstance;
|
||||
wclPal.lpszClassName = _T("Palette");
|
||||
wclPal.lpfnWndProc = PalWinProc;
|
||||
wclPal.style = CS_DBLCLKS;
|
||||
wclPal.cbSize = sizeof(WNDCLASSEX);
|
||||
wclPal.hIcon = NULL;
|
||||
wclPal.hIconSm = NULL;
|
||||
wclPal.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wclPal.lpszMenuName = NULL;
|
||||
wclPal.cbClsExtra = 0;
|
||||
wclPal.cbWndExtra = 0;
|
||||
wclPal.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
|
||||
RegisterClassEx (&wclPal);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK
|
||||
PalWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
|
|
@ -6,4 +6,6 @@
|
|||
* PROGRAMMERS: Benedikt Freisen
|
||||
*/
|
||||
|
||||
void RegisterWclPal();
|
||||
|
||||
LRESULT CALLBACK PalWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
|
142
reactos/base/applications/mspaint/scrollbox.c
Normal file
142
reactos/base/applications/mspaint/scrollbox.c
Normal file
|
@ -0,0 +1,142 @@
|
|||
/*
|
||||
* PROJECT: PAINT for ReactOS
|
||||
* LICENSE: LGPL
|
||||
* FILE: scrollbox.c
|
||||
* PURPOSE: Functionality surrounding the scroll box window class
|
||||
* PROGRAMMERS: Benedikt Freisen
|
||||
*/
|
||||
|
||||
/* INCLUDES *********************************************************/
|
||||
|
||||
#include "precomp.h"
|
||||
#include "scrollbox.h"
|
||||
|
||||
/* FUNCTIONS ********************************************************/
|
||||
|
||||
void
|
||||
RegisterWclScrollbox()
|
||||
{
|
||||
WNDCLASSEX wclScroll;
|
||||
/* initializing and registering the window class used for the scroll box */
|
||||
wclScroll.hInstance = hProgInstance;
|
||||
wclScroll.lpszClassName = _T("Scrollbox");
|
||||
wclScroll.lpfnWndProc = ScrollboxWinProc;
|
||||
wclScroll.style = 0;
|
||||
wclScroll.cbSize = sizeof(WNDCLASSEX);
|
||||
wclScroll.hIcon = NULL;
|
||||
wclScroll.hIconSm = NULL;
|
||||
wclScroll.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wclScroll.lpszMenuName = NULL;
|
||||
wclScroll.cbClsExtra = 0;
|
||||
wclScroll.cbWndExtra = 0;
|
||||
wclScroll.hbrBackground = GetSysColorBrush(COLOR_APPWORKSPACE);
|
||||
RegisterClassEx (&wclScroll);
|
||||
}
|
||||
|
||||
void
|
||||
UpdateScrollbox()
|
||||
{
|
||||
RECT clientRectScrollbox;
|
||||
RECT clientRectImageArea;
|
||||
SCROLLINFO si;
|
||||
GetClientRect(hScrollbox, &clientRectScrollbox);
|
||||
GetClientRect(hImageArea, &clientRectImageArea);
|
||||
si.cbSize = sizeof(SCROLLINFO);
|
||||
si.fMask = SIF_PAGE | SIF_RANGE;
|
||||
si.nMax = clientRectImageArea.right + 6 - 1;
|
||||
si.nMin = 0;
|
||||
si.nPage = clientRectScrollbox.right;
|
||||
SetScrollInfo(hScrollbox, SB_HORZ, &si, TRUE);
|
||||
GetClientRect(hScrollbox, &clientRectScrollbox);
|
||||
si.nMax = clientRectImageArea.bottom + 6 - 1;
|
||||
si.nPage = clientRectScrollbox.bottom;
|
||||
SetScrollInfo(hScrollbox, SB_VERT, &si, TRUE);
|
||||
MoveWindow(hScrlClient,
|
||||
-GetScrollPos(hScrollbox, SB_HORZ), -GetScrollPos(hScrollbox, SB_VERT),
|
||||
max(clientRectImageArea.right + 6, clientRectScrollbox.right),
|
||||
max(clientRectImageArea.bottom + 6, clientRectScrollbox.bottom), TRUE);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK
|
||||
ScrollboxWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_SIZE:
|
||||
if (hwnd == hScrollbox)
|
||||
{
|
||||
UpdateScrollbox();
|
||||
}
|
||||
break;
|
||||
case WM_HSCROLL:
|
||||
if (hwnd == hScrollbox)
|
||||
{
|
||||
SCROLLINFO si;
|
||||
si.cbSize = sizeof(SCROLLINFO);
|
||||
si.fMask = SIF_ALL;
|
||||
GetScrollInfo(hScrollbox, SB_HORZ, &si);
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case SB_THUMBTRACK:
|
||||
case SB_THUMBPOSITION:
|
||||
si.nPos = HIWORD(wParam);
|
||||
break;
|
||||
case SB_LINELEFT:
|
||||
si.nPos -= 5;
|
||||
break;
|
||||
case SB_LINERIGHT:
|
||||
si.nPos += 5;
|
||||
break;
|
||||
case SB_PAGELEFT:
|
||||
si.nPos -= si.nPage;
|
||||
break;
|
||||
case SB_PAGERIGHT:
|
||||
si.nPos += si.nPage;
|
||||
break;
|
||||
}
|
||||
SetScrollInfo(hScrollbox, SB_HORZ, &si, TRUE);
|
||||
MoveWindow(hScrlClient, -GetScrollPos(hScrollbox, SB_HORZ),
|
||||
-GetScrollPos(hScrollbox, SB_VERT), imgXRes * zoom / 1000 + 6,
|
||||
imgYRes * zoom / 1000 + 6, TRUE);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_VSCROLL:
|
||||
if (hwnd == hScrollbox)
|
||||
{
|
||||
SCROLLINFO si;
|
||||
si.cbSize = sizeof(SCROLLINFO);
|
||||
si.fMask = SIF_ALL;
|
||||
GetScrollInfo(hScrollbox, SB_VERT, &si);
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case SB_THUMBTRACK:
|
||||
case SB_THUMBPOSITION:
|
||||
si.nPos = HIWORD(wParam);
|
||||
break;
|
||||
case SB_LINEUP:
|
||||
si.nPos -= 5;
|
||||
break;
|
||||
case SB_LINEDOWN:
|
||||
si.nPos += 5;
|
||||
break;
|
||||
case SB_PAGEUP:
|
||||
si.nPos -= si.nPage;
|
||||
break;
|
||||
case SB_PAGEDOWN:
|
||||
si.nPos += si.nPage;
|
||||
break;
|
||||
}
|
||||
SetScrollInfo(hScrollbox, SB_VERT, &si, TRUE);
|
||||
MoveWindow(hScrlClient, -GetScrollPos(hScrollbox, SB_HORZ),
|
||||
-GetScrollPos(hScrollbox, SB_VERT), imgXRes * zoom / 1000 + 6,
|
||||
imgYRes * zoom / 1000 + 6, TRUE);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
13
reactos/base/applications/mspaint/scrollbox.h
Normal file
13
reactos/base/applications/mspaint/scrollbox.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* PROJECT: PAINT for ReactOS
|
||||
* LICENSE: LGPL
|
||||
* FILE: scrollbox.h
|
||||
* PURPOSE: Functionality surrounding the scroll box window class
|
||||
* PROGRAMMERS: Benedikt Freisen
|
||||
*/
|
||||
|
||||
void RegisterWclScrollbox();
|
||||
|
||||
void UpdateScrollbox();
|
||||
|
||||
LRESULT CALLBACK ScrollboxWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
|
@ -38,6 +38,26 @@ POINTS pos;
|
|||
POINTS frac;
|
||||
POINT delta;
|
||||
|
||||
void
|
||||
RegisterWclSelection()
|
||||
{
|
||||
WNDCLASSEX wclSelection;
|
||||
/* initializing and registering the window class for the selection frame */
|
||||
wclSelection.hInstance = hProgInstance;
|
||||
wclSelection.lpszClassName = _T("Selection");
|
||||
wclSelection.lpfnWndProc = SelectionWinProc;
|
||||
wclSelection.style = CS_DBLCLKS;
|
||||
wclSelection.cbSize = sizeof(WNDCLASSEX);
|
||||
wclSelection.hIcon = NULL;
|
||||
wclSelection.hIconSm = NULL;
|
||||
wclSelection.hCursor = LoadCursor(NULL, IDC_SIZEALL);
|
||||
wclSelection.lpszMenuName = NULL;
|
||||
wclSelection.cbClsExtra = 0;
|
||||
wclSelection.cbWndExtra = 0;
|
||||
wclSelection.hbrBackground = NULL;
|
||||
RegisterClassEx (&wclSelection);
|
||||
}
|
||||
|
||||
BOOL
|
||||
ColorKeyedMaskBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, HBITMAP hbmMask, int xMask, int yMask, DWORD dwRop, COLORREF keyColor)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
* PROGRAMMERS: Benedikt Freisen
|
||||
*/
|
||||
|
||||
void RegisterWclSelection();
|
||||
|
||||
void ForceRefreshSelectionContents();
|
||||
|
||||
LRESULT CALLBACK SelectionWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
/* INCLUDES *********************************************************/
|
||||
|
||||
#include "precomp.h"
|
||||
#include "sizebox.h"
|
||||
|
||||
/* FUNCTIONS ********************************************************/
|
||||
|
||||
|
@ -16,6 +17,26 @@ BOOL resizing = FALSE;
|
|||
short xOrig;
|
||||
short yOrig;
|
||||
|
||||
void
|
||||
RegisterWclSizebox()
|
||||
{
|
||||
WNDCLASSEX wclSizebox;
|
||||
/* initializing and registering the window class for the size boxes */
|
||||
wclSizebox.hInstance = hProgInstance;
|
||||
wclSizebox.lpszClassName = _T("Sizebox");
|
||||
wclSizebox.lpfnWndProc = SizeboxWinProc;
|
||||
wclSizebox.style = CS_DBLCLKS;
|
||||
wclSizebox.cbSize = sizeof(WNDCLASSEX);
|
||||
wclSizebox.hIcon = NULL;
|
||||
wclSizebox.hIconSm = NULL;
|
||||
wclSizebox.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wclSizebox.lpszMenuName = NULL;
|
||||
wclSizebox.cbClsExtra = 0;
|
||||
wclSizebox.cbWndExtra = 0;
|
||||
wclSizebox.hbrBackground = GetSysColorBrush(COLOR_HIGHLIGHT);
|
||||
RegisterClassEx (&wclSizebox);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK
|
||||
SizeboxWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
|
|
@ -6,4 +6,6 @@
|
|||
* PROGRAMMERS: Benedikt Freisen
|
||||
*/
|
||||
|
||||
void RegisterWclSizebox();
|
||||
|
||||
LRESULT CALLBACK SizeboxWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
|
|
@ -9,9 +9,30 @@
|
|||
/* INCLUDES *********************************************************/
|
||||
|
||||
#include "precomp.h"
|
||||
#include "textedit.h"
|
||||
|
||||
/* FUNCTIONS ********************************************************/
|
||||
|
||||
void
|
||||
RegisterWclTextEdit()
|
||||
{
|
||||
WNDCLASSEX wclTextEdit;
|
||||
/* initializing and registering the window class used for the text editor */
|
||||
wclTextEdit.hInstance = hProgInstance;
|
||||
wclTextEdit.lpszClassName = _T("TextEdit");
|
||||
wclTextEdit.lpfnWndProc = TextEditWinProc;
|
||||
wclTextEdit.style = CS_DBLCLKS;
|
||||
wclTextEdit.cbSize = sizeof(WNDCLASSEX);
|
||||
wclTextEdit.hIcon = LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON));
|
||||
wclTextEdit.hIconSm = LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON));
|
||||
wclTextEdit.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wclTextEdit.lpszMenuName = NULL;
|
||||
wclTextEdit.cbClsExtra = 0;
|
||||
wclTextEdit.cbWndExtra = 0;
|
||||
wclTextEdit.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
|
||||
RegisterClassEx (&wclTextEdit);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK
|
||||
TextEditWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
|
|
@ -6,4 +6,6 @@
|
|||
* PROGRAMMERS: Benedikt Freisen
|
||||
*/
|
||||
|
||||
void RegisterWclTextEdit();
|
||||
|
||||
LRESULT CALLBACK TextEditWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
|
|
@ -9,11 +9,31 @@
|
|||
/* INCLUDES *********************************************************/
|
||||
|
||||
#include "precomp.h"
|
||||
#include "toolsettings.h"
|
||||
|
||||
/* FUNCTIONS ********************************************************/
|
||||
|
||||
extern void zoomTo(int, int, int);
|
||||
|
||||
void RegisterWclSettings()
|
||||
{
|
||||
WNDCLASSEX wclSettings;
|
||||
/* initializing and registering the window class for the settings window */
|
||||
wclSettings.hInstance = hProgInstance;
|
||||
wclSettings.lpszClassName = _T("ToolSettings");
|
||||
wclSettings.lpfnWndProc = SettingsWinProc;
|
||||
wclSettings.style = CS_DBLCLKS;
|
||||
wclSettings.cbSize = sizeof(WNDCLASSEX);
|
||||
wclSettings.hIcon = NULL;
|
||||
wclSettings.hIconSm = NULL;
|
||||
wclSettings.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wclSettings.lpszMenuName = NULL;
|
||||
wclSettings.cbClsExtra = 0;
|
||||
wclSettings.cbWndExtra = 0;
|
||||
wclSettings.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
|
||||
RegisterClassEx (&wclSettings);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK
|
||||
SettingsWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
|
|
@ -6,4 +6,6 @@
|
|||
* PROGRAMMERS: Benedikt Freisen
|
||||
*/
|
||||
|
||||
void RegisterWclSettings();
|
||||
|
||||
LRESULT CALLBACK SettingsWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
|
|
@ -11,11 +11,33 @@
|
|||
|
||||
#include "precomp.h"
|
||||
|
||||
#include "winproc.h"
|
||||
#include "dialogs.h"
|
||||
#include "registry.h"
|
||||
#include "scrollbox.h"
|
||||
|
||||
/* FUNCTIONS ********************************************************/
|
||||
|
||||
void
|
||||
RegisterWclMain()
|
||||
{
|
||||
WNDCLASSEX wclMain;
|
||||
/* initializing and registering the window class used for the main window */
|
||||
wclMain.hInstance = hProgInstance;
|
||||
wclMain.lpszClassName = _T("MainWindow");
|
||||
wclMain.lpfnWndProc = MainWindowProcedure;
|
||||
wclMain.style = CS_DBLCLKS;
|
||||
wclMain.cbSize = sizeof(WNDCLASSEX);
|
||||
wclMain.hIcon = LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON));
|
||||
wclMain.hIconSm = LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON));
|
||||
wclMain.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wclMain.lpszMenuName = NULL;
|
||||
wclMain.cbClsExtra = 0;
|
||||
wclMain.cbWndExtra = 0;
|
||||
wclMain.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
|
||||
RegisterClassEx (&wclMain);
|
||||
}
|
||||
|
||||
void
|
||||
selectTool(int tool)
|
||||
{
|
||||
|
@ -212,7 +234,7 @@ InsertSelectionFromHBITMAP(HBITMAP bitmap, HWND window)
|
|||
BOOL drawing;
|
||||
|
||||
LRESULT CALLBACK
|
||||
WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message) /* handle the messages */
|
||||
{
|
||||
|
@ -365,93 +387,9 @@ WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
imgXRes * zoom / 1000 + 3,
|
||||
imgYRes * zoom / 1000 + 3, 3, 3, TRUE);
|
||||
}
|
||||
if ((hwnd == hImageArea) || (hwnd == hScrollbox))
|
||||
if (hwnd == hImageArea)
|
||||
{
|
||||
RECT clientRectScrollbox;
|
||||
RECT clientRectImageArea;
|
||||
SCROLLINFO si;
|
||||
GetClientRect(hScrollbox, &clientRectScrollbox);
|
||||
GetClientRect(hImageArea, &clientRectImageArea);
|
||||
si.cbSize = sizeof(SCROLLINFO);
|
||||
si.fMask = SIF_PAGE | SIF_RANGE;
|
||||
si.nMax = clientRectImageArea.right + 6 - 1;
|
||||
si.nMin = 0;
|
||||
si.nPage = clientRectScrollbox.right;
|
||||
SetScrollInfo(hScrollbox, SB_HORZ, &si, TRUE);
|
||||
GetClientRect(hScrollbox, &clientRectScrollbox);
|
||||
si.nMax = clientRectImageArea.bottom + 6 - 1;
|
||||
si.nPage = clientRectScrollbox.bottom;
|
||||
SetScrollInfo(hScrollbox, SB_VERT, &si, TRUE);
|
||||
MoveWindow(hScrlClient,
|
||||
-GetScrollPos(hScrollbox, SB_HORZ), -GetScrollPos(hScrollbox, SB_VERT),
|
||||
max(clientRectImageArea.right + 6, clientRectScrollbox.right),
|
||||
max(clientRectImageArea.bottom + 6, clientRectScrollbox.bottom), TRUE);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_HSCROLL:
|
||||
if (hwnd == hScrollbox)
|
||||
{
|
||||
SCROLLINFO si;
|
||||
si.cbSize = sizeof(SCROLLINFO);
|
||||
si.fMask = SIF_ALL;
|
||||
GetScrollInfo(hScrollbox, SB_HORZ, &si);
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case SB_THUMBTRACK:
|
||||
case SB_THUMBPOSITION:
|
||||
si.nPos = HIWORD(wParam);
|
||||
break;
|
||||
case SB_LINELEFT:
|
||||
si.nPos -= 5;
|
||||
break;
|
||||
case SB_LINERIGHT:
|
||||
si.nPos += 5;
|
||||
break;
|
||||
case SB_PAGELEFT:
|
||||
si.nPos -= si.nPage;
|
||||
break;
|
||||
case SB_PAGERIGHT:
|
||||
si.nPos += si.nPage;
|
||||
break;
|
||||
}
|
||||
SetScrollInfo(hScrollbox, SB_HORZ, &si, TRUE);
|
||||
MoveWindow(hScrlClient, -GetScrollPos(hScrollbox, SB_HORZ),
|
||||
-GetScrollPos(hScrollbox, SB_VERT), imgXRes * zoom / 1000 + 6,
|
||||
imgYRes * zoom / 1000 + 6, TRUE);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_VSCROLL:
|
||||
if (hwnd == hScrollbox)
|
||||
{
|
||||
SCROLLINFO si;
|
||||
si.cbSize = sizeof(SCROLLINFO);
|
||||
si.fMask = SIF_ALL;
|
||||
GetScrollInfo(hScrollbox, SB_VERT, &si);
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case SB_THUMBTRACK:
|
||||
case SB_THUMBPOSITION:
|
||||
si.nPos = HIWORD(wParam);
|
||||
break;
|
||||
case SB_LINEUP:
|
||||
si.nPos -= 5;
|
||||
break;
|
||||
case SB_LINEDOWN:
|
||||
si.nPos += 5;
|
||||
break;
|
||||
case SB_PAGEUP:
|
||||
si.nPos -= si.nPage;
|
||||
break;
|
||||
case SB_PAGEDOWN:
|
||||
si.nPos += si.nPage;
|
||||
break;
|
||||
}
|
||||
SetScrollInfo(hScrollbox, SB_VERT, &si, TRUE);
|
||||
MoveWindow(hScrlClient, -GetScrollPos(hScrollbox, SB_HORZ),
|
||||
-GetScrollPos(hScrollbox, SB_VERT), imgXRes * zoom / 1000 + 6,
|
||||
imgYRes * zoom / 1000 + 6, TRUE);
|
||||
UpdateScrollbox();
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -7,4 +7,6 @@
|
|||
* PROGRAMMERS: Benedikt Freisen
|
||||
*/
|
||||
|
||||
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
void RegisterWclMain();
|
||||
|
||||
LRESULT CALLBACK MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
|
Loading…
Reference in a new issue