Beispiel #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));


}
Beispiel #2
0
void 
CEditCell::OnChar (UINT nChar, UINT nRepCnt, UINT nFlags)
{
    BOOL Shift = GetKeyState(VK_SHIFT) < 0;
    switch (nChar)
    {
		case VK_ESCAPE :
		{
			if (Shift)
				// Shift+Escape -> disable autocomplete
				m_DoSuggest = FALSE;
			else {
				m_bEscape = TRUE;
				GetParent()->SetFocus();
			}
			return;
		}
		case VK_RETURN :
		{
			SetListText();
			if (m_SubItem == 0)
				m_pListCtrl->EditSubItem (m_Item, 1);
			else
				m_pListCtrl->EditSubItem (m_Item + 1, 0);
			return;
		}
		case VK_TAB :
		{
			if (Shift)
			{
				if (m_SubItem > 0)
					m_pListCtrl->EditSubItem (m_Item, m_SubItem - 1);
				else
				{
					if (m_Item > 0)
						m_pListCtrl->EditSubItem (m_Item - 1, 2);
				}
			}
			else
			{
				if (m_SubItem == 0)
					m_pListCtrl->EditSubItem (m_Item, 1);
				else if (m_SubItem < 2)
					m_pListCtrl->EditSubItem (m_Item, m_SubItem + 1);				
				else
					m_pListCtrl->EditSubItem (m_Item + 1, 0);
			}
			return;
		}
    }

    CEdit::OnChar (nChar, nRepCnt, nFlags);

    // Get text
    CString Text;
    GetWindowText(Text);

	// Make some suggestion
	if (m_DoSuggest && nChar != 8 && m_AutoComplete != NULL) {
		int iSelStart;
		int iSelEnd;
		GetSel(iSelStart, iSelEnd);
		CString sugg = GetSuggestion(Text);
		if (!sugg.IsEmpty()) {
			Text = sugg;
			SetWindowText(Text);
			SetSel(iSelStart, Text.GetLength());
		}
	}

    // Resize edit control if needed

    CWindowDC DC (this);
    CFont *pFont = GetParent()->GetFont();
    CFont *pFontDC = DC.SelectObject (pFont);
    CSize Size = DC.GetTextExtent (Text);
    DC.SelectObject (pFontDC);
    Size.cx += 5;			   	// add some extra buffer

    // Get client rect
    CRect Rect, ParentRect;
    GetClientRect (&Rect);
    GetParent()->GetClientRect (&ParentRect);

    // Transform rect to parent coordinates
    ClientToScreen (&Rect);
    GetParent()->ScreenToClient (&Rect);

    // Check whether control needs to be resized and whether there is space to grow
    if (Size.cx > Rect.Width())
    {
		if (Size.cx + Rect.left < ParentRect.right )
			Rect.right = Rect.left + Size.cx;
		else
			Rect.right = ParentRect.right;
		MoveWindow (&Rect);
    }
}
Beispiel #3
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);
	}
}