mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 06:02:56 +00:00
[MSPAINT_NEW] further ATLification, hard-coded observer pattern, minor cleanup (fourth batch of git commits)
svn path=/trunk/; revision=68370
This commit is contained in:
parent
c9860c44d6
commit
63185511a1
25 changed files with 361 additions and 211 deletions
|
@ -20,6 +20,7 @@ list(APPEND SOURCE
|
||||||
selection.cpp
|
selection.cpp
|
||||||
sizebox.cpp
|
sizebox.cpp
|
||||||
textedit.cpp
|
textedit.cpp
|
||||||
|
toolbox.cpp
|
||||||
toolsettings.cpp
|
toolsettings.cpp
|
||||||
toolsmodel.cpp
|
toolsmodel.cpp
|
||||||
winproc.cpp
|
winproc.cpp
|
||||||
|
|
|
@ -220,3 +220,9 @@
|
||||||
#define IDS_ANGLE 932
|
#define IDS_ANGLE 932
|
||||||
|
|
||||||
#define IDS_LOADERRORTEXT 933
|
#define IDS_LOADERRORTEXT 933
|
||||||
|
|
||||||
|
#define WM_TOOLSMODELTOOLCHANGED WM_APP
|
||||||
|
#define WM_TOOLSMODELSETTINGSCHANGED (WM_APP + 1)
|
||||||
|
#define WM_TOOLSMODELZOOMCHANGED (WM_APP + 2)
|
||||||
|
#define WM_PALETTEMODELCOLORCHANGED (WM_APP + 3)
|
||||||
|
#define WM_PALETTEMODELPALETTECHANGED (WM_APP + 4)
|
||||||
|
|
|
@ -58,7 +58,6 @@ class PaletteModel;
|
||||||
extern PaletteModel paletteModel;
|
extern PaletteModel paletteModel;
|
||||||
|
|
||||||
extern HWND hStatusBar;
|
extern HWND hStatusBar;
|
||||||
extern HWND hTrackbarZoom;
|
|
||||||
extern CHOOSECOLOR choosecolor;
|
extern CHOOSECOLOR choosecolor;
|
||||||
extern OPENFILENAME ofn;
|
extern OPENFILENAME ofn;
|
||||||
extern OPENFILENAME sfn;
|
extern OPENFILENAME sfn;
|
||||||
|
@ -88,6 +87,7 @@ extern BOOL showMiniature;
|
||||||
|
|
||||||
class CMainWindow;
|
class CMainWindow;
|
||||||
class CMiniatureWindow;
|
class CMiniatureWindow;
|
||||||
|
class CToolBox;
|
||||||
class CToolSettingsWindow;
|
class CToolSettingsWindow;
|
||||||
class CPaletteWindow;
|
class CPaletteWindow;
|
||||||
class CScrollboxWindow;
|
class CScrollboxWindow;
|
||||||
|
@ -98,7 +98,7 @@ class CTextEditWindow;
|
||||||
|
|
||||||
extern CMainWindow mainWindow;
|
extern CMainWindow mainWindow;
|
||||||
extern CMiniatureWindow miniature;
|
extern CMiniatureWindow miniature;
|
||||||
extern CMainWindow toolBoxContainer;
|
extern CToolBox toolBoxContainer;
|
||||||
extern CToolSettingsWindow toolSettingsWindow;
|
extern CToolSettingsWindow toolSettingsWindow;
|
||||||
extern CPaletteWindow paletteWindow;
|
extern CPaletteWindow paletteWindow;
|
||||||
extern CScrollboxWindow scrollboxWindow;
|
extern CScrollboxWindow scrollboxWindow;
|
||||||
|
|
|
@ -187,7 +187,6 @@ LRESULT CImgAreaWindow::OnLButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
|
||||||
GetPixel(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom(), GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom());
|
GetPixel(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom(), GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom());
|
||||||
if (tempColor != CLR_INVALID)
|
if (tempColor != CLR_INVALID)
|
||||||
paletteModel.SetFgColor(tempColor);
|
paletteModel.SetFgColor(tempColor);
|
||||||
paletteWindow.Invalidate(FALSE);
|
|
||||||
}
|
}
|
||||||
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) "");
|
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) "");
|
||||||
}
|
}
|
||||||
|
@ -209,7 +208,6 @@ LRESULT CImgAreaWindow::OnRButtonUp(UINT nMsg, WPARAM wParam, LPARAM lParam, BOO
|
||||||
GetPixel(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom(), GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom());
|
GetPixel(hDrawingDC, GET_X_LPARAM(lParam) * 1000 / toolsModel.GetZoom(), GET_Y_LPARAM(lParam) * 1000 / toolsModel.GetZoom());
|
||||||
if (tempColor != CLR_INVALID)
|
if (tempColor != CLR_INVALID)
|
||||||
paletteModel.SetBgColor(tempColor);
|
paletteModel.SetBgColor(tempColor);
|
||||||
paletteWindow.Invalidate(FALSE);
|
|
||||||
}
|
}
|
||||||
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) "");
|
SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM) "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ class CImgAreaWindow : public CWindowImpl<CMainWindow>
|
||||||
public:
|
public:
|
||||||
DECLARE_WND_CLASS_EX(_T("ImgAreaWindow"), CS_DBLCLKS, COLOR_BTNFACE)
|
DECLARE_WND_CLASS_EX(_T("ImgAreaWindow"), CS_DBLCLKS, COLOR_BTNFACE)
|
||||||
|
|
||||||
BEGIN_MSG_MAP(CPaletteWindow)
|
BEGIN_MSG_MAP(CImgAreaWindow)
|
||||||
MESSAGE_HANDLER(WM_SIZE, OnSize)
|
MESSAGE_HANDLER(WM_SIZE, OnSize)
|
||||||
MESSAGE_HANDLER(WM_PAINT, OnPaint)
|
MESSAGE_HANDLER(WM_PAINT, OnPaint)
|
||||||
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
|
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
|
||||||
|
|
|
@ -48,7 +48,6 @@ int textToolTextMaxLen = 0;
|
||||||
PaletteModel paletteModel;
|
PaletteModel paletteModel;
|
||||||
|
|
||||||
HWND hStatusBar;
|
HWND hStatusBar;
|
||||||
HWND hTrackbarZoom;
|
|
||||||
CHOOSECOLOR choosecolor;
|
CHOOSECOLOR choosecolor;
|
||||||
OPENFILENAME ofn;
|
OPENFILENAME ofn;
|
||||||
OPENFILENAME sfn;
|
OPENFILENAME sfn;
|
||||||
|
@ -78,7 +77,7 @@ BOOL showMiniature = FALSE;
|
||||||
|
|
||||||
CMainWindow mainWindow;
|
CMainWindow mainWindow;
|
||||||
CMiniatureWindow miniature;
|
CMiniatureWindow miniature;
|
||||||
CMainWindow toolBoxContainer;
|
CToolBox toolBoxContainer;
|
||||||
CToolSettingsWindow toolSettingsWindow;
|
CToolSettingsWindow toolSettingsWindow;
|
||||||
CPaletteWindow paletteWindow;
|
CPaletteWindow paletteWindow;
|
||||||
CScrollboxWindow scrollboxWindow;
|
CScrollboxWindow scrollboxWindow;
|
||||||
|
@ -106,12 +105,7 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
||||||
TCHAR progtitle[1000];
|
TCHAR progtitle[1000];
|
||||||
TCHAR resstr[100];
|
TCHAR resstr[100];
|
||||||
HMENU menu;
|
HMENU menu;
|
||||||
HWND hToolbar;
|
|
||||||
HIMAGELIST hImageList;
|
|
||||||
HANDLE haccel;
|
HANDLE haccel;
|
||||||
HBITMAP tempBm;
|
|
||||||
int i;
|
|
||||||
TCHAR tooltips[16][30];
|
|
||||||
HDC hDC;
|
HDC hDC;
|
||||||
|
|
||||||
TCHAR *c;
|
TCHAR *c;
|
||||||
|
@ -155,11 +149,11 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
||||||
|
|
||||||
/* create main window */
|
/* create main window */
|
||||||
RECT mainWindowPos = {0, 0, 544, 375}; // FIXME: use equivalent of CW_USEDEFAULT for position
|
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);
|
hwnd = mainWindow.Create(HWND_DESKTOP, mainWindowPos, progtitle, WS_OVERLAPPEDWINDOW);
|
||||||
|
|
||||||
RECT miniaturePos = {180, 200, 180 + 120, 200 + 100};
|
RECT miniaturePos = {180, 200, 180 + 120, 200 + 100};
|
||||||
miniature.Create(hwnd, miniaturePos, miniaturetitle,
|
miniature.Create(hwnd, miniaturePos, miniaturetitle,
|
||||||
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, WS_EX_PALETTEWINDOW, 0U, NULL);
|
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, WS_EX_PALETTEWINDOW);
|
||||||
|
|
||||||
/* loading and setting the window menu from resource */
|
/* loading and setting the window menu from resource */
|
||||||
menu = LoadMenu(hThisInstance, MAKEINTRESOURCE(ID_MENU));
|
menu = LoadMenu(hThisInstance, MAKEINTRESOURCE(ID_MENU));
|
||||||
|
@ -178,85 +172,40 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
||||||
hCurPen = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDC_PEN));
|
hCurPen = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDC_PEN));
|
||||||
hCurAirbrush = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDC_AIRBRUSH));
|
hCurAirbrush = LoadIcon(hThisInstance, MAKEINTRESOURCE(IDC_AIRBRUSH));
|
||||||
|
|
||||||
CreateWindowEx(0, _T("STATIC"), _T(""), WS_CHILD | WS_VISIBLE | SS_ETCHEDHORZ, 0, 0, 5000, 2, hwnd, NULL,
|
CreateWindowEx(0, _T("STATIC"), NULL, WS_CHILD | WS_VISIBLE | SS_ETCHEDHORZ, 0, 0, 5000, 2, hwnd, NULL,
|
||||||
hThisInstance, NULL);
|
hThisInstance, NULL);
|
||||||
|
|
||||||
RECT toolBoxContainerPos = {2, 2, 2 + 52, 2 + 350};
|
RECT toolBoxContainerPos = {2, 2, 2 + 52, 2 + 350};
|
||||||
toolBoxContainer.Create(hwnd, toolBoxContainerPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
toolBoxContainer.Create(hwnd, toolBoxContainerPos, NULL, WS_CHILD | WS_VISIBLE);
|
||||||
/* creating the 16 bitmap radio buttons and setting the bitmap */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* FIXME: Unintentionally there is a line above the tool bar (hidden by y-offset).
|
|
||||||
* To prevent cropping of the buttons height has been increased from 200 to 205
|
|
||||||
*/
|
|
||||||
hToolbar =
|
|
||||||
CreateWindowEx(0, TOOLBARCLASSNAME, NULL,
|
|
||||||
WS_CHILD | WS_VISIBLE | CCS_NOPARENTALIGN | CCS_VERT | CCS_NORESIZE | TBSTYLE_TOOLTIPS,
|
|
||||||
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);
|
|
||||||
ImageList_AddMasked(hImageList, tempBm, 0xff00ff);
|
|
||||||
DeleteObject(tempBm);
|
|
||||||
SendMessage(hToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
|
|
||||||
|
|
||||||
for(i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
TBBUTTON tbbutton;
|
|
||||||
int wrapnow = 0;
|
|
||||||
|
|
||||||
if (i % 2 == 1)
|
|
||||||
wrapnow = TBSTATE_WRAP;
|
|
||||||
|
|
||||||
LoadString(hThisInstance, IDS_TOOLTIP1 + i, tooltips[i], 30);
|
|
||||||
ZeroMemory(&tbbutton, sizeof(TBBUTTON));
|
|
||||||
tbbutton.iString = (INT_PTR) tooltips[i];
|
|
||||||
tbbutton.fsStyle = TBSTYLE_CHECKGROUP;
|
|
||||||
tbbutton.fsState = TBSTATE_ENABLED | wrapnow;
|
|
||||||
tbbutton.idCommand = ID_FREESEL + i;
|
|
||||||
tbbutton.iBitmap = i;
|
|
||||||
SendMessage(hToolbar, TB_ADDBUTTONS, 1, (LPARAM) &tbbutton);
|
|
||||||
}
|
|
||||||
|
|
||||||
SendMessage(hToolbar, TB_CHECKBUTTON, ID_PEN, MAKELONG(TRUE, 0));
|
|
||||||
SendMessage(hToolbar, TB_SETMAXTEXTROWS, 0, 0);
|
|
||||||
SendMessage(hToolbar, TB_SETBUTTONSIZE, 0, MAKELONG(25, 25));
|
|
||||||
|
|
||||||
/* creating the tool settings child window */
|
/* creating the tool settings child window */
|
||||||
RECT toolSettingsWindowPos = {5, 208, 5 + 42, 208 + 140};
|
RECT toolSettingsWindowPos = {5, 208, 5 + 42, 208 + 140};
|
||||||
toolSettingsWindow.Create(toolBoxContainer.m_hWnd, toolSettingsWindowPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
toolSettingsWindow.Create(toolBoxContainer.m_hWnd, toolSettingsWindowPos, NULL, WS_CHILD | WS_VISIBLE);
|
||||||
hTrackbarZoom =
|
|
||||||
CreateWindowEx(0, TRACKBAR_CLASS, _T(""), WS_CHILD | TBS_VERT | TBS_AUTOTICKS, 1, 1, 40, 64,
|
|
||||||
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 */
|
/* creating the palette child window */
|
||||||
RECT paletteWindowPos = {56, 9, 56 + 255, 9 + 32};
|
RECT paletteWindowPos = {56, 9, 56 + 255, 9 + 32};
|
||||||
paletteWindow.Create(hwnd, paletteWindowPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
paletteWindow.Create(hwnd, paletteWindowPos, NULL, WS_CHILD | WS_VISIBLE);
|
||||||
|
|
||||||
/* creating the scroll box */
|
/* creating the scroll box */
|
||||||
RECT scrollboxWindowPos = {56, 49, 56 + 472, 49 + 248};
|
RECT scrollboxWindowPos = {56, 49, 56 + 472, 49 + 248};
|
||||||
scrollboxWindow.Create(hwnd, scrollboxWindowPos, _T(""),
|
scrollboxWindow.Create(hwnd, scrollboxWindowPos, NULL,
|
||||||
WS_CHILD | WS_GROUP | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE, WS_EX_CLIENTEDGE, 0U, NULL);
|
WS_CHILD | WS_GROUP | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE, WS_EX_CLIENTEDGE);
|
||||||
|
|
||||||
/* creating the status bar */
|
/* creating the status bar */
|
||||||
hStatusBar =
|
hStatusBar =
|
||||||
CreateWindowEx(0, STATUSCLASSNAME, _T(""), SBARS_SIZEGRIP | WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hwnd,
|
CreateWindowEx(0, STATUSCLASSNAME, NULL, SBARS_SIZEGRIP | WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hwnd,
|
||||||
NULL, hThisInstance, NULL);
|
NULL, hThisInstance, NULL);
|
||||||
SendMessage(hStatusBar, SB_SETMINHEIGHT, 21, 0);
|
SendMessage(hStatusBar, SB_SETMINHEIGHT, 21, 0);
|
||||||
|
|
||||||
RECT scrlClientWindowPos = {0, 0, 0 + 500, 0 + 500};
|
RECT scrlClientWindowPos = {0, 0, 0 + 500, 0 + 500};
|
||||||
scrlClientWindow.Create(scrollboxWindow.m_hWnd, scrlClientWindowPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
scrlClientWindow.Create(scrollboxWindow.m_hWnd, scrlClientWindowPos, NULL, WS_CHILD | WS_VISIBLE);
|
||||||
|
|
||||||
/* create selection window (initially hidden) */
|
/* create selection window (initially hidden) */
|
||||||
RECT selectionWindowPos = {350, 0, 350 + 100, 0 + 100};
|
RECT selectionWindowPos = {350, 0, 350 + 100, 0 + 100};
|
||||||
selectionWindow.Create(scrlClientWindow.m_hWnd, selectionWindowPos, _T(""), WS_CHILD | BS_OWNERDRAW, 0, 0U, NULL);
|
selectionWindow.Create(scrlClientWindow.m_hWnd, selectionWindowPos, NULL, WS_CHILD | BS_OWNERDRAW);
|
||||||
|
|
||||||
/* creating the window inside the scroll box, on which the image in hDrawingDC's bitmap is drawn */
|
/* creating the window inside the scroll box, on which the image in hDrawingDC's bitmap is drawn */
|
||||||
RECT imageAreaPos = {3, 3, 3 + imgXRes, 3 + imgYRes};
|
RECT imageAreaPos = {3, 3, 3 + imgXRes, 3 + imgYRes};
|
||||||
imageArea.Create(scrlClientWindow.m_hWnd, imageAreaPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
imageArea.Create(scrlClientWindow.m_hWnd, imageAreaPos, NULL, WS_CHILD | WS_VISIBLE);
|
||||||
|
|
||||||
hDC = imageArea.GetDC();
|
hDC = imageArea.GetDC();
|
||||||
hDrawingDC = CreateCompatibleDC(hDC);
|
hDrawingDC = CreateCompatibleDC(hDC);
|
||||||
|
@ -339,14 +288,14 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
||||||
|
|
||||||
/* creating the size boxes */
|
/* creating the size boxes */
|
||||||
RECT sizeboxPos = {0, 0, 0 + 3, 0 + 3};
|
RECT sizeboxPos = {0, 0, 0 + 3, 0 + 3};
|
||||||
sizeboxLeftTop.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
sizeboxLeftTop.Create(scrlClientWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
|
||||||
sizeboxCenterTop.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
sizeboxCenterTop.Create(scrlClientWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
|
||||||
sizeboxRightTop.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
sizeboxRightTop.Create(scrlClientWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
|
||||||
sizeboxLeftCenter.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
sizeboxLeftCenter.Create(scrlClientWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
|
||||||
sizeboxRightCenter.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
sizeboxRightCenter.Create(scrlClientWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
|
||||||
sizeboxLeftBottom.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
sizeboxLeftBottom.Create(scrlClientWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
|
||||||
sizeboxCenterBottom.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
sizeboxCenterBottom.Create(scrlClientWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
|
||||||
sizeboxRightBottom.Create(scrlClientWindow.m_hWnd, sizeboxPos, _T(""), WS_CHILD | WS_VISIBLE, 0, 0U, NULL);
|
sizeboxRightBottom.Create(scrlClientWindow.m_hWnd, sizeboxPos, NULL, WS_CHILD | WS_VISIBLE);
|
||||||
/* placing the size boxes around the image */
|
/* placing the size boxes around the image */
|
||||||
imageArea.SendMessage(WM_SIZE, 0, 0);
|
imageArea.SendMessage(WM_SIZE, 0, 0);
|
||||||
|
|
||||||
|
@ -355,12 +304,7 @@ _tWinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPTSTR lpszArgument
|
||||||
|
|
||||||
/* creating the text editor window for the text tool */
|
/* creating the text editor window for the text tool */
|
||||||
RECT textEditWindowPos = {300, 0, 300 + 300, 0 + 200};
|
RECT textEditWindowPos = {300, 0, 300 + 300, 0 + 200};
|
||||||
textEditWindow.Create(hwnd, textEditWindowPos, _T(""), WS_OVERLAPPEDWINDOW, 0, 0U, NULL);
|
textEditWindow.Create(hwnd, textEditWindowPos, NULL, WS_OVERLAPPEDWINDOW);
|
||||||
/* 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, textEditWindow.m_hWnd, NULL, hThisInstance, NULL);
|
|
||||||
|
|
||||||
/* Make the window visible on the screen */
|
/* Make the window visible on the screen */
|
||||||
ShowWindow (hwnd, nFunsterStil);
|
ShowWindow (hwnd, nFunsterStil);
|
||||||
|
|
|
@ -12,7 +12,7 @@ class CMiniatureWindow : public CWindowImpl<CMiniatureWindow>
|
||||||
public:
|
public:
|
||||||
DECLARE_WND_CLASS_EX(_T("MiniatureWindow"), CS_DBLCLKS, COLOR_BTNFACE)
|
DECLARE_WND_CLASS_EX(_T("MiniatureWindow"), CS_DBLCLKS, COLOR_BTNFACE)
|
||||||
|
|
||||||
BEGIN_MSG_MAP(CPaletteWindow)
|
BEGIN_MSG_MAP(CMiniatureWindow)
|
||||||
MESSAGE_HANDLER(WM_CLOSE, OnClose)
|
MESSAGE_HANDLER(WM_CLOSE, OnClose)
|
||||||
MESSAGE_HANDLER(WM_PAINT, OnPaint)
|
MESSAGE_HANDLER(WM_PAINT, OnPaint)
|
||||||
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
|
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
|
||||||
|
|
|
@ -63,7 +63,6 @@ LRESULT CPaletteWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, B
|
||||||
if (GET_X_LPARAM(lParam) >= 31)
|
if (GET_X_LPARAM(lParam) >= 31)
|
||||||
{
|
{
|
||||||
paletteModel.SetFgColor(paletteModel.GetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14));
|
paletteModel.SetFgColor(paletteModel.GetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14));
|
||||||
InvalidateRect(NULL, FALSE);
|
|
||||||
if (toolsModel.GetActiveTool() == 10)
|
if (toolsModel.GetActiveTool() == 10)
|
||||||
ForceRefreshSelectionContents();
|
ForceRefreshSelectionContents();
|
||||||
}
|
}
|
||||||
|
@ -75,7 +74,6 @@ LRESULT CPaletteWindow::OnRButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, B
|
||||||
if (GET_X_LPARAM(lParam) >= 31)
|
if (GET_X_LPARAM(lParam) >= 31)
|
||||||
{
|
{
|
||||||
paletteModel.SetBgColor(paletteModel.GetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14));
|
paletteModel.SetBgColor(paletteModel.GetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14));
|
||||||
InvalidateRect(NULL, FALSE);
|
|
||||||
if (toolsModel.GetActiveTool() == 10)
|
if (toolsModel.GetActiveTool() == 10)
|
||||||
ForceRefreshSelectionContents();
|
ForceRefreshSelectionContents();
|
||||||
}
|
}
|
||||||
|
@ -90,7 +88,6 @@ LRESULT CPaletteWindow::OnLButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam,
|
||||||
paletteModel.SetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14,
|
paletteModel.SetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14,
|
||||||
choosecolor.rgbResult);
|
choosecolor.rgbResult);
|
||||||
paletteModel.SetFgColor(choosecolor.rgbResult);
|
paletteModel.SetFgColor(choosecolor.rgbResult);
|
||||||
InvalidateRect(NULL, FALSE);
|
|
||||||
if (toolsModel.GetActiveTool() == 10)
|
if (toolsModel.GetActiveTool() == 10)
|
||||||
ForceRefreshSelectionContents();
|
ForceRefreshSelectionContents();
|
||||||
}
|
}
|
||||||
|
@ -105,9 +102,20 @@ LRESULT CPaletteWindow::OnRButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam,
|
||||||
paletteModel.SetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14,
|
paletteModel.SetColor((GET_X_LPARAM(lParam) - 31) / 16 + (GET_Y_LPARAM(lParam) / 16) * 14,
|
||||||
choosecolor.rgbResult);
|
choosecolor.rgbResult);
|
||||||
paletteModel.SetBgColor(choosecolor.rgbResult);
|
paletteModel.SetBgColor(choosecolor.rgbResult);
|
||||||
InvalidateRect(NULL, FALSE);
|
|
||||||
if (toolsModel.GetActiveTool() == 10)
|
if (toolsModel.GetActiveTool() == 10)
|
||||||
ForceRefreshSelectionContents();
|
ForceRefreshSelectionContents();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LRESULT CPaletteWindow::OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
|
{
|
||||||
|
InvalidateRect(NULL, FALSE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CPaletteWindow::OnPaletteModelPaletteChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
|
{
|
||||||
|
InvalidateRect(NULL, FALSE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@ public:
|
||||||
MESSAGE_HANDLER(WM_RBUTTONDOWN, OnRButtonDown)
|
MESSAGE_HANDLER(WM_RBUTTONDOWN, OnRButtonDown)
|
||||||
MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk)
|
MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk)
|
||||||
MESSAGE_HANDLER(WM_RBUTTONDBLCLK, OnRButtonDblClk)
|
MESSAGE_HANDLER(WM_RBUTTONDBLCLK, OnRButtonDblClk)
|
||||||
|
MESSAGE_HANDLER(WM_PALETTEMODELCOLORCHANGED, OnPaletteModelColorChanged)
|
||||||
|
MESSAGE_HANDLER(WM_PALETTEMODELPALETTECHANGED, OnPaletteModelPaletteChanged)
|
||||||
END_MSG_MAP()
|
END_MSG_MAP()
|
||||||
|
|
||||||
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnPaint(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
|
@ -24,4 +26,6 @@ public:
|
||||||
LRESULT OnRButtonDown(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 OnLButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
LRESULT OnRButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnRButtonDblClk(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
|
LRESULT OnPaletteModelColorChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
|
LRESULT OnPaletteModelPaletteChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,6 +45,7 @@ void PaletteModel::SelectPalette(int nPalette)
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
m_nSelectedPalette = nPalette;
|
m_nSelectedPalette = nPalette;
|
||||||
|
NotifyPaletteChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
int PaletteModel::GetColor(int nIndex)
|
int PaletteModel::GetColor(int nIndex)
|
||||||
|
@ -58,7 +59,10 @@ int PaletteModel::GetColor(int nIndex)
|
||||||
void PaletteModel::SetColor(int nIndex, int newColor)
|
void PaletteModel::SetColor(int nIndex, int newColor)
|
||||||
{
|
{
|
||||||
if (nIndex < 28)
|
if (nIndex < 28)
|
||||||
|
{
|
||||||
m_colors[nIndex] = newColor;
|
m_colors[nIndex] = newColor;
|
||||||
|
NotifyPaletteChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int PaletteModel::GetFgColor()
|
int PaletteModel::GetFgColor()
|
||||||
|
@ -69,6 +73,7 @@ int PaletteModel::GetFgColor()
|
||||||
void PaletteModel::SetFgColor(int newColor)
|
void PaletteModel::SetFgColor(int newColor)
|
||||||
{
|
{
|
||||||
m_fgColor = newColor;
|
m_fgColor = newColor;
|
||||||
|
NotifyColorChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
int PaletteModel::GetBgColor()
|
int PaletteModel::GetBgColor()
|
||||||
|
@ -79,4 +84,15 @@ int PaletteModel::GetBgColor()
|
||||||
void PaletteModel::SetBgColor(int newColor)
|
void PaletteModel::SetBgColor(int newColor)
|
||||||
{
|
{
|
||||||
m_bgColor = newColor;
|
m_bgColor = newColor;
|
||||||
|
NotifyColorChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PaletteModel::NotifyColorChanged()
|
||||||
|
{
|
||||||
|
paletteWindow.SendMessage(WM_PALETTEMODELCOLORCHANGED);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PaletteModel::NotifyPaletteChanged()
|
||||||
|
{
|
||||||
|
paletteWindow.SendMessage(WM_PALETTEMODELPALETTECHANGED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,10 @@ private:
|
||||||
int m_nSelectedPalette;
|
int m_nSelectedPalette;
|
||||||
int m_fgColor;
|
int m_fgColor;
|
||||||
int m_bgColor;
|
int m_bgColor;
|
||||||
|
|
||||||
|
void NotifyColorChanged();
|
||||||
|
void NotifyPaletteChanged();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PaletteModel();
|
PaletteModel();
|
||||||
int SelectedPalette();
|
int SelectedPalette();
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "selection.h"
|
#include "selection.h"
|
||||||
#include "sizebox.h"
|
#include "sizebox.h"
|
||||||
#include "textedit.h"
|
#include "textedit.h"
|
||||||
|
#include "toolbox.h"
|
||||||
#include "toolsettings.h"
|
#include "toolsettings.h"
|
||||||
#include "toolsmodel.h"
|
#include "toolsmodel.h"
|
||||||
#include "winproc.h"
|
#include "winproc.h"
|
||||||
|
|
|
@ -11,7 +11,7 @@ class CScrollboxWindow : public CWindowImpl<CScrollboxWindow>
|
||||||
public:
|
public:
|
||||||
DECLARE_WND_CLASS_EX(_T("Scrollbox"), 0, COLOR_APPWORKSPACE)
|
DECLARE_WND_CLASS_EX(_T("Scrollbox"), 0, COLOR_APPWORKSPACE)
|
||||||
|
|
||||||
BEGIN_MSG_MAP(CPaletteWindow)
|
BEGIN_MSG_MAP(CScrollboxWindow)
|
||||||
MESSAGE_HANDLER(WM_SIZE, OnSize)
|
MESSAGE_HANDLER(WM_SIZE, OnSize)
|
||||||
MESSAGE_HANDLER(WM_HSCROLL, OnHScroll)
|
MESSAGE_HANDLER(WM_HSCROLL, OnHScroll)
|
||||||
MESSAGE_HANDLER(WM_VSCROLL, OnVScroll)
|
MESSAGE_HANDLER(WM_VSCROLL, OnVScroll)
|
||||||
|
|
|
@ -11,7 +11,7 @@ class CSelectionWindow : public CWindowImpl<CSelectionWindow>
|
||||||
public:
|
public:
|
||||||
DECLARE_WND_CLASS_EX(_T("Selection"), CS_DBLCLKS, COLOR_BTNFACE)
|
DECLARE_WND_CLASS_EX(_T("Selection"), CS_DBLCLKS, COLOR_BTNFACE)
|
||||||
|
|
||||||
BEGIN_MSG_MAP(CPaletteWindow)
|
BEGIN_MSG_MAP(CSelectionWindow)
|
||||||
MESSAGE_HANDLER(WM_PAINT, OnPaint)
|
MESSAGE_HANDLER(WM_PAINT, OnPaint)
|
||||||
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
|
MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
|
||||||
MESSAGE_HANDLER(WM_CREATE, OnCreate)
|
MESSAGE_HANDLER(WM_CREATE, OnCreate)
|
||||||
|
|
|
@ -11,7 +11,7 @@ class CSizeboxWindow : public CWindowImpl<CSizeboxWindow>
|
||||||
public:
|
public:
|
||||||
DECLARE_WND_CLASS_EX(_T("Sizebox"), CS_DBLCLKS, COLOR_HIGHLIGHT)
|
DECLARE_WND_CLASS_EX(_T("Sizebox"), CS_DBLCLKS, COLOR_HIGHLIGHT)
|
||||||
|
|
||||||
BEGIN_MSG_MAP(CPaletteWindow)
|
BEGIN_MSG_MAP(CSizeboxWindow)
|
||||||
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
|
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
|
||||||
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
|
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
|
||||||
MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
|
MESSAGE_HANDLER(WM_MOUSEMOVE, OnMouseMove)
|
||||||
|
|
|
@ -11,12 +11,21 @@
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
|
||||||
/* FUNCTIONS ********************************************************/
|
/* FUNCTIONS ********************************************************/
|
||||||
|
LRESULT CTextEditWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
|
{
|
||||||
|
/* creating the edit control within the editor window */
|
||||||
|
RECT editControlPos = {0, 0, 0 + 100, 0 + 100};
|
||||||
|
hwndEditCtl = editControl.Create(_T("EDIT"), m_hWnd, editControlPos, NULL,
|
||||||
|
WS_CHILD | WS_VISIBLE | WS_BORDER | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE | ES_NOHIDESEL | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
|
||||||
|
WS_EX_CLIENTEDGE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
LRESULT CTextEditWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
LRESULT CTextEditWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
{
|
{
|
||||||
RECT clientRect;
|
RECT clientRect;
|
||||||
GetClientRect(&clientRect);
|
GetClientRect(&clientRect);
|
||||||
::MoveWindow(hwndEditCtl, clientRect.left, clientRect.top, RECT_WIDTH(clientRect), RECT_HEIGHT(clientRect), TRUE);
|
editControl.MoveWindow(clientRect.left, clientRect.top, RECT_WIDTH(clientRect), RECT_HEIGHT(clientRect), TRUE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,12 +42,18 @@ LRESULT CTextEditWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL
|
||||||
case EN_UPDATE:
|
case EN_UPDATE:
|
||||||
{
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, textToolText);
|
HeapFree(GetProcessHeap(), 0, textToolText);
|
||||||
textToolTextMaxLen = ::GetWindowTextLength(hwndEditCtl) + 1;
|
textToolTextMaxLen = editControl.GetWindowTextLength() + 1;
|
||||||
textToolText = (LPTSTR) HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, sizeof(TCHAR) * textToolTextMaxLen);
|
textToolText = (LPTSTR) HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, sizeof(TCHAR) * textToolTextMaxLen);
|
||||||
::GetWindowText(hwndEditCtl, textToolText, textToolTextMaxLen);
|
editControl.GetWindowText(textToolText, textToolTextMaxLen);
|
||||||
ForceRefreshSelectionContents();
|
ForceRefreshSelectionContents();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LRESULT CTextEditWindow::OnToolsModelToolChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
|
{
|
||||||
|
ShowWindow((wParam == TOOL_TEXT) ? SW_SHOW : SW_HIDE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -11,13 +11,19 @@ class CTextEditWindow : public CWindowImpl<CTextEditWindow>
|
||||||
public:
|
public:
|
||||||
DECLARE_WND_CLASS_EX(_T("TextEdit"), CS_DBLCLKS, COLOR_BTNFACE)
|
DECLARE_WND_CLASS_EX(_T("TextEdit"), CS_DBLCLKS, COLOR_BTNFACE)
|
||||||
|
|
||||||
BEGIN_MSG_MAP(CPaletteWindow)
|
BEGIN_MSG_MAP(CTextEditWindow)
|
||||||
|
MESSAGE_HANDLER(WM_CREATE, OnCreate)
|
||||||
MESSAGE_HANDLER(WM_SIZE, OnSize)
|
MESSAGE_HANDLER(WM_SIZE, OnSize)
|
||||||
MESSAGE_HANDLER(WM_CLOSE, OnClose)
|
MESSAGE_HANDLER(WM_CLOSE, OnClose)
|
||||||
MESSAGE_HANDLER(WM_COMMAND, OnCommand)
|
MESSAGE_HANDLER(WM_COMMAND, OnCommand)
|
||||||
|
MESSAGE_HANDLER(WM_TOOLSMODELTOOLCHANGED, OnToolsModelToolChanged)
|
||||||
END_MSG_MAP()
|
END_MSG_MAP()
|
||||||
|
|
||||||
|
CWindow editControl;
|
||||||
|
|
||||||
|
LRESULT OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
LRESULT OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
LRESULT OnClose(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);
|
LRESULT OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
|
LRESULT OnToolsModelToolChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
};
|
};
|
||||||
|
|
135
reactos/base/applications/mspaint_new/toolbox.cpp
Normal file
135
reactos/base/applications/mspaint_new/toolbox.cpp
Normal file
|
@ -0,0 +1,135 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: PAINT for ReactOS
|
||||||
|
* LICENSE: LGPL
|
||||||
|
* FILE: base/applications/mspaint_new/toolbox.cpp
|
||||||
|
* PURPOSE: Window procedure of the main window and all children apart from
|
||||||
|
* hPalWin, hToolSettings and hSelection
|
||||||
|
* PROGRAMMERS: Benedikt Freisen
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES *********************************************************/
|
||||||
|
|
||||||
|
#include "precomp.h"
|
||||||
|
|
||||||
|
/* FUNCTIONS ********************************************************/
|
||||||
|
|
||||||
|
LRESULT CToolBox::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
|
{
|
||||||
|
HIMAGELIST hImageList;
|
||||||
|
HBITMAP tempBm;
|
||||||
|
int i;
|
||||||
|
TCHAR tooltips[16][30];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FIXME: Unintentionally there is a line above the tool bar (hidden by y-offset).
|
||||||
|
* To prevent cropping of the buttons height has been increased from 200 to 205
|
||||||
|
*/
|
||||||
|
RECT toolbarPos = {1, -2, 1 + 50, -2 + 205};
|
||||||
|
toolbar.Create(TOOLBARCLASSNAME, m_hWnd, toolbarPos, NULL,
|
||||||
|
WS_CHILD | WS_VISIBLE | CCS_NOPARENTALIGN | CCS_VERT | CCS_NORESIZE | TBSTYLE_TOOLTIPS);
|
||||||
|
hImageList = ImageList_Create(16, 16, ILC_COLOR24 | ILC_MASK, 16, 0);
|
||||||
|
toolbar.SendMessage(TB_SETIMAGELIST, 0, (LPARAM) hImageList);
|
||||||
|
tempBm = (HBITMAP) LoadImage((HINSTANCE) GetWindowLong(GWL_HINSTANCE), MAKEINTRESOURCE(IDB_TOOLBARICONS), IMAGE_BITMAP, 256, 16, 0);
|
||||||
|
ImageList_AddMasked(hImageList, tempBm, 0xff00ff);
|
||||||
|
DeleteObject(tempBm);
|
||||||
|
toolbar.SendMessage(TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
|
||||||
|
|
||||||
|
for(i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
TBBUTTON tbbutton;
|
||||||
|
int wrapnow = 0;
|
||||||
|
|
||||||
|
if (i % 2 == 1)
|
||||||
|
wrapnow = TBSTATE_WRAP;
|
||||||
|
|
||||||
|
LoadString((HINSTANCE) GetWindowLong(GWL_HINSTANCE), IDS_TOOLTIP1 + i, tooltips[i], 30);
|
||||||
|
ZeroMemory(&tbbutton, sizeof(TBBUTTON));
|
||||||
|
tbbutton.iString = (INT_PTR) tooltips[i];
|
||||||
|
tbbutton.fsStyle = TBSTYLE_CHECKGROUP;
|
||||||
|
tbbutton.fsState = TBSTATE_ENABLED | wrapnow;
|
||||||
|
tbbutton.idCommand = ID_FREESEL + i;
|
||||||
|
tbbutton.iBitmap = i;
|
||||||
|
toolbar.SendMessage(TB_ADDBUTTONS, 1, (LPARAM) &tbbutton);
|
||||||
|
}
|
||||||
|
|
||||||
|
toolbar.SendMessage(TB_CHECKBUTTON, ID_PEN, MAKELPARAM(TRUE, 0));
|
||||||
|
toolbar.SendMessage(TB_SETMAXTEXTROWS, 0, 0);
|
||||||
|
toolbar.SendMessage(TB_SETBUTTONSIZE, 0, MAKELPARAM(25, 25));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CToolBox::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
|
{
|
||||||
|
SetCursor(LoadCursor(NULL, IDC_ARROW));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CToolBox::OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
|
{
|
||||||
|
toolbar.SendMessage(WM_SYSCOLORCHANGE, 0, 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CToolBox::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
|
{
|
||||||
|
switch (LOWORD(wParam))
|
||||||
|
{
|
||||||
|
case ID_FREESEL:
|
||||||
|
toolsModel.SetActiveTool(1);
|
||||||
|
break;
|
||||||
|
case ID_RECTSEL:
|
||||||
|
toolsModel.SetActiveTool(2);
|
||||||
|
break;
|
||||||
|
case ID_RUBBER:
|
||||||
|
toolsModel.SetActiveTool(3);
|
||||||
|
break;
|
||||||
|
case ID_FILL:
|
||||||
|
toolsModel.SetActiveTool(4);
|
||||||
|
break;
|
||||||
|
case ID_COLOR:
|
||||||
|
toolsModel.SetActiveTool(5);
|
||||||
|
break;
|
||||||
|
case ID_ZOOM:
|
||||||
|
toolsModel.SetActiveTool(6);
|
||||||
|
break;
|
||||||
|
case ID_PEN:
|
||||||
|
toolsModel.SetActiveTool(7);
|
||||||
|
break;
|
||||||
|
case ID_BRUSH:
|
||||||
|
toolsModel.SetActiveTool(8);
|
||||||
|
break;
|
||||||
|
case ID_AIRBRUSH:
|
||||||
|
toolsModel.SetActiveTool(9);
|
||||||
|
break;
|
||||||
|
case ID_TEXT:
|
||||||
|
toolsModel.SetActiveTool(10);
|
||||||
|
break;
|
||||||
|
case ID_LINE:
|
||||||
|
toolsModel.SetActiveTool(11);
|
||||||
|
break;
|
||||||
|
case ID_BEZIER:
|
||||||
|
toolsModel.SetActiveTool(12);
|
||||||
|
break;
|
||||||
|
case ID_RECT:
|
||||||
|
toolsModel.SetActiveTool(13);
|
||||||
|
break;
|
||||||
|
case ID_SHAPE:
|
||||||
|
toolsModel.SetActiveTool(14);
|
||||||
|
break;
|
||||||
|
case ID_ELLIPSE:
|
||||||
|
toolsModel.SetActiveTool(15);
|
||||||
|
break;
|
||||||
|
case ID_RRECT:
|
||||||
|
toolsModel.SetActiveTool(16);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CToolBox::OnToolsModelToolChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
|
{
|
||||||
|
selectionWindow.ShowWindow(SW_HIDE);
|
||||||
|
pointSP = 0; // resets the point-buffer of the polygon and bezier functions
|
||||||
|
return 0;
|
||||||
|
}
|
30
reactos/base/applications/mspaint_new/toolbox.h
Normal file
30
reactos/base/applications/mspaint_new/toolbox.h
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: PAINT for ReactOS
|
||||||
|
* LICENSE: LGPL
|
||||||
|
* FILE: base/applications/mspaint_new/toolbox.h
|
||||||
|
* PURPOSE: Window procedure of the main window and all children apart from
|
||||||
|
* hPalWin, hToolSettings and hSelection
|
||||||
|
* PROGRAMMERS: Benedikt Freisen
|
||||||
|
*/
|
||||||
|
|
||||||
|
class CToolBox : public CWindowImpl<CMainWindow>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DECLARE_WND_CLASS_EX(_T("ToolBox"), CS_DBLCLKS, COLOR_BTNFACE)
|
||||||
|
|
||||||
|
BEGIN_MSG_MAP(CToolBox)
|
||||||
|
MESSAGE_HANDLER(WM_CREATE, OnCreate)
|
||||||
|
MESSAGE_HANDLER(WM_SETCURSOR, OnSetCursor)
|
||||||
|
MESSAGE_HANDLER(WM_SYSCOLORCHANGE, OnSysColorChange)
|
||||||
|
MESSAGE_HANDLER(WM_COMMAND, OnCommand)
|
||||||
|
MESSAGE_HANDLER(WM_TOOLSMODELTOOLCHANGED, OnToolsModelToolChanged)
|
||||||
|
END_MSG_MAP()
|
||||||
|
|
||||||
|
CWindow toolbar;
|
||||||
|
|
||||||
|
LRESULT OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
|
LRESULT OnSetCursor(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);
|
||||||
|
LRESULT OnToolsModelToolChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
|
};
|
|
@ -14,9 +14,18 @@
|
||||||
|
|
||||||
extern void zoomTo(int, int, int);
|
extern void zoomTo(int, int, int);
|
||||||
|
|
||||||
|
LRESULT CToolSettingsWindow::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, WINBOOL& bHandled)
|
||||||
|
{
|
||||||
|
RECT trackbarZoomPos = {1, 1, 1 + 40, 1 + 64};
|
||||||
|
trackbarZoom.Create(TRACKBAR_CLASS, m_hWnd, trackbarZoomPos, NULL, WS_CHILD | TBS_VERT | TBS_AUTOTICKS);
|
||||||
|
trackbarZoom.SendMessage(TBM_SETRANGE, (WPARAM) TRUE, MAKELPARAM(0, 6));
|
||||||
|
trackbarZoom.SendMessage(TBM_SETPOS, (WPARAM) TRUE, (LPARAM) 3);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
LRESULT CToolSettingsWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
LRESULT CToolSettingsWindow::OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
{
|
{
|
||||||
zoomTo(125 << SendMessage(hTrackbarZoom, TBM_GETPOS, 0, 0), 0, 0);
|
zoomTo(125 << trackbarZoom.SendMessage(TBM_GETPOS, 0, 0), 0, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,25 +190,17 @@ LRESULT CToolSettingsWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lPar
|
||||||
if ((y > 1) && (y < 64))
|
if ((y > 1) && (y < 64))
|
||||||
{
|
{
|
||||||
toolsModel.SetBackgroundTransparent((y - 2) / 31);
|
toolsModel.SetBackgroundTransparent((y - 2) / 31);
|
||||||
InvalidateRect(NULL, TRUE);
|
|
||||||
|
|
||||||
ForceRefreshSelectionContents();
|
ForceRefreshSelectionContents();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TOOL_RUBBER:
|
case TOOL_RUBBER:
|
||||||
if ((y > 1) && (y < 62))
|
if ((y > 1) && (y < 62))
|
||||||
{
|
|
||||||
toolsModel.SetRubberRadius((y - 2) / 15 + 2);
|
toolsModel.SetRubberRadius((y - 2) / 15 + 2);
|
||||||
InvalidateRect(NULL, TRUE);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case TOOL_BRUSH:
|
case TOOL_BRUSH:
|
||||||
if ((x > 1) && (x < 40) && (y > 1)
|
if ((x > 1) && (x < 40) && (y > 1) && (y < 62))
|
||||||
&& (y < 62))
|
|
||||||
{
|
|
||||||
toolsModel.SetBrushStyle((y - 2) / 15 * 3 + (x - 2) / 13);
|
toolsModel.SetBrushStyle((y - 2) / 15 * 3 + (x - 2) / 13);
|
||||||
InvalidateRect(NULL, TRUE);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case TOOL_AIRBRUSH:
|
case TOOL_AIRBRUSH:
|
||||||
if (y < 62)
|
if (y < 62)
|
||||||
|
@ -218,32 +219,49 @@ LRESULT CToolSettingsWindow::OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lPar
|
||||||
else
|
else
|
||||||
toolsModel.SetAirBrushWidth(12);
|
toolsModel.SetAirBrushWidth(12);
|
||||||
}
|
}
|
||||||
InvalidateRect(NULL, TRUE);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TOOL_LINE:
|
case TOOL_LINE:
|
||||||
case TOOL_BEZIER:
|
case TOOL_BEZIER:
|
||||||
if (y <= 62)
|
if (y <= 62)
|
||||||
{
|
|
||||||
toolsModel.SetLineWidth((y - 2) / 12 + 1);
|
toolsModel.SetLineWidth((y - 2) / 12 + 1);
|
||||||
InvalidateRect(NULL, TRUE);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case TOOL_RECT:
|
case TOOL_RECT:
|
||||||
case TOOL_SHAPE:
|
case TOOL_SHAPE:
|
||||||
case TOOL_ELLIPSE:
|
case TOOL_ELLIPSE:
|
||||||
case TOOL_RRECT:
|
case TOOL_RRECT:
|
||||||
if (y <= 60)
|
if (y <= 60)
|
||||||
{
|
|
||||||
toolsModel.SetShapeStyle((y - 2) / 20);
|
toolsModel.SetShapeStyle((y - 2) / 20);
|
||||||
InvalidateRect(NULL, TRUE);
|
|
||||||
}
|
|
||||||
if ((y >= 70) && (y <= 132))
|
if ((y >= 70) && (y <= 132))
|
||||||
{
|
|
||||||
toolsModel.SetLineWidth((y - 72) / 12 + 1);
|
toolsModel.SetLineWidth((y - 72) / 12 + 1);
|
||||||
InvalidateRect(NULL, TRUE);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LRESULT CToolSettingsWindow::OnToolsModelToolChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
|
{
|
||||||
|
Invalidate();
|
||||||
|
trackbarZoom.ShowWindow((wParam == TOOL_ZOOM) ? SW_SHOW : SW_HIDE);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CToolSettingsWindow::OnToolsModelSettingsChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
|
{
|
||||||
|
Invalidate();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CToolSettingsWindow::OnToolsModelZoomChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
|
{
|
||||||
|
int tbPos = 0;
|
||||||
|
int tempZoom = toolsModel.GetZoom();
|
||||||
|
|
||||||
|
while (tempZoom > 125)
|
||||||
|
{
|
||||||
|
tbPos++;
|
||||||
|
tempZoom = tempZoom >> 1;
|
||||||
|
}
|
||||||
|
trackbarZoom.SendMessage(TBM_SETPOS, (WPARAM) TRUE, (LPARAM) tbPos);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -11,13 +11,23 @@ class CToolSettingsWindow : public CWindowImpl<CToolSettingsWindow>
|
||||||
public:
|
public:
|
||||||
DECLARE_WND_CLASS_EX(_T("ToolSettings"), CS_DBLCLKS, COLOR_BTNFACE)
|
DECLARE_WND_CLASS_EX(_T("ToolSettings"), CS_DBLCLKS, COLOR_BTNFACE)
|
||||||
|
|
||||||
BEGIN_MSG_MAP(CPaletteWindow)
|
BEGIN_MSG_MAP(CToolSettingsWindow)
|
||||||
|
MESSAGE_HANDLER(WM_CREATE, OnCreate)
|
||||||
MESSAGE_HANDLER(WM_VSCROLL, OnVScroll)
|
MESSAGE_HANDLER(WM_VSCROLL, OnVScroll)
|
||||||
MESSAGE_HANDLER(WM_PAINT, OnPaint)
|
MESSAGE_HANDLER(WM_PAINT, OnPaint)
|
||||||
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
|
MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
|
||||||
|
MESSAGE_HANDLER(WM_TOOLSMODELTOOLCHANGED, OnToolsModelToolChanged)
|
||||||
|
MESSAGE_HANDLER(WM_TOOLSMODELSETTINGSCHANGED, OnToolsModelSettingsChanged)
|
||||||
|
MESSAGE_HANDLER(WM_TOOLSMODELZOOMCHANGED, OnToolsModelZoomChanged)
|
||||||
END_MSG_MAP()
|
END_MSG_MAP()
|
||||||
|
|
||||||
|
CWindow trackbarZoom;
|
||||||
|
|
||||||
|
LRESULT OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
LRESULT OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
LRESULT OnVScroll(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
LRESULT OnPaint(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);
|
LRESULT OnLButtonDown(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
|
LRESULT OnToolsModelToolChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
|
LRESULT OnToolsModelSettingsChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
|
LRESULT OnToolsModelZoomChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,6 +32,7 @@ int ToolsModel::GetLineWidth()
|
||||||
void ToolsModel::SetLineWidth(int nLineWidth)
|
void ToolsModel::SetLineWidth(int nLineWidth)
|
||||||
{
|
{
|
||||||
m_lineWidth = nLineWidth;
|
m_lineWidth = nLineWidth;
|
||||||
|
NotifyToolSettingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ToolsModel::GetShapeStyle()
|
int ToolsModel::GetShapeStyle()
|
||||||
|
@ -42,6 +43,7 @@ int ToolsModel::GetShapeStyle()
|
||||||
void ToolsModel::SetShapeStyle(int nShapeStyle)
|
void ToolsModel::SetShapeStyle(int nShapeStyle)
|
||||||
{
|
{
|
||||||
m_shapeStyle = nShapeStyle;
|
m_shapeStyle = nShapeStyle;
|
||||||
|
NotifyToolSettingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ToolsModel::GetBrushStyle()
|
int ToolsModel::GetBrushStyle()
|
||||||
|
@ -52,6 +54,7 @@ int ToolsModel::GetBrushStyle()
|
||||||
void ToolsModel::SetBrushStyle(int nBrushStyle)
|
void ToolsModel::SetBrushStyle(int nBrushStyle)
|
||||||
{
|
{
|
||||||
m_brushStyle = nBrushStyle;
|
m_brushStyle = nBrushStyle;
|
||||||
|
NotifyToolSettingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ToolsModel::GetActiveTool()
|
int ToolsModel::GetActiveTool()
|
||||||
|
@ -62,6 +65,7 @@ int ToolsModel::GetActiveTool()
|
||||||
void ToolsModel::SetActiveTool(int nActiveTool)
|
void ToolsModel::SetActiveTool(int nActiveTool)
|
||||||
{
|
{
|
||||||
m_activeTool = nActiveTool;
|
m_activeTool = nActiveTool;
|
||||||
|
NotifyToolChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ToolsModel::GetAirBrushWidth()
|
int ToolsModel::GetAirBrushWidth()
|
||||||
|
@ -72,6 +76,7 @@ int ToolsModel::GetAirBrushWidth()
|
||||||
void ToolsModel::SetAirBrushWidth(int nAirBrushWidth)
|
void ToolsModel::SetAirBrushWidth(int nAirBrushWidth)
|
||||||
{
|
{
|
||||||
m_airBrushWidth = nAirBrushWidth;
|
m_airBrushWidth = nAirBrushWidth;
|
||||||
|
NotifyToolSettingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ToolsModel::GetRubberRadius()
|
int ToolsModel::GetRubberRadius()
|
||||||
|
@ -82,6 +87,7 @@ int ToolsModel::GetRubberRadius()
|
||||||
void ToolsModel::SetRubberRadius(int nRubberRadius)
|
void ToolsModel::SetRubberRadius(int nRubberRadius)
|
||||||
{
|
{
|
||||||
m_rubberRadius = nRubberRadius;
|
m_rubberRadius = nRubberRadius;
|
||||||
|
NotifyToolSettingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL ToolsModel::IsBackgroundTransparent()
|
BOOL ToolsModel::IsBackgroundTransparent()
|
||||||
|
@ -92,6 +98,7 @@ BOOL ToolsModel::IsBackgroundTransparent()
|
||||||
void ToolsModel::SetBackgroundTransparent(BOOL bTransparent)
|
void ToolsModel::SetBackgroundTransparent(BOOL bTransparent)
|
||||||
{
|
{
|
||||||
m_transpBg = bTransparent;
|
m_transpBg = bTransparent;
|
||||||
|
NotifyToolSettingsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ToolsModel::GetZoom()
|
int ToolsModel::GetZoom()
|
||||||
|
@ -102,4 +109,22 @@ int ToolsModel::GetZoom()
|
||||||
void ToolsModel::SetZoom(int nZoom)
|
void ToolsModel::SetZoom(int nZoom)
|
||||||
{
|
{
|
||||||
m_zoom = nZoom;
|
m_zoom = nZoom;
|
||||||
|
NotifyZoomChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsModel::NotifyToolChanged()
|
||||||
|
{
|
||||||
|
toolBoxContainer.SendMessage(WM_TOOLSMODELTOOLCHANGED, m_activeTool);
|
||||||
|
toolSettingsWindow.SendMessage(WM_TOOLSMODELTOOLCHANGED, m_activeTool);
|
||||||
|
textEditWindow.SendMessage(WM_TOOLSMODELTOOLCHANGED, m_activeTool);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsModel::NotifyToolSettingsChanged()
|
||||||
|
{
|
||||||
|
toolSettingsWindow.SendMessage(WM_TOOLSMODELSETTINGSCHANGED);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolsModel::NotifyZoomChanged()
|
||||||
|
{
|
||||||
|
toolSettingsWindow.SendMessage(WM_TOOLSMODELZOOMCHANGED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,11 @@ private:
|
||||||
int m_rubberRadius;
|
int m_rubberRadius;
|
||||||
BOOL m_transpBg;
|
BOOL m_transpBg;
|
||||||
int m_zoom;
|
int m_zoom;
|
||||||
|
|
||||||
|
void NotifyToolChanged();
|
||||||
|
void NotifyToolSettingsChanged();
|
||||||
|
void NotifyZoomChanged();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ToolsModel();
|
ToolsModel();
|
||||||
int GetLineWidth();
|
int GetLineWidth();
|
||||||
|
|
|
@ -16,16 +16,6 @@
|
||||||
|
|
||||||
/* FUNCTIONS ********************************************************/
|
/* FUNCTIONS ********************************************************/
|
||||||
|
|
||||||
void CMainWindow::selectTool(int tool)
|
|
||||||
{
|
|
||||||
selectionWindow.ShowWindow(SW_HIDE);
|
|
||||||
toolsModel.SetActiveTool(tool);
|
|
||||||
pointSP = 0; // resets the point-buffer of the polygon and bezier functions
|
|
||||||
toolSettingsWindow.Invalidate(TRUE);
|
|
||||||
::ShowWindow(hTrackbarZoom, (tool == TOOL_ZOOM) ? SW_SHOW : SW_HIDE);
|
|
||||||
textEditWindow.ShowWindow((tool == TOOL_TEXT) ? SW_SHOW : SW_HIDE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
updateCanvasAndScrollbars()
|
updateCanvasAndScrollbars()
|
||||||
{
|
{
|
||||||
|
@ -41,9 +31,6 @@ updateCanvasAndScrollbars()
|
||||||
void
|
void
|
||||||
zoomTo(int newZoom, int mouseX, int mouseY)
|
zoomTo(int newZoom, int mouseX, int mouseY)
|
||||||
{
|
{
|
||||||
int tbPos = 0;
|
|
||||||
int tempZoom = newZoom;
|
|
||||||
|
|
||||||
RECT clientRectScrollbox;
|
RECT clientRectScrollbox;
|
||||||
RECT clientRectImageArea;
|
RECT clientRectImageArea;
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
|
@ -61,22 +48,15 @@ zoomTo(int newZoom, int mouseX, int mouseY)
|
||||||
scrollboxWindow.Invalidate(TRUE);
|
scrollboxWindow.Invalidate(TRUE);
|
||||||
imageArea.Invalidate(FALSE);
|
imageArea.Invalidate(FALSE);
|
||||||
|
|
||||||
scrollboxWindow.SendMessage(WM_HSCROLL, SB_THUMBPOSITION | (x << 16), 0);
|
scrollboxWindow.SendMessage(WM_HSCROLL, MAKEWPARAM(SB_THUMBPOSITION, x), 0);
|
||||||
scrollboxWindow.SendMessage(WM_VSCROLL, SB_THUMBPOSITION | (y << 16), 0);
|
scrollboxWindow.SendMessage(WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, y), 0);
|
||||||
|
|
||||||
while (tempZoom > 125)
|
|
||||||
{
|
|
||||||
tbPos++;
|
|
||||||
tempZoom = tempZoom >> 1;
|
|
||||||
}
|
|
||||||
SendMessage(hTrackbarZoom, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) tbPos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::alignChildrenToMainWindow()
|
void CMainWindow::alignChildrenToMainWindow()
|
||||||
{
|
{
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
RECT clientRect;
|
RECT clientRect;
|
||||||
mainWindow.GetClientRect(&clientRect);
|
GetClientRect(&clientRect);
|
||||||
|
|
||||||
if (toolBoxContainer.IsWindowVisible())
|
if (toolBoxContainer.IsWindowVisible())
|
||||||
{
|
{
|
||||||
|
@ -121,7 +101,7 @@ void CMainWindow::saveImage(BOOL overwrite)
|
||||||
CopyMemory(filepathname, sfn.lpstrFile, sizeof(filepathname));
|
CopyMemory(filepathname, sfn.lpstrFile, sizeof(filepathname));
|
||||||
LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr));
|
LoadString(hProgInstance, IDS_WINDOWTITLE, resstr, SIZEOF(resstr));
|
||||||
_stprintf(tempstr, resstr, filename);
|
_stprintf(tempstr, resstr, filename);
|
||||||
mainWindow.SetWindowText(tempstr);
|
SetWindowText(tempstr);
|
||||||
isAFile = TRUE;
|
isAFile = TRUE;
|
||||||
imageSaved = TRUE;
|
imageSaved = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -148,8 +128,8 @@ void CMainWindow::InsertSelectionFromHBITMAP(HBITMAP bitmap, HWND window)
|
||||||
HBITMAP hTempMask;
|
HBITMAP hTempMask;
|
||||||
|
|
||||||
HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME, NULL);
|
HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME, NULL);
|
||||||
SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELONG(TRUE, 0));
|
SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELPARAM(TRUE, 0));
|
||||||
SendMessage(window, WM_COMMAND, ID_RECTSEL, 0);
|
toolBoxContainer.SendMessage(WM_COMMAND, ID_RECTSEL);
|
||||||
|
|
||||||
DeleteObject(SelectObject(hSelDC, hSelBm = (HBITMAP) CopyImage(bitmap,
|
DeleteObject(SelectObject(hSelDC, hSelBm = (HBITMAP) CopyImage(bitmap,
|
||||||
IMAGE_BITMAP, 0, 0,
|
IMAGE_BITMAP, 0, 0,
|
||||||
|
@ -290,25 +270,19 @@ LRESULT CMainWindow::OnInitMenuPopup(UINT nMsg, WPARAM wParam, LPARAM lParam, BO
|
||||||
|
|
||||||
LRESULT CMainWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
LRESULT CMainWindow::OnSize(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
{
|
{
|
||||||
if (m_hWnd == mainWindow.m_hWnd)
|
int test[] = { LOWORD(lParam) - 260, LOWORD(lParam) - 140, LOWORD(lParam) - 20 };
|
||||||
{
|
SendMessage(hStatusBar, WM_SIZE, wParam, lParam);
|
||||||
int test[] = { LOWORD(lParam) - 260, LOWORD(lParam) - 140, LOWORD(lParam) - 20 };
|
SendMessage(hStatusBar, SB_SETPARTS, 3, (LPARAM)&test);
|
||||||
SendMessage(hStatusBar, WM_SIZE, wParam, lParam);
|
alignChildrenToMainWindow();
|
||||||
SendMessage(hStatusBar, SB_SETPARTS, 3, (LPARAM)&test);
|
Invalidate(TRUE);
|
||||||
alignChildrenToMainWindow();
|
|
||||||
Invalidate(TRUE);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CMainWindow::OnGetMinMaxInfo(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
LRESULT CMainWindow::OnGetMinMaxInfo(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||||
{
|
{
|
||||||
if (m_hWnd == mainWindow.m_hWnd)
|
MINMAXINFO *mm = (LPMINMAXINFO) lParam;
|
||||||
{
|
mm->ptMinTrackSize.x = 330;
|
||||||
MINMAXINFO *mm = (LPMINMAXINFO) lParam;
|
mm->ptMinTrackSize.y = 430;
|
||||||
mm->ptMinTrackSize.x = 330;
|
|
||||||
mm->ptMinTrackSize.y = 430;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,12 +331,12 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
||||||
TCHAR infotext[200];
|
TCHAR infotext[200];
|
||||||
LoadString(hProgInstance, IDS_INFOTITLE, infotitle, SIZEOF(infotitle));
|
LoadString(hProgInstance, IDS_INFOTITLE, infotitle, SIZEOF(infotitle));
|
||||||
LoadString(hProgInstance, IDS_INFOTEXT, infotext, SIZEOF(infotext));
|
LoadString(hProgInstance, IDS_INFOTEXT, infotext, SIZEOF(infotext));
|
||||||
ShellAbout(mainWindow.m_hWnd, infotitle, infotext, paintIcon);
|
ShellAbout(m_hWnd, infotitle, infotext, paintIcon);
|
||||||
DeleteObject(paintIcon);
|
DeleteObject(paintIcon);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IDM_HELPHELPTOPICS:
|
case IDM_HELPHELPTOPICS:
|
||||||
HtmlHelp(mainWindow.m_hWnd, _T("help\\Paint.chm"), 0, 0);
|
HtmlHelp(m_hWnd, _T("help\\Paint.chm"), 0, 0);
|
||||||
break;
|
break;
|
||||||
case IDM_FILEEXIT:
|
case IDM_FILEEXIT:
|
||||||
SendMessage(WM_CLOSE, wParam, lParam);
|
SendMessage(WM_CLOSE, wParam, lParam);
|
||||||
|
@ -475,8 +449,8 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
||||||
case IDM_EDITSELECTALL:
|
case IDM_EDITSELECTALL:
|
||||||
{
|
{
|
||||||
HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME, NULL);
|
HWND hToolbar = FindWindowEx(toolBoxContainer.m_hWnd, NULL, TOOLBARCLASSNAME, NULL);
|
||||||
SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELONG(TRUE, 0));
|
SendMessage(hToolbar, TB_CHECKBUTTON, ID_RECTSEL, MAKELPARAM(TRUE, 0));
|
||||||
SendMessage(WM_COMMAND, ID_RECTSEL, 0);
|
toolBoxContainer.SendMessage(WM_COMMAND, ID_RECTSEL);
|
||||||
startPaintingL(hDrawingDC, 0, 0, paletteModel.GetFgColor(), paletteModel.GetBgColor());
|
startPaintingL(hDrawingDC, 0, 0, paletteModel.GetFgColor(), paletteModel.GetBgColor());
|
||||||
whilePaintingL(hDrawingDC, imgXRes, imgYRes, paletteModel.GetFgColor(), paletteModel.GetBgColor());
|
whilePaintingL(hDrawingDC, imgXRes, imgYRes, paletteModel.GetFgColor(), paletteModel.GetBgColor());
|
||||||
endPaintingL(hDrawingDC, imgXRes, imgYRes, paletteModel.GetFgColor(), paletteModel.GetBgColor());
|
endPaintingL(hDrawingDC, imgXRes, imgYRes, paletteModel.GetFgColor(), paletteModel.GetBgColor());
|
||||||
|
@ -615,7 +589,6 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
||||||
}
|
}
|
||||||
case IDM_IMAGEDRAWOPAQUE:
|
case IDM_IMAGEDRAWOPAQUE:
|
||||||
toolsModel.SetBackgroundTransparent(!toolsModel.IsBackgroundTransparent());
|
toolsModel.SetBackgroundTransparent(!toolsModel.IsBackgroundTransparent());
|
||||||
toolSettingsWindow.Invalidate(TRUE);
|
|
||||||
break;
|
break;
|
||||||
case IDM_IMAGECROP:
|
case IDM_IMAGECROP:
|
||||||
insertReversible((HBITMAP) CopyImage(hSelBm, IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG));
|
insertReversible((HBITMAP) CopyImage(hSelBm, IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG));
|
||||||
|
@ -667,54 +640,6 @@ LRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bH
|
||||||
case IDM_VIEWZOOM800:
|
case IDM_VIEWZOOM800:
|
||||||
zoomTo(8000, 0, 0);
|
zoomTo(8000, 0, 0);
|
||||||
break;
|
break;
|
||||||
case ID_FREESEL:
|
|
||||||
selectTool(1);
|
|
||||||
break;
|
|
||||||
case ID_RECTSEL:
|
|
||||||
selectTool(2);
|
|
||||||
break;
|
|
||||||
case ID_RUBBER:
|
|
||||||
selectTool(3);
|
|
||||||
break;
|
|
||||||
case ID_FILL:
|
|
||||||
selectTool(4);
|
|
||||||
break;
|
|
||||||
case ID_COLOR:
|
|
||||||
selectTool(5);
|
|
||||||
break;
|
|
||||||
case ID_ZOOM:
|
|
||||||
selectTool(6);
|
|
||||||
break;
|
|
||||||
case ID_PEN:
|
|
||||||
selectTool(7);
|
|
||||||
break;
|
|
||||||
case ID_BRUSH:
|
|
||||||
selectTool(8);
|
|
||||||
break;
|
|
||||||
case ID_AIRBRUSH:
|
|
||||||
selectTool(9);
|
|
||||||
break;
|
|
||||||
case ID_TEXT:
|
|
||||||
selectTool(10);
|
|
||||||
break;
|
|
||||||
case ID_LINE:
|
|
||||||
selectTool(11);
|
|
||||||
break;
|
|
||||||
case ID_BEZIER:
|
|
||||||
selectTool(12);
|
|
||||||
break;
|
|
||||||
case ID_RECT:
|
|
||||||
selectTool(13);
|
|
||||||
break;
|
|
||||||
case ID_SHAPE:
|
|
||||||
selectTool(14);
|
|
||||||
break;
|
|
||||||
case ID_ELLIPSE:
|
|
||||||
selectTool(15);
|
|
||||||
break;
|
|
||||||
case ID_RRECT:
|
|
||||||
selectTool(16);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ class CMainWindow : public CWindowImpl<CMainWindow>
|
||||||
public:
|
public:
|
||||||
DECLARE_WND_CLASS_EX(_T("MainWindow"), CS_DBLCLKS, COLOR_BTNFACE)
|
DECLARE_WND_CLASS_EX(_T("MainWindow"), CS_DBLCLKS, COLOR_BTNFACE)
|
||||||
|
|
||||||
BEGIN_MSG_MAP(CPaletteWindow)
|
BEGIN_MSG_MAP(CMainWindow)
|
||||||
MESSAGE_HANDLER(WM_DROPFILES, OnDropFiles)
|
MESSAGE_HANDLER(WM_DROPFILES, OnDropFiles)
|
||||||
MESSAGE_HANDLER(WM_CREATE, OnCreate)
|
MESSAGE_HANDLER(WM_CREATE, OnCreate)
|
||||||
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
|
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
|
||||||
|
@ -38,7 +38,6 @@ public:
|
||||||
LRESULT OnSysColorChange(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);
|
LRESULT OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||||
|
|
||||||
void selectTool(int tool);
|
|
||||||
void alignChildrenToMainWindow();
|
void alignChildrenToMainWindow();
|
||||||
void saveImage(BOOL overwrite);
|
void saveImage(BOOL overwrite);
|
||||||
void UpdateApplicationProperties(HBITMAP bitmap, LPTSTR newfilename, LPTSTR newfilepathname);
|
void UpdateApplicationProperties(HBITMAP bitmap, LPTSTR newfilename, LPTSTR newfilepathname);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue