示例#1
0
wxSize wxListBox::DoGetBestClientSize() const
{
    // find the widest string
    int wLine;
    int wListbox = 0;
    for (unsigned int i = 0; i < m_noItems; i++)
    {
        wxString str(GetString(i));
        GetTextExtent(str, &wLine, NULL);
        if ( wLine > wListbox )
            wListbox = wLine;
    }

    // give it some reasonable default value if there are no strings in the
    // list
    if ( wListbox == 0 )
        wListbox = 6*GetCharWidth();

    // the listbox should be slightly larger than the widest string
    wListbox += 3*GetCharWidth();

    // add room for the scrollbar
    wListbox += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);

    // don't make the listbox too tall (limit height to 10 items) but don't
    // make it too small neither
    int hListbox = SendMessage(GetHwnd(), LB_GETITEMHEIGHT, 0, 0)*
                    wxMin(wxMax(m_noItems, 3), 10);

    return wxSize(wListbox, hListbox);
}
示例#2
0
文件: text.cpp 项目: Tellus/colobot
void CText::DrawString(const std::string &text, std::vector<FontMetaChar>::iterator format,
                       std::vector<FontMetaChar>::iterator end,
                       float size, Math::Point pos, float width, int eol, Color color)
{
    m_engine->SetState(ENG_RSTATE_TEXT);

    float start = pos.x;

    unsigned int fmtIndex = 0;

    std::vector<UTF8Char> chars;
    StringToUTFCharList(text, chars, format, end);
    for (auto it = chars.begin(); it != chars.end(); ++it)
    {
        FontType font = FONT_COLOBOT;
        if (format + fmtIndex != end)
            font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);

        UTF8Char ch = *it;

        float offset = pos.x - start;
        float cw = GetCharWidth(ch, font, size, offset);
        if (offset + cw > width)  // exceeds the maximum width?
        {
            ch = TranslateSpecialChar(CHAR_SKIP_RIGHT);
            cw = GetCharWidth(ch, font, size, offset);
            pos.x = start + width - cw;
            color = Color(1.0f, 0.0f, 0.0f);
            DrawCharAndAdjustPos(ch, font, size, pos, color);
            break;
        }

        FontHighlight hl = static_cast<FontHighlight>(format[fmtIndex] & FONT_MASK_HIGHLIGHT);
        if (hl != FONT_HIGHLIGHT_NONE)
        {
            Math::Point charSize;
            charSize.x = GetCharWidth(ch, font, size, offset);
            charSize.y = GetHeight(font, size);
            DrawHighlight(hl, pos, charSize);
        }

        DrawCharAndAdjustPos(ch, font, size, pos, color);

        // increment fmtIndex for each byte in multibyte character
        if ( ch.c1 != 0 )
            fmtIndex++;
        if ( ch.c2 != 0 )
            fmtIndex++;
        if ( ch.c3 != 0 )
            fmtIndex++;
    }

    if (eol != 0)
    {
        FontType font = FONT_COLOBOT;
        UTF8Char ch = TranslateSpecialChar(eol);
        color = Color(1.0f, 0.0f, 0.0f);
        DrawCharAndAdjustPos(ch, font, size, pos, color);
    }
}
示例#3
0
void WindowSetCursor (PCONINFO con, int x, int y, bool IsKanji)
{
    if (IsKanji)
        ChangeCaretSize (con->hWnd, GetCCharWidth (), GetCharHeight ());
    else
        ChangeCaretSize (con->hWnd, GetCharWidth (), GetCharHeight ());
    SetCaretPos (con->hWnd, x * GetCharWidth (), y * GetCharHeight ());
}
示例#4
0
int FPDFText_ProcessInterObj(const CPDF_TextObject* pPrevObj, const CPDF_TextObject* pObj)
{
    if(FPDFText_IsSameTextObject(pPrevObj, pObj)) {
        return -1;
    }
    CPDF_TextObjectItem item;
    int nItem = pPrevObj->CountItems();
    pPrevObj->GetItemInfo(nItem - 1, &item);
    FX_WCHAR preChar = 0, curChar = 0;
    CFX_WideString wstr = pPrevObj->GetFont()->UnicodeFromCharCode(item.m_CharCode);
    if(wstr.GetLength()) {
        preChar = wstr.GetAt(0);
    }
    FX_FLOAT last_pos = item.m_OriginX;
    int nLastWidth = GetCharWidth(item.m_CharCode, pPrevObj->GetFont());
    FX_FLOAT last_width = nLastWidth * pPrevObj->GetFontSize() / 1000;
    last_width = FXSYS_fabs(last_width);
    pObj->GetItemInfo(0, &item);
    wstr = pObj->GetFont()->UnicodeFromCharCode(item.m_CharCode);
    if(wstr.GetLength()) {
        curChar = wstr.GetAt(0);
    }
    int nThisWidth = GetCharWidth(item.m_CharCode, pObj->GetFont());
    FX_FLOAT this_width = nThisWidth * pObj->GetFontSize() / 1000;
    this_width = FXSYS_fabs(this_width);
    FX_FLOAT threshold = last_width > this_width ? last_width / 4 : this_width / 4;
    CFX_AffineMatrix prev_matrix, prev_reverse;
    pPrevObj->GetTextMatrix(&prev_matrix);
    prev_reverse.SetReverse(prev_matrix);
    FX_FLOAT x = pObj->GetPosX(), y = pObj->GetPosY();
    prev_reverse.Transform(x, y);
    if (FXSYS_fabs(y) > threshold * 2) {
        return 2;
    }
    threshold = (FX_FLOAT)(nLastWidth > nThisWidth ? nLastWidth : nThisWidth);
    threshold = threshold > 400 ? (threshold < 700 ? threshold / 4 :  threshold / 5) : (threshold / 2);
    threshold *= nLastWidth > nThisWidth ? FXSYS_fabs(pPrevObj->GetFontSize()) : FXSYS_fabs(pObj->GetFontSize());
    threshold /= 1000;
    if (FXSYS_fabs(last_pos + last_width - x) > threshold && curChar != L' ' && preChar != L' ')
        if(curChar != L' ' && preChar != L' ') {
            if((x - last_pos - last_width) > threshold || (last_pos - x - last_width) > threshold) {
                return 1;
            }
            if(x < 0 && (last_pos - x - last_width) > threshold) {
                return 1;
            }
            if((x - last_pos - last_width) > this_width || (x - last_pos - this_width) > last_width ) {
                return 1;
            }
        }
    if(last_pos + last_width > x + this_width && curChar == L' ') {
        return 3;
    }
    return 0;
}
RECT CBitmapFont::CalculateRect(int id)
{
	RECT rCell;
	rCell.left	= (id % GetNumCols()) * GetCharWidth();
	rCell.top	= (id / GetNumCols()) * GetCharHeight();

	rCell.right		= rCell.left + GetCharWidth();
	rCell.bottom	= rCell.top + GetCharHeight();

	return rCell;
}
示例#6
0
Optional<PAGECHAR_INFO> CPDF_TextPage::GenerateCharInfo(wchar_t unicode) {
  const PAGECHAR_INFO* pPrevCharInfo = GetPrevCharInfo();
  if (!pPrevCharInfo)
    return {};

  PAGECHAR_INFO info;
  info.m_Index = m_TextBuf.GetLength();
  info.m_CharCode = CPDF_Font::kInvalidCharCode;
  info.m_Unicode = unicode;
  info.m_Flag = FPDFTEXT_CHAR_GENERATED;

  int preWidth = 0;
  if (pPrevCharInfo->m_pTextObj && pPrevCharInfo->m_CharCode != -1) {
    preWidth = GetCharWidth(pPrevCharInfo->m_CharCode,
                            pPrevCharInfo->m_pTextObj->GetFont());
  }

  float fFontSize = pPrevCharInfo->m_pTextObj
                        ? pPrevCharInfo->m_pTextObj->GetFontSize()
                        : pPrevCharInfo->m_CharBox.Height();
  if (!fFontSize)
    fFontSize = kDefaultFontSize;

  info.m_Origin =
      CFX_PointF(pPrevCharInfo->m_Origin.x + preWidth * (fFontSize) / 1000,
                 pPrevCharInfo->m_Origin.y);
  info.m_CharBox = CFX_FloatRect(info.m_Origin.x, info.m_Origin.y,
                                 info.m_Origin.x, info.m_Origin.y);
  return info;
}
示例#7
0
wxSize wxRadioBox::GetMaxButtonSize() const
{
    // We use GetCheckBox() because there is no dedicated GetRadioBox() method
    // in wxRendererNative, but check and radio boxes are usually of the same
    // size anyhow. We also add half a character of width to account for the
    // extra space after the radio box itself.
    const int radioWidth =
        wxRendererNative::Get().GetCheckBoxSize(
            reinterpret_cast<wxWindow*>(const_cast<wxRadioBox*>(this))).x
        + GetCharWidth() / 2;

    // calculate the max button size
    int widthMax = 0,
        heightMax = 0;
    const unsigned int count = GetCount();
    for ( unsigned int i = 0 ; i < count; i++ )
    {
        int width, height;
        GetTextExtent(wxGetWindowText((*m_radioButtons)[i]), &width, &height);

        // adjust the size to take into account the radio box itself
        width += radioWidth;
        height *= 3;
        height /= 2;

        if ( widthMax < width )
            widthMax = width;
        if ( heightMax < height )
            heightMax = height;
    }

    return wxSize(widthMax, heightMax);
}
示例#8
0
PathProp::PathProp( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos,
        const wxSize& size, long style )
{
    m_opList = NULL;
    m_nSelected = 0;
    m_pEnroutePoint = NULL;
    m_bStartNow = false;
    m_pPath = NULL;

    m_pEnroutePoint = NULL;
    m_bStartNow = false;
#ifdef __WXOSX__
    style |= wxSTAY_ON_TOP;
#endif

    SetExtraStyle( GetExtraStyle() | wxWS_EX_BLOCK_EVENTS );
    wxDialog::Create( parent, id, caption, pos, size, style );

    wxFont *qFont = OCPNGetFont(_("Dialog"), 0);
    SetFont( *qFont );
        
    CreateControls();

    //  Make an estimate of the dialog size, without scrollbars showing
    wxSize esize;
    esize.x = GetCharWidth() * 110;
    esize.y = GetCharHeight() * 40;
    SetSize( esize );
    Centre();
}
示例#9
0
wxSize CFontNamesComboBox::DoGetBestSize() const
{
    int hBitmap = 0;
    int wChoice = 0;
    int hChoice;
    const unsigned int nItems = GetCount();
    for( unsigned int i = 0; i < nItems; i++ )
    {
        int wLine;
        GetTextExtent( GetString( i ), &wLine, NULL );
        if( wLine > wChoice )
            wChoice = wLine;
    }
    if( wChoice == 0 )
        wChoice = 100;
    wChoice += 5 * GetCharWidth();
    if( m_bmp1 )
    {
        wChoice += m_bmp1->GetWidth();
        hBitmap = m_bmp1->GetHeight();
    }
    int cx, cy;
    wxGetCharSize( GetHWND(), &cx, &cy, GetFont() );
    if( hBitmap > cy )
        cy = hBitmap;
    int hItem = SendMessage( GetHwnd(), CB_GETITEMHEIGHT, (WPARAM) -1, 0 );
    if( hItem > cy )
        hItem = cy;
    SendMessage( GetHwnd(), CB_SETITEMHEIGHT, (WPARAM) -1, hItem );
    hChoice = ( EDIT_HEIGHT_FROM_CHAR_HEIGHT( cy ) * 6 ) + hItem - 6;
    wxSize best( wChoice, hChoice );
    CacheBestSize( best );
    return best;
}
示例#10
0
void AISTargetListDialog::RecalculateSize()
{
    if(g_bresponsive){
        //  Make an estimate of the dialog size
        
        wxSize esize;
        esize.x = GetCharWidth() * 110;
        esize.y = GetCharHeight() * 40;
        
        wxSize dsize = gFrame->GetClientSize();
        esize.y = wxMin(esize.y, dsize.y - (4 * GetCharHeight()));
        esize.x = wxMin(esize.x, dsize.x - (2 * GetCharHeight()));
        SetClientSize(esize);
        
        wxSize fsize = GetSize();
        fsize.y = wxMin(fsize.y, dsize.y - (2 * GetCharHeight()));
        fsize.x = wxMin(fsize.x, dsize.x - (2 * GetCharHeight()));
        SetSize(fsize);
        
        if( m_pAuiManager ){
            wxAuiPaneInfo &pane = m_pAuiManager->GetPane(_T("AISTargetList"));
        
            if(pane.IsOk()){
                pane.FloatingSize(fsize.x, fsize.y);
                wxPoint pos = gFrame->GetScreenPosition();
                pane.FloatingPosition(pos.x + (dsize.x - fsize.x)/2, pos.y + (dsize.y - fsize.y)/2);
            }
            
            m_pAuiManager->Update();
        }
        
    }
    
}
示例#11
0
wxSize wxRadioButton::DoGetBestSize() const
{
    static int s_radioSize = 0;

    if ( !s_radioSize )
    {
        wxScreenDC dc;
        dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));

        s_radioSize = dc.GetCharHeight();
    }

    wxString str = GetLabel();

    int wRadio, hRadio;
    if ( !str.empty() )
    {
        GetTextExtent(GetLabelText(str), &wRadio, &hRadio);
        wRadio += s_radioSize + GetCharWidth();

        if ( hRadio < s_radioSize )
            hRadio = s_radioSize;
    }
    else
    {
        wRadio = s_radioSize;
        hRadio = s_radioSize;
    }

    wxSize best(wRadio, hRadio);
    CacheBestSize(best);
    return best;
}
示例#12
0
文件: trace.c 项目: mingpen/OpenNT
BOOL far pascal zGetCharWidth( HDC pp1, UINT pp2, UINT pp3, LPINT pp4 )
{
    BOOL r;

    SaveRegs();
    /*
    ** Log IN Parameters (No Create/Destroy Checking Yet!)
    */
    LogIn( (LPSTR)"APICALL:GetCharWidth HDC+UINT+UINT++",
        pp1, pp2, pp3, (short)0 );

    /*
    ** Call the API!
    */
    RestoreRegs();
    GrovelDS();
    r = GetCharWidth(pp1,pp2,pp3,pp4);
    UnGrovelDS();
    SaveRegs();
    /*
    ** Log Return Code & OUT Parameters (No Create/Destroy Checking Yet!)
    */
    LogOut( (LPSTR)"APIRET:GetCharWidth BOOL++++ARRAYINT+",
        r, (short)0, (short)0, (short)0, pp4, 1 + pp3 - pp2 );

    RestoreRegs();
    return( r );
}
示例#13
0
wxSize wxChoice::DoGetBestSize() const
{
    // find the widest string
    int wChoice = 0;
    const unsigned int nItems = GetCount();
    for ( unsigned int i = 0; i < nItems; i++ )
    {
        int wLine;
        GetTextExtent(GetString(i), &wLine, NULL);
        if ( wLine > wChoice )
            wChoice = wLine;
    }

    // give it some reasonable default value if there are no strings in the
    // list
    if ( wChoice == 0 )
        wChoice = 100;

    // the combobox should be slightly larger than the widest string
    wChoice += 5*GetCharWidth();

    wxSize best(wChoice, EDIT_HEIGHT_FROM_CHAR_HEIGHT(GetCharHeight()));
    CacheBestSize(best);
    return best;
}
示例#14
0
static void _InsertWidthArray(HDC hDC,
                              int start,
                              int end,
                              CPDF_Array* pWidthArray) {
  int size = end - start + 1;
  int* widths = FX_Alloc(int, size);
  GetCharWidth(hDC, start, end, widths);
  int i;
  for (i = 1; i < size; i++)
    if (widths[i] != *widths) {
      break;
    }
  if (i == size) {
    int first = pWidthArray->GetInteger(pWidthArray->GetCount() - 1);
    pWidthArray->AddInteger(first + size - 1);
    pWidthArray->AddInteger(*widths);
  } else {
    CPDF_Array* pWidthArray1 = new CPDF_Array;
    pWidthArray->Add(pWidthArray1);
    for (i = 0; i < size; i++) {
      pWidthArray1->AddInteger(widths[i]);
    }
  }
  FX_Free(widths);
}
示例#15
0
文件: text.cpp 项目: Tellus/colobot
int CText::Detect(const std::string &text, FontType font, float size, float offset)
{
    assert(font != FONT_BUTTON);

    float pos = 0.0f;
    unsigned int index = 0;
    while (index < text.length())
    {
        UTF8Char ch;

        int len = StrUtils::Utf8CharSizeAt(text, index);
        if (len >= 1)
            ch.c1 = text[index];
        if (len >= 2)
            ch.c2 = text[index+1];
        if (len >= 3)
            ch.c3 = text[index+2];

        index += len;

        if (ch.c1 == '\n')
            return index;

        float width = GetCharWidth(ch, font, size, pos);
        if (offset <= pos + width/2.0f)
            return index;

        pos += width;
    }

    return index;
}
示例#16
0
wxSize wxListBox::DoGetBestClientSize() const
{
    wxCoord width = 0,
            height = 0;

    size_t count = m_strings->GetCount();
    for ( size_t n = 0; n < count; n++ )
    {
        wxCoord w,h;
        GetTextExtent(this->GetString(n), &w, &h);

        if ( w > width )
            width = w;
        if ( h > height )
            height = h;
    }

    // if the listbox is empty, still give it some non zero (even if
    // arbitrary) size - otherwise, leave small margin around the strings
    if ( !width )
        width = 100;
    else
        width += 3*GetCharWidth();

    if ( !height )
        height = GetCharHeight();

    // we need the height of the entire listbox, not just of one line
    height *= wxMax(count, 7);

    return wxSize(width, height);
}
示例#17
0
wxSize wxRadioBox::GetTotalButtonSize( const wxSize& rSizeBtn ) const
{
    int    nCx1;
    int    nCy1;
    int    nHeight;
    int    nWidth;
    int    nWidthLabel = 0;

    nCx1 = GetCharWidth();
    nCy1 = GetCharHeight();
    nHeight = GetRowCount() * rSizeBtn.y + (2 * nCy1);
    nWidth  = GetColumnCount() * (rSizeBtn.x + nCx1) + nCx1;

    //
    // And also wide enough for its label
    //
    wxString sStr = wxGetWindowText(GetHwnd());
    if (!sStr.empty())
    {
        GetTextExtent( sStr
                      ,&nWidthLabel
                      ,NULL
                     );
        nWidthLabel += 2*nCx1;
    }
    if (nWidthLabel > nWidth)
        nWidth = nWidthLabel;

    wxSize total( nWidth, nHeight );
    return total;
} // end of wxRadioBox::GetTotalButtonSize
示例#18
0
文件: text.cpp 项目: Tellus/colobot
float CText::GetStringWidth(const std::string &text,
                            std::vector<FontMetaChar>::iterator format,
                            std::vector<FontMetaChar>::iterator end, float size)
{
    float width = 0.0f;
    unsigned int index = 0;
    unsigned int fmtIndex = 0;
    while (index < text.length())
    {
        FontType font = FONT_COLOBOT;
        if (format + fmtIndex != end)
            font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);

        UTF8Char ch;

        int len = StrUtils::Utf8CharSizeAt(text, index);
        if (len >= 1)
            ch.c1 = text[index];
        if (len >= 2)
            ch.c2 = text[index+1];
        if (len >= 3)
            ch.c3 = text[index+2];

        width += GetCharWidth(ch, font, size, width);

        index += len;
        fmtIndex++;
    }

    return width;
}
示例#19
0
wxSize wxDateTimePickerCtrl::DoGetBestSize() const
{
    wxClientDC dc(const_cast<wxDateTimePickerCtrl *>(this));

    // Use the same native format as the underlying native control.
#if wxUSE_INTL
    wxString s = wxDateTime::Now().Format(wxLocale::GetInfo(MSWGetFormat()));
#else // !wxUSE_INTL
    wxString s("XXX-YYY-ZZZZ");
#endif // wxUSE_INTL/!wxUSE_INTL

    // the best size for the control is bigger than just the string
    // representation of the current value because the control must accommodate
    // any date and while the widths of all digits are usually about the same,
    // the width of the month string varies a lot, so try to account for it
    s += wxT("WW");

    int x, y;
    dc.GetTextExtent(s, &x, &y);

    // account for the drop-down arrow or spin arrows
    x += wxSystemSettings::GetMetric(wxSYS_HSCROLL_ARROW_X);

    // and for the checkbox if we have it
    if ( MSWAllowsNone() )
        x += 3*GetCharWidth();

    wxSize best(x, EDIT_HEIGHT_FROM_CHAR_HEIGHT(y));
    CacheBestSize(best);
    return best;
}
示例#20
0
文件: Column.cpp 项目: PyroOS/Pyro
		void RenderLine(uint8 *pStart, float xOff, float vLineTop, float vLineBottom, int nCursor, int nSelStart, int nSelEnd, View *pcView, bool bSelected)
		{			
			Color32_s sCursCol(40,40,40);
			Color32_s sCursLineCol(255,235,186);
			
			if( ! bSelected )
			{
				sCursCol = lighten_color(sCursCol);
				sCursLineCol = lighten_color(sCursLineCol);
			}
		
			float vCharWidth = GetCharWidth();
			float vCharHeight = GetCharHeight();
			
			uint8 *pEnd = GetBuffer() + GetBufferLength();
			static char zLine[(3 * BYTES_PER_LINE) + 1];
			uint8 *p = pStart;
			for( int x = 0; x < 3 * BYTES_PER_LINE; x+=3 )
			{
				if( p < pEnd )
				{
					zLine[x] = get_nibble_char(*p, true);
					zLine[x + 1] = get_nibble_char(*p, false);
					p++;
				} else {
					zLine[x] = ' ';
					zLine[x + 1] = ' ';
				}
				zLine[x + 2] = ' ';
			}
					
			Rect cRect(xOff + GetX() + 2, vLineTop, xOff + GetX() + GetWidth() - 2, vLineBottom);
			
			pcView->SetFgColor(Color32_s(0,0,0));
							
			if( nSelStart < 0 )
			{				
				if( nCursor >= 0 )
					pcView->FillRect(cRect, sCursLineCol);
				
				pcView->DrawText(cRect, zLine);

				if( nCursor >= 0 )
				{
					float vCursorX = cRect.left + (3 * vCharWidth * nCursor);
					if( m_bSecondChar )
						vCursorX += vCharWidth;
					pcView->SetFgColor(sCursCol);
					pcView->DrawLine(Point(vCursorX, vLineTop), Point(vCursorX, vLineBottom));
					vCursorX++;
					pcView->DrawLine(Point(vCursorX, vLineTop), Point(vCursorX, vLineBottom));
				}
			}
			else
			{
				IPoint cSel1((int)(nSelStart * 3 * vCharWidth), (int)vCharHeight);
				IPoint cSel2((int)((nSelEnd * 3 * vCharWidth) + (vCharWidth * 2)), (int)vCharHeight);
				pcView->DrawSelectedText(cRect, zLine, cSel1, cSel2, SEL_CHAR);
			}
		}
