当前位置: 首页>>代码示例>>C++>>正文


C++ wxDC::GetTextExtent方法代码示例

本文整理汇总了C++中wxDC::GetTextExtent方法的典型用法代码示例。如果您正苦于以下问题:C++ wxDC::GetTextExtent方法的具体用法?C++ wxDC::GetTextExtent怎么用?C++ wxDC::GetTextExtent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wxDC的用法示例。


在下文中一共展示了wxDC::GetTextExtent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: oglCentreTextNoClipping

// Centre a list of strings in the given box
void oglCentreTextNoClipping(wxDC &dc, wxList *text_list,
                             double m_xpos, double m_ypos, double width, double height)
{
	int n = text_list->GetCount();

	if (!text_list || (n == 0))
		return;

	// First, get maximum dimensions of box enclosing text

#if wxCHECK_VERSION(2, 9, 0)
	wxCoord char_height = 0;
	wxCoord max_width = 0;
	wxCoord current_width = 0;
#else
	long char_height = 0;
	long max_width = 0;
	long current_width = 0;
#endif

	// Store text extents for speed
	double *widths = new double[n];

	wxNode *current = text_list->GetFirst();
	int i = 0;
	while (current)
	{
		wxShapeTextLine *line = (wxShapeTextLine *)current->GetData();
		dc.GetTextExtent(line->GetText(), &current_width, &char_height);
		widths[i] = current_width;

		if (current_width > max_width)
			max_width = current_width;
		current = current->GetNext();
		i ++;
	}

	double max_height = n * char_height;

	double yoffset = (double)(m_ypos - (height / 2.0) + (height - max_height) / 2.0);

	double xoffset = (double)(m_xpos - width / 2.0);

	current = text_list->GetFirst();
	i = 0;

	while (current)
	{
		wxShapeTextLine *line = (wxShapeTextLine *)current->GetData();

		double x = (double)((width - widths[i]) / 2.0 + xoffset);
		double y = (double)(i * char_height + yoffset);

		line->SetX( x - m_xpos );
		line->SetY( y - m_ypos );
		current = current->GetNext();
		i ++;
	}
	delete[] widths;
}
开发者ID:GHnubsST,项目名称:pgadmin3,代码行数:61,代码来源:oglmisc.cpp

示例2: OnDraw

void ExplainShape::OnDraw(wxDC &dc)
{
    wxBitmap &bmp = GetBitmap();
    if (!bmp.Ok())
        return;

    // We do not draw the root shape
    if (m_rootShape)
        return;

    int x, y;
    x = WXROUND(m_xpos - bmp.GetWidth() / 2.0);
    y = WXROUND(m_ypos - GetHeight() / 2.0);

    dc.DrawBitmap(bmp, x, y, true);

    int w, h;
    dc.SetFont(GetCanvas()->GetFont());
    dc.GetTextExtent(label, &w, &h);

    x = WXROUND(m_xpos - w / 2.0);
    y += bmp.GetHeight() + BMP_BORDER;

    dc.DrawText(label, x, y);
}
开发者ID:GHnubsST,项目名称:pgadmin3,代码行数:25,代码来源:explainShape.cpp

示例3: rect

wxSize
wxGridCellAutoWrapStringRenderer::GetBestSize(wxGrid& grid,
                                              wxGridCellAttr& attr,
                                              wxDC& dc,
                                              int row, int col)
{
    wxCoord x,y, height , width = grid.GetColSize(col) -10;
    int count = 250; //Limit iterations..

    wxRect rect(0,0,width,10);

    // M is a nice large character 'y' gives descender!.
    dc.GetTextExtent(wxT("My"), &x, &y);

    do
    {
        width+=10;
        rect.SetWidth(width);
        height = y * (wx_truncate_cast(wxCoord, GetTextLines(grid,dc,attr,rect,row,col).GetCount()));
        count--;
    // Search for a shape no taller than the golden ratio.
    } while (count && (width  < (height*1.68)) );


    return wxSize(width,height);
}
开发者ID:georgemoralis,项目名称:jpcsp2c,代码行数:26,代码来源:gridctrl.cpp

示例4: Draw

