mirror of
https://github.com/reactos/reactos.git
synced 2024-06-21 13:31:38 +00:00
[MSPAINT_NEW] port to ATL (first batch of git commits)
svn path=/trunk/; revision=68365
This commit is contained in:
parent
4a2b05ae84
commit
0dcecd61fc
|
@ -25,6 +25,7 @@ file(GLOB mspaint_new_rc_deps icons/*.*)
|
|||
add_rc_deps(rsrc.rc ${mspaint_new_rc_deps})
|
||||
add_executable(mspaint_new ${SOURCE} rsrc.rc)
|
||||
set_module_type(mspaint_new win32gui UNICODE)
|
||||
target_link_libraries(mspaint_new atlnew)
|
||||
add_importlibs(mspaint_new hhctrl comdlg32 shell32 user32 gdi32 advapi32 comctl32 msvcrt kernel32)
|
||||
add_pch(mspaint_new precomp.h SOURCE)
|
||||
add_cd_file(TARGET mspaint_new DESTINATION reactos/system32 FOR all)
|
||||
|
|
|
@ -66,7 +66,7 @@ MRDlgWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
int
|
||||
mirrorRotateDlg()
|
||||
{
|
||||
return DialogBox(hProgInstance, MAKEINTRESOURCE(IDD_MIRRORROTATE), hMainWnd, MRDlgWinProc);
|
||||
return DialogBox(hProgInstance, MAKEINTRESOURCE(IDD_MIRRORROTATE), mainWindow.m_hWnd, MRDlgWinProc);
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK
|
||||
|
@ -203,7 +203,7 @@ ATTDlgWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
int
|
||||
attributesDlg()
|
||||
{
|
||||
return DialogBox(hProgInstance, MAKEINTRESOURCE(IDD_ATTRIBUTES), hMainWnd, ATTDlgWinProc);
|
||||
return DialogBox(hProgInstance, MAKEINTRESOURCE(IDD_ATTRIBUTES), mainWindow.m_hWnd, ATTDlgWinProc);
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK
|
||||
|
@ -266,5 +266,5 @@ CHSIZEDlgWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
int
|
||||
changeSizeDlg()
|
||||
{
|
||||
return DialogBox(hProgInstance, MAKEINTRESOURCE(IDD_STRETCHSKEW), hMainWnd, CHSIZEDlgWinProc);
|
||||
return DialogBox(hProgInstance, MAKEINTRESOURCE(IDD_STRETCHSKEW), mainWindow.m_hWnd, CHSIZEDlgWinProc);
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ void ShowFileLoadError(LPTSTR name)
|
|||
LoadString(hProgInstance, IDS_PROGRAMNAME, programname, SIZEOF(programname));
|
||||
LoadString(hProgInstance, IDS_LOADERRORTEXT, loaderrortext, SIZEOF(loaderrortext));
|
||||
_stprintf(temptext, loaderrortext, name);
|
||||
MessageBox(hMainWnd, temptext, programname, MB_OK | MB_ICONEXCLAMATION);
|
||||
mainWindow.MessageBox(temptext, programname, MB_OK | MB_ICONEXCLAMATION);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -50,11 +50,8 @@ extern int transpBg;
|
|||
extern int zoom;
|
||||
extern RECT rectSel_src;
|
||||
extern RECT rectSel_dest;
|
||||
extern HWND hSelection;
|
||||
extern HWND hImageArea;
|
||||
extern HBITMAP hSelBm;
|
||||
extern HBITMAP hSelMask;
|
||||
extern HWND hwndTextEdit;
|
||||
extern HWND hwndEditCtl;
|
||||
extern LOGFONT lfTextFont;
|
||||
extern HFONT hfontTextFont;
|
||||
|
@ -70,11 +67,6 @@ extern int fgColor;
|
|||
extern int bgColor;
|
||||
|
||||
extern HWND hStatusBar;
|
||||
extern HWND hScrollbox;
|
||||
extern HWND hMainWnd;
|
||||
extern HWND hPalWin;
|
||||
extern HWND hToolBoxContainer;
|
||||
extern HWND hToolSettings;
|
||||
extern HWND hTrackbarZoom;
|
||||
extern CHOOSECOLOR choosecolor;
|
||||
extern OPENFILENAME ofn;
|
||||
|
@ -88,8 +80,6 @@ extern HCURSOR hCurZoom;
|
|||
extern HCURSOR hCurPen;
|
||||
extern HCURSOR hCurAirbrush;
|
||||
|
||||
extern HWND hScrlClient;
|
||||
|
||||
extern HWND hToolBtn[16];
|
||||
|
||||
extern HINSTANCE hProgInstance;
|
||||
|
@ -105,16 +95,32 @@ extern SYSTEMTIME fileTime;
|
|||
extern BOOL showGrid;
|
||||
extern BOOL showMiniature;
|
||||
|
||||
extern HWND hwndMiniature;
|
||||
class CMainWindow;
|
||||
class CToolSettingsWindow;
|
||||
class CPaletteWindow;
|
||||
class CScrollboxWindow;
|
||||
class CSelectionWindow;
|
||||
class CSizeboxWindow;
|
||||
class CTextEditWindow;
|
||||
|
||||
extern HWND hSizeboxLeftTop;
|
||||
extern HWND hSizeboxCenterTop;
|
||||
extern HWND hSizeboxRightTop;
|
||||
extern HWND hSizeboxLeftCenter;
|
||||
extern HWND hSizeboxRightCenter;
|
||||
extern HWND hSizeboxLeftBottom;
|
||||
extern HWND hSizeboxCenterBottom;
|
||||
extern HWND hSizeboxRightBottom;
|
||||
extern CMainWindow mainWindow;
|
||||
extern CMainWindow miniature;
|
||||
extern CMainWindow toolBoxContainer;
|
||||
extern CToolSettingsWindow toolSettingsWindow;
|
||||
extern CPaletteWindow paletteWindow;
|
||||
extern CScrollboxWindow scrollboxWindow;
|
||||
extern CScrollboxWindow scrlClientWindow;
|
||||
extern CSelectionWindow selectionWindow;
|
||||
extern CMainWindow imageArea;
|
||||
extern CSizeboxWindow sizeboxLeftTop;
|
||||
extern CSizeboxWindow sizeboxCenterTop;
|
||||
extern CSizeboxWindow sizeboxRightTop;
|
||||
extern CSizeboxWindow sizeboxLeftCenter;
|
||||
extern CSizeboxWindow sizeboxRightCenter;
|
||||
extern CSizeboxWindow sizeboxLeftBottom;
|
||||
extern CSizeboxWindow sizeboxCenterBottom;
|
||||
extern CSizeboxWindow sizeboxRightBottom;
|
||||
extern CTextEditWindow textEditWindow;
|
||||
|
||||
/* VARIABLES declared in mouse.c ************************************/
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ undo()
|
|||
{
|
||||
if (undoSteps > 0)
|
||||
{
|
||||
ShowWindow(hSelection, SW_HIDE);
|
||||
selectionWindow.ShowWindow(SW_HIDE);
|
||||
currInd = (currInd + HISTORYSIZE - 1) % HISTORYSIZE;
|
||||
SelectObject(hDrawingDC, hBms[currInd]);
|
||||
undoSteps--;
|
||||
|
@ -60,7 +60,7 @@ redo()
|
|||
{
|
||||
if (redoSteps > 0)
|
||||
{
|
||||
ShowWindow(hSelection, SW_HIDE);
|
||||
selectionWindow.ShowWindow(SW_HIDE);
|
||||
currInd = (currInd + 1) % HISTORYSIZE;
|
||||
SelectObject(hDrawingDC, hBms[currInd]);
|
||||
redoSteps--;
|
||||
|
|
|
@ -10,14 +10,6 @@
|
|||
|
||||
#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 ********************************************************/
|
||||
|
||||
HDC hDrawingDC;
|
||||
|
@ -50,13 +42,10 @@ int transpBg = 0;
|
|||
int zoom = 1000;
|
||||
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;
|
||||
|
@ -86,11 +75,6 @@ int fgColor = 0x00000000;
|
|||
int bgColor = 0x00ffffff;
|
||||
|
||||
HWND hStatusBar;
|
||||
HWND hScrollbox;
|
||||
HWND hMainWnd;
|
||||
HWND hPalWin;
|
||||
HWND hToolBoxContainer;
|
||||
HWND hToolSettings;
|
||||
HWND hTrackbarZoom;
|
||||
CHOOSECOLOR choosecolor;
|
||||
OPENFILENAME ofn;
|
||||
|
@ -104,8 +88,6 @@ HCURSOR hCurZoom;
|
|||
HCURSOR hCurPen;
|
||||
HCURSOR hCurAirbrush;
|
||||
|
||||
HWND hScrlClient;
|
||||
|
||||
HWND hToolBtn[16];
|
||||
|
||||
HINSTANCE hProgInstance;
|
||||
|
@ -121,16 +103,24 @@ SYSTEMTIME fileTime;
|
|||
BOOL showGrid = FALSE;
|
||||
BOOL showMiniature = FALSE;
|
||||
|
||||
HWND hwndMiniature;
|
||||
|
||||
HWND hSizeboxLeftTop;
|
||||
HWND hSizeboxCenterTop;
|
||||
HWND hSizeboxRightTop;
|
||||
HWND hSizeboxLeftCenter;
|
||||
HWND hSizeboxRightCenter;
|
||||
HWND hSizeboxLeftBottom;
|
||||
HWND hSizeboxCenterBottom;
|
||||
HWND hSizeboxRightBottom;
|
||||
CMainWindow mainWindow;
|
||||
CMainWindow miniature;
|
||||
CMainWindow toolBoxContainer;
|
||||
CToolSettingsWindow toolSettingsWindow;
|
||||
CPaletteWindow paletteWindow;
|
||||
CScrollboxWindow scrollboxWindow;
|
||||
CScrollboxWindow scrlClientWindow;
|
||||
CSelectionWindow selectionWindow;
|
||||
CMainWindow imageArea;
|
||||
CSizeboxWindow sizeboxLeftTop;
|
||||
CSizeboxWindow sizeboxCenterTop;
|
||||
CSizeboxWindow sizeboxRightTop;
|
||||
CSizeboxWindow sizeboxLeftCenter;
|
||||
CSizeboxWindow sizeboxRightCenter;
|
||||
CSizeboxWindow sizeboxLeftBottom;
|
||||
CSizeboxWindow sizeboxCenterBottom;
|
||||
CSizeboxWindow sizeboxRightBottom;
|
||||
CTextEditWindow textEditWindow;
|
||||
|
||||
/* entry point */
|
||||
|
||||
|
@ -189,30 +179,18 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
|||
/* initialize common controls library */
|
||||
InitCommonControls();
|
||||
|
||||
/* 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));
|
||||
_stprintf(progtitle, resstr, filename);
|
||||
LoadString(hThisInstance, IDS_MINIATURETITLE, miniaturetitle, SIZEOF(miniaturetitle));
|
||||
|
||||
/* create main window */
|
||||
hwnd =
|
||||
CreateWindowEx(0, _T("MainWindow"), progtitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 544,
|
||||
375, HWND_DESKTOP, NULL, hThisInstance, NULL);
|
||||
hMainWnd = hwnd;
|
||||
RECT mainWindowPos = {0, 0, 544, 375}; // FIXME: use equivalent of CW_USEDEFAULT for position
|
||||
hwnd = mainWindow.Create(HWND_DESKTOP, mainWindowPos, progtitle, WS_OVERLAPPEDWINDOW, 0, 0U, NULL);
|
||||
|
||||
hwndMiniature =
|
||||
CreateWindowEx(WS_EX_PALETTEWINDOW, _T("MainWindow"), miniaturetitle,
|
||||
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, 180, 200, 120, 100, hwnd,
|
||||
NULL, hThisInstance, NULL);
|
||||
RECT miniaturePos = {180, 200, 180 + 120, 200 + 100};
|
||||
miniature.Create(hwnd, miniaturePos, miniaturetitle,
|
||||
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, WS_EX_PALETTEWINDOW, 0U, NULL);
|
||||
|
||||
/* loading and setting the window menu from resource */
|
||||
menu = LoadMenu(hThisInstance, MAKEINTRESOURCE(ID_MENU));
|
||||
|
@ -234,9 +212,8 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
|||
CreateWindowEx(0, _T("STATIC"), _T(""), WS_CHILD | WS_VISIBLE | SS_ETCHEDHORZ, 0, 0, 5000, 2, hwnd, NULL,
|
||||
hThisInstance, NULL);
|
||||
|
||||
hToolBoxContainer =
|
||||
CreateWindowEx(0, _T("MainWindow"), _T(""), WS_CHILD | WS_VISIBLE, 2, 2, 52, 350, hwnd, NULL,
|
||||
hThisInstance, NULL);
|
||||
RECT toolBoxContainerPos = {2, 2, 2 + 52, 2 + 350};
|
||||
toolBoxContainer.Create(hwnd, toolBoxContainerPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
||||
/* creating the 16 bitmap radio buttons and setting the bitmap */
|
||||
|
||||
|
||||
|
@ -247,7 +224,7 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
|||
hToolbar =
|
||||
CreateWindowEx(0, TOOLBARCLASSNAME, NULL,
|
||||
WS_CHILD | WS_VISIBLE | CCS_NOPARENTALIGN | CCS_VERT | CCS_NORESIZE | TBSTYLE_TOOLTIPS,
|
||||
1, -2, 50, 205, hToolBoxContainer, NULL, hThisInstance, NULL);
|
||||
1, -2, 50, 205, toolBoxContainer.m_hWnd, NULL, hThisInstance, NULL);
|
||||
hImageList = ImageList_Create(16, 16, ILC_COLOR24 | ILC_MASK, 16, 0);
|
||||
SendMessage(hToolbar, TB_SETIMAGELIST, 0, (LPARAM) hImageList);
|
||||
tempBm = (HBITMAP) LoadImage(hThisInstance, MAKEINTRESOURCE(IDB_TOOLBARICONS), IMAGE_BITMAP, 256, 16, 0);
|
||||
|
@ -278,25 +255,22 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
|||
SendMessage(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(25, 25));
|
||||
|
||||
/* creating the tool settings child window */
|
||||
hToolSettings =
|
||||
CreateWindowEx(0, _T("ToolSettings"), _T(""), WS_CHILD | WS_VISIBLE, 5, 208, 42, 140,
|
||||
hToolBoxContainer, NULL, hThisInstance, NULL);
|
||||
RECT toolSettingsWindowPos = {5, 208, 5 + 42, 208 + 140};
|
||||
toolSettingsWindow.Create(toolBoxContainer.m_hWnd, toolSettingsWindowPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
||||
hTrackbarZoom =
|
||||
CreateWindowEx(0, TRACKBAR_CLASS, _T(""), WS_CHILD | TBS_VERT | TBS_AUTOTICKS, 1, 1, 40, 64,
|
||||
hToolSettings, NULL, hThisInstance, NULL);
|
||||
toolSettingsWindow.m_hWnd, NULL, hThisInstance, NULL);
|
||||
SendMessage(hTrackbarZoom, TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG(0, 6));
|
||||
SendMessage(hTrackbarZoom, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) 3);
|
||||
|
||||
/* creating the palette child window */
|
||||
hPalWin =
|
||||
CreateWindowEx(0, _T("Palette"), _T(""), WS_CHILD | WS_VISIBLE, 56, 9, 255, 32, hwnd, NULL,
|
||||
hThisInstance, NULL);
|
||||
RECT paletteWindowPos = {56, 9, 56 + 255, 9 + 32};
|
||||
paletteWindow.Create(hwnd, paletteWindowPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
||||
|
||||
/* creating the scroll box */
|
||||
hScrollbox =
|
||||
CreateWindowEx(WS_EX_CLIENTEDGE, _T("Scrollbox"), _T(""),
|
||||
WS_CHILD | WS_GROUP | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE, 56, 49, 472, 248, hwnd,
|
||||
NULL, hThisInstance, NULL);
|
||||
RECT scrollboxWindowPos = {56, 49, 56 + 472, 49 + 248};
|
||||
scrollboxWindow.Create(hwnd, scrollboxWindowPos, _T(""),
|
||||
WS_CHILD | WS_GROUP | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE, WS_EX_CLIENTEDGE, 0U, NULL);
|
||||
|
||||
/* creating the status bar */
|
||||
hStatusBar =
|
||||
|
@ -304,24 +278,21 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
|||
NULL, hThisInstance, NULL);
|
||||
SendMessage(hStatusBar, SB_SETMINHEIGHT, 21, 0);
|
||||
|
||||
hScrlClient =
|
||||
CreateWindowEx(0, _T("Scrollbox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 500, 500, hScrollbox, NULL,
|
||||
hThisInstance, NULL);
|
||||
RECT scrlClientWindowPos = {0, 0, 0 + 500, 0 + 500};
|
||||
scrlClientWindow.Create(scrollboxWindow.m_hWnd, scrlClientWindowPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
||||
|
||||
/* create selection window (initially hidden) */
|
||||
hSelection =
|
||||
CreateWindowEx(WS_EX_TRANSPARENT, _T("Selection"), _T(""), WS_CHILD | BS_OWNERDRAW, 350, 0, 100, 100,
|
||||
hScrlClient, NULL, hThisInstance, NULL);
|
||||
RECT selectionWindowPos = {350, 0, 350 + 100, 0 + 100};
|
||||
selectionWindow.Create(scrlClientWindow.m_hWnd, selectionWindowPos, _T(""), WS_CHILD | BS_OWNERDRAW, 0, 0U, NULL);
|
||||
|
||||
/* creating the window inside the scroll box, on which the image in hDrawingDC's bitmap is drawn */
|
||||
hImageArea =
|
||||
CreateWindowEx(0, _T("MainWindow"), _T(""), WS_CHILD | WS_VISIBLE, 3, 3, imgXRes, imgYRes, hScrlClient,
|
||||
NULL, hThisInstance, NULL);
|
||||
RECT imageAreaPos = {3, 3, 3 + imgXRes, 3 + imgYRes};
|
||||
imageArea.Create(scrlClientWindow.m_hWnd, imageAreaPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
||||
|
||||
hDC = GetDC(hImageArea);
|
||||
hDC = imageArea.GetDC();
|
||||
hDrawingDC = CreateCompatibleDC(hDC);
|
||||
hSelDC = CreateCompatibleDC(hDC);
|
||||
ReleaseDC(hImageArea, hDC);
|
||||
imageArea.ReleaseDC(hDC);
|
||||
SelectObject(hDrawingDC, CreatePen(PS_SOLID, 0, fgColor));
|
||||
SelectObject(hDrawingDC, CreateSolidBrush(bgColor));
|
||||
|
||||
|
@ -343,7 +314,7 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
|||
_tcscpy(filename, temp);
|
||||
LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr));
|
||||
_stprintf(tempstr, resstr, filename);
|
||||
SetWindowText(hMainWnd, tempstr);
|
||||
mainWindow.SetWindowText(tempstr);
|
||||
clearHistory();
|
||||
isAFile = TRUE;
|
||||
}
|
||||
|
@ -398,45 +369,29 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
|||
sfn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
|
||||
|
||||
/* creating the size boxes */
|
||||
hSizeboxLeftTop =
|
||||
CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
|
||||
hThisInstance, NULL);
|
||||
hSizeboxCenterTop =
|
||||
CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
|
||||
hThisInstance, NULL);
|
||||
hSizeboxRightTop =
|
||||
CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
|
||||
hThisInstance, NULL);
|
||||
hSizeboxLeftCenter =
|
||||
CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
|
||||
hThisInstance, NULL);
|
||||
hSizeboxRightCenter =
|
||||
CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
|
||||
hThisInstance, NULL);
|
||||
hSizeboxLeftBottom =
|
||||
CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
|
||||
hThisInstance, NULL);
|
||||
hSizeboxCenterBottom =
|
||||
CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
|
||||
hThisInstance, NULL);
|
||||
hSizeboxRightBottom =
|
||||
CreateWindowEx(0, _T("Sizebox"), _T(""), WS_CHILD | WS_VISIBLE, 0, 0, 3, 3, hScrlClient, NULL,
|
||||
hThisInstance, NULL);
|
||||
RECT sizeboxPos = {0, 0, 0 + 3, 0 + 3};
|
||||
sizeboxLeftTop.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
||||
sizeboxCenterTop.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
||||
sizeboxRightTop.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
||||
sizeboxLeftCenter.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
||||
sizeboxRightCenter.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
||||
sizeboxLeftBottom.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
||||
sizeboxCenterBottom.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
||||
sizeboxRightBottom.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
||||
/* placing the size boxes around the image */
|
||||
SendMessage(hImageArea, WM_SIZE, 0, 0);
|
||||
imageArea.SendMessage(WM_SIZE, 0, 0);
|
||||
|
||||
/* 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);
|
||||
RECT textEditWindowPos = {300, 0, 300 + 300, 0 + 200};
|
||||
textEditWindow.Create(hwnd, textEditWindowPos, _T(""), WS_OVERLAPPEDWINDOW, 0, 0U, 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);
|
||||
0, 0, 100, 100, textEditWindow.m_hWnd, NULL, hThisInstance, NULL);
|
||||
|
||||
/* Make the window visible on the screen */
|
||||
ShowWindow (hwnd, nFunsterStil);
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
void
|
||||
placeSelWin()
|
||||
{
|
||||
MoveWindow(hSelection, rectSel_dest.left * zoom / 1000, rectSel_dest.top * zoom / 1000,
|
||||
RECT_WIDTH(rectSel_dest) * zoom / 1000 + 6, RECT_HEIGHT(rectSel_dest) * zoom / 1000 + 6, TRUE);
|
||||
BringWindowToTop(hSelection);
|
||||
InvalidateRect(hImageArea, NULL, FALSE);
|
||||
selectionWindow.MoveWindow(rectSel_dest.left * zoom / 1000, rectSel_dest.top * zoom / 1000,
|
||||
RECT_WIDTH(rectSel_dest) * zoom / 1000 + 6, RECT_HEIGHT(rectSel_dest) * zoom / 1000 + 6, TRUE);
|
||||
selectionWindow.BringWindowToTop();
|
||||
imageArea.InvalidateRect(NULL, FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -64,7 +64,7 @@ startPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
|
|||
switch (activeTool)
|
||||
{
|
||||
case TOOL_FREESEL:
|
||||
ShowWindow(hSelection, SW_HIDE);
|
||||
selectionWindow.ShowWindow(SW_HIDE);
|
||||
if (ptStack != NULL)
|
||||
HeapFree(GetProcessHeap(), 0, ptStack);
|
||||
ptStack = (POINT*) HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, sizeof(POINT) * 1024);
|
||||
|
@ -81,7 +81,7 @@ startPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
|
|||
case TOOL_RECTSEL:
|
||||
case TOOL_TEXT:
|
||||
newReversible();
|
||||
ShowWindow(hSelection, SW_HIDE);
|
||||
selectionWindow.ShowWindow(SW_HIDE);
|
||||
rectSel_src.right = rectSel_src.left;
|
||||
rectSel_src.bottom = rectSel_src.top;
|
||||
break;
|
||||
|
@ -280,11 +280,11 @@ endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
|
|||
0, hSelMask, 0, 0, MAKEROP4(SRCCOPY, SRCAND));
|
||||
|
||||
placeSelWin();
|
||||
ShowWindow(hSelection, SW_SHOW);
|
||||
selectionWindow.ShowWindow(SW_SHOW);
|
||||
/* force refresh of selection contents */
|
||||
SendMessage(hSelection, WM_LBUTTONDOWN, 0, 0);
|
||||
SendMessage(hSelection, WM_MOUSEMOVE, 0, 0);
|
||||
SendMessage(hSelection, WM_LBUTTONUP, 0, 0);
|
||||
selectionWindow.SendMessage(WM_LBUTTONDOWN, 0, 0);
|
||||
selectionWindow.SendMessage(WM_MOUSEMOVE, 0, 0);
|
||||
selectionWindow.SendMessage(WM_LBUTTONUP, 0, 0);
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, ptStack);
|
||||
ptStack = NULL;
|
||||
|
@ -310,7 +310,7 @@ endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
|
|||
0, SRCCOPY);
|
||||
|
||||
placeSelWin();
|
||||
ShowWindow(hSelection, SW_SHOW);
|
||||
selectionWindow.ShowWindow(SW_SHOW);
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
break;
|
||||
|
@ -321,7 +321,7 @@ endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg)
|
|||
newReversible();
|
||||
|
||||
placeSelWin();
|
||||
ShowWindow(hSelection, SW_SHOW);
|
||||
selectionWindow.ShowWindow(SW_SHOW);
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -9,126 +9,105 @@
|
|||
/* INCLUDES *********************************************************/
|
||||
|
||||
#include "precomp.h"
|
||||
#include "palette.h"
|
||||
|
||||
/* FUNCTIONS ********************************************************/
|
||||
|
||||
void
|
||||
RegisterWclPal()
|
||||
LRESULT CPaletteWindow::OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
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);
|
||||
}
|
||||
RECT rc = { 0, 0, 31, 32 };
|
||||
HDC hDC = GetDC();
|
||||
HPEN oldPen;
|
||||
HBRUSH oldBrush;
|
||||
int i, a, b;
|
||||
|
||||
LRESULT CALLBACK
|
||||
PalWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
DefWindowProc(WM_PAINT, wParam, lParam);
|
||||
|
||||
for(b = 2; b < 30; b++)
|
||||
for(a = 2; a < 29; a++)
|
||||
if ((a + b) % 2 == 1)
|
||||
SetPixel(hDC, a, b, GetSysColor(COLOR_BTNHILIGHT));
|
||||
|
||||
DrawEdge(hDC, &rc, EDGE_RAISED, BF_TOPLEFT);
|
||||
DrawEdge(hDC, &rc, BDR_SUNKENOUTER, BF_TOPLEFT | BF_BOTTOMRIGHT);
|
||||
SetRect(&rc, 11, 12, 26, 27);
|
||||
DrawEdge(hDC, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
|
||||
oldPen = (HPEN) SelectObject(hDC, CreatePen(PS_NULL, 0, 0));
|
||||
oldBrush = (HBRUSH) SelectObject(hDC, CreateSolidBrush(bgColor));
|
||||
Rectangle(hDC, rc.left, rc.top + 2, rc.right - 1, rc.bottom - 1);
|
||||
DeleteObject(SelectObject(hDC, oldBrush));
|
||||
SetRect(&rc, 4, 5, 19, 20);
|
||||
DrawEdge(hDC, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
|
||||
oldBrush = (HBRUSH) SelectObject(hDC, CreateSolidBrush(fgColor));
|
||||
Rectangle(hDC, rc.left + 2, rc.top + 2, rc.right - 1, rc.bottom - 1);
|
||||
DeleteObject(SelectObject(hDC, oldBrush));
|
||||
DeleteObject(SelectObject(hDC, oldPen));
|
||||
|
||||
for(i = 0; i < 28; i++)
|
||||
{
|
||||
case WM_PAINT:
|
||||
{
|
||||
RECT rc = { 0, 0, 31, 32 };
|
||||
HDC hDC = GetDC(hwnd);
|
||||
HPEN oldPen;
|
||||
HBRUSH oldBrush;
|
||||
int i, a, b;
|
||||
|
||||
DefWindowProc(hwnd, message, wParam, lParam);
|
||||
|
||||
for(b = 2; b < 30; b++)
|
||||
for(a = 2; a < 29; a++)
|
||||
if ((a + b) % 2 == 1)
|
||||
SetPixel(hDC, a, b, GetSysColor(COLOR_BTNHILIGHT));
|
||||
|
||||
DrawEdge(hDC, &rc, EDGE_RAISED, BF_TOPLEFT);
|
||||
DrawEdge(hDC, &rc, BDR_SUNKENOUTER, BF_TOPLEFT | BF_BOTTOMRIGHT);
|
||||
SetRect(&rc, 11, 12, 26, 27);
|
||||
DrawEdge(hDC, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
|
||||
oldPen = (HPEN) SelectObject(hDC, CreatePen(PS_NULL, 0, 0));
|
||||
oldBrush = (HBRUSH) SelectObject(hDC, CreateSolidBrush(bgColor));
|
||||
Rectangle(hDC, rc.left, rc.top + 2, rc.right - 1, rc.bottom - 1);
|
||||
DeleteObject(SelectObject(hDC, oldBrush));
|
||||
SetRect(&rc, 4, 5, 19, 20);
|
||||
DrawEdge(hDC, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
|
||||
oldBrush = (HBRUSH) SelectObject(hDC, CreateSolidBrush(fgColor));
|
||||
Rectangle(hDC, rc.left + 2, rc.top + 2, rc.right - 1, rc.bottom - 1);
|
||||
DeleteObject(SelectObject(hDC, oldBrush));
|
||||
DeleteObject(SelectObject(hDC, oldPen));
|
||||
|
||||
for(i = 0; i < 28; i++)
|
||||
{
|
||||
SetRect(&rc, 31 + (i % 14) * 16,
|
||||
0 + (i / 14) * 16, 16 + 31 + (i % 14) * 16, 16 + 0 + (i / 14) * 16);
|
||||
DrawEdge(hDC, &rc, EDGE_RAISED, BF_TOPLEFT);
|
||||
DrawEdge(hDC, &rc, BDR_SUNKENOUTER, BF_RECT);
|
||||
oldPen = (HPEN) SelectObject(hDC, CreatePen(PS_NULL, 0, 0));
|
||||
oldBrush = (HBRUSH) SelectObject(hDC, CreateSolidBrush(palColors[i]));
|
||||
Rectangle(hDC, rc.left + 2, rc.top + 2, rc.right - 1, rc.bottom - 1);
|
||||
DeleteObject(SelectObject(hDC, oldBrush));
|
||||
DeleteObject(SelectObject(hDC, oldPen));
|
||||
}
|
||||
ReleaseDC(hwnd, hDC);
|
||||
break;
|
||||
}
|
||||
case WM_LBUTTONDOWN:
|
||||
if (GET_X_LPARAM(lParam) >= 31)
|
||||
{
|
||||
fgColor = palColors[(GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14];
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
if (activeTool == 10)
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
break;
|
||||
case WM_RBUTTONDOWN:
|
||||
if (GET_X_LPARAM(lParam) >= 31)
|
||||
{
|
||||
bgColor = palColors[(GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14];
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
if (activeTool == 10)
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
break;
|
||||
case WM_LBUTTONDBLCLK:
|
||||
if (GET_X_LPARAM(lParam) >= 31)
|
||||
if (ChooseColor(&choosecolor))
|
||||
{
|
||||
palColors[(GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14] =
|
||||
choosecolor.rgbResult;
|
||||
fgColor = choosecolor.rgbResult;
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
if (activeTool == 10)
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
break;
|
||||
case WM_RBUTTONDBLCLK:
|
||||
if (GET_X_LPARAM(lParam) >= 31)
|
||||
if (ChooseColor(&choosecolor))
|
||||
{
|
||||
palColors[(GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14] =
|
||||
choosecolor.rgbResult;
|
||||
bgColor = choosecolor.rgbResult;
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
if (activeTool == 10)
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
SetRect(&rc, 31 + (i % 14) * 16,
|
||||
0 + (i / 14) * 16, 16 + 31 + (i % 14) * 16, 16 + 0 + (i / 14) * 16);
|
||||
DrawEdge(hDC, &rc, EDGE_RAISED, BF_TOPLEFT);
|
||||
DrawEdge(hDC, &rc, BDR_SUNKENOUTER, BF_RECT);
|
||||
oldPen = (HPEN) SelectObject(hDC, CreatePen(PS_NULL, 0, 0));
|
||||
oldBrush = (HBRUSH) SelectObject(hDC, CreateSolidBrush(palColors[i]));
|
||||
Rectangle(hDC, rc.left + 2, rc.top + 2, rc.right - 1, rc.bottom - 1);
|
||||
DeleteObject(SelectObject(hDC, oldBrush));
|
||||
DeleteObject(SelectObject(hDC, oldPen));
|
||||
}
|
||||
|
||||
ReleaseDC(hDC);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CPaletteWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
if (GET_X_LPARAM(lParam) >= 31)
|
||||
{
|
||||
fgColor = palColors[(GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14];
|
||||
InvalidateRect(NULL, FALSE);
|
||||
if (activeTool == 10)
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CPaletteWindow::OnRButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
if (GET_X_LPARAM(lParam) >= 31)
|
||||
{
|
||||
bgColor = palColors[(GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14];
|
||||
InvalidateRect(NULL, FALSE);
|
||||
if (activeTool == 10)
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CPaletteWindow::OnLButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
if (GET_X_LPARAM(lParam) >= 31)
|
||||
if (ChooseColor(&choosecolor))
|
||||
{
|
||||
palColors[(GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14] =
|
||||
choosecolor.rgbResult;
|
||||
fgColor = choosecolor.rgbResult;
|
||||
InvalidateRect(NULL, FALSE);
|
||||
if (activeTool == 10)
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CPaletteWindow::OnRButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
if (GET_X_LPARAM(lParam) >= 31)
|
||||
if (ChooseColor(&choosecolor))
|
||||
{
|
||||
palColors[(GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14] =
|
||||
choosecolor.rgbResult;
|
||||
bgColor = choosecolor.rgbResult;
|
||||
InvalidateRect(NULL, FALSE);
|
||||
if (activeTool == 10)
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,22 @@
|
|||
* PROGRAMMERS: Benedikt Freisen
|
||||
*/
|
||||
|
||||
void RegisterWclPal();
|
||||
class CPaletteWindow : public CWindowImpl<CPaletteWindow>
|
||||
{
|
||||
public:
|
||||
DECLARE_WND_CLASS_EX(_T("Palette"), CS_DBLCLKS, COLOR_BTNFACE)
|
||||
|
||||
LRESULT CALLBACK PalWinProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
BEGIN_MSG_MAP(CPaletteWindow)
|
||||
MESSAGE_HANDLER(WM_PAINT, OnPaint)
|
||||
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
|
||||
MESSAGE_HANDLER(WM_RBUTTONDOWN, OnRButtonDown)
|
||||
MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk)
|
||||
MESSAGE_HANDLER(WM_RBUTTONDBLCLK, OnRButtonDblClk)
|
||||
END_MSG_MAP()
|
||||
|
||||
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnRButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnLButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnRButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
};
|
||||
|
|
|
@ -7,10 +7,13 @@
|
|||
#include <winbase.h>
|
||||
#include <winuser.h>
|
||||
#include <wingdi.h>
|
||||
#include <tchar.h>
|
||||
#include <atlbase.h>
|
||||
#include <atlcom.h>
|
||||
#include <atlwin.h>
|
||||
#include <windowsx.h>
|
||||
#include <commdlg.h>
|
||||
#include <commctrl.h>
|
||||
#include <tchar.h>
|
||||
#include <stdlib.h>
|
||||
#include <shellapi.h>
|
||||
#include <htmlhelp.h>
|
||||
|
@ -21,6 +24,12 @@
|
|||
#include "globalvar.h"
|
||||
#include "history.h"
|
||||
#include "mouse.h"
|
||||
#include "palette.h"
|
||||
#include "scrollbox.h"
|
||||
#include "selection.h"
|
||||
#include "sizebox.h"
|
||||
#include "textedit.h"
|
||||
#include "toolsettings.h"
|
||||
#include "winproc.h"
|
||||
|
||||
#endif /* _MSPAINT_H */
|
||||
|
|
|
@ -9,134 +9,108 @@
|
|||
/* 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);
|
||||
scrollboxWindow.GetClientRect(&clientRectScrollbox);
|
||||
imageArea.GetClientRect(&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);
|
||||
scrollboxWindow.SetScrollInfo(SB_HORZ, &si);
|
||||
scrollboxWindow.GetClientRect(&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);
|
||||
scrollboxWindow.SetScrollInfo(SB_VERT, &si);
|
||||
scrlClientWindow.MoveWindow(
|
||||
-scrollboxWindow.GetScrollPos(SB_HORZ), -scrollboxWindow.GetScrollPos(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)
|
||||
LRESULT CScrollboxWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
switch (message)
|
||||
if (m_hWnd == scrollboxWindow.m_hWnd)
|
||||
{
|
||||
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);
|
||||
UpdateScrollbox();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CScrollboxWindow::OnHScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
if (m_hWnd == scrollboxWindow.m_hWnd)
|
||||
{
|
||||
SCROLLINFO si;
|
||||
si.cbSize = sizeof(SCROLLINFO);
|
||||
si.fMask = SIF_ALL;
|
||||
scrollboxWindow.GetScrollInfo(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;
|
||||
}
|
||||
scrollboxWindow.SetScrollInfo(SB_HORZ, &si);
|
||||
scrlClientWindow.MoveWindow(-scrollboxWindow.GetScrollPos(SB_HORZ),
|
||||
-scrollboxWindow.GetScrollPos(SB_VERT), imgXRes * zoom / 1000 + 6,
|
||||
imgYRes * zoom / 1000 + 6, TRUE);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CScrollboxWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
if (m_hWnd == scrollboxWindow.m_hWnd)
|
||||
{
|
||||
SCROLLINFO si;
|
||||
si.cbSize = sizeof(SCROLLINFO);
|
||||
si.fMask = SIF_ALL;
|
||||
scrollboxWindow.GetScrollInfo(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;
|
||||
}
|
||||
scrollboxWindow.SetScrollInfo(SB_VERT, &si);
|
||||
scrlClientWindow.MoveWindow(-scrollboxWindow.GetScrollPos(SB_HORZ),
|
||||
-scrollboxWindow.GetScrollPos(SB_VERT), imgXRes * zoom / 1000 + 6,
|
||||
imgYRes * zoom / 1000 + 6, TRUE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -6,8 +6,20 @@
|
|||
* PROGRAMMERS: Benedikt Freisen
|
||||
*/
|
||||
|
||||
void RegisterWclScrollbox();
|
||||
class CScrollboxWindow : public CWindowImpl<CScrollboxWindow>
|
||||
{
|
||||
public:
|
||||
DECLARE_WND_CLASS_EX(_T("Scrollbox"), 0, COLOR_APPWORKSPACE)
|
||||
|
||||
BEGIN_MSG_MAP(CPaletteWindow)
|
||||
MESSAGE_HANDLER(WM_SIZE, OnSize)
|
||||
MESSAGE_HANDLER(WM_HSCROLL, OnHScroll)
|
||||
MESSAGE_HANDLER(WM_VSCROLL, OnVScroll)
|
||||
END_MSG_MAP()
|
||||
|
||||
LRESULT OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnHScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
};
|
||||
|
||||
void UpdateScrollbox();
|
||||
|
||||
LRESULT CALLBACK ScrollboxWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
|
|
@ -39,26 +39,6 @@ POINTS frac;
|
|||
POINT delta;
|
||||
DWORD system_selection_color;
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -93,11 +73,11 @@ ColorKeyedMaskBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight,
|
|||
void
|
||||
ForceRefreshSelectionContents()
|
||||
{
|
||||
if (IsWindowVisible(hSelection))
|
||||
if (selectionWindow.IsWindowVisible())
|
||||
{
|
||||
SendMessage(hSelection, WM_LBUTTONDOWN, 0, MAKELPARAM(0, 0));
|
||||
SendMessage(hSelection, WM_MOUSEMOVE, 0, MAKELPARAM(0, 0));
|
||||
SendMessage(hSelection, WM_LBUTTONUP, 0, MAKELPARAM(0, 0));
|
||||
selectionWindow.SendMessage(WM_LBUTTONDOWN, 0, MAKELPARAM(0, 0));
|
||||
selectionWindow.SendMessage(WM_MOUSEMOVE, 0, MAKELPARAM(0, 0));
|
||||
selectionWindow.SendMessage(WM_LBUTTONUP, 0, MAKELPARAM(0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,199 +112,217 @@ identifyCorner(short x, short y, short w, short h)
|
|||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CALLBACK
|
||||
SelectionWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT CSelectionWindow::OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
switch (message)
|
||||
if (!moving)
|
||||
{
|
||||
case WM_PAINT:
|
||||
HDC hDC = GetDC();
|
||||
DefWindowProc(WM_PAINT, wParam, lParam);
|
||||
SelectionFrame(hDC, 1, 1, RECT_WIDTH(rectSel_dest) * zoom / 1000 + 5,
|
||||
RECT_HEIGHT(rectSel_dest) * zoom / 1000 + 5,
|
||||
system_selection_color);
|
||||
ReleaseDC(hDC);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CSelectionWindow::OnEraseBkgnd(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
// do nothing => transparent background
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CSelectionWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
/* update the system selection color */
|
||||
system_selection_color = GetSysColor(COLOR_HIGHLIGHT);
|
||||
SendMessage(WM_PAINT, 0, MAKELPARAM(0, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CSelectionWindow::OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
/* update the system selection color */
|
||||
system_selection_color = GetSysColor(COLOR_HIGHLIGHT);
|
||||
SendMessage(WM_PAINT, 0, MAKELPARAM(0, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CSelectionWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
SetCursor(LoadCursor(NULL, IDC_SIZEALL));
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CSelectionWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
delta.x = 0;
|
||||
delta.y = 0;
|
||||
SetCapture();
|
||||
if (action != ACTION_MOVE)
|
||||
SetCursor(LoadCursor(NULL, cursors[action]));
|
||||
moving = TRUE;
|
||||
scrlClientWindow.InvalidateRect(NULL, TRUE);
|
||||
imageArea.SendMessage(WM_PAINT, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CSelectionWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
if (moving)
|
||||
{
|
||||
TCHAR sizeStr[100];
|
||||
POINT deltaUsed;
|
||||
resetToU1();
|
||||
frac.x += GET_X_LPARAM(lParam) - pos.x;
|
||||
frac.y += GET_Y_LPARAM(lParam) - pos.y;
|
||||
delta.x += frac.x * 1000 / zoom;
|
||||
delta.y += frac.y * 1000 / zoom;
|
||||
if (zoom < 1000)
|
||||
{
|
||||
if (!moving)
|
||||
{
|
||||
HDC hDC = GetDC(hwnd);
|
||||
DefWindowProc(hwnd, message, wParam, lParam);
|
||||
SelectionFrame(hDC, 1, 1, RECT_WIDTH(rectSel_dest) * zoom / 1000 + 5,
|
||||
RECT_HEIGHT(rectSel_dest) * zoom / 1000 + 5,
|
||||
system_selection_color);
|
||||
ReleaseDC(hwnd, hDC);
|
||||
}
|
||||
break;
|
||||
frac.x = 0;
|
||||
frac.y = 0;
|
||||
}
|
||||
case WM_CREATE:
|
||||
case WM_SYSCOLORCHANGE:
|
||||
else
|
||||
{
|
||||
/* update the system selection color */
|
||||
system_selection_color = GetSysColor(COLOR_HIGHLIGHT);
|
||||
SendMessage(hwnd, WM_PAINT, 0, MAKELPARAM(0, 0));
|
||||
break;
|
||||
frac.x -= (frac.x * 1000 / zoom) * zoom / 1000;
|
||||
frac.y -= (frac.y * 1000 / zoom) * zoom / 1000;
|
||||
}
|
||||
case WM_LBUTTONDOWN:
|
||||
switch (action)
|
||||
{
|
||||
case ACTION_MOVE: /* move selection */
|
||||
deltaUsed.x = delta.x;
|
||||
deltaUsed.y = delta.y;
|
||||
OffsetRect(&rectSel_dest, deltaUsed.x, deltaUsed.y);
|
||||
break;
|
||||
case ACTION_RESIZE_TOP_LEFT: /* resize at upper left corner */
|
||||
deltaUsed.x = min(delta.x, RECT_WIDTH(rectSel_dest) - 1);
|
||||
deltaUsed.y = min(delta.y, RECT_HEIGHT(rectSel_dest) - 1);
|
||||
rectSel_dest.left += deltaUsed.x;
|
||||
rectSel_dest.top += deltaUsed.y;
|
||||
break;
|
||||
case ACTION_RESIZE_TOP: /* resize at top edge */
|
||||
deltaUsed.x = delta.x;
|
||||
deltaUsed.y = min(delta.y, RECT_HEIGHT(rectSel_dest) - 1);
|
||||
rectSel_dest.top += deltaUsed.y;
|
||||
break;
|
||||
case ACTION_RESIZE_TOP_RIGHT: /* resize at upper right corner */
|
||||
deltaUsed.x = max(delta.x, -(RECT_WIDTH(rectSel_dest) - 1));
|
||||
deltaUsed.y = min(delta.y, RECT_HEIGHT(rectSel_dest) - 1);
|
||||
rectSel_dest.top += deltaUsed.y;
|
||||
rectSel_dest.right += deltaUsed.x;
|
||||
break;
|
||||
case ACTION_RESIZE_LEFT: /* resize at left edge */
|
||||
deltaUsed.x = min(delta.x, RECT_WIDTH(rectSel_dest) - 1);
|
||||
deltaUsed.y = delta.y;
|
||||
rectSel_dest.left += deltaUsed.x;
|
||||
break;
|
||||
case ACTION_RESIZE_RIGHT: /* resize at right edge */
|
||||
deltaUsed.x = max(delta.x, -(RECT_WIDTH(rectSel_dest) - 1));
|
||||
deltaUsed.y = delta.y;
|
||||
rectSel_dest.right += deltaUsed.x;
|
||||
break;
|
||||
case ACTION_RESIZE_BOTTOM_LEFT: /* resize at lower left corner */
|
||||
deltaUsed.x = min(delta.x, RECT_WIDTH(rectSel_dest) - 1);
|
||||
deltaUsed.y = max(delta.y, -(RECT_HEIGHT(rectSel_dest) - 1));
|
||||
rectSel_dest.left += deltaUsed.x;
|
||||
rectSel_dest.bottom += deltaUsed.y;
|
||||
break;
|
||||
case ACTION_RESIZE_BOTTOM: /* resize at bottom edge */
|
||||
deltaUsed.x = delta.x;
|
||||
deltaUsed.y = max(delta.y, -(RECT_HEIGHT(rectSel_dest) - 1));
|
||||
rectSel_dest.bottom += deltaUsed.y;
|
||||
break;
|
||||
case ACTION_RESIZE_BOTTOM_RIGHT: /* resize at lower right corner */
|
||||
deltaUsed.x = max(delta.x, -(RECT_WIDTH(rectSel_dest) - 1));
|
||||
deltaUsed.y = max(delta.y, -(RECT_HEIGHT(rectSel_dest) - 1));
|
||||
rectSel_dest.right += deltaUsed.x;
|
||||
rectSel_dest.bottom += deltaUsed.y;
|
||||
break;
|
||||
}
|
||||
delta.x -= deltaUsed.x;
|
||||
delta.y -= deltaUsed.y;
|
||||
|
||||
_stprintf(sizeStr, _T("%d x %d"), RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest));
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr);
|
||||
|
||||
if (activeTool == TOOL_TEXT)
|
||||
{
|
||||
Text(hDrawingDC, rectSel_dest.left, rectSel_dest.top, rectSel_dest.right, rectSel_dest.bottom, fgColor, bgColor, textToolText, hfontTextFont, transpBg);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
delta.x = 0;
|
||||
delta.y = 0;
|
||||
SetCapture(hwnd);
|
||||
if (action != ACTION_MOVE)
|
||||
SetCursor(LoadCursor(NULL, cursors[action]));
|
||||
moving = TRUE;
|
||||
InvalidateRect(hScrlClient, NULL, TRUE);
|
||||
break;
|
||||
}
|
||||
case WM_MOUSEMOVE:
|
||||
if (moving)
|
||||
StretchBlt(hDrawingDC, rectSel_dest.left, rectSel_dest.top, RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest), hSelDC, 0, 0, GetDIBWidth(hSelBm), GetDIBHeight(hSelBm), SRCCOPY);
|
||||
else
|
||||
if (transpBg == 0)
|
||||
MaskBlt(hDrawingDC, rectSel_dest.left, rectSel_dest.top, RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest),
|
||||
hSelDC, 0, 0, hSelMask, 0, 0, MAKEROP4(SRCCOPY, SRCAND));
|
||||
else
|
||||
{
|
||||
TCHAR sizeStr[100];
|
||||
POINT deltaUsed;
|
||||
resetToU1();
|
||||
frac.x += GET_X_LPARAM(lParam) - pos.x;
|
||||
frac.y += GET_Y_LPARAM(lParam) - pos.y;
|
||||
delta.x += frac.x * 1000 / zoom;
|
||||
delta.y += frac.y * 1000 / zoom;
|
||||
if (zoom < 1000)
|
||||
{
|
||||
frac.x = 0;
|
||||
frac.y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
frac.x -= (frac.x * 1000 / zoom) * zoom / 1000;
|
||||
frac.y -= (frac.y * 1000 / zoom) * zoom / 1000;
|
||||
}
|
||||
switch (action)
|
||||
{
|
||||
case ACTION_MOVE: /* move selection */
|
||||
deltaUsed.x = delta.x;
|
||||
deltaUsed.y = delta.y;
|
||||
OffsetRect(&rectSel_dest, deltaUsed.x, deltaUsed.y);
|
||||
break;
|
||||
case ACTION_RESIZE_TOP_LEFT: /* resize at upper left corner */
|
||||
deltaUsed.x = min(delta.x, RECT_WIDTH(rectSel_dest) - 1);
|
||||
deltaUsed.y = min(delta.y, RECT_HEIGHT(rectSel_dest) - 1);
|
||||
rectSel_dest.left += deltaUsed.x;
|
||||
rectSel_dest.top += deltaUsed.y;
|
||||
break;
|
||||
case ACTION_RESIZE_TOP: /* resize at top edge */
|
||||
deltaUsed.x = delta.x;
|
||||
deltaUsed.y = min(delta.y, RECT_HEIGHT(rectSel_dest) - 1);
|
||||
rectSel_dest.top += deltaUsed.y;
|
||||
break;
|
||||
case ACTION_RESIZE_TOP_RIGHT: /* resize at upper right corner */
|
||||
deltaUsed.x = max(delta.x, -(RECT_WIDTH(rectSel_dest) - 1));
|
||||
deltaUsed.y = min(delta.y, RECT_HEIGHT(rectSel_dest) - 1);
|
||||
rectSel_dest.top += deltaUsed.y;
|
||||
rectSel_dest.right += deltaUsed.x;
|
||||
break;
|
||||
case ACTION_RESIZE_LEFT: /* resize at left edge */
|
||||
deltaUsed.x = min(delta.x, RECT_WIDTH(rectSel_dest) - 1);
|
||||
deltaUsed.y = delta.y;
|
||||
rectSel_dest.left += deltaUsed.x;
|
||||
break;
|
||||
case ACTION_RESIZE_RIGHT: /* resize at right edge */
|
||||
deltaUsed.x = max(delta.x, -(RECT_WIDTH(rectSel_dest) - 1));
|
||||
deltaUsed.y = delta.y;
|
||||
rectSel_dest.right += deltaUsed.x;
|
||||
break;
|
||||
case ACTION_RESIZE_BOTTOM_LEFT: /* resize at lower left corner */
|
||||
deltaUsed.x = min(delta.x, RECT_WIDTH(rectSel_dest) - 1);
|
||||
deltaUsed.y = max(delta.y, -(RECT_HEIGHT(rectSel_dest) - 1));
|
||||
rectSel_dest.left += deltaUsed.x;
|
||||
rectSel_dest.bottom += deltaUsed.y;
|
||||
break;
|
||||
case ACTION_RESIZE_BOTTOM: /* resize at bottom edge */
|
||||
deltaUsed.x = delta.x;
|
||||
deltaUsed.y = max(delta.y, -(RECT_HEIGHT(rectSel_dest) - 1));
|
||||
rectSel_dest.bottom += deltaUsed.y;
|
||||
break;
|
||||
case ACTION_RESIZE_BOTTOM_RIGHT: /* resize at lower right corner */
|
||||
deltaUsed.x = max(delta.x, -(RECT_WIDTH(rectSel_dest) - 1));
|
||||
deltaUsed.y = max(delta.y, -(RECT_HEIGHT(rectSel_dest) - 1));
|
||||
rectSel_dest.right += deltaUsed.x;
|
||||
rectSel_dest.bottom += deltaUsed.y;
|
||||
break;
|
||||
}
|
||||
delta.x -= deltaUsed.x;
|
||||
delta.y -= deltaUsed.y;
|
||||
ColorKeyedMaskBlt(hDrawingDC, rectSel_dest.left, rectSel_dest.top, RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest),
|
||||
hSelDC, 0, 0, hSelMask, 0, 0, MAKEROP4(SRCCOPY, SRCAND), bgColor);
|
||||
}
|
||||
}
|
||||
imageArea.InvalidateRect(NULL, FALSE);
|
||||
imageArea.SendMessage(WM_PAINT, 0, 0);
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
}
|
||||
else
|
||||
{
|
||||
int w = RECT_WIDTH(rectSel_dest) * zoom / 1000 + 6;
|
||||
int h = RECT_HEIGHT(rectSel_dest) * zoom / 1000 + 6;
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) NULL);
|
||||
action = identifyCorner(pos.x, pos.y, w, h);
|
||||
if (action != ACTION_MOVE)
|
||||
SetCursor(LoadCursor(NULL, cursors[action]));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
_stprintf(sizeStr, _T("%d x %d"), RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest));
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr);
|
||||
|
||||
if (activeTool == TOOL_TEXT)
|
||||
{
|
||||
Text(hDrawingDC, rectSel_dest.left, rectSel_dest.top, rectSel_dest.right, rectSel_dest.bottom, fgColor, bgColor, textToolText, hfontTextFont, transpBg);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (action != ACTION_MOVE)
|
||||
StretchBlt(hDrawingDC, rectSel_dest.left, rectSel_dest.top, RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest), hSelDC, 0, 0, GetDIBWidth(hSelBm), GetDIBHeight(hSelBm), SRCCOPY);
|
||||
else
|
||||
if (transpBg == 0)
|
||||
MaskBlt(hDrawingDC, rectSel_dest.left, rectSel_dest.top, RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest),
|
||||
hSelDC, 0, 0, hSelMask, 0, 0, MAKEROP4(SRCCOPY, SRCAND));
|
||||
else
|
||||
{
|
||||
ColorKeyedMaskBlt(hDrawingDC, rectSel_dest.left, rectSel_dest.top, RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest),
|
||||
hSelDC, 0, 0, hSelMask, 0, 0, MAKEROP4(SRCCOPY, SRCAND), bgColor);
|
||||
}
|
||||
}
|
||||
InvalidateRect(hImageArea, NULL, FALSE);
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
LRESULT CSelectionWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
if (moving)
|
||||
{
|
||||
moving = FALSE;
|
||||
ReleaseCapture();
|
||||
if (action != ACTION_MOVE)
|
||||
{
|
||||
if (activeTool == TOOL_TEXT)
|
||||
{
|
||||
// FIXME: What to do?
|
||||
}
|
||||
else
|
||||
{
|
||||
int w = RECT_WIDTH(rectSel_dest) * zoom / 1000 + 6;
|
||||
int h = RECT_HEIGHT(rectSel_dest) * zoom / 1000 + 6;
|
||||
pos.x = GET_X_LPARAM(lParam);
|
||||
pos.y = GET_Y_LPARAM(lParam);
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) NULL);
|
||||
action = identifyCorner(pos.x, pos.y, w, h);
|
||||
if (action != ACTION_MOVE)
|
||||
SetCursor(LoadCursor(NULL, cursors[action]));
|
||||
HDC hTempDC;
|
||||
HBITMAP hTempBm;
|
||||
hTempDC = CreateCompatibleDC(hSelDC);
|
||||
hTempBm = CreateDIBWithProperties(RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest));
|
||||
SelectObject(hTempDC, hTempBm);
|
||||
SelectObject(hSelDC, hSelBm);
|
||||
StretchBlt(hTempDC, 0, 0, RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest), hSelDC, 0, 0,
|
||||
GetDIBWidth(hSelBm), GetDIBHeight(hSelBm), SRCCOPY);
|
||||
DeleteObject(hSelBm);
|
||||
hSelBm = hTempBm;
|
||||
hTempBm = CreateBitmap(RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest), 1, 1, NULL);
|
||||
SelectObject(hTempDC, hTempBm);
|
||||
SelectObject(hSelDC, hSelMask);
|
||||
StretchBlt(hTempDC, 0, 0, RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest), hSelDC, 0, 0,
|
||||
GetDIBWidth(hSelMask), GetDIBHeight(hSelMask), SRCCOPY);
|
||||
DeleteObject(hSelMask);
|
||||
hSelMask = hTempBm;
|
||||
SelectObject(hSelDC, hSelBm);
|
||||
DeleteDC(hTempDC);
|
||||
}
|
||||
break;
|
||||
case WM_LBUTTONUP:
|
||||
if (moving)
|
||||
{
|
||||
moving = FALSE;
|
||||
ReleaseCapture();
|
||||
if (action != ACTION_MOVE)
|
||||
{
|
||||
if (activeTool == TOOL_TEXT)
|
||||
{
|
||||
// FIXME: What to do?
|
||||
}
|
||||
else
|
||||
{
|
||||
HDC hTempDC;
|
||||
HBITMAP hTempBm;
|
||||
hTempDC = CreateCompatibleDC(hSelDC);
|
||||
hTempBm = CreateDIBWithProperties(RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest));
|
||||
SelectObject(hTempDC, hTempBm);
|
||||
SelectObject(hSelDC, hSelBm);
|
||||
StretchBlt(hTempDC, 0, 0, RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest), hSelDC, 0, 0,
|
||||
GetDIBWidth(hSelBm), GetDIBHeight(hSelBm), SRCCOPY);
|
||||
DeleteObject(hSelBm);
|
||||
hSelBm = hTempBm;
|
||||
hTempBm = CreateBitmap(RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest), 1, 1, NULL);
|
||||
SelectObject(hTempDC, hTempBm);
|
||||
SelectObject(hSelDC, hSelMask);
|
||||
StretchBlt(hTempDC, 0, 0, RECT_WIDTH(rectSel_dest), RECT_HEIGHT(rectSel_dest), hSelDC, 0, 0,
|
||||
GetDIBWidth(hSelMask), GetDIBHeight(hSelMask), SRCCOPY);
|
||||
DeleteObject(hSelMask);
|
||||
hSelMask = hTempBm;
|
||||
SelectObject(hSelDC, hSelBm);
|
||||
DeleteDC(hTempDC);
|
||||
}
|
||||
}
|
||||
placeSelWin();
|
||||
ShowWindow(hSelection, SW_HIDE);
|
||||
ShowWindow(hSelection, SW_SHOW);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
}
|
||||
placeSelWin();
|
||||
ShowWindow(SW_HIDE);
|
||||
ShowWindow(SW_SHOW);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -6,8 +6,30 @@
|
|||
* PROGRAMMERS: Benedikt Freisen
|
||||
*/
|
||||
|
||||
void RegisterWclSelection();
|
||||
class CSelectionWindow : public CWindowImpl<CSelectionWindow>
|
||||
{
|
||||
public:
|
||||
DECLARE_WND_CLASS_EX(_T("Selection"), CS_DBLCLKS, COLOR_BTNFACE)
|
||||
|
||||
BEGIN_MSG_MAP(CPaletteWindow)
|
||||
MESSAGE_HANDLER(WM_PAINT, OnPaint)
|
||||
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
|
||||
MESSAGE_HANDLER(WM_CREATE, OnCreate)
|
||||
MESSAGE_HANDLER(WM_SYSCOLORCHANGE, OnSysColorChange)
|
||||
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
|
||||
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
|
||||
MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
|
||||
MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
|
||||
END_MSG_MAP()
|
||||
|
||||
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnEraseBkgnd(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
};
|
||||
|
||||
void ForceRefreshSelectionContents();
|
||||
|
||||
LRESULT CALLBACK SelectionWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
/* INCLUDES *********************************************************/
|
||||
|
||||
#include "precomp.h"
|
||||
#include "sizebox.h"
|
||||
|
||||
/* FUNCTIONS ********************************************************/
|
||||
|
||||
|
@ -17,106 +16,85 @@ BOOL resizing = FALSE;
|
|||
short xOrig;
|
||||
short yOrig;
|
||||
|
||||
void
|
||||
RegisterWclSizebox()
|
||||
LRESULT CSizeboxWindow::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
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)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_SETCURSOR:
|
||||
if ((hwnd == hSizeboxLeftTop) || (hwnd == hSizeboxRightBottom))
|
||||
SetCursor(LoadCursor(NULL, IDC_SIZENWSE));
|
||||
if ((hwnd == hSizeboxLeftBottom) || (hwnd == hSizeboxRightTop))
|
||||
SetCursor(LoadCursor(NULL, IDC_SIZENESW));
|
||||
if ((hwnd == hSizeboxLeftCenter) || (hwnd == hSizeboxRightCenter))
|
||||
SetCursor(LoadCursor(NULL, IDC_SIZEWE));
|
||||
if ((hwnd == hSizeboxCenterTop) || (hwnd == hSizeboxCenterBottom))
|
||||
SetCursor(LoadCursor(NULL, IDC_SIZENS));
|
||||
break;
|
||||
case WM_LBUTTONDOWN:
|
||||
resizing = TRUE;
|
||||
xOrig = GET_X_LPARAM(lParam);
|
||||
yOrig = GET_Y_LPARAM(lParam);
|
||||
SetCapture(hwnd);
|
||||
break;
|
||||
case WM_MOUSEMOVE:
|
||||
if (resizing)
|
||||
{
|
||||
TCHAR sizeStr[100];
|
||||
short xRel;
|
||||
short yRel;
|
||||
xRel = (GET_X_LPARAM(lParam) - xOrig) * 1000 / zoom;
|
||||
yRel = (GET_Y_LPARAM(lParam) - yOrig) * 1000 / zoom;
|
||||
if (hwnd == hSizeboxLeftTop)
|
||||
_stprintf(sizeStr, _T("%d x %d"), imgXRes - xRel, imgYRes - yRel);
|
||||
if (hwnd == hSizeboxCenterTop)
|
||||
_stprintf(sizeStr, _T("%d x %d"), imgXRes, imgYRes - yRel);
|
||||
if (hwnd == hSizeboxRightTop)
|
||||
_stprintf(sizeStr, _T("%d x %d"), imgXRes + xRel, imgYRes - yRel);
|
||||
if (hwnd == hSizeboxLeftCenter)
|
||||
_stprintf(sizeStr, _T("%d x %d"), imgXRes - xRel, imgYRes);
|
||||
if (hwnd == hSizeboxRightCenter)
|
||||
_stprintf(sizeStr, _T("%d x %d"), imgXRes + xRel, imgYRes);
|
||||
if (hwnd == hSizeboxLeftBottom)
|
||||
_stprintf(sizeStr, _T("%d x %d"), imgXRes - xRel, imgYRes + yRel);
|
||||
if (hwnd == hSizeboxCenterBottom)
|
||||
_stprintf(sizeStr, _T("%d x %d"), imgXRes, imgYRes + yRel);
|
||||
if (hwnd == hSizeboxRightBottom)
|
||||
_stprintf(sizeStr, _T("%d x %d"), imgXRes + xRel, imgYRes + yRel);
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr);
|
||||
}
|
||||
break;
|
||||
case WM_LBUTTONUP:
|
||||
if (resizing)
|
||||
{
|
||||
short xRel;
|
||||
short yRel;
|
||||
ReleaseCapture();
|
||||
resizing = FALSE;
|
||||
xRel = (GET_X_LPARAM(lParam) - xOrig) * 1000 / zoom;
|
||||
yRel = (GET_Y_LPARAM(lParam) - yOrig) * 1000 / zoom;
|
||||
if (hwnd == hSizeboxLeftTop)
|
||||
cropReversible(imgXRes - xRel, imgYRes - yRel, xRel, yRel);
|
||||
if (hwnd == hSizeboxCenterTop)
|
||||
cropReversible(imgXRes, imgYRes - yRel, 0, yRel);
|
||||
if (hwnd == hSizeboxRightTop)
|
||||
cropReversible(imgXRes + xRel, imgYRes - yRel, 0, yRel);
|
||||
if (hwnd == hSizeboxLeftCenter)
|
||||
cropReversible(imgXRes - xRel, imgYRes, xRel, 0);
|
||||
if (hwnd == hSizeboxRightCenter)
|
||||
cropReversible(imgXRes + xRel, imgYRes, 0, 0);
|
||||
if (hwnd == hSizeboxLeftBottom)
|
||||
cropReversible(imgXRes - xRel, imgYRes + yRel, xRel, 0);
|
||||
if (hwnd == hSizeboxCenterBottom)
|
||||
cropReversible(imgXRes, imgYRes + yRel, 0, 0);
|
||||
if (hwnd == hSizeboxRightBottom)
|
||||
cropReversible(imgXRes + xRel, imgYRes + yRel, 0, 0);
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) _T(""));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
if ((m_hWnd == sizeboxLeftTop.m_hWnd) || (m_hWnd == sizeboxRightBottom.m_hWnd))
|
||||
SetCursor(LoadCursor(NULL, IDC_SIZENWSE));
|
||||
if ((m_hWnd == sizeboxLeftBottom.m_hWnd) || (m_hWnd == sizeboxRightTop.m_hWnd))
|
||||
SetCursor(LoadCursor(NULL, IDC_SIZENESW));
|
||||
if ((m_hWnd == sizeboxLeftCenter.m_hWnd) || (m_hWnd == sizeboxRightCenter.m_hWnd))
|
||||
SetCursor(LoadCursor(NULL, IDC_SIZEWE));
|
||||
if ((m_hWnd == sizeboxCenterTop.m_hWnd) || (m_hWnd == sizeboxCenterBottom.m_hWnd))
|
||||
SetCursor(LoadCursor(NULL, IDC_SIZENS));
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CSizeboxWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
resizing = TRUE;
|
||||
xOrig = GET_X_LPARAM(lParam);
|
||||
yOrig = GET_Y_LPARAM(lParam);
|
||||
SetCapture();
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CSizeboxWindow::OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
if (resizing)
|
||||
{
|
||||
TCHAR sizeStr[100];
|
||||
short xRel;
|
||||
short yRel;
|
||||
xRel = (GET_X_LPARAM(lParam) - xOrig) * 1000 / zoom;
|
||||
yRel = (GET_Y_LPARAM(lParam) - yOrig) * 1000 / zoom;
|
||||
if (m_hWnd == sizeboxLeftTop.m_hWnd)
|
||||
_stprintf(sizeStr, _T("%d x %d"), imgXRes - xRel, imgYRes - yRel);
|
||||
if (m_hWnd == sizeboxCenterTop.m_hWnd)
|
||||
_stprintf(sizeStr, _T("%d x %d"), imgXRes, imgYRes - yRel);
|
||||
if (m_hWnd == sizeboxRightTop.m_hWnd)
|
||||
_stprintf(sizeStr, _T("%d x %d"), imgXRes + xRel, imgYRes - yRel);
|
||||
if (m_hWnd == sizeboxLeftCenter.m_hWnd)
|
||||
_stprintf(sizeStr, _T("%d x %d"), imgXRes - xRel, imgYRes);
|
||||
if (m_hWnd == sizeboxRightCenter.m_hWnd)
|
||||
_stprintf(sizeStr, _T("%d x %d"), imgXRes + xRel, imgYRes);
|
||||
if (m_hWnd == sizeboxLeftBottom.m_hWnd)
|
||||
_stprintf(sizeStr, _T("%d x %d"), imgXRes - xRel, imgYRes + yRel);
|
||||
if (m_hWnd == sizeboxCenterBottom.m_hWnd)
|
||||
_stprintf(sizeStr, _T("%d x %d"), imgXRes, imgYRes + yRel);
|
||||
if (m_hWnd == sizeboxRightBottom.m_hWnd)
|
||||
_stprintf(sizeStr, _T("%d x %d"), imgXRes + xRel, imgYRes + yRel);
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) sizeStr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CSizeboxWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
if (resizing)
|
||||
{
|
||||
short xRel;
|
||||
short yRel;
|
||||
ReleaseCapture();
|
||||
resizing = FALSE;
|
||||
xRel = (GET_X_LPARAM(lParam) - xOrig) * 1000 / zoom;
|
||||
yRel = (GET_Y_LPARAM(lParam) - yOrig) * 1000 / zoom;
|
||||
if (m_hWnd == sizeboxLeftTop)
|
||||
cropReversible(imgXRes - xRel, imgYRes - yRel, xRel, yRel);
|
||||
if (m_hWnd == sizeboxCenterTop.m_hWnd)
|
||||
cropReversible(imgXRes, imgYRes - yRel, 0, yRel);
|
||||
if (m_hWnd == sizeboxRightTop.m_hWnd)
|
||||
cropReversible(imgXRes + xRel, imgYRes - yRel, 0, yRel);
|
||||
if (m_hWnd == sizeboxLeftCenter.m_hWnd)
|
||||
cropReversible(imgXRes - xRel, imgYRes, xRel, 0);
|
||||
if (m_hWnd == sizeboxRightCenter.m_hWnd)
|
||||
cropReversible(imgXRes + xRel, imgYRes, 0, 0);
|
||||
if (m_hWnd == sizeboxLeftBottom.m_hWnd)
|
||||
cropReversible(imgXRes - xRel, imgYRes + yRel, xRel, 0);
|
||||
if (m_hWnd == sizeboxCenterBottom.m_hWnd)
|
||||
cropReversible(imgXRes, imgYRes + yRel, 0, 0);
|
||||
if (m_hWnd == sizeboxRightBottom.m_hWnd)
|
||||
cropReversible(imgXRes + xRel, imgYRes + yRel, 0, 0);
|
||||
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) _T(""));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,20 @@
|
|||
* PROGRAMMERS: Benedikt Freisen
|
||||
*/
|
||||
|
||||
void RegisterWclSizebox();
|
||||
class CSizeboxWindow : public CWindowImpl<CSizeboxWindow>
|
||||
{
|
||||
public:
|
||||
DECLARE_WND_CLASS_EX(_T("Sizebox"), CS_DBLCLKS, COLOR_HIGHLIGHT)
|
||||
|
||||
LRESULT CALLBACK SizeboxWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
BEGIN_MSG_MAP(CPaletteWindow)
|
||||
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
|
||||
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
|
||||
MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
|
||||
MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
|
||||
END_MSG_MAP()
|
||||
|
||||
LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
};
|
||||
|
|
|
@ -9,62 +9,36 @@
|
|||
/* INCLUDES *********************************************************/
|
||||
|
||||
#include "precomp.h"
|
||||
#include "textedit.h"
|
||||
|
||||
/* FUNCTIONS ********************************************************/
|
||||
|
||||
void
|
||||
RegisterWclTextEdit()
|
||||
LRESULT CTextEditWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
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)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_SIZE:
|
||||
{
|
||||
RECT clientRect;
|
||||
GetClientRect(hwnd, &clientRect);
|
||||
MoveWindow(hwndEditCtl, clientRect.left, clientRect.top, RECT_WIDTH(clientRect), RECT_HEIGHT(clientRect), TRUE);
|
||||
break;
|
||||
}
|
||||
case WM_CLOSE:
|
||||
ShowWindow(hwnd, SW_HIDE);
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
switch(HIWORD(wParam))
|
||||
{
|
||||
case EN_UPDATE:
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, textToolText);
|
||||
textToolTextMaxLen = GetWindowTextLength(hwndEditCtl) + 1;
|
||||
textToolText = (LPTSTR) HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, sizeof(TCHAR) * textToolTextMaxLen);
|
||||
GetWindowText(hwndEditCtl, textToolText, textToolTextMaxLen);
|
||||
ForceRefreshSelectionContents();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
RECT clientRect;
|
||||
GetClientRect(&clientRect);
|
||||
::MoveWindow(hwndEditCtl, clientRect.left, clientRect.top, RECT_WIDTH(clientRect), RECT_HEIGHT(clientRect), TRUE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CTextEditWindow::OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
ShowWindow(SW_HIDE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CTextEditWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
switch(HIWORD(wParam))
|
||||
{
|
||||
case EN_UPDATE:
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, textToolText);
|
||||
textToolTextMaxLen = ::GetWindowTextLength(hwndEditCtl) + 1;
|
||||
textToolText = (LPTSTR) HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, sizeof(TCHAR) * textToolTextMaxLen);
|
||||
::GetWindowText(hwndEditCtl, textToolText, textToolTextMaxLen);
|
||||
ForceRefreshSelectionContents();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,18 @@
|
|||
* PROGRAMMERS: Benedikt Freisen
|
||||
*/
|
||||
|
||||
void RegisterWclTextEdit();
|
||||
class CTextEditWindow : public CWindowImpl<CTextEditWindow>
|
||||
{
|
||||
public:
|
||||
DECLARE_WND_CLASS_EX(_T("TextEdit"), CS_DBLCLKS, COLOR_BTNFACE)
|
||||
|
||||
LRESULT CALLBACK TextEditWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
BEGIN_MSG_MAP(CPaletteWindow)
|
||||
MESSAGE_HANDLER(WM_SIZE, OnSize)
|
||||
MESSAGE_HANDLER(WM_CLOSE, OnClose)
|
||||
MESSAGE_HANDLER(WM_COMMAND, OnCommand)
|
||||
END_MSG_MAP()
|
||||
|
||||
LRESULT OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
};
|
||||
|
|
|
@ -9,269 +9,241 @@
|
|||
/* INCLUDES *********************************************************/
|
||||
|
||||
#include "precomp.h"
|
||||
#include "toolsettings.h"
|
||||
|
||||
/* FUNCTIONS ********************************************************/
|
||||
|
||||
extern void zoomTo(int, int, int);
|
||||
|
||||
void RegisterWclSettings()
|
||||
LRESULT CToolSettingsWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
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)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_VSCROLL:
|
||||
zoomTo(125 << SendMessage(hTrackbarZoom, TBM_GETPOS, 0, 0), 0, 0);
|
||||
break;
|
||||
case WM_PAINT:
|
||||
{
|
||||
HDC hdc = GetDC(hwnd);
|
||||
RECT rect1 = { 0, 0, 42, 66 };
|
||||
RECT rect2 = { 0, 70, 42, 136 };
|
||||
|
||||
DefWindowProc(hwnd, message, wParam, lParam);
|
||||
|
||||
DrawEdge(hdc, &rect1, BDR_SUNKENOUTER, (activeTool == TOOL_ZOOM) ? BF_RECT : BF_RECT | BF_MIDDLE);
|
||||
DrawEdge(hdc, &rect2, (activeTool >= TOOL_RECT) ? BDR_SUNKENOUTER : 0, BF_RECT | BF_MIDDLE);
|
||||
switch (activeTool)
|
||||
{
|
||||
case TOOL_FREESEL:
|
||||
case TOOL_RECTSEL:
|
||||
case TOOL_TEXT:
|
||||
{
|
||||
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
|
||||
Rectangle(hdc, 2, transpBg * 31 + 2, 41, transpBg * 31 + 33);
|
||||
DeleteObject(SelectObject(hdc, oldPen));
|
||||
DrawIconEx(hdc, 1, 2, hNontranspIcon, 40, 30, 0, NULL, DI_NORMAL);
|
||||
DrawIconEx(hdc, 1, 33, hTranspIcon, 40, 30, 0, NULL, DI_NORMAL);
|
||||
break;
|
||||
}
|
||||
case TOOL_RUBBER:
|
||||
{
|
||||
int i;
|
||||
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
|
||||
for(i = 0; i < 4; i++)
|
||||
{
|
||||
if (rubberRadius == i + 2)
|
||||
{
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
|
||||
Rectangle(hdc, 14, i * 15 + 2, 29, i * 15 + 17);
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT));
|
||||
}
|
||||
else
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT));
|
||||
Rectangle(hdc, 19 - i, i * 14 + 7, 24 + i, i * 16 + 12);
|
||||
}
|
||||
DeleteObject(SelectObject(hdc, oldPen));
|
||||
break;
|
||||
}
|
||||
case TOOL_BRUSH:
|
||||
{
|
||||
int i;
|
||||
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
|
||||
Rectangle(hdc, brushStyle % 3 * 13 + 2, brushStyle / 3 * 15 + 2, brushStyle % 3 * 13 + 15,
|
||||
brushStyle / 3 * 15 + 17);
|
||||
DeleteObject(SelectObject(hdc, oldPen));
|
||||
for(i = 0; i < 12; i++)
|
||||
Brush(hdc, i % 3 * 13 + 7, i / 3 * 15 + 8, i % 3 * 13 + 7, i / 3 * 15 + 8,
|
||||
GetSysColor((i == brushStyle) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), i);
|
||||
break;
|
||||
}
|
||||
case TOOL_AIRBRUSH:
|
||||
{
|
||||
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
|
||||
switch (airBrushWidth)
|
||||
{
|
||||
case 5:
|
||||
Rectangle(hdc, 2, 2, 21, 31);
|
||||
break;
|
||||
case 8:
|
||||
Rectangle(hdc, 20, 2, 41, 31);
|
||||
break;
|
||||
case 3:
|
||||
Rectangle(hdc, 2, 30, 16, 61);
|
||||
break;
|
||||
case 12:
|
||||
Rectangle(hdc, 15, 30, 41, 61);
|
||||
break;
|
||||
}
|
||||
Airbrush(hdc, 10, 15,
|
||||
GetSysColor((airBrushWidth == 5) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 5);
|
||||
Airbrush(hdc, 30, 15,
|
||||
GetSysColor((airBrushWidth == 8) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 8);
|
||||
Airbrush(hdc, 8, 45,
|
||||
GetSysColor((airBrushWidth == 3) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 3);
|
||||
Airbrush(hdc, 27, 45,
|
||||
GetSysColor((airBrushWidth == 12) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 12);
|
||||
DeleteObject(SelectObject(hdc, oldPen));
|
||||
break;
|
||||
}
|
||||
case TOOL_LINE:
|
||||
case TOOL_BEZIER:
|
||||
{
|
||||
int i;
|
||||
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
|
||||
for(i = 0; i < 5; i++)
|
||||
{
|
||||
if (lineWidth == i + 1)
|
||||
{
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
|
||||
Rectangle(hdc, 2, i * 12 + 2, 41, i * 12 + 14);
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT));
|
||||
}
|
||||
else
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT));
|
||||
Rectangle(hdc, 5, i * 12 + 6, 38, i * 12 + 8 + i);
|
||||
}
|
||||
DeleteObject(SelectObject(hdc, oldPen));
|
||||
break;
|
||||
}
|
||||
case TOOL_RECT:
|
||||
case TOOL_SHAPE:
|
||||
case TOOL_ELLIPSE:
|
||||
case TOOL_RRECT:
|
||||
{
|
||||
int i;
|
||||
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
|
||||
for(i = 0; i < 3; i++)
|
||||
{
|
||||
if (shapeStyle == i)
|
||||
{
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
|
||||
Rectangle(hdc, 2, i * 20 + 2, 41, i * 20 + 22);
|
||||
}
|
||||
}
|
||||
Rect(hdc, 5, 6, 37, 16,
|
||||
GetSysColor((shapeStyle == 0) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT),
|
||||
GetSysColor(COLOR_APPWORKSPACE), 1, 0);
|
||||
Rect(hdc, 5, 26, 37, 36,
|
||||
GetSysColor((shapeStyle == 1) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT),
|
||||
GetSysColor(COLOR_APPWORKSPACE), 1, 1);
|
||||
Rect(hdc, 5, 46, 37, 56, GetSysColor(COLOR_APPWORKSPACE), GetSysColor(COLOR_APPWORKSPACE),
|
||||
1, 1);
|
||||
for(i = 0; i < 5; i++)
|
||||
{
|
||||
if (lineWidth == i + 1)
|
||||
{
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
|
||||
Rectangle(hdc, 2, i * 12 + 72, 41, i * 12 + 84);
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT));
|
||||
}
|
||||
else
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT));
|
||||
Rectangle(hdc, 5, i * 12 + 76, 38, i * 12 + 78 + i);
|
||||
}
|
||||
DeleteObject(SelectObject(hdc, oldPen));
|
||||
break;
|
||||
}
|
||||
}
|
||||
ReleaseDC(hwnd, hdc);
|
||||
break;
|
||||
}
|
||||
case WM_LBUTTONDOWN:
|
||||
{
|
||||
int x = GET_X_LPARAM(lParam);
|
||||
int y = GET_Y_LPARAM(lParam);
|
||||
switch (activeTool)
|
||||
{
|
||||
case TOOL_FREESEL:
|
||||
case TOOL_RECTSEL:
|
||||
case TOOL_TEXT:
|
||||
if ((y > 1) && (y < 64))
|
||||
{
|
||||
transpBg = (y - 2) / 31;
|
||||
InvalidateRect(hwnd, NULL, TRUE);
|
||||
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
break;
|
||||
case TOOL_RUBBER:
|
||||
if ((y > 1) && (y < 62))
|
||||
{
|
||||
rubberRadius = (y - 2) / 15 + 2;
|
||||
InvalidateRect(hwnd, NULL, TRUE);
|
||||
}
|
||||
break;
|
||||
case TOOL_BRUSH:
|
||||
if ((x > 1) && (x < 40) && (y > 1)
|
||||
&& (y < 62))
|
||||
{
|
||||
brushStyle = (y - 2) / 15 * 3 + (x - 2) / 13;
|
||||
InvalidateRect(hwnd, NULL, TRUE);
|
||||
}
|
||||
break;
|
||||
case TOOL_AIRBRUSH:
|
||||
if (y < 62)
|
||||
{
|
||||
if (y < 30)
|
||||
{
|
||||
if (x < 20)
|
||||
airBrushWidth = 5;
|
||||
else
|
||||
airBrushWidth = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x < 15)
|
||||
airBrushWidth = 3;
|
||||
else
|
||||
airBrushWidth = 12;
|
||||
}
|
||||
InvalidateRect(hwnd, NULL, TRUE);
|
||||
}
|
||||
break;
|
||||
case TOOL_LINE:
|
||||
case TOOL_BEZIER:
|
||||
if (y <= 62)
|
||||
{
|
||||
lineWidth = (y - 2) / 12 + 1;
|
||||
InvalidateRect(hwnd, NULL, TRUE);
|
||||
}
|
||||
break;
|
||||
case TOOL_RECT:
|
||||
case TOOL_SHAPE:
|
||||
case TOOL_ELLIPSE:
|
||||
case TOOL_RRECT:
|
||||
if (y <= 60)
|
||||
{
|
||||
shapeStyle = (y - 2) / 20;
|
||||
InvalidateRect(hwnd, NULL, TRUE);
|
||||
}
|
||||
if ((y >= 70) && (y <= 132))
|
||||
{
|
||||
lineWidth = (y - 72) / 12 + 1;
|
||||
InvalidateRect(hwnd, NULL, TRUE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
zoomTo(125 << SendMessage(hTrackbarZoom, TBM_GETPOS, 0, 0), 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CToolSettingsWindow::OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
HDC hdc = GetDC();
|
||||
RECT rect1 = { 0, 0, 42, 66 };
|
||||
RECT rect2 = { 0, 70, 42, 136 };
|
||||
|
||||
DefWindowProc(WM_PAINT, wParam, lParam);
|
||||
|
||||
DrawEdge(hdc, &rect1, BDR_SUNKENOUTER, (activeTool == TOOL_ZOOM) ? BF_RECT : BF_RECT | BF_MIDDLE);
|
||||
DrawEdge(hdc, &rect2, (activeTool >= TOOL_RECT) ? BDR_SUNKENOUTER : 0, BF_RECT | BF_MIDDLE);
|
||||
switch (activeTool)
|
||||
{
|
||||
case TOOL_FREESEL:
|
||||
case TOOL_RECTSEL:
|
||||
case TOOL_TEXT:
|
||||
{
|
||||
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
|
||||
Rectangle(hdc, 2, transpBg * 31 + 2, 41, transpBg * 31 + 33);
|
||||
DeleteObject(SelectObject(hdc, oldPen));
|
||||
DrawIconEx(hdc, 1, 2, hNontranspIcon, 40, 30, 0, NULL, DI_NORMAL);
|
||||
DrawIconEx(hdc, 1, 33, hTranspIcon, 40, 30, 0, NULL, DI_NORMAL);
|
||||
break;
|
||||
}
|
||||
case TOOL_RUBBER:
|
||||
{
|
||||
int i;
|
||||
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
|
||||
for(i = 0; i < 4; i++)
|
||||
{
|
||||
if (rubberRadius == i + 2)
|
||||
{
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
|
||||
Rectangle(hdc, 14, i * 15 + 2, 29, i * 15 + 17);
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT));
|
||||
}
|
||||
else
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT));
|
||||
Rectangle(hdc, 19 - i, i * 14 + 7, 24 + i, i * 16 + 12);
|
||||
}
|
||||
DeleteObject(SelectObject(hdc, oldPen));
|
||||
break;
|
||||
}
|
||||
case TOOL_BRUSH:
|
||||
{
|
||||
int i;
|
||||
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
|
||||
Rectangle(hdc, brushStyle % 3 * 13 + 2, brushStyle / 3 * 15 + 2, brushStyle % 3 * 13 + 15,
|
||||
brushStyle / 3 * 15 + 17);
|
||||
DeleteObject(SelectObject(hdc, oldPen));
|
||||
for(i = 0; i < 12; i++)
|
||||
Brush(hdc, i % 3 * 13 + 7, i / 3 * 15 + 8, i % 3 * 13 + 7, i / 3 * 15 + 8,
|
||||
GetSysColor((i == brushStyle) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), i);
|
||||
break;
|
||||
}
|
||||
case TOOL_AIRBRUSH:
|
||||
{
|
||||
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
|
||||
switch (airBrushWidth)
|
||||
{
|
||||
case 5:
|
||||
Rectangle(hdc, 2, 2, 21, 31);
|
||||
break;
|
||||
case 8:
|
||||
Rectangle(hdc, 20, 2, 41, 31);
|
||||
break;
|
||||
case 3:
|
||||
Rectangle(hdc, 2, 30, 16, 61);
|
||||
break;
|
||||
case 12:
|
||||
Rectangle(hdc, 15, 30, 41, 61);
|
||||
break;
|
||||
}
|
||||
Airbrush(hdc, 10, 15,
|
||||
GetSysColor((airBrushWidth == 5) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 5);
|
||||
Airbrush(hdc, 30, 15,
|
||||
GetSysColor((airBrushWidth == 8) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 8);
|
||||
Airbrush(hdc, 8, 45,
|
||||
GetSysColor((airBrushWidth == 3) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 3);
|
||||
Airbrush(hdc, 27, 45,
|
||||
GetSysColor((airBrushWidth == 12) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT), 12);
|
||||
DeleteObject(SelectObject(hdc, oldPen));
|
||||
break;
|
||||
}
|
||||
case TOOL_LINE:
|
||||
case TOOL_BEZIER:
|
||||
{
|
||||
int i;
|
||||
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
|
||||
for(i = 0; i < 5; i++)
|
||||
{
|
||||
if (lineWidth == i + 1)
|
||||
{
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
|
||||
Rectangle(hdc, 2, i * 12 + 2, 41, i * 12 + 14);
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT));
|
||||
}
|
||||
else
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT));
|
||||
Rectangle(hdc, 5, i * 12 + 6, 38, i * 12 + 8 + i);
|
||||
}
|
||||
DeleteObject(SelectObject(hdc, oldPen));
|
||||
break;
|
||||
}
|
||||
case TOOL_RECT:
|
||||
case TOOL_SHAPE:
|
||||
case TOOL_ELLIPSE:
|
||||
case TOOL_RRECT:
|
||||
{
|
||||
int i;
|
||||
HPEN oldPen = (HPEN) SelectObject(hdc, CreatePen(PS_NULL, 0, 0));
|
||||
for(i = 0; i < 3; i++)
|
||||
{
|
||||
if (shapeStyle == i)
|
||||
{
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
|
||||
Rectangle(hdc, 2, i * 20 + 2, 41, i * 20 + 22);
|
||||
}
|
||||
}
|
||||
Rect(hdc, 5, 6, 37, 16,
|
||||
GetSysColor((shapeStyle == 0) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT),
|
||||
GetSysColor(COLOR_APPWORKSPACE), 1, 0);
|
||||
Rect(hdc, 5, 26, 37, 36,
|
||||
GetSysColor((shapeStyle == 1) ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT),
|
||||
GetSysColor(COLOR_APPWORKSPACE), 1, 1);
|
||||
Rect(hdc, 5, 46, 37, 56, GetSysColor(COLOR_APPWORKSPACE), GetSysColor(COLOR_APPWORKSPACE),
|
||||
1, 1);
|
||||
for(i = 0; i < 5; i++)
|
||||
{
|
||||
if (lineWidth == i + 1)
|
||||
{
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHT));
|
||||
Rectangle(hdc, 2, i * 12 + 72, 41, i * 12 + 84);
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_HIGHLIGHTTEXT));
|
||||
}
|
||||
else
|
||||
SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT));
|
||||
Rectangle(hdc, 5, i * 12 + 76, 38, i * 12 + 78 + i);
|
||||
}
|
||||
DeleteObject(SelectObject(hdc, oldPen));
|
||||
break;
|
||||
}
|
||||
}
|
||||
ReleaseDC(hdc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CToolSettingsWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
int x = GET_X_LPARAM(lParam);
|
||||
int y = GET_Y_LPARAM(lParam);
|
||||
switch (activeTool)
|
||||
{
|
||||
case TOOL_FREESEL:
|
||||
case TOOL_RECTSEL:
|
||||
case TOOL_TEXT:
|
||||
if ((y > 1) && (y < 64))
|
||||
{
|
||||
transpBg = (y - 2) / 31;
|
||||
InvalidateRect(NULL, TRUE);
|
||||
|
||||
ForceRefreshSelectionContents();
|
||||
}
|
||||
break;
|
||||
case TOOL_RUBBER:
|
||||
if ((y > 1) && (y < 62))
|
||||
{
|
||||
rubberRadius = (y - 2) / 15 + 2;
|
||||
InvalidateRect(NULL, TRUE);
|
||||
}
|
||||
break;
|
||||
case TOOL_BRUSH:
|
||||
if ((x > 1) && (x < 40) && (y > 1)
|
||||
&& (y < 62))
|
||||
{
|
||||
brushStyle = (y - 2) / 15 * 3 + (x - 2) / 13;
|
||||
InvalidateRect(NULL, TRUE);
|
||||
}
|
||||
break;
|
||||
case TOOL_AIRBRUSH:
|
||||
if (y < 62)
|
||||
{
|
||||
if (y < 30)
|
||||
{
|
||||
if (x < 20)
|
||||
airBrushWidth = 5;
|
||||
else
|
||||
airBrushWidth = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x < 15)
|
||||
airBrushWidth = 3;
|
||||
else
|
||||
airBrushWidth = 12;
|
||||
}
|
||||
InvalidateRect(NULL, TRUE);
|
||||
}
|
||||
break;
|
||||
case TOOL_LINE:
|
||||
case TOOL_BEZIER:
|
||||
if (y <= 62)
|
||||
{
|
||||
lineWidth = (y - 2) / 12 + 1;
|
||||
InvalidateRect(NULL, TRUE);
|
||||
}
|
||||
break;
|
||||
case TOOL_RECT:
|
||||
case TOOL_SHAPE:
|
||||
case TOOL_ELLIPSE:
|
||||
case TOOL_RRECT:
|
||||
if (y <= 60)
|
||||
{
|
||||
shapeStyle = (y - 2) / 20;
|
||||
InvalidateRect(NULL, TRUE);
|
||||
}
|
||||
if ((y >= 70) && (y <= 132))
|
||||
{
|
||||
lineWidth = (y - 72) / 12 + 1;
|
||||
InvalidateRect(NULL, TRUE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,18 @@
|
|||
* PROGRAMMERS: Benedikt Freisen
|
||||
*/
|
||||
|
||||
void RegisterWclSettings();
|
||||
class CToolSettingsWindow : public CWindowImpl<CToolSettingsWindow>
|
||||
{
|
||||
public:
|
||||
DECLARE_WND_CLASS_EX(_T("ToolSettings"), CS_DBLCLKS, COLOR_BTNFACE)
|
||||
|
||||
LRESULT CALLBACK SettingsWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
BEGIN_MSG_MAP(CPaletteWindow)
|
||||
MESSAGE_HANDLER(WM_VSCROLL, OnVScroll)
|
||||
MESSAGE_HANDLER(WM_PAINT, OnPaint)
|
||||
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
|
||||
END_MSG_MAP()
|
||||
|
||||
LRESULT OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
};
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -7,6 +7,48 @@
|
|||
* PROGRAMMERS: Benedikt Freisen
|
||||
*/
|
||||
|
||||
void RegisterWclMain();
|
||||
class CMainWindow : public CWindowImpl<CMainWindow>
|
||||
{
|
||||
public:
|
||||
DECLARE_WND_CLASS_EX(_T("MainWindow"), CS_DBLCLKS, COLOR_BTNFACE)
|
||||
|
||||
LRESULT CALLBACK MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
BEGIN_MSG_MAP(CPaletteWindow)
|
||||
MESSAGE_HANDLER(WM_DROPFILES, OnDropFiles)
|
||||
MESSAGE_HANDLER(WM_CREATE, OnCreate)
|
||||
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
|
||||
MESSAGE_HANDLER(WM_CLOSE, OnClose)
|
||||
MESSAGE_HANDLER(WM_INITMENUPOPUP, OnInitMenuPopup)
|
||||
MESSAGE_HANDLER(WM_SIZE, OnSize)
|
||||
MESSAGE_HANDLER(WM_GETMINMAXINFO, OnGetMinMaxInfo)
|
||||
MESSAGE_HANDLER(WM_PAINT, OnPaint)
|
||||
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
|
||||
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
|
||||
MESSAGE_HANDLER(WM_RBUTTONDOWN, OnRButtonDown)
|
||||
MESSAGE_HANDLER(WM_LBUTTONUP, OnLButtonUp)
|
||||
MESSAGE_HANDLER(WM_RBUTTONUP, OnRButtonUp)
|
||||
MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
|
||||
MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
|
||||
MESSAGE_HANDLER(WM_MOUSELEAVE, OnMouseLeave)
|
||||
MESSAGE_HANDLER(WM_SYSCOLORCHANGE, OnSysColorChange)
|
||||
MESSAGE_HANDLER(WM_COMMAND, OnCommand)
|
||||
END_MSG_MAP()
|
||||
|
||||
LRESULT OnDropFiles(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnDestroy(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnInitMenuPopup(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnGetMinMaxInfo(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnRButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnRButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnKeyDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnMouseMove(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnMouseLeave(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue