Example #1
0
void CInitBrushNameDlg::InitGadgetText(String_32* pString, BOOL resizeDialog /*= TRUE*/)
{
	if (pString != NULL)
		m_strSuggest = *pString;
	SetStringGadgetValue(_R(IDC_EDITBRUSHNAME), *GetSuggestion(&m_strSuggest));

	// change the dialog title to "Enter brush name:"
	// Errr, NO!  This is very bad for translation!
//	String_256 Name = TEXT("Create new brush:");
//	SetTitlebarName(&Name);

	// Show the help button
	HideGadget(_R(ID_CC_HELP_BUTTON), FALSE);

	// show the group info text
	SetStringGadgetValue(_R(IDC_STATICBRUSHGROUP), _R(IDS_BRUSHGROUP));
	HideGadget(_R(IDC_STATICBRUSHGROUP), FALSE);

	
	
	HighlightText(_R(IDC_EDITBRUSHNAME));
	SetKeyboardFocus(_R(IDC_EDITBRUSHNAME));


}
Example #2
0
void CNameBrushDlg::InitGadgetText(String_32* pString, BOOL resizeDialog /*= TRUE*/)
{
	if (pString != NULL)
		m_strSuggest = *pString;
	SetStringGadgetValue(_R(IDC_EDITBRUSHNAME), *GetSuggestion(&m_strSuggest));
	HighlightText(_R(IDC_EDITBRUSHNAME));
	SetKeyboardFocus(_R(IDC_EDITBRUSHNAME));

	// change the dialog title to "Enter brush name:"
	String_256 Name = TEXT("Enter brush name:");
	SetTitlebarName(&Name);

	if (resizeDialog)
	{
		// what we want to do is shrink the dialog by the size of the label and then hide it
		RECT LabelRect;
		GetGadgetPosition(_R(IDC_STATICBRUSHGROUP), &LabelRect);
		
		// hide the label
		HideGadget(_R(IDC_STATICBRUSHGROUP), TRUE);

		// get the size of this dialog
		RECT DialogRect;
		GetWindowPosition(&DialogRect);
		
		// subtract the size of the label
		INT32 Subtract = LabelRect.bottom - LabelRect.top;
		DialogRect.bottom -= Subtract;

		// We want to move up the buttons
		RECT OkRect;
		if (GetGadgetPosition(_R(IDOK), &OkRect))
		{
			OkRect.top -= Subtract;
			OkRect.bottom -= Subtract;
			INT32 Width = OkRect.right - OkRect.left;
			Width = (Width * 2) / 3;
			OkRect.left += Width ;
			OkRect.right += Width;
			SetGadgetPosition(_R(IDOK), OkRect);
		}

		RECT CancelRect;
		if (GetGadgetPosition(_R(IDCANCEL), &CancelRect))
		{
			CancelRect.top -= Subtract;
			CancelRect.bottom -= Subtract;
			INT32 Width = CancelRect.right - CancelRect.left;
			Width = (Width * 2) / 3;
			CancelRect.left += Width;
			CancelRect.right += Width;
			SetGadgetPosition(_R(IDCANCEL), CancelRect);
		}

		// Reset the window
		SetWindowPosition(DialogRect);
		
		// Hide the help button
		HideGadget(_R(ID_CC_HELP_BUTTON), TRUE);
	}
}
Example #3
0
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);
}