本文整理汇总了C++中wxRect::GetWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ wxRect::GetWidth方法的具体用法?C++ wxRect::GetWidth怎么用?C++ wxRect::GetWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxRect
的用法示例。
在下文中一共展示了wxRect::GetWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
void wxCustomStatusBarFieldText::Render(wxDC& dc, const wxRect& rect, wxCustomStatusBarArt::Ptr_t art)
{
m_rect = rect;
wxSize textSize = dc.GetTextExtent(m_text);
// Center text
wxCoord textY = (rect.GetHeight() - textSize.GetHeight()) / 2 + rect.y;
wxCoord textX;
if(m_textAlign == wxALIGN_CENTER) {
textX = (rect.GetWidth() - textSize.GetWidth()) / 2 + rect.x;
} else {
// left
textX = rect.x + 5;
}
// draw border line
art->DrawFieldSeparator(dc, rect);
// Draw the text
art->DrawText(dc, textX, textY + 1, m_text);
}
示例2: PaintStraightGradientBox
void DrawingUtils::PaintStraightGradientBox(wxDC& dc,
const wxRect& rect,
const wxColour& startColor,
const wxColour& endColor,
bool vertical)
{
int rd, gd, bd, high = 0;
rd = endColor.Red() - startColor.Red();
gd = endColor.Green() - startColor.Green();
bd = endColor.Blue() - startColor.Blue();
/// Save the current pen and brush
wxPen savedPen = dc.GetPen();
wxBrush savedBrush = dc.GetBrush();
if(vertical)
high = rect.GetHeight() - 1;
else
high = rect.GetWidth() - 1;
if(high < 1) return;
for(int i = 0; i <= high; ++i) {
int r = startColor.Red() + ((i * rd * 100) / high) / 100;
int g = startColor.Green() + ((i * gd * 100) / high) / 100;
int b = startColor.Blue() + ((i * bd * 100) / high) / 100;
wxPen p(wxColor(r, g, b));
dc.SetPen(p);
if(vertical)
dc.DrawLine(rect.x, rect.y + i, rect.x + rect.width, rect.y + i);
else
dc.DrawLine(rect.x + i, rect.y, rect.x + i, rect.y + rect.height);
}
/// Restore the pen and brush
dc.SetPen(savedPen);
dc.SetBrush(savedBrush);
}
示例3: DrawFore
void CPathItem::DrawFore(wxDC &dc, wxRect &rc)
{
dc.SetTextForeground(*wxBLACK);
wxString csName(_T("mixer"));
if(NULL != m_pInput)
{
const char *nname = m_pInput->GetName();
const char *dname = m_pInput->GetDisplayName();
csName = (wxChar*)(strlen(nname) > strlen(dname) ? dname : nname);
}
int width = rc.GetWidth();
if(!m_bFirst)
width -= CORNER_LENGTH;
wxFont oldFont = dc.GetFont();
wxFont font(7, wxSWISS, wxNORMAL, wxNORMAL);
font.SetWeight(IsSelected() ? wxBOLD : wxNORMAL);
font.SetStyle(IsSelected() ? wxITALIC : wxNORMAL );
font.SetPointSize( 7 );
dc.SetFont( font );
int w=0, h=0;
dc.GetTextExtent(csName, &w, &h);
if(h<rc.GetHeight())
{
if(w>width)
{
csName.Printf(_T("%c"),csName[0]);
dc.GetTextExtent(csName, &w, &h);
}
int x = rc.GetX() + width/2 - w/2 + (m_bFirst ? 0 : CORNER_LENGTH);
int y = rc.GetY() + rc.GetHeight()/2 - h/2;
dc.DrawText( csName, x, y );
}
dc.SetFont( oldFont );
}
示例4: wxSplit
wxArrayString
wxGridCellAutoWrapStringRenderer::GetTextLines(wxGrid& grid,
wxDC& dc,
const wxGridCellAttr& attr,
const wxRect& rect,
int row, int col)
{
dc.SetFont(attr.GetFont());
const wxCoord maxWidth = rect.GetWidth();
// Transform logical lines into physical ones, wrapping the longer ones.
const wxArrayString
logicalLines = wxSplit(grid.GetCellValue(row, col), '\n', '\0');
// Trying to do anything if the column is hidden anyhow doesn't make sense
// and we run into problems in BreakLine() in this case.
if ( maxWidth <= 0 )
return logicalLines;
wxArrayString physicalLines;
for ( wxArrayString::const_iterator it = logicalLines.begin();
it != logicalLines.end();
++it )
{
const wxString& line = *it;
if ( dc.GetTextExtent(line).x > maxWidth )
{
// Line does not fit, break it up.
BreakLine(dc, line, maxWidth, physicalLines);
}
else // The entire line fits as is
{
physicalLines.push_back(line);
}
}
return physicalLines;
}
示例5: DrawBackground
void wxAuiGenericTabArt::DrawBackground(wxDC& dc,
wxWindow* WXUNUSED(wnd),
const wxRect& rect)
{
// draw background
wxColor top_color = m_baseColour.ChangeLightness(90);
wxColor bottom_color = m_baseColour.ChangeLightness(170);
wxRect r;
if (m_flags &wxAUI_NB_BOTTOM)
r = wxRect(rect.x, rect.y, rect.width+2, rect.height);
// TODO: else if (m_flags &wxAUI_NB_LEFT) {}
// TODO: else if (m_flags &wxAUI_NB_RIGHT) {}
else //for wxAUI_NB_TOP
r = wxRect(rect.x, rect.y, rect.width+2, rect.height-3);
dc.GradientFillLinear(r, top_color, bottom_color, wxSOUTH);
// draw base lines
dc.SetPen(m_borderPen);
int y = rect.GetHeight();
int w = rect.GetWidth();
if (m_flags &wxAUI_NB_BOTTOM)
{
dc.SetBrush(wxBrush(bottom_color));
dc.DrawRectangle(-1, 0, w+2, 4);
}
// TODO: else if (m_flags &wxAUI_NB_LEFT) {}
// TODO: else if (m_flags &wxAUI_NB_RIGHT) {}
else //for wxAUI_NB_TOP
{
dc.SetBrush(m_baseColourBrush);
dc.DrawRectangle(-1, y-4, w+2, 4);
}
}
示例6: OnDrawItem
void BrowseTileListBox::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const
{
ItemsMap::const_iterator item_iterator = items.find(int(n));
Item* item = item_iterator->second;
Sprite* sprite = gui.gfx.getSprite(item->getClientID());
if (sprite)
sprite->DrawTo(&dc, SPRITE_SIZE_32x32, rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight());
if (IsSelected(n))
{
item->select();
dc.SetTextForeground(wxColor(0xFF, 0xFF, 0xFF));
}
else {
item->deselect();
dc.SetTextForeground(wxColor(0x00, 0x00, 0x00));
}
wxString label;
label << item->getID() << wxT(" - ") << item->getName();
dc.DrawText(label, rect.GetX() + 40, rect.GetY() + 6);
}
示例7: DrawBackground
void SAuiTabArt::DrawBackground(wxDC& dc,
wxWindow* WXUNUSED(wnd),
const wxRect& rect)
{
// draw background
wxColor top_color = (m_mainTabs && Global::win_version_major >= 10) ? col_w10_bg : m_baseColour;
wxColor bottom_color = (m_mainTabs && Global::win_version_major >= 10) ? col_w10_bg : m_baseColour;
wxRect r;
if (m_flags &wxAUI_NB_BOTTOM)
r = wxRect(rect.x, rect.y, rect.width + 2, rect.height);
else
r = wxRect(rect.x, rect.y, rect.width + 2, rect.height);
dc.GradientFillLinear(r, top_color, bottom_color, wxSOUTH);
// draw base lines
dc.SetPen(wxPen(m_baseColour));
int y = rect.GetHeight();
int w = rect.GetWidth();
if (m_flags &wxAUI_NB_BOTTOM)
{
dc.SetBrush(wxBrush(bottom_color));
dc.DrawRectangle(-1, 0, w + 2, 4);
}
else
{
//dc.SetPen(*wxTRANSPARENT_PEN);
//dc.SetBrush(wxBrush(m_activeColour));
//dc.SetBrush(wxBrush(wxColor(224, 238, 255)));
//dc.DrawRectangle(-1, y - 4, w + 2, 4);
dc.SetPen(m_borderPen);
dc.DrawLine(-2, y - 1, w + 2, y - 1);
}
}
示例8: DrawPaneButton
void clAuiDockArt::DrawPaneButton(
wxDC& dc, wxWindow* window, int button, int button_state, const wxRect& _rect, wxAuiPaneInfo& pane)
{
int xx = _rect.GetTopLeft().x + ((_rect.GetWidth() - AUI_BUTTON_SIZE) / 2);
int yy = _rect.GetTopLeft().y + ((_rect.GetHeight() - AUI_BUTTON_SIZE) / 2);
switch(button) {
case wxAUI_BUTTON_CLOSE:
dc.DrawBitmap(m_dockCloseBmp, xx, yy);
break;
case wxAUI_BUTTON_MAXIMIZE_RESTORE:
if(pane.IsMaximized()) {
dc.DrawBitmap(m_dockMinimizeBmp, xx, yy);
} else {
dc.DrawBitmap(m_dockExpandeBmp, xx, yy);
}
break;
case wxAUI_BUTTON_PIN:
dc.DrawBitmap(m_dockMoreBmp, xx, yy);
break;
default:
wxAuiDefaultDockArt::DrawPaneButton(dc, window, button, button_state, _rect, pane);
break;
}
}
示例9: DrawGradientRectangle
static void DrawGradientRectangle(wxDC& dc,
const wxRect& rect,
const wxColour& start_color,
const wxColour& end_color,
int direction)
{
int rd, gd, bd, high = 0;
rd = end_color.Red() - start_color.Red();
gd = end_color.Green() - start_color.Green();
bd = end_color.Blue() - start_color.Blue();
if (direction == wxAUI_GRADIENT_VERTICAL)
high = rect.GetHeight()-1;
else
high = rect.GetWidth()-1;
for (int i = 0; i <= high; ++i)
{
int r,g,b;
r = start_color.Red() + (high <= 0 ? 0 : (((i*rd*100)/high)/100));
g = start_color.Green() + (high <= 0 ? 0 : (((i*gd*100)/high)/100));
b = start_color.Blue() + (high <= 0 ? 0 : (((i*bd*100)/high)/100));
wxPen p(wxColor((unsigned char)r,
(unsigned char)g,
(unsigned char)b));
dc.SetPen(p);
if (direction == wxAUI_GRADIENT_VERTICAL)
dc.DrawLine(rect.x, rect.y+i, rect.x+rect.width, rect.y+i);
else
dc.DrawLine(rect.x+i, rect.y, rect.x+i, rect.y+rect.height);
}
}
示例10: DrawFore
void CParameter::DrawFore(wxDC& dc, wxRect& rc)
{
m_iSamplesPerPixel = m_pTracks->GetSamplesPerPixel();
if(m_fMax == 0.f)
return;
m_fScale = (float)rc.GetHeight() / (float)(m_fMax - m_fMin);
int start = m_pRegion->GetStartPos();
int end = m_pRegion->GetEndPos();
int offset = m_pRegion->GetStartOffset();
int top = rc.GetTop();
int bottom = rc.GetTop() + rc.GetHeight();
int left = rc.GetX() + 1;
int right = left + rc.GetWidth() - 1;
float value = 0.f;
int prevX = left;
int prevY = bottom;
int pos = m_bAfterTrack ? 0 : start;
bool bLoaded = false;
bool bDrawCircle = true;
if(!m_pInput->GetParamAt(pos, m_index, &value))
{
pos = m_pInput->GetPrevOffset(pos);
bDrawCircle = false;
}
else
bLoaded = true;
wxPen oldpen = dc.GetPen();
wxColor color = m_color;
if( IsSelected() )
color.Set(255-color.Red(), 255-color.Green(), 255-color.Blue());
dc.SetPen( wxPen(color) );
do {
if(m_pInput->GetParamAt(pos, m_index, &value))
{
bLoaded = true;
int x = pos;
int y = (int)((float)bottom - (value * m_fScale));
if(y>top && y<bottom)
{
if(m_bAfterTrack && offset>=0)
x += start - offset;
x /= m_iSamplesPerPixel;
if(x <= left)
prevX = left;
else if(x >= right)
y = prevY;
else
{
dc.DrawLine(prevX, prevY, x, prevY); // Horizontal line
dc.DrawLine(x, prevY, x, y); // Vertical line
if( bDrawCircle )
{
if(m_pSelectedPoint &&
m_pSelectedPoint->m_offset==pos &&
m_pSelectedPoint->m_value==value)
{
dc.DrawRectangle(x-3, y-3, 6, 6); // Selected parameter
}
else
dc.DrawCircle(x, y, 3); // Parameter
}
prevX = x;
}
bDrawCircle = true;
prevY = y;
}
}
pos = m_pInput->GetNextOffset(pos);
} while ( pos>0 && pos<end && prevX<right );
if(bLoaded && prevX<right) // there have been parameters!
dc.DrawLine(prevX, prevY, right, prevY);
dc.SetPen(oldpen);
}
示例11: FitShapeToRect
void wxSFGridShape::FitShapeToRect(wxSFShapeBase *shape, const wxRect& rct)
{
wxRect shapeBB = shape->GetBoundingBox();
wxRealPoint prevPos = shape->GetRelativePosition();
// do vertical alignment
switch( shape->GetVAlign() )
{
case valignTOP:
shape->SetRelativePosition( prevPos.x, rct.GetTop() + shape->GetVBorder() );
break;
case valignMIDDLE:
shape->SetRelativePosition( prevPos.x, rct.GetTop() + (rct.GetHeight()/2 - shapeBB.GetHeight()/2) );
break;
case valignBOTTOM:
shape->SetRelativePosition( prevPos.x, rct.GetBottom() - shapeBB.GetHeight() - shape->GetVBorder() );
break;
case valignEXPAND:
if( shape->ContainsStyle( sfsSIZE_CHANGE ) )
{
shape->SetRelativePosition( prevPos.x, rct.GetTop() + shape->GetVBorder() );
shape->Scale( 1.f, double(rct.GetHeight() - 2*shape->GetVBorder())/shapeBB.GetHeight() );
}
break;
default:
shape->SetRelativePosition( prevPos.x, rct.GetTop() );
break;
}
prevPos = shape->GetRelativePosition();
// do horizontal alignment
switch( shape->GetHAlign() )
{
case halignLEFT:
shape->SetRelativePosition( rct.GetLeft() + shape->GetHBorder(), prevPos.y );
break;
case halignCENTER:
shape->SetRelativePosition( rct.GetLeft() + (rct.GetWidth()/2 - shapeBB.GetWidth()/2), prevPos.y );
break;
case halignRIGHT:
shape->SetRelativePosition( rct.GetRight() - shapeBB.GetWidth() - shape->GetHBorder(), prevPos.y );
break;
case halignEXPAND:
if( shape->ContainsStyle( sfsSIZE_CHANGE ) )
{
shape->SetRelativePosition( rct.GetLeft() + shape->GetHBorder(), prevPos.y );
shape->Scale( double(rct.GetWidth() - 2*shape->GetHBorder())/shapeBB.GetWidth(), 1.f );
}
break;
default:
shape->SetRelativePosition( rct.GetLeft(), prevPos.y );
break;
}
}
示例12: SetGrid
void ImageButton::SetGrid(const wxRect& rect) {
SetGrid(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight());
}
示例13: DrawRectangle
void SDC::DrawRectangle(const wxRect& rect) {
DrawRectangle(rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight());
}
示例14: Capture
bool Camera_StarfishClass::Capture(int duration, usImage& img, int options, const wxRect& subframe)
{
bool debug = true;
int xsize, ysize, xpos, ypos;
bool usingSubFrames = UseSubframes && subframe.GetWidth() > 0 && subframe.GetHeight() > 0;
IOReturn rval;
// init memory
if (img.Init(FullSize)) {
DisconnectWithAlert(CAPT_FAIL_MEMORY);
return true;
}
if (usingSubFrames)
{
xsize = subframe.GetWidth();
ysize = subframe.GetHeight();
xpos = subframe.GetLeft();
ypos = subframe.GetTop();
subImage.Init(xsize, ysize);
subImage.Clear();
}
else
{
xsize = FullSize.GetWidth();
ysize = FullSize.GetHeight();
xpos = 0;
ypos = 0;
}
img.Clear();
// set ROI if something has changed
if (lastSubFrame != subframe)
{
rval = fcUsb_cmd_setRoi(CamNum, (unsigned short)xpos, (unsigned short)ypos, (unsigned short)(xpos + xsize - 1), (unsigned short)(ypos + ysize - 1));
//Debug.AddLine(wxString::Format("Starfish: using %s", usingSubFrames ? " sub-frames" : " full frames"));
//Debug.AddLine(wxString::Format("Starfish: ROI set from {%d,%d} to {%d,%d)", xpos, ypos, xpos + xsize - 1, ypos + ysize - 1));
if (rval != kIOReturnSuccess) { if (debug) pFrame->Alert(_T("Starfish Err 1")); return true; }
lastSubFrame = subframe;
}
// set duration
fcUsb_cmd_setIntegrationTime(CamNum, (unsigned int) duration);
rval = fcUsb_cmd_startExposure(CamNum);
if (rval != kIOReturnSuccess) { if (debug) pFrame->Alert(_T("Starfish Err 2")); return true; }
CameraWatchdog watchdog(duration, GetTimeoutMs());
if (duration > 100)
{
// wait until near end of exposure
if (WorkerThread::MilliSleep(duration - 100, WorkerThread::INT_ANY) &&
(WorkerThread::TerminateRequested() || StopExposure(CamNum)))
{
return true;
}
}
// wait for image to finish and d/l
while (fcUsb_cmd_getState(CamNum) != 0)
{
wxMilliSleep(50);
if (WorkerThread::InterruptRequested() &&
(WorkerThread::TerminateRequested() || StopExposure(CamNum)))
{
return true;
}
if (watchdog.Expired())
{
DisconnectWithAlert(CAPT_FAIL_TIMEOUT);
return true;
}
}
if (usingSubFrames)
{
rval = fcUsb_cmd_getRawFrame(CamNum, (unsigned short)ysize, (unsigned short)xsize, subImage.ImageData);
// Transfer the subframe to the corresponding location in the full-size frame
for (int y = 0; y < ysize; y++)
{
const unsigned short *pSrc = subImage.ImageData + y * xsize;
unsigned short *pDest = img.ImageData + (ypos + y) * FullSize.GetWidth() + xpos;
for (int x = 0; x < xsize; x++)
*pDest++ = *pSrc++;
}
img.Subframe = subframe;
}
else
{
rval = fcUsb_cmd_getRawFrame(CamNum, (unsigned short)ysize, (unsigned short)xsize, img.ImageData);
}
/* if (rval != kIOReturnSuccess) {
if (debug) pFrame->Alert(wxString::Format("Starfish Err 3 %d",rval));
//return true;
}*/
if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img);
//.........这里部分代码省略.........
示例15: SetClientSize
void wxPlFrame::SetClientSize( const wxRect &rect )
{
SetClientSize( rect.GetWidth(), rect.GetHeight() );
}