// ----------------------------------------------------------------------------- /// Merges this gadgets and sourceBarDescr gadgets and inserts them into /// destWindow's gadgets. bool TBarDescr::Merge(const TBarDescr& srcBarDescr, TGadgetWindow& destWindow) { if (BarRes && BarRes->IsOK()){ RemoveGadgets(destWindow); if(!srcBarDescr.Gadgets->Size()) CreateGadgets(srcBarDescr.Gadgets, *((TBarDescr&)srcBarDescr).GetBuilder(), srcBarDescr.BarRes); TCelArray& cellArray = destWindow.GetCelArray(); cellArray.RemoveAll(); int gdIndex1 = 0; int gdIndex2 = 0; int cellIndex = 0; int cellIndex1 = 0; int cellIndex2 = 0; for (int g = 0; g < NumGroups; g++){ if (srcBarDescr.GroupCount[g] > 0){ for (int i=0; i < srcBarDescr.GroupCount[g]; i++){ __TBarDescrGdNode* node = (*srcBarDescr.Gadgets)[gdIndex1]; destWindow.Insert(*node->Gadget); if(node->UseGlyph){ cellArray.Add(*srcBarDescr.CelArray, cellIndex1); TButtonGadget* bg = TYPESAFE_DOWNCAST(node->Gadget, TButtonGadget); if(bg) bg->SetGlyphIndex(cellIndex); cellIndex++; cellIndex1++; } gdIndex1++; } } else if (srcBarDescr.GroupCount[g] == 0 && GroupCount[g] > 0) { for (int i=0; i < GroupCount[g]; i++){ __TBarDescrGdNode* node = (*Gadgets)[gdIndex2]; destWindow.Insert(*node->Gadget); if(node->UseGlyph){ cellArray.Add(*CelArray, cellIndex2); TButtonGadget* bg = TYPESAFE_DOWNCAST(node->Gadget, TButtonGadget); if(bg) bg->SetGlyphIndex(cellIndex); cellIndex++; cellIndex2++; } gdIndex2++; } } } destWindow.Invalidate(); destWindow.LayoutSession(); destWindow.UpdateWindow(); return true; } return false; }
void TTabButtonGadget :: CheckOverlappedRegion ( TRegion & Region ) { register TGadget * p = Window -> FirstGadget ( ), * q = 0 ; if ( State == Down ) return ; // Rechercher le gadget de gauche (y a pas de PreviousGadget( ) ) while ( p && p != this ) { q = p ; p = p -> NextGadget ( ) ; } // Si trouvé et que le gadget est Up, il faut retirer son intersection avec // ce gadget de la région visible (uniquement si le gadget de gauche est un // onglet) if ( q ) { TTabButtonGadget * tab = TYPESAFE_DOWNCAST ( q, TTabButtonGadget ) ; if ( tab && tab -> State == Down ) { TRegion LeftRegion ; tab -> GetRegion ( LeftRegion, OuterRegion ) ; Region -= LeftRegion ; } } // On regarde à droite p = NextGadget ( ) ; if ( p ) { TTabButtonGadget * tab = TYPESAFE_DOWNCAST ( p, TTabButtonGadget ) ; if ( tab ) { TRegion RightRegion ; tab -> GetRegion ( RightRegion, OuterRegion ) ; Region -= RightRegion ; } } }
owl::tstring GetHintText(TWindow* win, uint id, THintText hintType) // Search the parent frame window of win and return the result of GetHintText { TWindow* parent= win->GetParentO(); TDecoratedFrame* frame= parent ? TYPESAFE_DOWNCAST(parent, TDecoratedFrame) : 0; while (parent && !frame) { parent = parent->GetParentO(); if (parent) frame = TYPESAFE_DOWNCAST(parent, TDecoratedFrame); } return frame ? frame->GetHintText(id, hintType) : owl::tstring(); }
void TTabButtonGadget :: SetButtonState ( TState state ) { register TState previous = State ; TShapeButtonGadget :: SetButtonState ( state ) ; if ( Overlap && previous != State ) { TGadget * g = NextGadget ( ) ; TTabButtonGadget * tab = TYPESAFE_DOWNCAST ( g, TTabButtonGadget ) ; if ( previous == Down && State == Up ) { if ( tab && tab -> State == Up ) { TRegion * Region = new TRegion ( ) ; GetRegion ( * Region, OuterRegion ) ; tab -> SetIntersectionRegion ( Region ) ; tab -> Invalidate ( ) ; } } } }
// /// Called by EvHelp() to activate the help file with the help context ID. // void THelpFileManager::ActivateHelp(TWindow* /*window*/, int helpFileContextId, uint helpCmd) { if (helpCmd == HELP_INDEX || helpCmd == HELP_CONTENTS) helpCmd = HELP_FINDER; TApplication* app = TYPESAFE_DOWNCAST(this, TApplication); #if !defined(NO_HTMLHELP) if(UseHTMLHelp){ if (app) HelpState = ToBool(HtmlHelp(app->GetMainWindow(), GetHelpFile().c_str(), helpCmd, helpFileContextId) != 0); else HelpState = ToBool(HtmlHelp(0, GetHelpFile().c_str(), helpCmd, helpFileContextId) != 0); } else{ #endif if (app) HelpState = ToBool(app->GetMainWindow()->WinHelp(GetHelpFile().c_str(), helpCmd, helpFileContextId)); else HelpState = ToBool(::WinHelp(0, GetHelpFile().c_str(), helpCmd, helpFileContextId)); #if !defined(NO_HTMLHELP) } #endif }
////////////////////////////////////////////////////////// // WinDEUApp // --------- // Ask for confirmation before exiting application bool WinDEUApp::CanClose () { BOOL result; // Default member function if ( TApplication::CanClose() == FALSE ) return FALSE; TMainFrame *mainFrame = TYPESAFE_DOWNCAST(GetMainWindow(), TMainFrame); // Close level editor and return if ( mainFrame->inEditor ) { mainFrame->StopEditLevel(); return FALSE; } // Last chance message /* result = mainFrame->MessageBox ( "Do you really want to quit?", "Quit", MB_YESNO | MB_ICONQUESTION) == IDYES ? TRUE : FALSE ; */ result = TRUE; // Close WinHelp if ( result && HelpOpened ) { mainFrame->WinHelp(HelpFileName, HELP_QUIT, 0L); HelpOpened = FALSE; } return result; }
///////////////////////////////////////////////////////////////// // TMainClient // ----------- // void TMainClient::CmFileOpenWad () { // save current working directory (of windeu32.exe) // the TFileOpenDialog below is going to set // it to the folder of the file being opened... char workdir[256]; GetCurrentDirectory(256, workdir); SET_HELP_CONTEXT(Open_WAD_file); // // Display standard Open dialog box to select a file name. // *FileData.FileName = 0; if (TFileOpenDialog(this, FileData).Execute() == IDOK) { // restore workingdirectory to folder of windeu32.exe SetCurrentDirectory(workdir); #if 0 OpenPatchWad(FileData.FileName); CloseUnusedWadFiles(); #endif // Sets a new client window (the editor) and destroy // the old one (the main client) TMainFrame *MainFrame = TYPESAFE_DOWNCAST (GetApplication()->GetMainWindow(), TMainFrame); MainFrame->EditLevel (FileData.FileName, FALSE) ; } RESTORE_HELP_CONTEXT(); }
// /// Use the Windows message to get the active mdi child, and then down cast /// to our MDI child derived class before returning it. // TMDIChild* TMDIClient::GetActiveMDIChild() { THandle hWnd = THandle(HandleMessage(WM_MDIGETACTIVE)); return TYPESAFE_DOWNCAST(GetWindowPtr(hWnd), TMDIChild); }
// /// Sets the text for the default text message gadget by specifying the id. // void TMessageBar::SetMessageText(int id, const tstring& text) { TTextGadget* tg = TYPESAFE_DOWNCAST(GadgetWithId(id), TTextGadget); if (tg) tg->SetText(text.c_str()); }
// ----------------------------------------------------------------------------- /// Removes the gadgets in destWindow and then inserts these gadgets. bool TBarDescr::Restore(TGadgetWindow& destWindow) { if (BarRes && BarRes->IsOK()){ RemoveGadgets(destWindow); TCelArray& cellArray = destWindow.GetCelArray(); cellArray.RemoveAll(); int gdIndex = 0; int cellIndex = 0; for (int g=0; g < NumGroups; g++){ if(GroupCount[g]!= 0){ for (int i=0; i < GroupCount[g]; i++){ __TBarDescrGdNode* node = (*Gadgets)[gdIndex]; destWindow.Insert(*node->Gadget); if(node->UseGlyph){ cellArray.Add(*CelArray, cellIndex); TButtonGadget* bg = TYPESAFE_DOWNCAST(node->Gadget, TButtonGadget); if(bg) bg->SetGlyphIndex(cellIndex); cellIndex++; } gdIndex++; } } } destWindow.Invalidate(); destWindow.LayoutSession(); destWindow.UpdateWindow(); return true; } return false; }
//------------------------------------------------------------------------------ // bool TGadgetListBox::IsFlat() { TGadgetWindow* wnd = TYPESAFE_DOWNCAST(GetParentO(),TGadgetWindow); if(wnd) return ToBool(wnd->GetFlatStyle()&TGadgetWindow::FlatStandard); return false; }
// /// Creates the interface element associated with the MDI client window. Calls /// TWindow::Create after first setting the child window menu in ClientAttr to the /// parent frame window's child menu. // bool TMDIClient::Create() { TMDIFrame* frame = TYPESAFE_DOWNCAST(GetParentO(),TMDIFrame); CHECK(frame); ClientAttr->hWindowMenu = frame->FindChildMenu(frame->GetMenu()); return TWindow::Create(); }
void THelpFileManager::SetHelpCursor() { if(!HelpCursor){ TApplication* app = TYPESAFE_DOWNCAST(this, TApplication); if(app) HelpCursor = new TCursor(*app, TResId(IDC_HELPCURSOR)); } ::SetCursor(*HelpCursor); }
void GetWorkMessage (char *buffer, size_t bufferSize) { TMainFrame *mainFrame = TYPESAFE_DOWNCAST(((TApplication *)::Module)->GetMainWindow(), TMainFrame); strncpy (buffer, ((TTextGadget *)mainFrame->GetStatusBar()->FirstGadget())->GetText (), bufferSize); buffer[bufferSize-1] = '\0'; }
// /// Overrides TGadget's Insert function and tells the button not to notch its corners. /// /// Only TButtonGadgets or derived gadgets are supported. // void TToolBox::Insert(TGadget& g, TPlacement placement, TGadget* sibling) { TGadgetWindow::Insert(g, placement, sibling); // Notch the corners if it's a buttonGadget // TButtonGadget* bg = TYPESAFE_DOWNCAST(&g,TButtonGadget); if (bg) bg->SetNotchCorners(false); }
// /// Responds to a menu item selection. // void TRecentFiles::CmFile(uint id) { TApplication* app = TYPESAFE_DOWNCAST(this, TApplication); TFrameWindow* window = app ? app->GetMainWindow() : 0; if (window) { // Foward menu selection command to specified target // window->SendMessage(MruMessage, id, 0); } }
void poundsMDIChild::EvGetMinMaxInfo (MINMAXINFO far& minmaxinfo) { poundsApp *theApp = TYPESAFE_DOWNCAST(GetApplication(), poundsApp); if (theApp) { if (theApp->Printing) { minmaxinfo.ptMaxSize = TPoint(32000, 32000); minmaxinfo.ptMaxTrackSize = TPoint(32000, 32000); return; } } TMDIChild::EvGetMinMaxInfo(minmaxinfo); }
////////////////////////////////////////////////////////// // mtlrchApp // ===== // Response Table handlers: // void mtlrchApp::EvNewView (TView& view) { TMDIClient *mdiClient = TYPESAFE_DOWNCAST(GetMainWindow()->GetClientWindow(), TMDIClient); if (mdiClient) { mtlrchMDIChild* child = new mtlrchMDIChild(*mdiClient, 0, view.GetWindow()); // Associate ICON w/ this child window. child->SetIcon(this, IDI_DOC); child->Create(); } }
void TFuncSpecView::EvGetMinMaxInfo(MINMAXINFO far& minmaxinfo) { TSwitchMinApp* theApp = TYPESAFE_DOWNCAST(GetApplication(), TSwitchMinApp); if (theApp) { if (theApp->Printing) { minmaxinfo.ptMaxSize = TPoint(32000, 32000); minmaxinfo.ptMaxTrackSize = TPoint(32000, 32000); return; } } TWindow::EvGetMinMaxInfo(minmaxinfo); }
// /// Reads information in the TProfile to display the menu choices. // void TRecentFiles::CeExit(TCommandEnabler& ce) { ce.Enable(true); TMenuItemEnabler* me = TYPESAFE_DOWNCAST(&ce, TMenuItemEnabler); if (me == 0) return; HMENU hMenu = me->GetMenu(); RemoveMruItemsFromMenu(hMenu); InsertMruItemsToMenu(hMenu); }
void WorkMessage (char *workstr, ...) { va_list args; static char msg[256]; TMainFrame *mainFrame = TYPESAFE_DOWNCAST(((TApplication *)::Module)->GetMainWindow(), TMainFrame); va_start( args, workstr); vsprintf( msg, workstr, args); va_end( args); ((TTextGadget *)mainFrame->GetStatusBar()->FirstGadget())->SetText( msg); mainFrame->GetStatusBar()->UpdateWindow(); }
// /// Applies the specified 'action' function to each TPropertyPage child of the /// sheet. /// \note The logic here traverses the TPropertySheet's ChildList. Therefore /// we will miss any page that does not have an associated TPropertyPage /// inserted in the sheet's ChildList. void TPropertySheet::ForEachPage(TActionPageFunc action, void* paramList) { if (GetLastChild()) { TWindow* curChild; TWindow* nextChild = GetLastChild()->Next(); TPropertyPage* curPage; do { curChild = nextChild; nextChild = nextChild->Next(); curPage = TYPESAFE_DOWNCAST(curChild, TPropertyPage); if (curPage) action(curPage, paramList); } while (curChild != GetLastChild() && GetLastChild() != 0); } }
// /// Applies the specified 'test' function to each 'TPropertyPage' of the sheet and /// returns the first page which causes the 'test' function to return true. Returns /// '0' if no page meets the condition. // TPropertyPage* TPropertySheet::FirstPageThat(TCondPageFunc test, void* paramList) { if (GetLastChild()) { TWindow* curChild; TWindow* nextChild = GetLastChild()->Next(); TPropertyPage* curPage; do { curChild = nextChild; nextChild = nextChild->Next(); curPage = TYPESAFE_DOWNCAST(curChild, TPropertyPage); if (curPage) { if (test(curPage, paramList)) return curPage; } } while (curChild != GetLastChild() && GetLastChild() != 0); } return 0; }
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) { // Call next hook in chain and return if nCode less than 0 if ( nCode >= 0 ) { // Call WinHelp if F1 key is pressed if ( ( wParam == VK_F1 ) && /* F1 */ ((lParam & 0x80000000L) == 0 ) /* Key pressed */ ) { WinDEUApp *app = TYPESAFE_DOWNCAST(::Module, WinDEUApp); app->AppHelp(HELP_CONTEXT, HelpContext); // Return 1 to avoid passing message to the active window // (The message is not pushed in the queue) return 1; } } return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam); }
///////////////////////////////////////////////////////////////// // TMainClient // ----------- // void TMainClient::CmEditorCreate () { char LevelName[9]; SET_HELP_CONTEXT(Create_level); // Executes the dialog box to get level number #if 0 sprintf(LevelName, "temp.roo"); if (1) #endif { // Sets a new client window (the editor) and destroy // the old one (the main client) TMainFrame *MainFrame = TYPESAFE_DOWNCAST(GetApplication()->GetMainWindow(), TMainFrame); MainFrame->EditLevel (LevelName, TRUE) ; } RESTORE_HELP_CONTEXT(); return; // 'this' is not valid anymore }
// /// Deactivates the help. // void THelpFileManager::DeactivateHelp() { TApplication* app = TYPESAFE_DOWNCAST(this, TApplication); #if !defined(NO_HTMLHELP) if(UseHTMLHelp){ if (app) HtmlHelp(app->GetMainWindow(), GetHelpFile().c_str(), HELP_QUIT, 0); else HtmlHelp(0, GetHelpFile().c_str(), HELP_QUIT, 0); } else{ #endif if (app) app->GetMainWindow()->WinHelp(GetHelpFile().c_str(), HELP_QUIT, 0); else ::WinHelp(0, GetHelpFile().c_str(), HELP_QUIT, 0); #if !defined(NO_HTMLHELP) } #endif }
///////////////////////////////////////////////////////////////// // TMainClient // ----------- // void TMainClient::CmEditorEdit () { return; // We don't like this option ARK #if 0 char LevelName[9]; SET_HELP_CONTEXT(Edit_level); // Executes the dialog box to get level number if (TEpisodeMissionDialog (this, LevelName).Execute() == IDOK) { // Sets a new client window (the editor) and destroy // the old one (the main client) TMainFrame *MainFrame = TYPESAFE_DOWNCAST (GetApplication()->GetMainWindow(), TMainFrame); MainFrame->EditLevel (LevelName, FALSE) ; } RESTORE_HELP_CONTEXT(); return; // 'this' is not valid anymore #endif }
void TFlatPainter::Paint(TDC& dc, TRect& rect) { TWindow* wnd = TYPESAFE_DOWNCAST(this, TWindow); if(!wnd) return; if(IsSet(fpMouseIn) && wnd->IsWindowEnabled()){ // We draw the "tracked" situation #ifdef TEST TBrush brush (TColor::LtRed); #else TBrush brush (TColor::Sys3dFace); #endif dc.FrameRect(rect, brush); rect.Inflate(-1, -1); dc.FrameRect(rect, brush); rect.Inflate(-1, -1); dc.FrameRect(rect, brush); rect.Inflate(1, 1); TUIBorder::DrawEdge(dc, rect, TUIBorder::SunkenOuter, TUIBorder::Rect); } else{ // We draw the "untracked" situation #ifdef TEST TBrush brush(TColor::LtBlue); TBrush brush2(TColor::LtGreen); #else TBrush brush(TColor::Sys3dFace); TBrush brush2(TColor::SysWindow); #endif dc.FrameRect(rect,brush); rect.Inflate(-1, -1); dc.FrameRect(rect,brush); rect.Inflate(-1, -1); dc.FrameRect(rect, brush2); } }
void THelpFileManager::CmWhatIsThis() { PRECONDITION(LastParent); if(!LastParent) return; LastParent->ScreenToClient(LastHit); // TWindow HWND hWnd = LastParent->ChildWindowFromPoint(LastHit); HELPINFO Info; Info.cbSize = sizeof(Info); Info.MousePos = LastHit; if(hWnd){ TGadgetWindow* gwin = TYPESAFE_DOWNCAST(GetWindowPtr(hWnd), TGadgetWindow); if(gwin){ TGadget* gd = gwin->GadgetFromPoint(LastHit); if(gd){ Info.iContextType = HELPINFO_MENUITEM; Info.iCtrlId = gd->GetId(); EvHelp(Info); } return; } } Info.iContextType = HELPINFO_WINDOW; Info.dwContextId = 0; // If the click wasn't on one of the controls, open Help for dialog. if (hWnd == 0 || hWnd == LastParent->GetHandle()){ Info.iContextType = HELPINFO_MENUITEM; Info.iCtrlId = IDHELP; Info.hItemHandle = LastParent->GetHandle(); } else{ Info.iCtrlId = ::GetDlgCtrlID(hWnd); Info.hItemHandle = hWnd; } EvHelp(Info); }
TFileFormatDialog::TFileFormatDialog (TWindow* parent, TResId resId, TModule* module): TDialog(parent, resId, module), hTestFixedFont( 0 ), xFont( poundsApp::xFont ), yFont( poundsApp::yFont ) { //{{TFileFormatDialogXFER_USE}} MercMode = new TRadioButton(this, IDC_MERC, 0); TFCMode = new TRadioButton(this, IDC_TFCMUD, 0); EnvyMode = new TRadioButton(this, IDC_ENVY, 0); MobProgs = new TCheckBox(this, IDC_MOBPROGS, 0); RomMode = new TRadioButton(this, IDC_ROM, 0); Envy20Mode = new TRadioButton(this, IDC_ENVY20, 0); OghamMode = new TRadioButton(this, IDC_OGHAM, 0); Rom24Mode = new TRadioButton(this, IDC_ROM24, 0); SetTransferBuffer(&TFileFormatDialogData); //{{TFileFormatDialogXFER_USE_END}} // INSERT>> Your constructor code here. MuditorApp = TYPESAFE_DOWNCAST(GetApplication(), poundsApp); TFileFormatDialogData.MercMode = (MuditorApp->CurrentMode == poundsApp::MercMode); TFileFormatDialogData.TFCMode = (MuditorApp->CurrentMode == poundsApp::TFCMode); TFileFormatDialogData.EnvyMode = (MuditorApp->CurrentMode == poundsApp::EnvyMode); TFileFormatDialogData.RomMode = (MuditorApp->CurrentMode == poundsApp::RomMode); TFileFormatDialogData.Envy20Mode = (MuditorApp->CurrentMode == poundsApp::Envy2Mode); TFileFormatDialogData.OghamMode = (MuditorApp->CurrentMode == poundsApp::OghamMode); TFileFormatDialogData.Rom24Mode = (MuditorApp->CurrentMode == poundsApp::Rom24Mode); TFileFormatDialogData.MobProgs = MuditorApp->fMOBprograms; }