BOOL PlugInsTab::CommitSection() { ERROR2IF(pPrefsDlg == NULL,FALSE,"PlugInsTab::CommitSection called with no dialog pointer"); BOOL ok = pPrefsDlg->TalkToPage(_R(IDD_OPTSTAB_PLUGINS)); // The units page identifier if (!ok) return TRUE; // Talk to page failed to return now ok = CommitDialogValues(); 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); }