ReactOS  0.4.15-dev-4916-gd519b11
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 },
86  { ID_COLOR, TOOL_COLOR },
87  { ID_ZOOM, TOOL_ZOOM },
88  { ID_PEN, TOOL_PEN },
89  { ID_BRUSH, TOOL_BRUSH },
91  { ID_TEXT, TOOL_TEXT },
92  { ID_LINE, TOOL_LINE },
94  { ID_RECT, TOOL_RECT },
95  { ID_SHAPE, TOOL_SHAPE },
97  { ID_RRECT, TOOL_RRECT },
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_RECT
Definition: resource.h:118
#define ID_SHAPE
Definition: resource.h:119
#define IDB_TOOLBARICONS
Definition: resource.h:15
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1613
ToolsModel toolsModel
Definition: main.cpp:18
#define TB_SETBUTTONSIZE
Definition: commctrl.h:1135
#define TB_BUTTONSTRUCTSIZE
Definition: commctrl.h:1134
#define ID_LINE
Definition: resource.h:116
void resetTool()
Definition: toolsmodel.cpp:231
#define ID_PEN
Definition: resource.h:112
#define TRUE
Definition: types.h:120
#define SW_HIDE
Definition: winuser.h:762
#define ID_ZOOM
Definition: resource.h:111
#define MAKELPARAM(l, h)
Definition: winuser.h:3988
#define ZeroMemory
Definition: winbase.h:1667
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define ID_FREESEL
Definition: resource.h:106
UINT_PTR WPARAM
Definition: windef.h:207
#define WS_CHILD
Definition: pedump.c:617
int32_t INT_PTR
Definition: typedefs.h:64
BYTE fsStyle
Definition: commctrl.h:952
WPARAM wParam
Definition: combotst.c:138
#define CCS_VERT
Definition: commctrl.h:2249
TOOLTYPE tool
Definition: toolbox.cpp:77
#define ID_BRUSH
Definition: resource.h:113
#define TB_SETMAXTEXTROWS
Definition: commctrl.h:1162
LRESULT OnToolsModelToolChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: toolbox.cpp:114
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
#define TBSTYLE_CHECKGROUP
Definition: commctrl.h:985
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TOOLBARCLASSNAME
Definition: commctrl.h:946
LONG_PTR LPARAM
Definition: windef.h:208
#define CCS_NOPARENTALIGN
Definition: commctrl.h:2246
INT_PTR iString
Definition: commctrl.h:959
int iBitmap
Definition: commctrl.h:949
LRESULT OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: toolbox.cpp:100
#define TB_SETIMAGELIST
Definition: commctrl.h:1150
char TCHAR
Definition: xmlstorage.h:189
#define ID_AIRBRUSH
Definition: resource.h:114
LRESULT OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: toolbox.cpp:16
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:383
#define _countof(array)
Definition: sndvol32.h:68
#define ILC_COLOR24
Definition: commctrl.h:357
#define ID_RECTSEL
Definition: resource.h:107
#define ID_RRECT
Definition: resource.h:121
#define IDS_TOOLTIP1
Definition: resource.h:188
#define TBSTYLE_TOOLTIPS
Definition: commctrl.h:989
#define CCS_NORESIZE
Definition: commctrl.h:2245
TOOLTYPE GetActiveTool() const
Definition: toolsmodel.cpp:76
#define ID_ELLIPSE
Definition: resource.h:120
int idCommand
Definition: commctrl.h:950
#define TB_ADDBUTTONS
Definition: commctrl.h:1271
#define TB_CHECKBUTTON
Definition: commctrl.h:1043
#define ILC_MASK
Definition: commctrl.h:351
HWND m_hWnd
Definition: atlwin.h:267
LRESULT OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: toolbox.cpp:62
HINSTANCE hProgInstance
Definition: main.cpp:50
#define LoadCursor
Definition: winuser.h:5792
#define ID_BEZIER
Definition: resource.h:117
#define ID_TEXT
Definition: resource.h:115
#define ID_FILL
Definition: resource.h:109
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
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define ID_COLOR
Definition: resource.h:110
void SetActiveTool(TOOLTYPE nActiveTool)
Definition: toolsmodel.cpp:86
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define IMAGE_BITMAP
Definition: winuser.h:211
static const COMMAND_TO_TOOL CommandToToolMapping[]
Definition: toolbox.cpp:80
LRESULT OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: toolbox.cpp:68
#define IDC_ARROW
Definition: winuser.h:682
#define TBSTATE_ENABLED
Definition: commctrl.h:974
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1082
#define TBSTATE_WRAP
Definition: commctrl.h:977
#define ID_RUBBER
Definition: resource.h:108
#define LoadImage
Definition: winuser.h:5795
INT WINAPI ImageList_AddMasked(HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
Definition: imagelist.c:563
static HBITMAP
Definition: button.c:44
TOOLTYPE
Definition: toolsmodel.h:11
BYTE fsState
Definition: commctrl.h:951
LONG_PTR LRESULT
Definition: windef.h:209
#define WS_VISIBLE
Definition: pedump.c:620
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define LoadString
Definition: winuser.h:5799
CSelectionWindow selectionWindow
Definition: main.cpp:71
CWindow toolbar
Definition: toolbox.h:25