ReactOS 0.4.15-dev-5667-ged97270
toolbox.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: PAINT for ReactOS
3 * LICENSE: LGPL
4 * FILE: base/applications/mspaint/toolbox.cpp
5 * PURPOSE: Window procedure of the main window and all children apart from
6 * hPalWin, hToolSettings and hSelection
7 * PROGRAMMERS: Benedikt Freisen
8 */
9
10/* INCLUDES *********************************************************/
11
12#include "precomp.h"
13
14/* FUNCTIONS ********************************************************/
15
17{
18 HIMAGELIST hImageList;
19 HBITMAP tempBm;
20 int i;
21 TCHAR tooltips[16][30];
22
23 /*
24 * FIXME: Unintentionally there is a line above the tool bar (hidden by y-offset).
25 * To prevent cropping of the buttons height has been increased from 200 to 205
26 */
27 RECT toolbarPos = {1, -2, 1 + 50, -2 + 205};
30 hImageList = ImageList_Create(16, 16, ILC_COLOR24 | ILC_MASK, 16, 0);
31 toolbar.SendMessage(TB_SETIMAGELIST, 0, (LPARAM) hImageList);
33 ImageList_AddMasked(hImageList, tempBm, 0xff00ff);
34 DeleteObject(tempBm);
36
37 for(i = 0; i < 16; i++)
38 {
39 TBBUTTON tbbutton;
40 int wrapnow = 0;
41
42 if (i % 2 == 1)
43 wrapnow = TBSTATE_WRAP;
44
45 LoadString(hProgInstance, IDS_TOOLTIP1 + i, tooltips[i], 30);
46 ZeroMemory(&tbbutton, sizeof(TBBUTTON));
47 tbbutton.iString = (INT_PTR) tooltips[i];
48 tbbutton.fsStyle = TBSTYLE_CHECKGROUP;
49 tbbutton.fsState = TBSTATE_ENABLED | wrapnow;
50 tbbutton.idCommand = ID_FREESEL + i;
51 tbbutton.iBitmap = i;
52 toolbar.SendMessage(TB_ADDBUTTONS, 1, (LPARAM) &tbbutton);
53 }
54
58
59 return 0;
60}
61
63{
65 return 0;
66}
67
69{
71 return 0;
72}
73
75{
78};
79
81{
85 { ID_FILL, TOOL_FILL },
87 { ID_ZOOM, TOOL_ZOOM },
88 { ID_PEN, TOOL_PEN },
91 { ID_TEXT, TOOL_TEXT },
92 { ID_LINE, TOOL_LINE },
94 { ID_RECT, TOOL_RECT },
98};
99
101{
102 UINT id = LOWORD(wParam);
103 for (size_t i = 0; i < _countof(CommandToToolMapping); ++i)
104 {
105 if (CommandToToolMapping[i].id == id)
106 {
108 break;
109 }
110 }
111 return 0;
112}
113
115{
116 selectionWindow.ShowWindow(SW_HIDE);
117 toolsModel.resetTool(); // resets the point-buffer of the polygon and bezier functions
118
119 // Check the toolbar button
121 for (size_t i = 0; i < _countof(CommandToToolMapping); ++i)
122 {
123 if (CommandToToolMapping[i].tool == tool)
124 {
126 break;
127 }
128 }
129
130 return 0;
131}
#define ID_LINE
Definition: resource.h:116
#define ID_RECT
Definition: resource.h:118
#define ID_ELLIPSE
Definition: resource.h:120
#define IDB_TOOLBARICONS
Definition: resource.h:15
#define ID_COLOR
Definition: resource.h:110
#define ID_BRUSH
Definition: resource.h:113
#define ID_FILL
Definition: resource.h:109
#define ID_TEXT
Definition: resource.h:115
#define ID_SHAPE
Definition: resource.h:119
#define IDS_TOOLTIP1
Definition: resource.h:188
#define ID_PEN
Definition: resource.h:112
#define ID_AIRBRUSH
Definition: resource.h:114
#define ID_RUBBER
Definition: resource.h:108
#define ID_ZOOM
Definition: resource.h:111
#define ID_BEZIER
Definition: resource.h:117
#define ID_FREESEL
Definition: resource.h:106
#define ID_RECTSEL
Definition: resource.h:107
#define ID_RRECT
Definition: resource.h:121
HWND Create(LPCTSTR lpstrWndClass, HWND hWndParent, _U_RECT rect=NULL, LPCTSTR szWindowName=NULL, DWORD dwStyle=0, DWORD dwExStyle=0, _U_MENUorID MenuOrID=0U, LPVOID lpCreateParam=NULL)
Definition: atlwin.h:411
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1110
HWND m_hWnd
Definition: atlwin.h:267
LRESULT OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: toolbox.cpp:68
LRESULT OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: toolbox.cpp:16
CWindow toolbar
Definition: toolbox.h:25
LRESULT OnToolsModelToolChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: toolbox.cpp:114
LRESULT OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: toolbox.cpp:100
LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: toolbox.cpp:62
void resetTool()
Definition: toolsmodel.cpp:231
void SetActiveTool(TOOLTYPE nActiveTool)
Definition: toolsmodel.cpp:86
TOOLTYPE GetActiveTool() const
Definition: toolsmodel.cpp:76
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
INT WINAPI ImageList_AddMasked(HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
Definition: imagelist.c:563
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
unsigned int BOOL
Definition: ntddk_ex.h:94
pKey DeleteObject()
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
ToolsModel toolsModel
Definition: main.cpp:18
CSelectionWindow selectionWindow
Definition: main.cpp:71
HINSTANCE hProgInstance
Definition: main.cpp:50
static HBITMAP
Definition: button.c:44
unsigned int UINT
Definition: ndis.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define WS_CHILD
Definition: pedump.c:617
#define WS_VISIBLE
Definition: pedump.c:620
#define TB_ADDBUTTONS
Definition: commctrl.h:1271
#define TBSTYLE_TOOLTIPS
Definition: commctrl.h:989
#define TB_BUTTONSTRUCTSIZE
Definition: commctrl.h:1134
#define TB_CHECKBUTTON
Definition: commctrl.h:1043
#define CCS_VERT
Definition: commctrl.h:2249
#define TB_SETIMAGELIST
Definition: commctrl.h:1150
#define TBSTYLE_CHECKGROUP
Definition: commctrl.h:985
#define TB_SETBUTTONSIZE
Definition: commctrl.h:1135
#define TBSTATE_ENABLED
Definition: commctrl.h:974
#define TOOLBARCLASSNAME
Definition: commctrl.h:946
#define ILC_MASK
Definition: commctrl.h:351
#define CCS_NOPARENTALIGN
Definition: commctrl.h:2246
#define CCS_NORESIZE
Definition: commctrl.h:2245
#define TBSTATE_WRAP
Definition: commctrl.h:977
#define ILC_COLOR24
Definition: commctrl.h:357
#define TB_SETMAXTEXTROWS
Definition: commctrl.h:1162
#define _countof(array)
Definition: sndvol32.h:68
TOOLTYPE tool
Definition: toolbox.cpp:77
BYTE fsState
Definition: commctrl.h:951
INT_PTR iString
Definition: commctrl.h:959
int idCommand
Definition: commctrl.h:950
int iBitmap
Definition: commctrl.h:949
BYTE fsStyle
Definition: commctrl.h:952
static const COMMAND_TO_TOOL CommandToToolMapping[]
Definition: toolbox.cpp:80
TOOLTYPE
Definition: toolsmodel.h:12
@ TOOL_AIRBRUSH
Definition: toolsmodel.h:21
@ TOOL_COLOR
Definition: toolsmodel.h:17
@ TOOL_SHAPE
Definition: toolsmodel.h:26
@ TOOL_RUBBER
Definition: toolsmodel.h:15
@ TOOL_BRUSH
Definition: toolsmodel.h:20
@ TOOL_RECT
Definition: toolsmodel.h:25
@ TOOL_BEZIER
Definition: toolsmodel.h:24
@ TOOL_FILL
Definition: toolsmodel.h:16
@ TOOL_TEXT
Definition: toolsmodel.h:22
@ TOOL_PEN
Definition: toolsmodel.h:19
@ TOOL_LINE
Definition: toolsmodel.h:23
@ TOOL_FREESEL
Definition: toolsmodel.h:13
@ TOOL_ZOOM
Definition: toolsmodel.h:18
@ TOOL_ELLIPSE
Definition: toolsmodel.h:27
@ TOOL_RRECT
Definition: toolsmodel.h:28
@ TOOL_RECTSEL
Definition: toolsmodel.h:14
int32_t INT_PTR
Definition: typedefs.h:64
#define ZeroMemory
Definition: winbase.h:1670
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define SW_HIDE
Definition: winuser.h:762
#define IMAGE_BITMAP
Definition: winuser.h:211
#define MAKELPARAM(l, h)
Definition: winuser.h:3998
#define IDC_ARROW
Definition: winuser.h:682
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1616
#define LoadCursor
Definition: winuser.h:5802
#define LoadImage
Definition: winuser.h:5805
#define LoadString
Definition: winuser.h:5809
#define MAKEINTRESOURCE
Definition: winuser.h:591
char TCHAR
Definition: xmlstorage.h:189