#include "precomp.h"
#include "winproc.h"
+#include "scrollbox.h"
#include "palette.h"
#include "toolsettings.h"
#include "selection.h"
#include "sizebox.h"
+#include "textedit.h"
/* FUNCTIONS ********************************************************/
int rubberRadius = 4;
int transpBg = 0;
int zoom = 1000;
-int rectSel_src[4];
-int rectSel_dest[4];
+RECT rectSel_src;
+RECT rectSel_dest;
HWND hSelection;
HWND hImageArea;
HBITMAP hSelBm;
HBITMAP hSelMask;
+LOGFONT lfTextFont;
+HFONT hfontTextFont;
+HWND hwndTextEdit;
+HWND hwndEditCtl;
+LPTSTR textToolText = NULL;
+int textToolTextMaxLen = 0;
/* array holding palette colors; may be changed by the user during execution */
int palColors[28];
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;
-
TCHAR progtitle[1000];
TCHAR resstr[100];
HMENU menu;
0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xffffff
};
+ /* init font for text tool */
+ lfTextFont.lfHeight = 0;
+ lfTextFont.lfWidth = 0;
+ lfTextFont.lfEscapement = 0;
+ lfTextFont.lfOrientation = 0;
+ lfTextFont.lfWeight = FW_NORMAL;
+ lfTextFont.lfItalic = FALSE;
+ lfTextFont.lfUnderline = FALSE;
+ lfTextFont.lfStrikeOut = FALSE;
+ lfTextFont.lfCharSet = DEFAULT_CHARSET;
+ lfTextFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
+ lfTextFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
+ lfTextFont.lfQuality = DEFAULT_QUALITY;
+ lfTextFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
+ lstrcpy(lfTextFont.lfFaceName, _T(""));
+ hfontTextFont = CreateFontIndirect(&lfTextFont);
+
/* init palette */
selectedPalette = 1;
CopyMemory(palColors, modernPalColors, sizeof(palColors));
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);
+ /* 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));
/* 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);
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 */
/* 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);
/* by moving the window, the things in WM_SIZE are done */
MoveWindow(hwnd, 100, 100, 600, 450, TRUE);
+ /* creating the text editor window for the text tool */
+ hwndTextEdit =
+ CreateWindowEx(0, _T("TextEdit"), _T(""), WS_OVERLAPPEDWINDOW, 300, 0, 300,
+ 200, hwnd, NULL, hThisInstance, NULL);
+ /* creating the edit control within the editor window */
+ hwndEditCtl =
+ CreateWindowEx(WS_EX_CLIENTEDGE, _T("EDIT"), _T(""),
+ WS_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE | ES_NOHIDESEL | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
+ 0, 0, 100, 100, hwndTextEdit, NULL, hThisInstance, NULL);
+
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);