void GroupVisual::Draw ( wxDC& dc, InstanceCtrl* parent, wxRect limitingRect, bool hasSelection, int selectionIndex, bool hasFocus, int focusIndex, bool highlight )
{
	int i;
	int count = items.size();
	int style = 0;
	wxRect rect;
	
	// Draw the header
	if(!no_header)
	{
		wxColour textColor = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);

		if (highlight)
		{
			textColor = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT);
		}

		wxBrush brush(textColor);
		wxPen pen(textColor);
		dc.SetBrush(brush);
		dc.SetPen(pen);
		wxSize sz = dc.GetTextExtent(GetName());
		dc.SetTextForeground(textColor);
		
		dc.DrawText( GetName() , 20, y_position + 5 );
		int atheight = y_position + header_height / 2;
		if(sz.x + 30 < limitingRect.width - 10)
			dc.DrawLine(sz.x + 30,atheight, limitingRect.width - 10, atheight);
		
		dc.SetBrush(*wxTRANSPARENT_BRUSH);
		dc.SetPen(textColor);
		
		// Ungrouped can't be hidden, so don't draw the box.
		if (m_group)
		{
			dc.DrawRectangle(5,atheight -5, 10,10);
			dc.DrawRectangle(7,atheight -1, 6,2);
			if(!IsExpanded())
			{
				dc.DrawRectangle(9,atheight -3, 2,6);
			}
		}
	}
	
	if(IsExpanded()) for (i = 0; i < count; i++)
	{
		parent->GetItemRect(VisualCoord(index,i), rect, false);

		if (!limitingRect.Intersects(rect))
			continue;
		style = 0;
		if (hasSelection && selectionIndex == i)
			style |= wxINST_SELECTED;
		if (hasFocus && i == focusIndex)
			style |= wxINST_IS_FOCUS;

		InstanceVisual& item = items[i];
		item.Draw(dc, parent, rect, style);
	}
}
开发者ID:Glought,项目名称:MultiMC4,代码行数:60,代码来源:instancectrl.cpp

示例5: wxHtmlCell

wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell()
{
    m_Word = word;
    dc.GetTextExtent(m_Word, &m_Width, &m_Height, &m_Descent);
    SetCanLiveOnPagebreak(false);
    m_allowLinebreak = true;
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:7,代码来源:htmlcell.cpp

示例6: DrawCenteredText

// draw text centered around x (though still at y down)
void DrawCenteredText(wxDC& dc, const wxString& text, const wxPoint& pt)
{
    wxCoord w, h;
    dc.GetTextExtent(text, &w, &h);
    w = std::max(0, pt.x - w/2);
    dc.DrawText(text, w, pt.y);
}
开发者ID:colindr,项目名称:calchart,代码行数:8,代码来源:draw.cpp

示例7: DrawFieldText

void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
{
    int leftMargin = 2;

    wxRect rect;
    GetFieldRect(i, rect);

    if ( !IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) )
    {
        dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ;
    }

    wxString text(GetStatusText(i));

    long x, y;

    dc.GetTextExtent(text, &x, &y);

    int xpos = rect.x + leftMargin + 1 ;
    int ypos = 1 ;

    dc.SetClippingRegion(rect.x, 0, rect.width, m_height);

    dc.DrawText(text, xpos, ypos);

    dc.DestroyClippingRegion();
}
开发者ID:Bluehorn,项目名称:wxPython,代码行数:27,代码来源:statbrma.cpp

示例8: DrawFieldText

void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
{
    int leftMargin = 2;
    int w, h ;
    GetSize( &w , &h ) ;
    wxRect rect;
    GetFieldRect(i, rect);
    
    if ( !MacIsReallyHilited()  )
    {
        dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ;
    }
    
    wxString text(GetStatusText(i));
    
    long x, y;
    
    dc.GetTextExtent(text, &x, &y);
    
    int xpos = rect.x + leftMargin + 1 ;
    int ypos = 1 ;
    
    if ( MacGetTopLevelWindow()->MacGetMetalAppearance()  )
        ypos++ ;
        
    dc.SetClippingRegion(rect.x, 0, rect.width, h);
    
    dc.DrawText(text, xpos, ypos);
    
    dc.DestroyClippingRegion();
}
开发者ID:HackLinux,项目名称:chandler-1,代码行数:31,代码来源:statbrma.cpp

