MsgResult CustomizeBarDlg::Message(Msg* Message) { if (IS_OUR_DIALOG_MSG(Message)) { DialogMsg* Msg = (DialogMsg*)Message; BOOL EndDialog = FALSE; switch (Msg->DlgMsg) { case DIM_COMMIT: { EndDialog = TRUE; } break; case DIM_CANCEL: // Cancel all changes the user wants to make to toolbars... EndDialog = TRUE; break; // default: } if (EndDialog) // Dialog communication over { Close(); // Close the dialog End(); // Destroy dialog } // return (DLG_EAT_IF_HUNGRY(Msg)); } // return OK; // Pass all messages on to the base class for final handling . . . return DialogOp::Message(Message); }
MsgResult TEMPLATESGallery::Message(Msg* Message) { if (IS_OUR_DIALOG_MSG(Message)) { DialogMsg* Msg = (DialogMsg*)Message; switch (Msg->DlgMsg) { case DIM_CREATE: SGInit::UpdateGalleryButton(OPTOKEN_DISPLAYTEMPLATEGALLERY, TRUE); break; case DIM_CANCEL: SGInit::UpdateGalleryButton(OPTOKEN_DISPLAYTEMPLATEGALLERY, FALSE); break; } return(SuperGallery::Message(Message)); } // If we have no displaytree, then we have not been shown, or something terrible has // happened, so we don't bother handling any of these messages. if (DisplayTree == NULL) return(SuperGallery::Message(Message)); // **** TO DO **** // Just another note: Most galleries ignore most messages when closed (!IsVisible()) // This means that they must re-create themselves properly to get back up to date // when they are opened - this is done in the PostCreate handler. If you wish to // respond to messages to keep up to date while closed, you should address the // default code in the PostCreate handler as well. if (IsVisible() && MESSAGE_IS_A(Message, DocChangingMsg)) { DocChangingMsg *TheMsg = (DocChangingMsg *) Message; switch ( TheMsg->State ) { case DocChangingMsg::DocState::BORN: // New document - add to display tree { INT32 Extent = GetDisplayExtent(); // Remember previous list extent CreateNewSubtree(TheMsg->pChangingDoc); // Add a subtree for this doc ShadeGallery(FALSE); // Unshade the gallery InvalidateCachedFormat(); // And redraw what is necessary RedrawEverythingBelow(-Extent); } break; // Pass this message on to the base class as well } } return(SuperGallery::Message(Message)); }
MsgResult ArrangeAlignment::Message(Msg* Message) { if (IS_OUR_DIALOG_MSG(Message)) { DialogMsg* Msg=(DialogMsg*)Message; switch (Msg->DlgMsg) { case DIM_CREATE: // dialog created - restore its previous state BuildIDSDropList(_R(IDC_ALIGNDIALOG_HORIZONTAL), HAlignIDS, Align.h); BuildIDSDropList(_R(IDC_ALIGNDIALOG_VERTICAL), VAlignIDS, Align.v); SetRadioGroup(TargetArea, TargetArea[Align.target]); UpdateState(); break; case DIM_LFT_BN_CLICKED: // mouse clicks may change greyed state of buttons case DIM_SELECTION_CHANGED: // mouse clicks may change greyed state of buttons UpdateState(); break; case DIM_LFT_BN_DOWN: // Handle clicks in the diagram control if (Msg->GadgetID == _R(IDC_ALIGNDIALOG_DIAGRAM)) DiagramClicked((ReDrawInfoType*) Msg->DlgMsgParam); break; case DIM_REDRAW: // handle redraw request for diagram gadget if (Msg->GadgetID == _R(IDC_ALIGNDIALOG_DIAGRAM)) RedrawDiagram((ReDrawInfoType*)Msg->DlgMsgParam); break; case DIM_COMMIT: // handle left hand OK click DialogOKed(); break; case DIM_CANCEL: // handle cancel // Close(); // End(); // Do not call Close() and End(). The base class does this. break; default: break; } } else if (MESSAGE_IS_A(Message, SelChangingMsg)) { // if selection has changed, update state of dialog if ( ((SelChangingMsg*)Message)->State == SelChangingMsg::SELECTIONCHANGED ) UpdateState(); } // Pass all unhandled messages to base class for default processing! return DialogOp::Message(Message); }
/******************************************************************************************** > MsgResult TipsDlg::Message(Msg* pMessage) Author: Colin_Barfoot (Xara Group Ltd) <*****@*****.**> Created: 03/08/96 Purpose: Dispatches messages to various other member functions beginning On... ********************************************************************************************/ MsgResult TipsDlg::Message(Msg* pMessage) { if (IS_OUR_DIALOG_MSG(pMessage)) { m_pCurrentMsg = (DialogMsg*)pMessage; switch (m_pCurrentMsg->DlgMsg) { case DIM_CREATE: { break; } case DIM_REDRAW: { // Get the redraw information from the message ReDrawInfoType* pReDrawInfo = (ReDrawInfoType*) m_pCurrentMsg->DlgMsgParam; OnRedraw(pReDrawInfo); break; } case DIM_COMMIT: OnCommit(); // and fall through... case DIM_CANCEL: Close(); // Close and destroy the dialog delete m_pTipTextGadget; End(); // WARNING: Destroys this!!! return (DLG_EAT_IF_HUNGRY((DialogMsg*)pMessage)); // End() destroyed m_... case DIM_LFT_BN_CLICKED: // A control on the dialog box has been clicked... switch (m_pCurrentMsg->GadgetID) { case _R(IDC_MORE): // clicked on "Tell me more..." OnMoreHelp(); return (DLG_EAT_IF_HUNGRY(m_pCurrentMsg)); case _R(IDC_NEXTTIP): OnNextTip(); break; } break; // DIM_LFT_BN_CLICKED } } return OK; }
MsgResult StandardBar::Message( Msg* Msg) { if (Msg->IsKindOf(CC_RUNTIME_CLASS(StandardBarMsg))) { StandardBarMsg * pMsg = ((StandardBarMsg *)(Msg)); // If we're already got one, EAT the message. Else OK, so pass on. if (pMsg->m_MsgType == StandardBarMsg::HELLO) return (pMsg->m_pOpDescriptor == m_pOpDesc)?EAT_MSG:OK; else if (pMsg->m_MsgType == StandardBarMsg::CLOSE) { if (pMsg->m_pOpDescriptor == m_pOpDesc) { Close(); // Hide the dialog m_pOpDesc = NULL; // zap out OpDescriptor pointer End(); return OK; } } else return OK; // who knows what that is all about... } DialogMsg* DMsg = (DialogMsg*)Msg; if (IS_OUR_DIALOG_MSG(Msg)) { // Handle ok button if ((DMsg->DlgMsg == DIM_COMMIT) || (DMsg->DlgMsg == DIM_CANCEL)) { Close(); // Hide the dialog m_pOpDesc = NULL; // zap out OpDescriptor pointer End(); return OK; } } return DialogOp::Message(Msg); }
MsgResult WebAddressDlg::Message( Msg* Message) { BOOL fEndDialog=FALSE; //If the message is a dialog message if (IS_OUR_DIALOG_MSG(Message)) { //Then work out what it says DialogMsg* pDialogMsg = ((DialogMsg*) Message); switch (pDialogMsg->DlgMsg) { case DIM_CREATE: OnCreate(); break; case DIM_COMMIT: OnAddButtonClicked(); break; case DIM_CANCEL: fEndDialog = TRUE; break; case DIM_TEXT_CHANGED: //This ensures that, when this code changes some text //in an edit field, we don't handle the "text changed" message if (WebAddressDlg::DontHandleNextTextMessage) { WebAddressDlg::DontHandleNextTextMessage=FALSE; } else OnDialogChange(); break; case DIM_LFT_BN_CLICKED: switch(pDialogMsg->GadgetID) { case _R(IDC_WEBADDRESS_REMOVE): OnRemoveButtonClicked(); break; case _R(IDC_WEBADDRESS_OBJECTSHAPE): case _R(IDC_WEBADDRESS_RECTANGLE): OnDialogChange(); break; case _R(IDC_WEBADDRESS_CORRECT): OnAutoCorrectClicked(); break; } break; //NB: This means someone has altered the combo box. It doesn't mean //the selection has changed! case DIM_SELECTION_CHANGED: OnDialogChange(); break; } } else if (MESSAGE_IS_A(Message, SelChangingMsg)) { if ( ((SelChangingMsg*)Message)->State == SelChangingMsg::SELECTIONCHANGED ) OnSelectionChange(); } if (fEndDialog) { Close(); End(); } return DialogOp::Message(Message); }
MsgResult URLImportDlg::Message(Msg* Message) { //If the message came from within our dialog if (IS_OUR_DIALOG_MSG(Message)) { //Then cast it into a dialog message and handle it DialogMsg* Msg = (DialogMsg*)Message; //If this flag gets set, we should close the dialog BOOL EndDialog = FALSE; //Now pass the message to a message handling function switch (Msg->DlgMsg) { case DIM_CREATE: OnCreate(); break; case DIM_COMMIT: OnCommit(); EndDialog=TRUE; break; case DIM_CANCEL: DialogWasCancelled=TRUE; EndDialog = TRUE; break; case DIM_LFT_BN_CLICKED: // A control on the dialog box has been clicked... if(Msg->GadgetID==_R(IDC_URLIMPORT_IMPORT)) { OnCommit(); EndDialog=TRUE; } break; case DIM_TEXT_CHANGED: // The user has typed in an edit field switch (Msg->GadgetID) { case _R(IDC_URLIMPORT_URL): if (URLImportDlg::DontHandleNextMessage) URLImportDlg::DontHandleNextMessage=FALSE; else OnURLChanged(); break; } break; } //And end the dialog if necessary if (EndDialog) { Close(); End(); } } //Now pass the message down to the base class return DialogOp::Message(Message); }
MsgResult ImagemapDlg::Message(Msg* Message) { //If the message came from within our dialog if (IS_OUR_DIALOG_MSG(Message)) { //Then cast it into a dialog message and handle it DialogMsg* Msg = (DialogMsg*)Message; //If this flag gets set, we should close the dialog BOOL EndDialog = FALSE; //Now pass the message to a message handling function switch (Msg->DlgMsg) { case DIM_CREATE: OnCreate(); break; case DIM_COMMIT: OnCommit(); EndDialog=TRUE; break; case DIM_CANCEL: DialogWasCancelled=TRUE; EndDialog = TRUE; break; case DIM_LFT_BN_CLICKED: // A control on the dialog box has been clicked... switch (Msg->GadgetID) { case _R(IDC_IMAGEMAP_AREA_SELECTION): OnAreaSelectionClicked(); break; case _R(IDC_IMAGEMAP_AREA_DRAWING): OnAreaDrawingClicked(); break; } break; case DIM_TEXT_CHANGED: // The user has typed in an edit field switch (Msg->GadgetID) { case _R(IDC_IMAGEMAP_WIDTH): if (ImagemapDlg::DontHandleNextMessage) ImagemapDlg::DontHandleNextMessage=FALSE; else OnWidthChanged(); break; case _R(IDC_IMAGEMAP_HEIGHT): if (ImagemapDlg::DontHandleNextMessage) ImagemapDlg::DontHandleNextMessage=FALSE; else OnHeightChanged(); break; } break; } //And end the dialog if necessary if (EndDialog) { Close(); End(); } } //Now pass the message down to the base class return DialogOp::Message(Message); }
MsgResult CBaseBrushNameDlg::Message(Msg* pMessage) { // A message from the dialog or its gadgets? if (IS_OUR_DIALOG_MSG(pMessage)) { DialogMsg* pMsg = (DialogMsg*) pMessage; switch (pMsg->DlgMsg) { case DIM_CREATE: InitGadgetText(); break; case DIM_TEXT_CHANGED: // Disable the OK/Apply button if there's no document or entered text. EnableGadget(_R(IDOK), !GetStringGadgetValue(_R(IDC_EDITBRUSHNAME), 0).IsEmpty() && Document::GetSelected() != 0); break; case DIM_LFT_BN_CLICKED: // enter messages when the edit box has the focus get cast to this if (pMsg->GadgetID == _R(ID_CC_HELP_BUTTON)) break; case DIM_COMMIT: { // Check name for validity. String_256 strEnter = GetStringGadgetValue(_R(IDC_EDITBRUSHNAME), 0); UINT32 nErrID = IsValid(strEnter); if (nErrID != 0) { // Invalid, reinitialise. InformError(nErrID); if (nErrID == _R(IDS_BRUSHNAME_INVALID)) { String_32 s(strEnter); InitGadgetText(&s, FALSE); } else InitGadgetText(NULL); break; } else { // Entry is valid, try committing it. String_32 FinalString(strEnter); if (DoCommit(strEnter)) { // Don't close, reinitialise (dialog is modeless). InitGadgetText(); pMsg->DlgMsg = DIM_NONE; // stop base class closing it break; } else { // Close(); // End(); - base class will close break; } } } break; case DIM_CANCEL: HandleCancel(); // base class will close break; default: break; } } // Has the document been switched or closed? else if (MESSAGE_IS_A(pMessage, DocChangingMsg)) { DocChangingMsg* pMsg = (DocChangingMsg*) pMessage; if (pMsg->State == DocChangingMsg::SELCHANGED) EnableGadget(_R(IDOK), pMsg->pNewDoc != 0); } // Pass everything on to the base class . . . return DialogOp::Message(pMessage); }
MsgResult ToolnameDlg::Message(Msg* Message) { if (IS_OUR_DIALOG_MSG(Message)) { DialogMsg* Msg = (DialogMsg*)Message; BOOL EndDialog = FALSE; switch (Msg->DlgMsg) { case DIM_CREATE: SetKeyboardFocus (_R(IDC_EDITNEWBARNAME)) ; HighlightText (_R(IDC_EDITNEWBARNAME)) ; break ; case DIM_COMMIT: { // Accept all changes that the user wants to make to toolbars... BOOL VV; String_32 NewBarName = GetStringGadgetValue(_R(IDC_EDITNEWBARNAME),&VV); if(NewBarName.Length()==0) { UINT32 Number = DialogBarOp::FindUniqueBarNumber(); NewBarName._MakeMsg(TEXT("Bar #1%ld"),Number); } DialogBarOp* pNewBar = new DialogBarOp(NewBarName); if (pNewBar) { pNewBar->SetDockBarType(DOCKBAR_FLOAT); pNewBar->Create(); // The Create function sends a message which we intercept to update // the list of bars in the Toolbars... dialog. // this is very dangerous in fact it blows up.. // so I have removed it .. chris. /* if (pNewBar) { // Find toolbar dialog and close it... ToolbarDlg* pToolbarDlg = ToolbarDlg::GetToolbarDlg(); if (pToolbarDlg) { pToolbarDlg->Close(); pToolbarDlg->End(); } } */ ToolbarDlg* pToolbarDlg = ToolbarDlg::GetToolbarDlg(); pToolbarDlg->ShowToolbarList(); } EndDialog = TRUE; } break; case DIM_CANCEL: // Cancel all changes the user wants to make to toolbars... EndDialog = TRUE; break; // default: } if (EndDialog) // Dialog communication over { Close(); // Close the dialog End(); // Destroy dialog } // return (DLG_EAT_IF_HUNGRY(Msg)); } // return OK; // Pass everything on to the base-class . . . return DialogOp::Message(Message); }
MsgResult ToolbarDlg::Message(Msg* Message) { if (IS_OUR_DIALOG_MSG(Message)) { DialogMsg* Msg = (DialogMsg*)Message; BOOL EndDialog = FALSE; switch (Msg->DlgMsg) { case DIM_CANCEL: case DIM_COMMIT: // Cancel all changes the user wants to make to toolbars... EndDialog = TRUE; break; case DIM_SELECTION_CHANGED: case DIM_SELECTION_CHANGED_COMMIT: TakeToolbarDetails(); break; case DIM_LFT_BN_CLICKED: { // A control in the Toolbars... dialog has been clicked... CMainFrame* pFrame = GetMainFrame(); BOOL check; BOOL VV; switch (Msg->GadgetID) { case _R(IDC_BIGALL): // Select all the large buttons... SetLongGadgetValue(_R(IDC_BIGTOP),1); SetLongGadgetValue(_R(IDC_BIGLEFT),1); SetLongGadgetValue(_R(IDC_BIGRIGHT),1); SetLongGadgetValue(_R(IDC_BIGBOTTOM),1); SetLongGadgetValue(_R(IDC_BIGFLOAT),1); TakeToolbarDetails(); break; case _R(IDC_BIGNONE): // Deselect all the large buttons... SetLongGadgetValue(_R(IDC_BIGTOP),0); SetLongGadgetValue(_R(IDC_BIGLEFT),0); SetLongGadgetValue(_R(IDC_BIGRIGHT),0); SetLongGadgetValue(_R(IDC_BIGBOTTOM),0); SetLongGadgetValue(_R(IDC_BIGFLOAT),0); TakeToolbarDetails(); break; case _R(IDC_NEWBAR): NewToolbar(); break; case _R(IDC_BIGTOP): check = (BOOL)GetLongGadgetValue(_R(IDC_BIGTOP),0,1,_R(IDS_PHILS_EXAMPLE),&VV); pFrame->GetDockBar(DOCKBAR_TOP)->SetBigControlState(check); break; case _R(IDC_BIGLEFT): check = (BOOL)GetLongGadgetValue(_R(IDC_BIGLEFT),0,1,_R(IDS_PHILS_EXAMPLE),&VV); pFrame->GetDockBar(DOCKBAR_LEFT)->SetBigControlState(check); break; case _R(IDC_BIGRIGHT): check = (BOOL)GetLongGadgetValue(_R(IDC_BIGRIGHT),0,1,_R(IDS_PHILS_EXAMPLE),&VV); pFrame->GetDockBar(DOCKBAR_RIGHT)->SetBigControlState(check); break; case _R(IDC_BIGBOTTOM): check = (BOOL)GetLongGadgetValue(_R(IDC_BIGBOTTOM),0,1,_R(IDS_PHILS_EXAMPLE),&VV); pFrame->GetDockBar(DOCKBAR_BOTTOM)->SetBigControlState(check); break; case _R(IDC_BIGFLOAT): check = (BOOL)GetLongGadgetValue(_R(IDC_BIGFLOAT),0,1,_R(IDS_PHILS_EXAMPLE),&VV); pFrame->GetDockBar(DOCKBAR_FLOAT)->SetBigControlState(check); break; case _R(IDC_DELETEBAR): { String_32 BarName; GetSelectedBarName(&BarName); if (BarName != String_8(TEXT(""))) { // we can't delete the infoobar if(BarName == String_32(TEXT("Infobar"))) { InformWarning(_R(IDS_CANTDELETEINFOBAR),_R(IDS_OK)); break; } INT32 ButtonPressed = 1; ButtonPressed = InformWarning(_R(IDS_WARNDELETEBAR), _R(IDS_OK),_R(IDS_CANCEL)); Error::ClearError(); if (ButtonPressed == 1) DeleteSelectedBar(); } break; } case _R(IDC_RESETBARS): { INT32 ButtonPressed = 1; ButtonPressed = InformWarning(_R(IDS_WARNRESETBARS), _R(IDS_OK),_R(IDS_CANCEL)); Error::ClearError(); if(ButtonPressed == 1) { Progress::Start(FALSE); // lock the window to avoid untidy layout recalcs ::LockWindowUpdate(GetMainFrame()->GetSafeHwnd()); // tell the mainframe we are changing modes - this prevents // some unnecessary work GetMainFrame()->SetChangingMode(TRUE); // kill all bars ( except infobar at the mo..) BROADCAST_TO_CLASS(DialogMsg(NULL, DIM_BAR_DEATH, NULL ),DialogBarOp); // hide the info bar InformationBarOp::SetVisibility(FALSE,TRUE); DialogBarOp::WipeBarFiles(); DialogBarOp::LoadDefaultBars(); // force the info bar to the correct visible state InformationBarOp::SetVisibility(InformationBarOp::IsVisible(),TRUE); // All clear to Mainframe GetMainFrame()->SetChangingMode(FALSE); // Make sure everything is positioned correctly GetMainFrame()->RecalcLayout(); // Now handle the toolbar .... GetMainFrame ()->SetToolbarCreated (TRUE); GetMainFrame ()->RelocateToolbar (); // and unlock and show the window ::LockWindowUpdate(NULL); ShowToolbarList(); ShowToolbarSizes(); Progress::Stop(); } break; } } break; } } if (EndDialog) // Dialog communication over { Close(); // Close the dialog End(); // Destroy dialog return(OK); // After destroying this object, it's very dangerous to call base class! } } else if ( MESSAGE_IS_A(Message,BarMsg) ) { switch ( ((BarMsg*)Message)->Reason ) { case BAR_CHANGESTATE: // A bar simply became horizontal, vertical or floating and we don't care // about that so do nothing. break; default: // In most cases of BarMsg we want to show the user what happened... ShowToolbarList(); // Show changes in bars to user // Note: it would be more optimal to use the pointer // to the bar that comes with this message to just // alter that item in the list. break; } } return DialogOp::Message(Message); }
MsgResult RenderDemoDlg::Message(Msg* Message) { // See if it is for us if (IS_OUR_DIALOG_MSG(Message)) { // it is DialogMsg* Msg = (DialogMsg*)Message; // decide what to do switch (Msg->DlgMsg) { // Create message case DIM_CREATE : break; // Close and destroy the dialog case DIM_COMMIT : case DIM_CANCEL : { Close(); End(); break; } case DIM_LFT_BN_CLICKED : { // See which button was pressed if (Msg->GadgetID == _R(IDC_REDRAWBTN)) { // Toggle the colour ShowFirst = ShowFirst ? FALSE : TRUE; // invalidate the gadget with the picture in it InvalidateGadget(_R(IDC_REDRAW_ME)); } break; } case DIM_REDRAW : { // This is where all the redrawing is done // Which control in the window is sending the redraw message (if there are many // grdraw controls you can tell which is which from the Gadget ID if (Msg->GadgetID == _R(IDC_REDRAW_ME)) { // Draw the redraw_me control in here // Render this control RenderControl((ReDrawInfoType*) Msg->DlgMsgParam); } else // there are no other controls that should get a redraw message ever { // give out an error in debug builds, ignore in retail builds ERROR3("Got a redraw message for a control I don't know about"); break; } break; } default: break; } // Return return (DLG_EAT_IF_HUNGRY(Msg)); } return OK; }
MsgResult NativePrefsDlg::Message(Msg* Message) { if (IS_OUR_DIALOG_MSG(Message) && mpParams) { DialogMsg* Msg = (DialogMsg*)Message; MsgResult Result; // Should now handle the required messages that we respond to switch (Msg->DlgMsg) { case DIM_CREATE: { InitDialog(); } break; case DIM_COMMIT: { // (ok) accept all changes that the user has made to the settings // brackets make the ok local to this case BOOL ok; ok = CommitDialogValues (); if (ok) { // Values found ok so quit dialogue then go ahead and export if ( mpParams != NULL ) { mpParams->SetWebOk( TRUE ); // Flag ok used. } else { ERROR3 ( "mpParams is not set!" ); } } } break; case DIM_CANCEL: // Cancel all changes that the user has made to the settings if ( mpParams != NULL ) { mpParams->SetWebOk(FALSE); // Flag cancel used } else { ERROR3 ( "mpParams is not set!" ); } break; default: break; } // Allow the base class access to the message, it will do the // DLG_EAT_IF_HUNGRY(Msg) for us // Must do this before the Close and End Result = DialogOp::Message ( Message ); // The message was for our dialog box so return that we have handled it, if necessary return Result; } return DialogOp::Message(Message); }
MsgResult PrintPrefsDlg::Message(Msg* Message) { TRACEUSER( "Neville", _T("PrintPrefsDlg::Message\n")); ERROR3IF(Message == NULL,"PrintPrefsDlg::Message null message received"); // Jason - This is a message-loop lock which is used in the DIM_CREATE code to // allow the print marks manager cache print marks - this causes a lot of diocument // message broadcats and suchlike, which cause re-entrant messages to come in // here and trigger 3 billion ERROR3s. While caching the print marks, we lock this // message handler so that it just ignores all resultant broadcasts. static BOOL IgnoreAllMessages = FALSE; if (IgnoreAllMessages) return DialogTabOp::Message(Message); // Cope with messages for the dialog box if (MESSAGE_IS_A(Message,PrintMsg)) // Check for print messages { PrintMsg* pPrintMsg = (PrintMsg*)Message; if (pPrintMsg->Reason == PrintMsg::SETTINGSCHANGED) { // Tell the print layout tab about the print settings change OptionsTabs *pOptionsTabs = OptionsTabs::GetFirst(); while (pOptionsTabs != NULL) { if (pOptionsTabs->GetPageID() == _R(IDD_OPTSTAB_PRINTLAYOUT) || pOptionsTabs->GetPageID() == _R(IDD_OPTSTAB_PRINTGENERAL)) { PrintBaseTab* pBaseTab = (PrintBaseTab *) pOptionsTabs; pBaseTab->PrintSettingsChanged(); } // Get the next option's tab. pOptionsTabs = OptionsTabs::GetNext(pOptionsTabs); } } return DialogTabOp::Message(Message); } if (IS_OUR_DIALOG_MSG(Message)) { DialogMsg* Msg = (DialogMsg*)Message; MsgResult Result; // Main handler for dialog type messages BOOL EndDialog = FALSE; // TRUE if we should quit the dialog BOOL CommitValues = FALSE; // TRUE if we should commit the dialog values BOOL OldApplyNow = OptionsTabs::GetApplyNowState(); // Old ApplyNow button state // Make sure that we have set up our class variables so that the tabs know what // is the current document and spread to work on. Document *pDocument = Document::GetSelected(); OptionsTabs::SetCurrentDocAndSpread(pDocument); // Plus the current document units are correct OptionsTabs::SetUpDocUnits(); // Check if sending init/create message and if so set flag True. // If True then do not ungrey the ApplyNow button on changing messages if (Msg->DlgMsg == DIM_CREATE) { TRACEUSER( "Neville", _T("PrintPrefsDlg::Message DIM_CREATE\n")); OptionsTabs::SetInitMessageState(TRUE); } // If the message is not for the main options window then try the tab pages BOOL FoundPage = FALSE; TRACEUSER( "Neville", _T("PrintPrefsDlg::Message PageID = %d\n"),Msg->PageID); if (Msg->PageID != 0) { // Now go through all the tabs declared to the system // And see if the message is for that page or not. OptionsTabs *pOptionsTabs = OptionsTabs::GetFirst(); while (pOptionsTabs != NULL && !FoundPage) { CDlgResID PageId = pOptionsTabs->GetPageID(); if (PageId == Msg->PageID) { // Found the correct page so stop the search and send the message // to that page pOptionsTabs->HandleMsg(Msg); FoundPage = TRUE; } // Get the next option's tab. pOptionsTabs = OptionsTabs::GetNext(pOptionsTabs); } } else { // Main page window switch (Msg->DlgMsg) { case DIM_CREATE: // Creating the main dialog box { // grey out the apply now button as this should only become enabled when // we have made a change to the dialog box. OptionsTabs::SetInitMessageState(FALSE); IgnoreAllMessages = TRUE; // BLOCK { // Make sure the print marks are cached by the PMManager. This must be done now // because we want to demand-load the marks, but if we leave it any later we get // an awful lot of rather nasty problems with document messages flying around. PrintMarksMan* pMarksMan = GetApplication()->GetMarksManager(); if (pMarksMan) { pMarksMan->ConstructCache(); if (Document::GetSelected() != NULL) pMarksMan->AddDefaultMarksToDoc(Document::GetSelected()); } } IgnoreAllMessages = FALSE; OptionsTabs::SetApplyNowState(FALSE); OptionsTabs::GreyApplyNow(); // remove the apply now button as not required. CDlgResID PageID = GetCurrentPageID(); // Get currently selected Tab id TalkToPage(0); // Select the main tab HideGadget(_R(ID_APPLY_NOW), TRUE); // hide button on main tab TalkToPage(PageID); // Select the originally selected tab // Pass the message up to all the tabs in case it's of use to them OptionsTabs *pOptionsTabs = OptionsTabs::GetFirst(); while (pOptionsTabs != NULL) { if (pOptionsTabs->IsKindOf(CC_RUNTIME_CLASS(PrintSepsTab)) || // only these classes need this message pOptionsTabs->IsKindOf(CC_RUNTIME_CLASS(PrintImagesetterTab))) pOptionsTabs->HandleMsg(Msg); pOptionsTabs = OptionsTabs::GetNext(pOptionsTabs); } break; } case DIM_COMMIT: // Want to commit and quit { OptionsTabs *pOptionsTabs = OptionsTabs::GetFirst(); while (pOptionsTabs != NULL) { if (pOptionsTabs->IsKindOf(CC_RUNTIME_CLASS(PrintSepsTab)) || // only these classes need this message pOptionsTabs->IsKindOf(CC_RUNTIME_CLASS(PrintImagesetterTab))) pOptionsTabs->HandleMsg(Msg); // Get the next option's tab. pOptionsTabs = OptionsTabs::GetNext(pOptionsTabs); } OkUsed = TRUE; // Flag ok used EndDialog = TRUE; CommitValues = TRUE; } break; case DIM_SOFT_COMMIT: // Want to commit but leave the dialogue open { // Pass the message up to all the tabs in case it's of use to them OptionsTabs *pOptionsTabs = OptionsTabs::GetFirst(); while (pOptionsTabs != NULL) { if (pOptionsTabs->IsKindOf(CC_RUNTIME_CLASS(PrintSepsTab)) || // only these classes need this message pOptionsTabs->IsKindOf(CC_RUNTIME_CLASS(PrintImagesetterTab))) pOptionsTabs->HandleMsg(Msg); pOptionsTabs = OptionsTabs::GetNext(pOptionsTabs); } OkUsed = TRUE; // Flag ok used CommitValues = TRUE; } break; case DIM_CANCEL: // Want to quit { // Pass the message up to all the tabs in case it's of use to them OptionsTabs *pOptionsTabs = OptionsTabs::GetFirst(); while (pOptionsTabs != NULL) { if (pOptionsTabs->IsKindOf(CC_RUNTIME_CLASS(PrintSepsTab)) || // only these classes need this message pOptionsTabs->IsKindOf(CC_RUNTIME_CLASS(PrintImagesetterTab))) pOptionsTabs->HandleMsg(Msg); pOptionsTabs = OptionsTabs::GetNext(pOptionsTabs); } } OkUsed = FALSE; // Flag ok used EndDialog = TRUE; break; default: break; } } // Commit values here if (CommitValues) { BOOL ok = CommitDialogValues(); // Only unset EndDialog as in SOFT_COMMIT case we do not want to end the // Operation and hence close the dialog box if (!ok) { Msg->DlgMsg = DIM_NONE; // prevent baseclass from removing the dialog EndDialog = FALSE; // Values not correct so do not allow exit } } if ( !OldApplyNow && OptionsTabs::GetApplyNowState() && !EndDialog && !OptionsTabs::GetInitMessageState() ) { // Check for a change from apply now being False to it becoming // True as an item has been changed. OptionsTabs::UngreyApplyNow(); } if ( OptionsTabs::GetApplyNowState() && (Msg->DlgMsg == DIM_SOFT_COMMIT) && !EndDialog && !OptionsTabs::GetInitMessageState() ) { // Check for an apply now (DIM_SOFT_COMMIT) being used and the // apply being True, should always be the case, so that we can reset // the grey state to False as we are in an unchanged state. OptionsTabs::SetApplyNowState(FALSE); OptionsTabs::GreyApplyNow(); } // End dialog here if (EndDialog) { // Grey all the tabs to remove the Indexed colour in use error OptionsTabs::SetCurrentDocAndSpread(NULL); OptionsTabs *pOptionsTabs = OptionsTabs::GetFirst(); while (pOptionsTabs != NULL) { if (pOptionsTabs->IsPrintingOption()) pOptionsTabs->GreySection(); pOptionsTabs = OptionsTabs::GetNext(pOptionsTabs); } // Note this destroys "this". Hence don't call the base class Close(); // Hide the dialog box End(); // Finish the operation // Make sure that we remove our options tabs link to the dialog box class // as the dialog will now be destroyed OptionsTabs::pPrefsDlg = NULL; return OK; } // Allow the base class access to the message, it will do the // DLG_EAT_IF_HUNGRY(Msg) for us // Must do this before the Close and End Result = DialogTabOp::Message(Message); // Check if have been sending an init/create message and if so then set flag False. // Only do this in the init/create case as we might be sent one of these and then // be sent other messages whilst in the middle of the init/create message such as // text changing messages. if (Msg->DlgMsg == DIM_CREATE) OptionsTabs::SetInitMessageState(FALSE); // The message was for our dialog box so return that we have handled it, if necessary //return (DLG_EAT_IF_HUNGRY(Msg)); return Result; } // If nobody above has processed the message, then pass it around all the tabs in // case it's of use to them. OptionsTabs *pOptionsTabs = OptionsTabs::GetFirst(); while (pOptionsTabs != NULL) { pOptionsTabs->Message(Message); pOptionsTabs = OptionsTabs::GetNext(pOptionsTabs); } return DialogTabOp::Message(Message); }