#include "StdAfx.h" #include "CTokenizer.h" #include "T2BitImage.h" #include "T2DlgItemAllPurpose.h" #include "T2DlgItemVScr.h" #include "T2PluginInfoTable.h" #include "T2PluginLoader.h" #include "T2PrefDialogBox.h" #include "../T2TowerDoc.h" T2PrefDialogBox::T2PrefDialogBox() { mCurrentTab = -1; mImage = NULL; mVScroll = NULL; mAllPurpose = NULL; mTopmostTab = NULL; mCheckA = NULL; mCheckB = NULL; mButton1a = NULL; mButton1b = NULL; mButton2a = NULL; mButton2b = NULL; mAboutButton = NULL; mMakePrefButton = NULL; } /*virtual*/ T2PrefDialogBox::~T2PrefDialogBox() { if (mImage) delete mImage; } /*virtual*/ BOOL T2PrefDialogBox::OnT2DialogCommand(WPARAM inWParam, LPARAM inLParam) { BOOL result = false; WORD code = HIWORD(inWParam); WORD id = LOWORD(inWParam); if (id == 1002) { if (mAllPurpose && mVScroll) { RECT alppsRect, scrollRect; mAllPurpose->GetClientRect(&alppsRect); mAllPurpose->ClientToScreen(&alppsRect); ScreenToClient(&alppsRect); mVScroll->GetClientRect(&scrollRect); mVScroll->ClientToScreen(&scrollRect); ScreenToClient(&scrollRect); UnionRect(&alppsRect, &alppsRect, &scrollRect); InvalidateRect(&alppsRect); } else { InvalidateRect(NULL); } result = true; } else if (id == 1001 && code == 0 && mAllPurpose) { RECT clientRect; mAllPurpose->GetClientRect(&clientRect); POINT pt = mAllPurpose->GetUpPoint(); if (PtInRect(&clientRect, pt)) { int value = mVScroll->GetValue(); pt.y += value * 72; mCurrentTab = pt.y / 72; if (mCurrentTab >= 0 && mCurrentTab <= 4) { if (mTopmostTab) mTopmostTab->ShowWindow(SW_HIDE); CWnd *theWindow = GetDlgItem(1003 + mCurrentTab); theWindow->ShowWindow(SW_SHOWNORMAL); theWindow->BringWindowToTop(); switch (mCurrentTab + 1003) { case 1003: mCheckA->BringWindowToTop(); mCheckB->BringWindowToTop(); break; } mTopmostTab = theWindow; } } mAllPurpose->ClientToScreen(&clientRect); ScreenToClient(&clientRect); InvalidateRect(&clientRect); } return result; } /*virtual*/ BOOL T2PrefDialogBox::OnT2EraseBkgnd(CDC* pDC) { int save = pDC->SaveDC(); pDC->SelectPalette(mPalette, false); pDC->RealizePalette(); if (mAllPurpose && mImage) { // fuck it #pragma var_order(rect3, allpsRect, var38, scrollValue, rect2, rect1) RECT allpsRect; mAllPurpose->GetClientRect(&allpsRect); InflateRect(&allpsRect, -1, -1); allpsRect.right += 1; allpsRect.bottom += 1; mAllPurpose->ClientToScreen(&allpsRect); ScreenToClient(&allpsRect); pDC->SelectStockObject(NULL_PEN); pDC->SelectStockObject(WHITE_BRUSH); pDC->Rectangle(&allpsRect); int scrollValue = mVScroll->GetValue(); RECT rect1, rect2, rect3; SetRect(&rect1, 0, scrollValue * 32, 32, scrollValue * 32 + 32); SetRect(&rect2, 4, 4, 68, 68); mAllPurpose->ClientToScreen(&rect2); ScreenToClient(&rect2); int var38 = mImage->mBitmap.header.biHeight; while (rect2.top < allpsRect.bottom && rect1.top < var38) { rect3 = rect2; if (rect2.bottom > allpsRect.bottom) { rect2.bottom = allpsRect.bottom; rect1.bottom = rect1.top + ((rect2.bottom - rect2.top + 1) / 2) - 1; } StretchDIBits(pDC->m_hDC, rect2.left, rect2.bottom - 1, rect2.right - rect2.left, rect2.top - rect2.bottom, rect1.left, rect1.top, rect1.right - rect1.left, rect1.bottom - rect1.top, mImage->mData, (BITMAPINFO *) &mImage->mBitmap, DIB_PAL_COLORS, SRCCOPY); if (scrollValue++ == mCurrentTab) { CBrush brush(RGB(255, 0, 0)); pDC->FrameRect(&rect3, &brush); } OffsetRect(&rect1, 0, 32); OffsetRect(&rect2, 0, 72); } } pDC->RestoreDC(save); return true; } /*virtual*/ void T2PrefDialogBox::OnT2Create() { T2TowerDoc *theDoc = mTowerDoc; #line 146 _ASSERT(theDoc != NULL); mVScroll = (T2DlgItemVScr *) GetDlgItem(1002); mVScroll->SetPage(2); mVScroll->SetRange(5); mVScroll->SetValue(0); mAllPurpose = (T2DlgItemAllPurpose *) GetDlgItem(1001); HMODULE theModule = AfxGetInstanceHandle(); mImage = new T2BitImage(theModule, 189, true); SetupPluginPref(); CWnd *theDialog = GetDlgItem(1003); mCheckA = theDialog->GetDlgItem(1011); // check1 mCheckB = theDialog->GetDlgItem(1012); // check2 theDialog = GetDlgItem(1004); mButton1a = theDialog->GetDlgItem(1102); // button1 mButton1b = theDialog->GetDlgItem(1103); // button2 theDialog = GetDlgItem(1005); mButton2a = theDialog->GetDlgItem(1104); mButton2b = theDialog->GetDlgItem(1105); theDialog = GetDlgItem(1006); mAboutButton = theDialog->GetDlgItem(1106); theDialog = GetDlgItem(1007); mMakePrefButton = theDialog->GetDlgItem(1107); } /*virtual*/ void T2PrefDialogBox::OnT2Destroy() { } /*virtual*/ void T2PrefDialogBox::CreateDlgItem(CTokenizer& inTokenizer, T2DialogDef& inDef) { if (!_stricmp(inTokenizer.Current(), "ALPPS")) { RECT theItemRect; UINT theID = inTokenizer.NextInteger(); theItemRect.left = inTokenizer.NextInteger(); theItemRect.top = inTokenizer.NextInteger(); theItemRect.right = inTokenizer.NextInteger(); theItemRect.bottom = inTokenizer.NextInteger(); T2DlgItemAllPurpose *alpps = new T2DlgItemAllPurpose(mTowerDoc, mImageObj, mPalette); alpps->Create("", inDef.flags, theItemRect, this, theID); if (mCurrentFont >= 0) alpps->SetFont(*mFonts[mCurrentFont]); } else { T2Dialog::CreateDlgItem(inTokenizer, inDef); } } void T2PrefDialogBox::SetupPluginPref() { CWnd *thePluginDialog = GetDlgItem(1006); #line 204 _ASSERT(thePluginDialog != NULL); T2PluginInfoTable *theTable = (T2PluginInfoTable *) thePluginDialog->GetDlgItem(1022); #line 208 _ASSERT(theTable != NULL); theTable->SetCellDataSize(sizeof(T2PluginSpecifier *)); theTable->InsertCols(1, 0, NULL); theTable->SetColWidth(500, 0, 0); theTable->SetRowHeight(12, 0, 0); T2PluginSpecifier *theSpecifier; POSITION pos; mTowerDoc->mT2PluginLoader->SetTypeFilter(pos, 0); while ((theSpecifier = mTowerDoc->mT2PluginLoader->GetNext(pos))) theTable->Add(theSpecifier); }