summaryrefslogtreecommitdiff
path: root/src/Plugins/ToolPalette/DefaultToolPalette/ToolPalette.cpp
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2023-07-11 17:52:00 +0100
committerAsh Wolf <ninji@wuffs.org>2023-07-11 17:52:00 +0100
commit024306ccab5f6d51f3fce269fb1984fd02f3bb02 (patch)
tree8d359495d72bf4e7295c7eab4cb220edc2d4b60c /src/Plugins/ToolPalette/DefaultToolPalette/ToolPalette.cpp
parent0f3cba6fcea0ffd511dfe3275d57a5b9e69be5be (diff)
downloadt2win-024306ccab5f6d51f3fce269fb1984fd02f3bb02.tar.gz
t2win-024306ccab5f6d51f3fce269fb1984fd02f3bb02.zip
add Floor, add DefaultToolPalettemain
Diffstat (limited to '')
-rw-r--r--src/Plugins/ToolPalette/DefaultToolPalette/ToolPalette.cpp863
1 files changed, 858 insertions, 5 deletions
diff --git a/src/Plugins/ToolPalette/DefaultToolPalette/ToolPalette.cpp b/src/Plugins/ToolPalette/DefaultToolPalette/ToolPalette.cpp
index f290c82..53c032b 100644
--- a/src/Plugins/ToolPalette/DefaultToolPalette/ToolPalette.cpp
+++ b/src/Plugins/ToolPalette/DefaultToolPalette/ToolPalette.cpp
@@ -1,7 +1,860 @@
+#include "StdAfx.h"
#include "ToolPalette.h"
+#include "ToolPaletteItem.h"
+#include "../../../T2DLL/T2BitImage.h"
+#include "../../../T2DLL/T2ImageObj.h"
+#include "../../../T2DLL/T2PaletteAnimeDef.h"
+#include "../../../T2DLL/T2ToolDef.h"
+#include "../../../T2DLL/T2ToolHelpWnd.h"
+#include "../../../T2DLL/T2WorldDef.h"
+#include "../../../T2TowerDoc.h"
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
+ToolPalette::ToolPalette() {
+ mSize130.cx = 26;
+ mSize130.cy = 26;
+
+ mSize138.cx = 76;
+ mSize138.cy = 13;
+
+ m140 = 16;
+ m144 = 3;
+ m148 = 4;
+ m124 = 0;
+
+ mImageObj = NULL;
+ mImage = NULL;
+ mToolHelpWnd = NULL;
+
+ _184 = -1;
+}
+
+/*virtual*/ ToolPalette::~ToolPalette() {
+ int i;
+
+ for (i = 0; i < kNumCommand; i++)
+ delete mCommands[i];
+
+ delete mCategoryTitle;
+ for (i = 0; i < kNumCategory; i++)
+ delete mCategories[i];
+ delete mCategoryScroll;
+
+ delete mToolTitle;
+ for (i = 0; i < kNumTool; i++)
+ delete mTools[i];
+ delete mToolScroll;
+
+ if (mImageObj)
+ delete mImageObj;
+ if (mImage)
+ delete mImage;
+
+ POSITION pos = mHistoryList.GetHeadPosition();
+ while (pos)
+ delete mHistoryList.GetNext(pos);
+}
+
+/*virtual*/ void ToolPalette::ItemCallbackDown(ToolPaletteItem *inItem) {
+ if (inItem->GetMode() != kTPIMode1)
+ return;
+
+ T2ToolIconItem *icon = inItem->GetIcon();
+ if (icon->mEnableCount > 0)
+ return;
+ if (icon->m30 == 0)
+ return;
+
+ T2ToolIconItem *changeIcon = ChangeIconItem(icon);
+ if (changeIcon && changeIcon->mToolCallback) {
+ T2ToolCallback *theToolCallback = changeIcon->mToolCallback;
+ theToolCallback->toolCallback_vf00(this, changeIcon);
+ }
+
+ T2ToolCallback *theToolCallback = icon->mToolCallback;
+ if (theToolCallback)
+ theToolCallback->toolCallback_vf00(this, icon);
+
+ mClickedItem = icon;
+ m15C = (T2ToolDef *) GetIconPlugin(mSel);
+ ShowHelpWindow();
+}
+
+/*virtual*/ void ToolPalette::ItemCallbackUp(ToolPaletteItem *inItem) {
+ if (mTimerID)
+ KillTimer(mTimerID);
+
+ HideHelpWindow();
+
+ if (inItem->GetMode() != kTPIMode1)
+ return;
+
+ T2ToolIconItem *icon = inItem->GetIcon();
+ if (icon->mEnableCount > 0)
+ return;
+ if (icon->m30 == 0)
+ return;
+
+ int i;
+ if (icon->m18) {
+ icon->m24 = false;
+
+ switch (icon->mOption) {
+ case kToolOption0:
+ for (i = 0; i < kNumCommand; i++)
+ mCommands[i]->InvalidateRect(NULL);
+ break;
+
+ case kToolOption4:
+ for (i = 0; i < kNumCategory; i++)
+ mCategories[i]->InvalidateRect(NULL);
+ break;
+
+ case kToolOption1:
+ case kToolOption2:
+ case kToolOption3:
+ for (i = 0; i < kNumTool; i++)
+ mTools[i]->InvalidateRect(NULL);
+ break;
+ }
+
+ T2ToolCallback *theToolCallback = icon->mToolCallback;
+ if (theToolCallback)
+ theToolCallback->toolCallback_vf00(this, icon);
+ }
+}
+
+T2ToolIconItem *ToolPalette::ChangeIconItem(T2ToolIconItem *inItem) {
+ T2ToolIconItem *result = NULL;
+
+ if (inItem->m18 != 0) {
+ inItem->m24 = true;
+
+ int i;
+ switch (inItem->mOption) {
+ case kToolOption0:
+ for (i = 0; i < kNumCommand; i++)
+ mCommands[i]->InvalidateRect(NULL);
+ break;
+ case kToolOption4:
+ for (i = 0; i < kNumCategory; i++)
+ mCategories[i]->InvalidateRect(NULL);
+ break;
+ case kToolOption1:
+ case kToolOption2:
+ case kToolOption3:
+ for (i = 0; i < kNumTool; i++)
+ mTools[i]->InvalidateRect(NULL);
+ break;
+ }
+ } else {
+ T2ToolIconItem *oldItem = GetItem(mSel);
+ ToolHistoryItem *history;
+
+ switch (inItem->mOption) {
+ case kToolOption0:
+ mSel = inItem->mID;
+ Updated();
+ break;
+
+ case kToolOption4: {
+ POSITION pos = mToolIconList->GetHeadPosition();
+ T2ToolIconItem *lowItem = NULL;
+ T2ToolIconItem *theItem;
+ while (pos) {
+ theItem = mToolIconList->GetNext(pos);
+ if (theItem->mOption == kToolOption1 || theItem->mOption == kToolOption2 || theItem->mOption == kToolOption3) {
+ if (((T2ToolDef *) theItem->mPlugin)->mCategoryNo == inItem->mValiation) {
+ if (lowItem) {
+ if (lowItem->mToolDef) {
+ if (theItem->mToolDef) {
+ if (theItem->mToolDef->GetSortKey() < lowItem->mToolDef->GetSortKey())
+ lowItem = theItem;
+ }
+ } else {
+ lowItem = theItem;
+ }
+ } else {
+ lowItem = theItem;
+ }
+ }
+ }
+ }
+
+#line 330
+ _ASSERT(lowItem != NULL);
+
+ theItem = lowItem;
+ mSel = theItem->mID;
+ history = GetToolHistory(((T2ToolDef *) GetIconPlugin(mSel))->mCategoryNo);
+
+ int theScrollPos = 0;
+ if (history->_C != -1) {
+ mSel = history->_C;
+ theScrollPos = history->_8;
+ } else {
+ history->_C = mSel;
+ history->_8 = theScrollPos;
+ }
+
+ _184 = mSel;
+ mToolScroll->SetScrollPos(theScrollPos);
+ Updated();
+ break;
+ }
+
+ case kToolOption1:
+ case kToolOption2:
+ case kToolOption3:
+ mSel = inItem->mID;
+ history = GetToolHistory(((T2ToolDef *) GetIconPlugin(mSel))->mCategoryNo);
+ history->_8 = mToolScroll->GetScrollPos();
+ history->_C = mSel;
+ Updated();
+ break;
+ }
+ }
+
+ return result;
+}
+
+/*virtual*/ T2ToolIconItem *ToolPalette::EnableIcon(unsigned short inMask) {
+ T2ToolIconItem *icon = T2ToolWindow::EnableIcon(inMask);
+ if (icon) {
+ ChangeIconItem(icon);
+ ListUpdated();
+ }
+ return icon;
+}
+
+/*virtual*/ int ToolPalette::OnCreateProc(LPCREATESTRUCT lpCreateStruct) {
+#pragma var_order(windowRect, y, rect2, x2, y2, i, clientRect, y3, rect1, x)
+ int i;
+
+ mImageObj = new T2ImageObj;
+ mImage = new T2BitImage(mModule, 1000, true);
+ mImageObj->AddObject(mModule, 1000, mImage);
+
+ for (i = 0; i < kNumCommand; i++)
+ mCommands[i] = new ToolPaletteItem(mDocument, kTPIMode1);
+
+ mCategoryTitle = new ToolPaletteItem(mDocument, kTPIMode0);
+ for (i = 0; i < kNumCategory; i++)
+ mCategories[i] = new ToolPaletteItem(mDocument, kTPIMode1);
+ mCategoryScroll = new ToolPaletteItem(mDocument, kTPIMode2);
+
+ mToolTitle = new ToolPaletteItem(mDocument, kTPIMode0);
+ for (i = 0; i < kNumTool; i++)
+ mTools[i] = new ToolPaletteItem(mDocument, kTPIMode1);
+ mToolScroll = new ToolPaletteItem(mDocument, kTPIMode2);
+
+ mWndClass = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW | CS_NOCLOSE, NULL, (HBRUSH) GetStockObject(WHITE_BRUSH));
+
+ CRect rect1, rect2;
+ int x = 0, y = 0, x2, y2, y3;
+ m14C[kToolHelpMode0] = y + 5;
+
+ for (i = 0; i < kNumCommand; i++) {
+ x2 = (mSize130.cx - 1) * x + 3;
+ y2 = (mSize130.cy - 1) * y + 5;
+ rect1.SetRect(x2, y2, x2 + mSize130.cx, y2 + mSize130.cy);
+ rect2.UnionRect(rect2, rect1);
+ mCommands[i]->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect1, this, i + 1000);
+
+ x++;
+ if (x >= 3) {
+ x = 0;
+ y++;
+ }
+ }
+
+ x2 = 3;
+ y = 3;
+ y2 += mSize130.cy + 4;
+ rect1.SetRect(x2, y2, x2 + mSize130.cx * 3 - 2, y2 + m140 + 2);
+ rect2.UnionRect(rect2, rect1);
+ mCategoryTitle->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect1, this, 1100);
+
+ y2 += m140 + 2;
+ m14C[kToolHelpMode1] = y2;
+
+ x = 0;
+ y = 0;
+
+ for (i = 0; i < kNumCategory; i++) {
+ x2 = (mSize130.cx - 1) * x + 3;
+ y3 = y2 + (mSize130.cy - 1) * y;
+ rect1.SetRect(x2, y3, x2 + mSize130.cx, y3 + mSize130.cy);
+ rect2.UnionRect(rect2, rect1);
+ mCategories[i]->Create(mWndClass, "", WS_CHILD, rect1, this, i + 1200);
+
+ y++;
+ if (y >= 3) {
+ y = 0;
+ x++;
+ }
+ }
+ y = 3;
+
+ y2 += (mSize130.cy - 1) * y;
+ x2 = 3;
+ rect1.SetRect(x2, y2, x2 + mSize138.cx, y2 + mSize138.cy);
+ rect2.UnionRect(rect2, rect1);
+ mCategoryScroll->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect1, this, 1300);
+
+ y = m140;
+ y2 += mSize138.cy + 6;
+ rect1.SetRect(x2, y2, x2 + mSize130.cx * 3 - 2, y2 + y + 2);
+ rect2.UnionRect(rect2, rect1);
+ mToolTitle->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect1, this, 1400);
+
+ y2 += y + 2;
+ m14C[kToolHelpMode2] = y2;
+
+ x = 0;
+ y = 0;
+
+ for (i = 0; i < kNumTool; i++) {
+ x2 = (mSize130.cx - 1) * x + 3;
+ y3 = y2 + (mSize130.cy - 1) * y;
+ rect1.SetRect(x2, y3, x2 + mSize130.cx, y3 + mSize130.cy);
+ rect2.UnionRect(rect2, rect1);
+ mTools[i]->Create(mWndClass, "", WS_CHILD, rect1, this, i + 1500);
+
+ y++;
+ if (y >= 4) {
+ y = 0;
+ x++;
+ }
+ }
+ y = 4;
+
+ y2 += (mSize130.cy - 1) * y;
+ x2 = 3;
+ rect1.SetRect(x2, y2, x2 + mSize138.cx, y2 + mSize138.cy);
+ rect2.UnionRect(rect2, rect1);
+ mToolScroll->Create(mWndClass, "", WS_VISIBLE | WS_CHILD, rect1, this, 1600);
+
+ CRect windowRect;
+ GetWindowRect(windowRect);
+
+ CRect clientRect;
+ GetClientRect(clientRect);
+
+ SetWindowPos(
+ NULL,
+ 0,
+ 0,
+ rect2.Width() + (windowRect.Width() - clientRect.Width()) + 6,
+ rect2.Height() + (windowRect.Height() - clientRect.Height()) + 11,
+ SWP_NOMOVE | SWP_NOZORDER
+ );
+
+ m124 = true;
+ ListUpdated();
+ Updated();
+
+ return 0;
+}
+
+/*virtual*/ BOOL ToolPalette::OnEraseBkgndProc(CDC *pDC) {
+ int saved = pDC->SaveDC();
+ pDC->SelectPalette(mWorldDef->GetPalette(), false);
+ pDC->RealizePalette();
+
+ CBrush backBrush;
+ backBrush.CreateStockObject(LTGRAY_BRUSH);
+
+ CRect rect1;
+ GetClientRect(rect1);
+ pDC->FillRect(rect1, &backBrush);
+
+ CPen pen1;
+ pen1.CreatePen(PS_SOLID, 0, PALETTEINDEX(T2PaletteAnimeDef::GetCommonColor(0)));
+
+ CPen pen2;
+ pen2.CreatePen(PS_SOLID, 0, PALETTEINDEX(T2PaletteAnimeDef::GetCommonColor(3)));
+
+ CRect rect2, rect3;
+ GetClientRect(rect2);
+
+ pDC->SelectObject(pen1);
+ pDC->MoveTo(rect2.right - 1, rect2.top);
+ pDC->LineTo(rect2.left, rect2.top);
+ pDC->LineTo(rect2.left, rect2.bottom);
+
+ pDC->SelectObject(pen2);
+ pDC->MoveTo(rect2.right - 1, rect2.top + 1);
+ pDC->LineTo(rect2.right - 1, rect2.bottom - 1);
+ pDC->LineTo(rect2.left, rect2.bottom - 1);
+
+ mCategoryTitle->GetWindowRect(rect2);
+ ScreenToClient(rect2);
+
+ mCategoryScroll->GetWindowRect(rect3);
+ ScreenToClient(rect3);
+
+ pDC->SelectObject(pen2);
+ pDC->MoveTo(rect3.right, rect2.top - 1);
+ pDC->LineTo(rect2.left - 1, rect2.top - 1);
+ pDC->LineTo(rect2.left - 1, rect3.bottom + 1);
+
+ pDC->SelectObject(pen1);
+ pDC->MoveTo(rect3.right, rect2.top);
+ pDC->LineTo(rect3.right, rect3.bottom);
+ pDC->LineTo(rect3.left - 1, rect3.bottom);
+
+ mToolTitle->GetWindowRect(rect2);
+ ScreenToClient(rect2);
+
+ mToolScroll->GetWindowRect(rect3);
+ ScreenToClient(rect3);
+
+ pDC->SelectObject(pen2);
+ pDC->MoveTo(rect3.right, rect2.top - 1);
+ pDC->LineTo(rect2.left - 1, rect2.top - 1);
+ pDC->LineTo(rect2.left - 1, rect3.bottom + 1);
+
+ pDC->SelectObject(pen1);
+ pDC->MoveTo(rect3.right, rect2.top);
+ pDC->LineTo(rect3.right, rect3.bottom);
+ pDC->LineTo(rect3.left - 1, rect3.bottom);
+
+ pDC->RestoreDC(saved);
+ return true;
+}
+
+/*virtual*/ void ToolPalette::OnSizeProc(UINT nType, int cx, int cy) {
+}
+
+/*virtual*/ void ToolPalette::Updated() {
+ if (!m124)
+ return;
+
+ T2ToolDef *thePlugin;
+ T2ToolIconItem *icon;
+ int theCategoryNo;
+ POSITION pos;
+
+ int theOption = GetIconOption(mSel);
+ BYTE isChange = 0;
+
+ switch (theOption) {
+ case kToolOption1:
+ case kToolOption2:
+ case kToolOption3:
+ thePlugin = (T2ToolDef *) GetIconPlugin(mSel);
+#line 596
+ _ASSERT(thePlugin != NULL);
+
+ theCategoryNo = thePlugin->mCategoryNo;
+ pos = mToolIconList->GetHeadPosition();
+ while (pos) {
+ icon = mToolIconList->GetNext(pos);
+ switch (icon->mOption) {
+ case kToolOption4:
+ if (icon->mValiation == theCategoryNo) {
+ if (!icon->m24) {
+ icon->m24 = true;
+ isChange |= 1;
+ }
+ } else {
+ if (icon->m24) {
+ icon->m24 = false;
+ isChange |= 1;
+ }
+ }
+ break;
+
+ case kToolOption1:
+ case kToolOption2:
+ case kToolOption3:
+ if (icon->mID == mSel) {
+ ToolHistoryItem *history = GetToolHistory(((T2ToolDef *) GetIconPlugin(mSel))->mCategoryNo);
+ if (history->_C == -1) {
+ history->_C = mSel;
+ history->_8 = 0;
+ }
+ if (!icon->m24) {
+ icon->m24 = true;
+ isChange |= 2;
+ }
+
+ mCategoryTitle->SetText(thePlugin->mCategoryName);
+ mToolTitle->SetText(*thePlugin->mToolName[icon->mValiation]);
+ } else {
+ if (icon->m24) {
+ icon->m24 = false;
+ isChange |= 2;
+ }
+ }
+ break;
+
+ case kToolOption0:
+ if (icon->m24) {
+ icon->m24 = false;
+ isChange |= 4;
+ }
+ break;
+ }
+ }
+
+ if (isChange & 1) {
+ for (int i = 0; i < kNumCategory; i++)
+ mCategories[i]->InvalidateRect(NULL);
+ ChangeCategory(theCategoryNo);
+ }
+ if (isChange & 2) {
+ for (int i = 0; i < kNumTool; i++)
+ mTools[i]->InvalidateRect(NULL);
+ }
+ if (isChange & 4) {
+ for (int i = 0; i < kNumCommand; i++)
+ mCommands[i]->InvalidateRect(NULL);
+ }
+
+ mDocument->SetCursorType(kCursorDefault, false);
+ break;
+
+ case kToolOption0:
+ pos = mToolIconList->GetHeadPosition();
+ while (pos) {
+ icon = mToolIconList->GetNext(pos);
+ switch (icon->mOption) {
+ case kToolOption1:
+ case kToolOption2:
+ case kToolOption3:
+ if (icon->m24) {
+ icon->m24 = false;
+ isChange |= 1;
+ }
+ break;
+
+ case kToolOption4:
+ if (icon->m24) {
+ icon->m24 = false;
+ isChange |= 2;
+ }
+ break;
+
+ case kToolOption0:
+ if (icon->mID == mSel) {
+ if (!icon->m24) {
+ icon->m24 = true;
+ isChange |= 4;
+ }
+ } else {
+ if (icon->m24) {
+ icon->m24 = false;
+ isChange |= 4;
+ }
+ }
+ break;
+ }
+ }
+
+ if (isChange & 1) {
+ for (int i = 0; i < kNumCategory; i++)
+ mCategories[i]->InvalidateRect(NULL);
+ ChangeCategory();
+ }
+ if (isChange & 2) {
+ for (int i = 0; i < kNumTool; i++)
+ mTools[i]->InvalidateRect(NULL);
+ }
+
+ if (isChange && 4) {
+ for (int i = 0; i < kNumCommand; i++)
+ mCommands[i]->InvalidateRect(NULL);
+ }
+ if (isChange) {
+ mCategoryTitle->SetText("");
+ mToolTitle->SetText("");
+ }
+
+ mDocument->SetCursorType(mSel, false);
+ break;
+ }
+
+ if (isChange) {
+ mCategoryTitle->InvalidateRect(NULL);
+ mToolTitle->InvalidateRect(NULL);
+ }
+}
+
+/*virtual*/ void ToolPalette::ListUpdated() {
+ if (!m124)
+ return;
+
+ UpdateCommand();
+ UpdateCategory();
+ UpdateTool();
+}
+
+void ToolPalette::UpdateScroll(ToolPaletteItem *inItem) {
+ if (inItem == mCategoryScroll)
+ UpdateCategory();
+
+ if (inItem == mToolScroll) {
+ UpdateTool();
+ if (_184 != -1) {
+ ToolHistoryItem *history = GetToolHistory(((T2ToolDef *) GetIconPlugin(_184))->mCategoryNo);
+ history->_8 = mToolScroll->GetScrollPos();
+ }
+ }
+}
+
+static const char *commandNames[] = {
+ "ToolDestruct",
+ "ToolFinger",
+ "ToolInfo",
+ "ToolZoom",
+ "ToolHand",
+ "ToolMic",
+ "ToolRoot"
+};
+
+void ToolPalette::UpdateCommand() {
+ BOOL valid = true;
+ int i;
+
+ for (i = 0; i < kNumCommand; i++) {
+ if (GetID(commandNames[i], 0) == -1) {
+ valid = false;
+ break;
+ }
+ }
+
+ if (valid) {
+ for (i = 0; i < kNumCommand; i++)
+ mCommands[i]->SetIcon(GetItem(commandNames[i], 0));
+ }
+}
+
+void ToolPalette::UpdateCategory() {
+ int baseIndex = mCategoryScroll->GetScrollPos() * m144;
+ int currIndex = 0;
+ int numIcons = 0;
+ CList<T2ToolIconItem *, T2ToolIconItem *> iconList;
+
+ POSITION pos = mToolIconList->GetHeadPosition();
+ while (pos) {
+ T2ToolIconItem *icon = mToolIconList->GetNext(pos);
+ if (icon->mOption == kToolOption4) {
+ BOOL added = false;
+ if (icon->mToolDef) {
+ POSITION pos2 = iconList.GetHeadPosition();
+ while (pos2) {
+ POSITION prevPos2 = pos2;
+ T2ToolIconItem *icon2 = iconList.GetNext(pos2);
+ if (icon2->mToolDef && icon2->mToolDef->GetSortKey() > icon->mToolDef->GetSortKey()) {
+ iconList.InsertBefore(prevPos2, icon);
+ added = true;
+ break;
+ }
+ }
+ }
+
+ if (!added)
+ iconList.AddTail(icon);
+ }
+ }
+
+ pos = iconList.GetHeadPosition();
+ while (pos) {
+ T2ToolIconItem *icon = iconList.GetNext(pos);
+ if (currIndex >= baseIndex && numIcons < kNumCategory) {
+ mCategories[numIcons]->SetIcon(icon);
+ mCategories[numIcons]->ShowWindow(SW_SHOW);
+ numIcons++;
+ }
+ currIndex++;
+ }
+
+ for (; numIcons < kNumCategory; numIcons++)
+ mCategories[numIcons]->ShowWindow(SW_HIDE);
+
+ currIndex = ((currIndex + m144 - 1) / m144) - 3;
+ if (currIndex < 0)
+ currIndex = 0;
+ mCategoryScroll->SetScrollRange(currIndex);
+}
+
+void ToolPalette::UpdateTool() {
+ T2ToolIconItem *icon;
+ POSITION pos = mToolIconList->GetHeadPosition();
+
+ while (pos) {
+ icon = mToolIconList->GetNext(pos);
+ if (icon->mOption == kToolOption4 && icon->m24) {
+ ChangeCategory(icon->mValiation);
+ break;
+ }
+ }
+}
+
+void ToolPalette::ChangeCategory(int inCategory) {
+ if (!m124)
+ return;
+
+ int baseIndex = mToolScroll->GetScrollPos() * m148;
+ int currIndex = 0;
+ int numIcons = 0;
+ CList<T2ToolIconItem *, T2ToolIconItem *> iconList;
+
+ POSITION pos = mToolIconList->GetHeadPosition();
+ while (pos) {
+ T2ToolIconItem *icon = mToolIconList->GetNext(pos);
+ if (icon->mOption == kToolOption1 || icon->mOption == kToolOption2 || icon->mOption == kToolOption3) {
+ if (((T2ToolDef *) icon->mPlugin)->mCategoryNo == inCategory) {
+ BOOL added = false;
+ if (icon->mToolDef) {
+ POSITION pos2 = iconList.GetHeadPosition();
+ while (pos2) {
+ POSITION prevPos2 = pos2;
+ T2ToolIconItem *icon2 = iconList.GetNext(pos2);
+ if (icon2->mToolDef && icon2->mToolDef->GetSortKey() > icon->mToolDef->GetSortKey()) {
+ iconList.InsertBefore(prevPos2, icon);
+ added = true;
+ break;
+ }
+ }
+ }
+
+ if (!added)
+ iconList.AddTail(icon);
+ }
+ }
+ }
+
+ pos = iconList.GetHeadPosition();
+ while (pos) {
+ T2ToolIconItem *icon = iconList.GetNext(pos);
+ if (currIndex >= baseIndex && numIcons < kNumTool) {
+ mTools[numIcons]->SetIcon(icon);
+ mTools[numIcons]->ShowWindow(SW_SHOW);
+ numIcons++;
+ }
+ currIndex++;
+ }
+
+ for (; numIcons < kNumTool; numIcons++)
+ mTools[numIcons]->ShowWindow(SW_HIDE);
+
+ currIndex = ((currIndex + m148 - 1) / m148) - 3;
+ if (currIndex < 0)
+ currIndex = 0;
+ mToolScroll->SetScrollRange(currIndex);
+}
+
+void ToolPalette::ChangeCategory() {
+ if (!m124)
+ return;
+
+ for (int i = 0; i < kNumTool; i++)
+ mTools[i]->ShowWindow(SW_HIDE);
+ mToolScroll->SetScrollRange(0);
+}
+
+/*virtual*/ void ToolPalette::RedrawButton() {
+ if (!m124)
+ return;
+
+ int i;
+ for (i = 0; i < kNumCategory; i++)
+ mCategories[i]->InvalidateRect(NULL);
+ for (i = 0; i < kNumTool; i++)
+ mTools[i]->InvalidateRect(NULL);
+ for (i = 0; i < kNumCommand; i++)
+ mCommands[i]->InvalidateRect(NULL);
+}
+
+void ToolPalette::ShowHelpWindow() {
+ HideHelpWindow();
+
+ int mode;
+ switch (mClickedItem->mOption) {
+ case kToolOption0:
+ mode = kToolHelpMode0;
+ break;
+ case kToolOption4:
+ mode = kToolHelpMode1;
+ break;
+ default:
+ mode = kToolHelpMode2;
+ break;
+ }
+
+ RECT rect;
+ GetWindowRect(&rect);
+
+ mToolHelpPt.y = GetSystemMetrics(SM_CYSMSIZE);
+ mToolHelpPt.y += rect.top;
+ mToolHelpPt.x = rect.right + 8;
+ mToolHelpPt.y += m14C[mode];
+
+ CString text;
+ mToolHelpValiation = mClickedItem->mValiation;
+ mToolHelpMode = mode;
+
+ switch (mode) {
+ case kToolHelpMode0:
+ mToolHelpStr2 = mClickedItem->m2C;
+ break;
+ case kToolHelpMode1:
+ mToolHelpStr1 = m15C->mCategoryName;
+ mToolHelpStr2 = m15C->mCategoryCommentString;
+ break;
+ case kToolHelpMode2:
+ mToolHelpDef = m15C;
+ break;
+ }
+
+ mToolHelpWnd = new T2ToolHelpWnd;
+ StartTimer(500);
+}
+
+void ToolPalette::HideHelpWindow() {
+ if (mToolHelpWnd) {
+ mToolHelpWnd->CloseToolHelp();
+ mToolHelpWnd = NULL;
+ }
+ StopTimer();
+}
+
+/*virtual*/ void ToolPalette::OnTimerProc(UINT nIDEvent) {
+ mToolHelpWnd->OpenToolHelp(mToolHelpPt, mToolHelpMode, mToolHelpStr1, mToolHelpStr2, mToolHelpDef, mToolHelpValiation);
+ StopTimer();
+}
+
+ToolHistoryItem *ToolPalette::GetToolHistory(int inID) {
+ ToolHistoryItem *history;
+ POSITION pos = mHistoryList.GetHeadPosition();
+ while (pos) {
+ history = mHistoryList.GetNext(pos);
+ if (history->_4 == inID)
+ return history;
+ }
+
+ history = new ToolHistoryItem;
+ history->_4 = inID;
+ mHistoryList.AddTail(history);
+ return history;
+}
+
+
+ToolHistoryItem::ToolHistoryItem() {
+ _4 = -1;
+ _8 = 0;
+ _C = -1;
+}
+
+/*virtual*/ ToolHistoryItem::~ToolHistoryItem() {
+}
+
+
+
+ToolHistoryList::ToolHistoryList() {
+}
+
+/*virtual*/ ToolHistoryList::~ToolHistoryList() {
+}