示例9: PaintLabels

void AudioDisplay::PaintLabels(wxDC &dc, TimeRange updtime)
{
	std::vector<AudioLabelProvider::AudioLabel> labels;
	controller->GetTimingController()->GetLabels(updtime, labels);
	if (labels.empty()) return;

	wxDCFontChanger fc(dc);
	wxFont font = dc.GetFont();
	font.SetWeight(wxFONTWEIGHT_BOLD);
	dc.SetFont(font);
	dc.SetTextForeground(*wxWHITE);
	for (auto const& label : labels)
	{
		wxSize extent = dc.GetTextExtent(label.text);
		int left = RelativeXFromTime(label.range.begin());
		int width = AbsoluteXFromTime(label.range.length());

		// If it doesn't fit, truncate
		if (width < extent.GetWidth())
		{
			dc.SetClippingRegion(left, audio_top + 4, width, extent.GetHeight());
			dc.DrawText(label.text, left, audio_top + 4);
			dc.DestroyClippingRegion();
		}
		// Otherwise center in the range
		else
		{
			dc.DrawText(label.text, left + (width - extent.GetWidth()) / 2, audio_top + 4);
		}
	}
}
开发者ID:Gpower2,项目名称:Aegisub,代码行数:31,代码来源:audio_display.cpp

示例10: drawGuides

void FloorTruss::drawGuides(wxDC &dc, unsigned left, unsigned top,
    unsigned right, unsigned bottom) {
    
    float six_inches = (right-left) / (60.0f*2);
    
    float one_inch = (right-left) / 60.0f / 12.0f;
    
    unsigned px_width = one_inch * width;
    unsigned px_height = one_inch * height;
    
    wxCoord line_height, unused;
    dc.GetTextExtent(wxT("X"), &unused, &line_height);
    
    // height
    drawGuide(dc, left + six_inches + px_width/2 - line_height / 2,
        bottom - px_height, px_height, height, true, line_height);
    
    // base
    drawGuide(dc, left + six_inches, bottom + line_height / 10, px_width,
        width, false, line_height);
    
    // base to back of truck
    drawGuide(dc, left + six_inches + px_width, bottom + line_height / 10,
        right - left - six_inches - px_width, 60*12 - 6 - width, false,
        line_height);
}
开发者ID:parkovski,项目名称:tsched,代码行数:26,代码来源:floortruss.cpp

示例11: GetPanelClientSize

wxSize wxRibbonAUIArtProvider::GetPanelClientSize(
                        wxDC& dc,
                        const wxRibbonPanel* wnd,
                        wxSize size,
                        wxPoint* client_offset)
{
    dc.SetFont(m_panel_label_font);
    wxSize label_size = dc.GetTextExtent(wnd->GetLabel());
    int label_height = label_size.GetHeight() + 5;
    if(m_flags & wxRIBBON_BAR_FLOW_VERTICAL)
    {
        size.DecBy(4, label_height + 6);
        if(client_offset)
            *client_offset = wxPoint(2, label_height + 3);
    }
    else
    {
        size.DecBy(6, label_height + 4);
        if(client_offset)
            *client_offset = wxPoint(3, label_height + 2);
    }
    if (size.x < 0) size.x = 0;
    if (size.y < 0) size.y = 0;
    return size;
}
开发者ID:AaronDP,项目名称:wxWidgets,代码行数:25,代码来源:art_aui.cpp

示例12: Render

/**
 * Render the event in the bitmap
 */
