FX_FLOAT CPDF_VariableText::GetAutoFontSize() {
  int32_t nTotal = sizeof(gFontSizeSteps) / sizeof(uint8_t);
  if (IsMultiLine())
    nTotal /= 4;
  if (nTotal <= 0)
    return 0;
  if (GetPlateWidth() <= 0)
    return 0;

  int32_t nLeft = 0;
  int32_t nRight = nTotal - 1;
  int32_t nMid = nTotal / 2;
  while (nLeft <= nRight) {
    if (IsBigger(gFontSizeSteps[nMid])) {
      nRight = nMid - 1;
      nMid = (nLeft + nRight) / 2;
      continue;
    } else {
      nLeft = nMid + 1;
      nMid = (nLeft + nRight) / 2;
      continue;
    }
  }
  return (FX_FLOAT)gFontSizeSteps[nMid];
}
示例#2
0
bool wxTextCtrl::AcceptsFocus() const
{
    // we don't want focus if we can't be edited unless we're a multiline
    // control because then it might be still nice to get focus from keyboard
    // to be able to scroll it without mouse
    return (IsEditable() || IsMultiLine()) && wxControl::AcceptsFocus();
}
示例#3
0
void wxTextCtrl::SetInsertionPoint( long pos )
{
    wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );

    if ( IsMultiLine() )
    {
        gtk_signal_disconnect_by_func( GTK_OBJECT(m_text),
                                       GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);

        /* we fake a set_point by inserting and deleting. as the user
           isn't supposed to get to know about this non-sense, we
           disconnect so that no events are sent to the user program. */

        gint tmp = (gint)pos;
        gtk_editable_insert_text( GTK_EDITABLE(m_text), " ", 1, &tmp );
        gtk_editable_delete_text( GTK_EDITABLE(m_text), tmp-1, tmp );

        gtk_signal_connect( GTK_OBJECT(m_text), "changed",
                            GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);

        // bring editable's cursor uptodate. Bug in GTK.
        SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
    }
    else
    {
        gtk_entry_set_position( GTK_ENTRY(m_text), (int)pos );

        // Bring editable's cursor uptodate. Bug in GTK.
        SET_EDITABLE_POS(m_text, (guint32)pos);
    }
}
示例#4
0
GtkAdjustment *wxTextCtrl::GetVAdj() const
{
    if ( !IsMultiLine() )
        return NULL;

    return GTK_TEXT(m_text)->vadj;
}
示例#5
0
//#warning Remove this when wxMAC has been fixed.
// https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1189859&group_id=9863
void CMuleTextCtrl::Clear()
{
	if (IsMultiLine()) {
		wxFont font = GetFont();
		wxTextCtrl::Clear();
		SetFont(font);
	} else {
		wxTextCtrl::Clear();
	}
}
示例#6
0
CString	CGumpStatic::GetString(BOOL bBegin) const
{
	CString ret, str;
	if (bBegin) {
		ret += CGumpEntity::GetString(TRUE) + "\n";
		str.Format(" <text font='%d' hue='0x%X' align='%s' multiline='%d'>%s</text>", 
			GetFontId(), GetHueId(), GfxAligntoText(m_textAlign), IsMultiLine(), GetTitle());
		ret += str;
	} else {
		ret += CGumpEntity::GetString(FALSE);
	}
	
	return ret;
}
示例#7
0
void CGumpStatic::Draw( CDC* dc, CRect rect )
{
	dc->SelectObject( CStdGrfx::dialogBrush() );
	dc->SelectObject( CStdGrfx::dialogPen() );

	CGumpEditorDoc* pDoc = GfxGetGumpDocument();
	ASSERT(pDoc);

	//dc->Rectangle( rect );

	//LOGFONT lf;
	//CFont font;
	//GetFont( lf );
	//// MS Sans Serif will not scale below 8 pts
	//if( GetZoom() < 1 )
	//	lstrcpy( lf.lfFaceName, _T( "Arial" ) );

	//
	//font.CreateFontIndirect( &lf );

	CFont* pFont = pDoc->GetFont(m_fontId);
	CFont* pOld = dc->SelectObject(pFont);

	CString strText = GetTitle();
	UINT align[] = { TA_LEFT, DT_CENTER, TA_RIGHT };
	UINT format =  DT_TOP | align[m_textAlign];
	
	if (IsMultiLine()) {
		strText = GfxFormatText(strText);
	}
	else {
		format |= DT_SINGLELINE;
	}

	int oldMode = dc->SetBkMode( TRANSPARENT );
	
	COLORREF color = pDoc->GetHueColor(m_hueId, m_fontId);
	COLORREF oldColor = dc->SetTextColor(color);
	
	dc->DrawText( strText, rect, format);
	
	dc->SetBkMode(oldMode);
	dc->SetTextColor(oldColor);

	dc->SelectStockObject( ANSI_VAR_FONT );
	dc->SelectStockObject( BLACK_PEN );
	dc->SelectStockObject( WHITE_BRUSH );
}
void wxTextCtrl::OnChar(wxKeyEvent& event)
{
    int key = event.GetKeyCode() ;
    bool eat_key = false ;
    long from, to;

    if ( !IsEditable() && !event.IsKeyInCategory(WXK_CATEGORY_ARROW | WXK_CATEGORY_TAB) &&
        !( key == WXK_RETURN && ( (m_windowStyle & wxTE_PROCESS_ENTER) || (m_windowStyle & wxTE_MULTILINE) ) )
//        && key != WXK_PAGEUP && key != WXK_PAGEDOWN && key != WXK_HOME && key != WXK_END
        )
    {
        // eat it
        return ;
    }

    if ( !GetTextPeer()->CanClipMaxLength() )
    {
        // Check if we have reached the max # of chars (if it is set), but still
        // allow navigation and deletion
        GetSelection( &from, &to );
        if ( !IsMultiLine() && m_maxLength && GetValue().length() >= m_maxLength &&
            !event.IsKeyInCategory(WXK_CATEGORY_ARROW | WXK_CATEGORY_TAB | WXK_CATEGORY_CUT) &&
            !( key == WXK_RETURN && (m_windowStyle & wxTE_PROCESS_ENTER) ) &&
            from == to )
        {
            // eat it, we don't want to add more than allowed # of characters

            // TODO: generate EVT_TEXT_MAXLEN()
            return;
        }
    }

    // assume that any key not processed yet is going to modify the control
    m_dirty = true;

    switch ( key )
    {
        case WXK_RETURN:
            if (m_windowStyle & wxTE_PROCESS_ENTER)
            {
                wxCommandEvent event(wxEVT_TEXT_ENTER, m_windowId);
                event.SetEventObject( this );
                event.SetString( GetValue() );
                if ( HandleWindowEvent(event) )
                    return;
            }

            if ( !(m_windowStyle & wxTE_MULTILINE) )
            {
                wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
                if ( tlw && tlw->GetDefaultItem() )
                {
                    wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton);
                    if ( def && def->IsEnabled() )
                    {
                        wxCommandEvent event(wxEVT_BUTTON, def->GetId() );
                        event.SetEventObject(def);
                        def->Command(event);

                        return ;
                    }
                }

                // this will make wxWidgets eat the ENTER key so that
                // we actually prevent line wrapping in a single line text control
                eat_key = true;
            }
            break;

        case WXK_TAB:
            if ( !(m_windowStyle & wxTE_PROCESS_TAB))
            {
                int flags = 0;
                if (!event.ShiftDown())
                    flags |= wxNavigationKeyEvent::IsForward ;
                if (event.ControlDown())
                    flags |= wxNavigationKeyEvent::WinChange ;
                Navigate(flags);

                return;
            }
            else
            {
                // This is necessary (don't know why);
                // otherwise the tab will not be inserted.
                WriteText(wxT("\t"));
                eat_key = true;
            }
            break;

        default:
            break;
    }

    if (!eat_key)
    {
        // perform keystroke handling
        event.Skip(true) ;
    }

    // osx_cocoa sends its event upon insertText
#if wxOSX_USE_CARBON
    if ( ( key >= 0x20 && key < WXK_START ) ||
         ( key >= WXK_NUMPAD0 && key <= WXK_DIVIDE ) ||
         key == WXK_RETURN ||
         key == WXK_DELETE ||
         key == WXK_BACK)
    {
        wxCommandEvent event1(wxEVT_TEXT, m_windowId);
        event1.SetEventObject( this );
        wxPostEvent( GetEventHandler(), event1 );
    }
#endif
}
示例#9
0
WXWidget wxTextCtrl::GetTopWidget() const
{
    return IsMultiLine() ? (WXWidget)XtParent((Widget)m_mainWidget)
                         : m_mainWidget;
}
示例#10
0
CDiagramEntity* CGumpStatic::Clone()
{
	CGumpStatic* obj = new CGumpStatic(GetHueId(), GetFontId(), GetTextAlign(), IsMultiLine());
	obj->Copy( this );
	return obj;
}