void CBitmapFont::DrawString(const char* szText, int nPosX, int nPosY)
{
	CSGD_TextureManager* pTM = CSGD_TextureManager::GetInstance();

	//	iterate through the string 1 character at a time
	int length = (int)strlen(szText);

	for (int i=0; i < length; i++)
	{
		//	get ascii value of character
		char ch = szText[i];

		//	make sure character is uppercase
		ch = toupper(ch);

		//	calculate the id on the bitmap using the start char
		int id = ch - GetStartChar();

		//	Make a rect based on an ID
		RECT rLetter = CalculateRect(id);

		//	Draw it to the screen
		pTM->Draw(GetFontImageID(), nPosX + (i*GetCharWidth()), nPosY, 1.0f, 1.0f, &rLetter);
	}
}
示例#22
0
文件: text.cpp 项目: xiendev/colobot
void CText::DrawString(const std::string &text, std::vector<FontMetaChar>::iterator format,
                       std::vector<FontMetaChar>::iterator end,
                       float size, Math::Point pos, float width, int eol, Color color)
{
    m_engine->SetState(ENG_RSTATE_TEXT);

    float start = pos.x;

    unsigned int fmtIndex = 0;

    std::vector<UTF8Char> chars;
    StringToUTFCharList(text, chars);
    for (auto it = chars.begin(); it != chars.end(); ++it)
    {
        FontType font = FONT_COLOBOT;
        if (format + fmtIndex != end)
            font = static_cast<FontType>(*(format + fmtIndex) & FONT_MASK_FONT);

        // TODO: if (font == FONT_BUTTON)
        if (font == FONT_BUTTON) continue;

        UTF8Char ch = *it;

        float offset = pos.x - start;
        float cw = GetCharWidth(ch, font, size, offset);
        if (offset + cw > width)  // exceeds the maximum width?
        {
            // TODO: special end-of-line char
            break;
        }

        FontHighlight hl = static_cast<FontHighlight>(format[fmtIndex] & FONT_MASK_HIGHLIGHT);
        if (hl != FONT_HIGHLIGHT_NONE)
        {
            Math::Point charSize;
            charSize.x = GetCharWidth(ch, font, size, offset);
            charSize.y = GetHeight(font, size);
            DrawHighlight(hl, pos, charSize);
        }

        DrawCharAndAdjustPos(ch, font, size, pos, color);

        fmtIndex++;
    }

    // TODO: eol
}
示例#23
0
void HandleMouseLeftUpWhenCaptured (PCONINFO con, int x, int y, WPARAM wParam)
{
    x /= GetCharWidth ();
    y /= GetCharHeight ();

    TextCopy (con, con->m_origx, con->m_origy, x, y);

    con->m_oldx = x;
    con->m_oldy = y;
}
示例#24
0
wxSize wxChoice::DoGetBestSize() const
{
    // We use the base window size for the height (which is wrong as it doesn't
    // take the font into account -- TODO) and add some margins to the width
    // computed by the base class method to account for the arrow.
    const int lbHeight = wxWindow::DoGetBestSize().y;

    return wxSize(wxChoiceBase::DoGetBestSize().x + 2*lbHeight + GetCharWidth(),
                  lbHeight);
}
示例#25
0
BOOL C_Font::AddFont(long ,LOGFONT *)
{

#if 0
	FONTLIST *newfont,*cur;
	HDC hdc;

	newfont=new FONTLIST;
	newfont->Spacing_=Spacing_;
	newfont->Font_=CreateFontIndirect(reqs);
	if(newfont->Font_ == NULL)
	{
		delete newfont;
		return(FALSE);
	}
	memcpy(&newfont->logfont,reqs,sizeof(LOGFONT));

	newfont->ID_=ID;
	Handler_->GetDC(&hdc);
	SelectObject(hdc,newfont->Font_);
	GetTextMetrics(hdc,&newfont->Metrics_);
	newfont->Widths_=new INT[newfont->Metrics_.tmLastChar+1];
	if(!GetCharWidth(hdc,0,newfont->Metrics_.tmLastChar,&newfont->Widths_[0]))
	{
		VOID *lpMsgBuf;

		FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
					  NULL,GetLastError(),MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),(LPTSTR) &lpMsgBuf,0,NULL );

		// Display the string.
		MessageBox( NULL, (char *)lpMsgBuf, "GetLastError", MB_OK|MB_ICONINFORMATION );

		// Free the buffer.
		LocalFree( lpMsgBuf );
	}
	Handler_->ReleaseDC(hdc);

	newfont->Next=NULL;

	if(Root_ == NULL)
	{
		Root_=newfont;
	}
	else
	{
		cur=Root_;
		while(cur->Next)
			cur=cur->Next;
		cur->Next=newfont;
	}

	return(TRUE);
