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 16 LRESULT CToolBox::OnCreate(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 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}; 28 toolbar.Create(TOOLBARCLASSNAME, m_hWnd, toolbarPos, NULL, 29 WS_CHILD | WS_VISIBLE | CCS_NOPARENTALIGN | CCS_VERT | CCS_NORESIZE | TBSTYLE_TOOLTIPS); 30 hImageList = ImageList_Create(16, 16, ILC_COLOR24 | ILC_MASK, 16, 0); 31 toolbar.SendMessage(TB_SETIMAGELIST, 0, (LPARAM) hImageList); 32 tempBm = (HBITMAP) LoadImage(hProgInstance, MAKEINTRESOURCE(IDB_TOOLBARICONS), IMAGE_BITMAP, 256, 16, 0); 33 ImageList_AddMasked(hImageList, tempBm, 0xff00ff); 34 DeleteObject(tempBm); 35 toolbar.SendMessage(TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0); 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 55 toolbar.SendMessage(TB_CHECKBUTTON, ID_PEN, MAKELPARAM(TRUE, 0)); 56 toolbar.SendMessage(TB_SETMAXTEXTROWS, 0, 0); 57 toolbar.SendMessage(TB_SETBUTTONSIZE, 0, MAKELPARAM(25, 25)); 58 59 return 0; 60 } 61 62 LRESULT CToolBox::OnSetCursor(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 63 { 64 SetCursor(LoadCursor(NULL, IDC_ARROW)); 65 return 0; 66 } 67 68 LRESULT CToolBox::OnSysColorChange(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 69 { 70 toolbar.SendMessage(WM_SYSCOLORCHANGE, 0, 0); 71 return 0; 72 } 73 74 LRESULT CToolBox::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 75 { 76 switch (LOWORD(wParam)) 77 { 78 case ID_FREESEL: 79 toolsModel.SetActiveTool(1); 80 break; 81 case ID_RECTSEL: 82 toolsModel.SetActiveTool(2); 83 break; 84 case ID_RUBBER: 85 toolsModel.SetActiveTool(3); 86 break; 87 case ID_FILL: 88 toolsModel.SetActiveTool(4); 89 break; 90 case ID_COLOR: 91 toolsModel.SetActiveTool(5); 92 break; 93 case ID_ZOOM: 94 toolsModel.SetActiveTool(6); 95 break; 96 case ID_PEN: 97 toolsModel.SetActiveTool(7); 98 break; 99 case ID_BRUSH: 100 toolsModel.SetActiveTool(8); 101 break; 102 case ID_AIRBRUSH: 103 toolsModel.SetActiveTool(9); 104 break; 105 case ID_TEXT: 106 toolsModel.SetActiveTool(10); 107 break; 108 case ID_LINE: 109 toolsModel.SetActiveTool(11); 110 break; 111 case ID_BEZIER: 112 toolsModel.SetActiveTool(12); 113 break; 114 case ID_RECT: 115 toolsModel.SetActiveTool(13); 116 break; 117 case ID_SHAPE: 118 toolsModel.SetActiveTool(14); 119 break; 120 case ID_ELLIPSE: 121 toolsModel.SetActiveTool(15); 122 break; 123 case ID_RRECT: 124 toolsModel.SetActiveTool(16); 125 break; 126 } 127 return 0; 128 } 129 130 LRESULT CToolBox::OnToolsModelToolChanged(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 131 { 132 selectionWindow.ShowWindow(SW_HIDE); 133 pointSP = 0; // resets the point-buffer of the polygon and bezier functions 134 return 0; 135 } 136