void LinkEvent::Render(wxDC & dc, int x, int y, unsigned int width, gd::EventsEditorItemsAreas & areas, gd::EventsEditorSelection & selection, const gd::Platform & platform)
{
#if !defined(GD_NO_WX_GUI)
    dc.SetBrush( wxBrush( wxColour( 255, 255, 255 ) ) );
    dc.SetPen( wxPen( wxColour( 0, 0, 0 ), 1) );
    wxRect rect(x+1, y, width, GetRenderedHeight(width, platform)-2);
    dc.DrawRectangle(rect);

    dc.DrawBitmap( gd::SkinHelper::GetIcon("events", 24), x+4, y + 1, true);

    dc.SetTextBackground( wxColour( 255, 255, 255 ) );
    if ( !IsDisabled() )
        dc.SetTextForeground( wxColour( 0, 0, 0 ) );
    else
        dc.SetTextForeground( wxColour( 160, 160, 160 ) );
    dc.SetFont( wxFont( 12, wxDEFAULT, wxNORMAL, wxNORMAL ) );
    dc.DrawText( _("Link to ")+GetTarget(), x+32, y + 3 );
    wxRect lien = dc.GetTextExtent(_("Link to ")+GetTarget());

    dc.SetFont( wxFont( 10, wxDEFAULT, wxNORMAL, wxNORMAL ) );
    if ( IncludeAllEvents() )
        dc.DrawText( _("Include all events"), x+lien.GetWidth()+32+10, y + 5 );
    else
        dc.DrawText( _("Include events ")+ToString(GetIncludeStart()+1)+_(" to ")+ToString(GetIncludeEnd()+1), x+lien.GetWidth()+32+10, y + 5 );
#endif
}
开发者ID:kumarjith,项目名称:GD,代码行数:29,代码来源:LinkEvent.cpp

示例13: GetSize

void wxJigsawInputParameter::GetSize(wxDC & dc, wxCoord * w, wxCoord * h, double scale)
{
	wxCoord shapeWidth(0), shapeHeight(0);
	if(m_NeedCalcLabelSize)
	{
		dc.GetTextExtent(m_Label, &m_LabelSize.x, &m_LabelSize.y, 0, 0, (wxFont *)&dc.GetFont());
		m_NeedCalcLabelSize = false;
	}
	if(m_Shape)
	{
		m_Shape->GetSize(dc, &shapeWidth, &shapeHeight, scale);
	}
	else
	{
		wxSize defaultSize = wxJigsawInputParameter::GetDefaultParameterSize();
		shapeWidth = defaultSize.GetWidth()*scale;
		shapeHeight = defaultSize.GetHeight()*scale;
	}
	if(w)
	{
		*w = m_LabelSize.GetWidth() + wxJigsawInputParameter::ParameterSpacing*scale + shapeWidth;
	}
	if(h)
	{
		*h = wxMax(m_LabelSize.GetHeight(), shapeHeight);
	}
}
开发者ID:cubemoon,项目名称:game-editor,代码行数:27,代码来源:wxJigsawInputParameter.cpp

示例14: GetTabCtrlHeight

int wxRibbonAUIArtProvider::GetTabCtrlHeight(
                        wxDC& dc,
                        wxWindow* WXUNUSED(wnd),
                        const wxRibbonPageTabInfoArray& pages)
{
    int text_height = 0;
    int icon_height = 0;

    if(pages.GetCount() <= 1 && (m_flags & wxRIBBON_BAR_ALWAYS_SHOW_TABS) == 0)
    {
        // To preserve space, a single tab need not be displayed. We still need
        // one pixel of border though.
        return 1;
    }

    if(m_flags & wxRIBBON_BAR_SHOW_PAGE_LABELS)
    {
        dc.SetFont(m_tab_active_label_font);
        text_height = dc.GetTextExtent(wxT("ABCDEFXj")).GetHeight();
    }
    if(m_flags & wxRIBBON_BAR_SHOW_PAGE_ICONS)
    {
        size_t numpages = pages.GetCount();
        for(size_t i = 0; i < numpages; ++i)
        {
            const wxRibbonPageTabInfo& info = pages.Item(i);
            if(info.page->GetIcon().IsOk())
            {
                icon_height = wxMax(icon_height, info.page->GetIcon().GetHeight());
            }
        }
    }

    return wxMax(text_height, icon_height) + 10;
}
开发者ID:AaronDP,项目名称:wxWidgets,代码行数:35,代码来源:art_aui.cpp

示例15: Ascent

int SurfaceImpl::Ascent(Font &font) {
    SetFont(font);
    int w, h, d, e;
    hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
    font.ascent = h - d;
    return font.ascent;
}
开发者ID:simple-codeblocks,项目名称:Codeblocks,代码行数:7,代码来源:PlatWX.cpp


注:本文中的wxDC::GetTextExtent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。