#endif
	return(FALSE);
}
示例#26
0
wxTextCtrlHitTestResult
wxTextCtrl::HitTest(const wxPoint& pt, long *posOut) const
{
    // first get the position from Windows
    // for the plain ones, we are limited to 16 bit positions which are
    // combined in a single 32 bit value
    LPARAM lParam = MAKELPARAM(pt.x, pt.y);

    LRESULT pos = ::SendMessage(GetBuddyHwnd(), EM_CHARFROMPOS, 0, lParam);

    if ( pos == -1 )
    {
        // this seems to indicate an error...
        return wxTE_HT_UNKNOWN;
    }

    // for plain EDIT controls the higher word contains something else
    pos = LOWORD(pos);


    // next determine where it is relatively to our point: EM_CHARFROMPOS
    // always returns the closest character but we need to be more precise, so
    // double check that we really are where it pretends
    POINTL ptReal;

    LRESULT lRc = ::SendMessage(GetBuddyHwnd(), EM_POSFROMCHAR, pos, 0);

    if ( lRc == -1 )
    {
        // this is apparently returned when pos corresponds to the last
        // position
        ptReal.x =
        ptReal.y = 0;
    }
    else
    {
        ptReal.x = LOWORD(lRc);
        ptReal.y = HIWORD(lRc);
    }

    wxTextCtrlHitTestResult rc;

    if ( pt.y > ptReal.y + GetCharHeight() )
        rc = wxTE_HT_BELOW;
    else if ( pt.x > ptReal.x + GetCharWidth() )
        rc = wxTE_HT_BEYOND;
    else
        rc = wxTE_HT_ON_TEXT;

    if ( posOut )
        *posOut = pos;

    return rc;
}
示例#27
0
wxRect wxStaticBox::GetBorderGeometry() const
{
    // FIXME should use the renderer here
    wxRect rect;
    rect.width =
    rect.x = GetCharWidth() / 2 + 1;
    rect.y = GetCharHeight() + 1;
    rect.height = rect.y / 2;

    return rect;
}
示例#28
0
void SjLogListCtrl::SizeChanged()
{
	wxSize size = GetClientSize();
	int    charW = GetCharWidth(); // Returns the average character width for this window.
	int    w1 = charW*10;
	int    w2 = charW*10;

	SetColumnWidth(0, size.x-w1-w2);
	SetColumnWidth(1, w1);
	SetColumnWidth(2, w2);
}
示例#29
0
文件: Column.cpp 项目: PyroOS/Pyro
		uint8 *GetCursorAt(const Point &cPos)
		{
			int x = (int)(cPos.x / GetCharWidth());
			int y = (int)(cPos.y / GetCharHeight()) + GetScrollLine();
			if( x < 0 || x >= BYTES_PER_LINE )
				return NULL;
			uint8 *pCursor = GetBuffer() + (y * BYTES_PER_LINE) + x;
			if( pCursor >= GetBuffer() + GetBufferLength() )
				return NULL;
			return pCursor;
		}
示例#30
0
wxSize wxDatePickerCtrl::DoGetBestSize() const
{
    wxClientDC dc(const_cast<wxDatePickerCtrl *>(this));

    // we can't use FormatDate() here as the CRT doesn't always use the same
    // format as the date picker control
    wxString s;
    for ( int len = 100; ; len *= 2 )
    {
        if ( ::GetDateFormat
               (
                    LOCALE_USER_DEFAULT,    // the control should use the same
                    DATE_SHORTDATE,         // the format used by the control
                    NULL,                   // use current date (we don't care)
                    NULL,                   // no custom format
                    wxStringBuffer(s, len), // output buffer
                    len                     // and its length
               ) )
        {
            // success
            break;
        }

        const DWORD rc = ::GetLastError();
        if ( rc != ERROR_INSUFFICIENT_BUFFER )
        {
            wxLogApiError(wxT("GetDateFormat"), rc);

            // fall back on wxDateTime, what else to do?
            s = wxDateTime::Today().FormatDate();
            break;
        }
    }

    // the best size for the control is bigger than just the string
    // representation of todays date because the control must accommodate any
    // date and while the widths of all digits are usually about the same, the
    // width of the month string varies a lot, so try to account for it
    s += wxT("WW");

    int x, y;
    dc.GetTextExtent(s, &x, &y);

    // account for the drop-down arrow or spin arrows
    x += wxSystemSettings::GetMetric(wxSYS_HSCROLL_ARROW_X);

    // and for the checkbox if we have it
    if ( HasFlag(wxDP_ALLOWNONE) )
        x += 3*GetCharWidth();

    wxSize best(x, EDIT_HEIGHT_FROM_CHAR_HEIGHT(y));
    CacheBestSize(best);
    return best;
}