// This function converts to the right size with the given background colour wxBitmap PrepareIcon(wxIcon icon, wxSize size) { if (icon.GetWidth() == size.GetWidth() && icon.GetHeight() == size.GetHeight()) return icon; wxBitmap bmp; bmp.CopyFromIcon(icon); return bmp.ConvertToImage().Rescale(size.GetWidth(), size.GetHeight()); }
wxString Variant::MakeString (const wxSize & size) { wxString tmp; tmp << "{" << size.GetWidth() << ", " << size.GetHeight() << "}" ; return tmp; }
bool wxVideoXANIM::SetSize(wxSize size) { if (!m_video_output) return false; m_video_output->SetSize(size.GetWidth(), size.GetHeight()); return false; }
void TstLayer_t::setSize(const wxSize &sz) { if (sz == mDC->GetSize()) return; mSurface->SetWidth(sz.GetWidth()); mSurface->SetHeight(sz.GetHeight()); _updateDC(); }
void wxPolarAreaChart::SliceArc::Resize(const wxSize &size) { wxDouble x = (size.GetX() / 2); wxDouble y = (size.GetY() / 2); wxDouble radius = ((x < y) ? x : y); SetCenter(x, y); }
void wxJigsawInputParameter::Draw(wxDC & dc, const wxPoint & pos, const wxSize & offset, double scale, wxColour color) { wxPoint realPosition( pos.x + offset.GetWidth(), pos.y /*+ offset.GetHeight()*/); /*wxLogTrace(wxTraceMask(), _("ParameterPos = %i,%i; Offset=%i, %i"), realPosition.x, realPosition.y, offset.x, offset.y);*/ wxSize labelSize; wxSize size = GetSize(dc, scale); dc.GetTextExtent(m_Label, &labelSize.x, &labelSize.y, 0, 0, (wxFont *)&dc.GetFont()); //Draw the text with bevel wxRect rectText(realPosition, size); rectText.x++; rectText.y++; dc.SetTextForeground(*wxBLACK); dc.DrawLabel(m_Label, rectText, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); rectText.x--; rectText.y--; dc.SetTextForeground(*wxWHITE); dc.DrawLabel(m_Label, rectText, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); wxPoint shapePos; wxSize shapeSize; if(m_Shape) { shapeSize = m_Shape->GetSize(dc, scale); shapePos = wxPoint( pos.x + labelSize.x + wxJigsawInputParameter::ParameterSpacing*scale, pos.y + (size.GetHeight()-shapeSize.GetHeight())/2); m_Shape->SetPosition(shapePos.x, shapePos.y + (size.GetHeight()-shapeSize.GetHeight())*scale/2 - offset.GetHeight()); m_Shape->Draw(dc, offset, scale); } else { dc.SetPen(*wxBLACK_PEN); wxBrush paramBrush(wxColour(color.Red()*.9,color.Green()*.9,color.Blue()*.9)); dc.SetBrush(paramBrush); //dc.SetBrush(*wxWHITE_BRUSH); shapeSize = wxJigsawInputParameter::GetDefaultParameterSize(); shapeSize.x *= scale; shapeSize.y *= scale; shapePos = wxPoint( realPosition.x + labelSize.x + wxJigsawInputParameter::ParameterSpacing*scale, realPosition.y + (size.GetHeight()-shapeSize.GetHeight())/2); wxJigsawShape::DrawShapeHeader(dc, shapePos, shapeSize, GetStyle()); } //dc.SetBrush(*wxTRANSPARENT_BRUSH); //dc.SetPen(*wxBLACK_PEN); //dc.DrawRectangle(realPosition, size); }
wxSize wxRibbonGallery::DoGetNextLargerSize(wxOrientation direction, wxSize relative_to) const { if(m_art == NULL) return relative_to; wxMemoryDC dc; wxSize client = m_art->GetGalleryClientSize(dc, this, relative_to, NULL, NULL, NULL, NULL); // No need to grow if the given size can already display every item int nitems = (client.GetWidth() / m_bitmap_padded_size.x) * (client.GetHeight() / m_bitmap_padded_size.y); if(nitems >= (int)m_items.GetCount()) return relative_to; switch(direction) { case wxHORIZONTAL: client.IncBy(m_bitmap_padded_size.x, 0); break; case wxVERTICAL: client.IncBy(0, m_bitmap_padded_size.y); break; case wxBOTH: client.IncBy(m_bitmap_padded_size); break; } client.x = (client.x / m_bitmap_padded_size.x) * m_bitmap_padded_size.x; client.y = (client.y / m_bitmap_padded_size.y) * m_bitmap_padded_size.y; wxSize size = m_art->GetGallerySize(dc, this, client); wxSize minimum = GetMinSize(); if(size.GetWidth() < minimum.GetWidth() || size.GetHeight() < minimum.GetHeight()) { return relative_to; } switch(direction) { case wxHORIZONTAL: size.SetHeight(relative_to.GetHeight()); break; case wxVERTICAL: size.SetWidth(relative_to.GetWidth()); break; default: break; } return size; }
bool wxRibbonPanel::IsMinimised(wxSize at_size) const { if(!m_minimised_size.IsFullySpecified()) return false; return (at_size.GetX() <= m_minimised_size.GetX() && at_size.GetY() <= m_minimised_size.GetY()) || at_size.GetX() < m_smallest_unminimised_size.GetX() || at_size.GetY() < m_smallest_unminimised_size.GetY(); }
void EffectAssist::AdjustClientSizes(wxSize s) { mSize = s; if( mAssistPanel != nullptr ) { s.SetWidth(s.GetWidth()-15); s.SetHeight(s.GetHeight()-15); mAssistPanel->AdjustSize(s); } }
bool check_negative_size(VALUE val, wxSize &size) { size = unwrap<wxSize>(val); if(size.GetHeight() <= 0 || size.GetWidth() <= 0) { rb_raise(rb_eArgError,"%" PRIsVALUE " does have invalid size.", RB_OBJ_STRING(rb_inspect(val))); return false; } return true; }
void ClippingBoxTestCaseBase::OneRegionAndReset() { // Setting one clipping box and next destroy it. // Final clipping box should be the same as DC surface. m_dc->SetClippingRegion(10, 20, 80, 75); m_dc->DestroyClippingRegion(); m_dc->SetBackground(wxBrush(s_fgColour, wxBRUSHSTYLE_SOLID)); m_dc->Clear(); CheckBox(0, 0, s_dcSize.GetWidth(), s_dcSize.GetHeight()); }
void RenderCanvas::OnPaint( wxPaintEvent& event ) { // This is required even though dc is not used otherwise. // PrepareDC(dc); wxPaintDC dc(this); const wxSize size = GetClientSize(); if ( m_RenderManager ) m_RenderManager->ResizeViewport( size.GetWidth(), size.GetHeight() ); RenderFrame(); event.Skip(); }
wxMoColourPanel::wxMoColourPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style | wxNO_BORDER | wxFULL_REPAINT_ON_RESIZE, name ), wxMoColour( (wxColour::ChannelType) 0, (wxColour::ChannelType)0, (wxColour::ChannelType)0, (wxColour::ChannelType)255 ) { SetBackgroundStyle(wxBG_STYLE_CUSTOM ); if (!m_Pattern.Create( size.GetWidth(), size.GetHeight(), 24 )) { wxMessageBox(wxString("wxMoColourPanel error creating pattern bitmap.")); } }
static int GetSizeInOrientation(wxSize size, wxOrientation orientation) { switch(orientation) { case wxHORIZONTAL: return size.GetWidth(); case wxVERTICAL: return size.GetHeight(); case wxBOTH: return size.GetWidth() * size.GetHeight(); default: return 0; } }
bool wxcWrite(const wxString& path, const wxSize& val) { wxConfigBase* conf = wxConfigBase::Get(false); if (!conf) return false; if (!conf->Write(path + wxT("_w"), val.GetWidth())) return false; if (!conf->Write(path + wxT("_h"), val.GetHeight())) return false; return true; }
void ClippingBoxTestCaseBase::OneLargeRegion() { // Setting one clipping box larger then DC surface. // Final clipping box should be limited to the DC extents. m_dc->SetClippingRegion(-10, -20, s_dcSize.GetWidth()+30, s_dcSize.GetHeight()+50); m_dc->SetBackground(wxBrush(s_fgColour, wxBRUSHSTYLE_SOLID)); m_dc->Clear(); CheckBox(0, 0, s_dcSize.GetWidth(), s_dcSize.GetHeight()); }
void SetPixelSize(const wxSize& pixelSize) { wxCHECK_RET( pixelSize.GetWidth() >= 0, "negative font width" ); wxCHECK_RET( pixelSize.GetHeight() != 0, "zero font height" ); Free(); m_nativeFontInfo.SetPixelSize(pixelSize); m_sizeUsingPixels = true; }
bool TryParse( wxSize& dest, wxStringTokenizer& parts ) { long result[2]; if( !parts.HasMoreTokens() || !parts.GetNextToken().ToLong( &result[0] ) ) return false; if( !parts.HasMoreTokens() || !parts.GetNextToken().ToLong( &result[1] ) ) return false; dest.SetWidth( result[0] ); dest.SetHeight( result[1] ); return true; }
void ClientSizeTestCase::ClientSizeNotNegative() { wxWindow* w = new wxWindow(wxTheApp->GetTopWindow(), -1, wxDefaultPosition, wxDefaultSize, wxBORDER_THEME); w->SetSize(wxSize(1,1)); const wxSize szw = w->GetClientSize(); CPPUNIT_ASSERT(szw.GetWidth() >= 0); CPPUNIT_ASSERT(szw.GetHeight() >= 0); w->Destroy(); }
void wxDoughnutAndPieChartBase::SliceArc::Resize(const wxSize &size, const wxDoughnutAndPieChartOptionsBase& options) { wxDouble x = (size.GetX() / 2) - 2; wxDouble y = (size.GetY() / 2) - 2; wxDouble outerRadius = ((x < y) ? x : y) - (GetOptions().GetOutlineWidth() / 2); wxDouble innerRadius = outerRadius * ((wxDouble)options.GetPercentageInnerCutout()) / 100; SetCenter(x, y); SetRadiuses(outerRadius, innerRadius); }
static void AdjustFontSize(wxFont& font, wxDC& dc, const wxSize& pixelSize) { int currentSize = 0; int largestGood = 0; int smallestBad = 0; bool initialGoodFound = false; bool initialBadFound = false; // NB: this assignment was separated from the variable definition // in order to fix a gcc v3.3.3 compiler crash currentSize = font.GetPointSize(); while (currentSize > 0) { dc.SetFont(font); // if currentSize (in points) results in a font that is smaller // than required by pixelSize it is considered a good size if (dc.GetCharHeight() <= pixelSize.GetHeight() && (!pixelSize.GetWidth() || dc.GetCharWidth() <= pixelSize.GetWidth())) { largestGood = currentSize; initialGoodFound = true; } else { smallestBad = currentSize; initialBadFound = true; } if (!initialGoodFound) { currentSize /= 2; } else if (!initialBadFound) { currentSize *= 2; } else { int distance = smallestBad - largestGood; if (distance == 1) break; currentSize = largestGood + distance / 2; } font.SetPointSize(currentSize); } if (currentSize != largestGood) font.SetPointSize(largestGood); }
void wxPolarAreaChart::Add(const wxChartSliceData &slice, size_t index, const wxSize &size) { wxDouble x = (size.GetX() / 2); wxDouble y = (size.GetY() / 2); wxDouble radius = ((x < y) ? x : y); SliceArc::ptr newSlice = SliceArc::ptr(new SliceArc(slice, x, y, 0, 0, radius)); m_slices.insert(m_slices.begin() + index, newSlice); }
wxSize wxcRead(const wxString& path, const wxSize& def) { wxConfigBase* conf = wxConfigBase::Get(false); if (!conf) return def; wxSize val = def; int i; if (conf->Read(path + wxT("_w"), &i, def.GetWidth())) val.SetWidth(i); if (conf->Read(path + wxT("_h"), &i, def.GetHeight())) val.SetHeight(i); return val; }
void TestDialog::AdjustPanelBestSize( const wxSize & panelBestSize, wxSize &finalPanelSize, wxSize &finalClientSize) { wxString log; const wxSize clientSize = GetClientSize(); log << wxT("\nClient size is ") << clientSize; wxCollapsiblePane *cpane = wxDynamicCast( FindWindow(ID_COLLPANE), wxCollapsiblePane ); // size of borders, margins and other controls const wxSize restSize = clientSize - cpane->GetSize(); log << wxT("\nSize of dialog minus collpane is ") << restSize; // For that, this is how big the dialog has to be. If expected client width is less that current width, we keep // the same width. For height, we just add the height required by the panel to our current client height since // so far the panel's client height was 0 const wxSize dlgBestClientSize( clientSize.x > panelBestSize.x? clientSize.x: panelBestSize.x + restSize.x, panelBestSize.y + clientSize.y ); log << wxT("\nFor that, the dialog has to be ") << dlgBestClientSize; // Available screen size (minus any app bars, status bars, etc const wxSize dispSize = GetCurrentUsableDisplaySize(this); log << wxT("\nBut the display size is only ") << dispSize; wxSize decoSize( GetSize() - clientSize ); log << wxT("\nWindow decorations are ") << GetSize() << wxT(" minus ") << clientSize << wxT(", that is ") << decoSize; if ( decoSize.x == 0 ) decoSize.x = 2*wxSystemSettings::GetMetric( wxSYS_BORDER_X, this); if (decoSize.y == 0 ) decoSize.y = 2*wxSystemSettings::GetMetric( wxSYS_BORDER_Y, this) + wxSystemSettings::GetMetric(wxSYS_CAPTION_Y, this); log << wxT("\nFinal Window decorations are ") << decoSize; // This is how big the client size could be. Basically, the entire screen minus all window decorations const wxSize maxClientSize = dispSize - decoSize; log << wxT("\nSo the max possible client size is ") << maxClientSize; // We only get as big as we need to be, so as to not cover up the entire screen unnecessarily finalClientSize.Set( wxMin(maxClientSize.x, dlgBestClientSize.x), wxMin(maxClientSize.y, dlgBestClientSize.y) ); log << wxT("\nSo the final client size is ") << finalClientSize; finalPanelSize.Set( wxMin( (finalClientSize.x - restSize.x), panelBestSize.x), finalClientSize.y - restSize.y - cpane->GetSize().y ); log << wxT("\nSo the final panel size is ") << finalPanelSize; wxLogDebug(log); }
void wxPolarAreaChart::DoSetSize(const wxSize &size) { wxSize newSize( size.GetWidth() - m_options.GetPadding().GetTotalHorizontalPadding(), size.GetHeight() - m_options.GetPadding().GetTotalVerticalPadding() ); m_grid.Resize(newSize); for (size_t i = 0; i < m_slices.size(); ++i) { m_slices[i]->Resize(newSize); } }
//////////////////////////////////////////////////////////////////// // Method: Constructor // Class: CCamView // Purose: build my CCamView object // Input: nothing // Output: nothing //////////////////////////////////////////////////////////////////// CCamView::CCamView( wxWindow *frame, const wxPoint& pos, const wxSize& size ): wxWindow(frame, -1, pos, size, wxSIMPLE_BORDER ) { m_pCamera = NULL; // set my canvas width/height m_nWidth = size.GetWidth( ); m_nHeight = size.GetHeight( ); m_bDrawing = false; m_bNewImage = 0; }
bool wxDrawerWindow::Create(wxWindow *parent, wxWindowID id, const wxString& WXUNUSED(title), wxSize size, wxDirection edge, const wxString& name) { wxASSERT_MSG(NULL != parent, wxT("wxDrawerWindows must be attached to a parent window.")); // Constrain the drawer size to the parent window. const wxSize parentSize(parent->GetClientSize()); if (wxLEFT == edge || wxRIGHT == edge) { if (size.GetHeight() > parentSize.GetHeight()) size.SetHeight(parentSize.GetHeight() - (kLeadingOffset + kTrailingOffset)); } else { if (size.GetWidth() > parentSize.GetWidth()) size.SetWidth(parentSize.GetWidth() - (kLeadingOffset + kTrailingOffset)); } // Create the drawer window. const wxPoint pos(0, 0); const wxSize dummySize(0,0); const long style = wxFRAME_DRAWER; bool success = wxNonOwnedWindow::Create(parent, id, pos, size, style, name); if (success) { // this->MacCreateRealWindow(pos, size, style, name); success = (GetWXWindow() != NULL); } if (success) { // Use drawer brush. SetBackgroundColour( wxColour( wxMacCreateCGColorFromHITheme( kThemeBrushDrawerBackground ) ) ); ::SetThemeWindowBackground((WindowRef)GetWXWindow(), kThemeBrushDrawerBackground, false); // Leading and trailing offset are gaps from parent window edges // to where the drawer starts. ::SetDrawerOffsets((WindowRef)GetWXWindow() , kLeadingOffset, kTrailingOffset); // Set the drawers parent. // Is there a better way to get the parent's WindowRef? wxTopLevelWindow* tlwParent = wxDynamicCast(parent, wxTopLevelWindow); if (NULL != tlwParent) { OSStatus status = ::SetDrawerParent((WindowRef) GetWXWindow(), (WindowRef)tlwParent->GetWXWindow()); success = (noErr == status); } else success = false; } return success && SetPreferredEdge(edge); }
wxSize wxRibbonGallery::DoGetNextSmallerSize(wxOrientation direction, wxSize relative_to) const { if(m_art == NULL) return relative_to; wxMemoryDC dc; wxSize client = m_art->GetGalleryClientSize(dc, this, relative_to, NULL, NULL, NULL, NULL); switch(direction) { case wxHORIZONTAL: client.DecBy(1, 0); break; case wxVERTICAL: client.DecBy(0, 1); break; case wxBOTH: client.DecBy(1, 1); break; } if(client.GetWidth() < 0 || client.GetHeight() < 0) return relative_to; client.x = (client.x / m_bitmap_padded_size.x) * m_bitmap_padded_size.x; client.y = (client.y / m_bitmap_padded_size.y) * m_bitmap_padded_size.y; wxSize size = m_art->GetGallerySize(dc, this, client); wxSize minimum = GetMinSize(); if(size.GetWidth() < minimum.GetWidth() || size.GetHeight() < minimum.GetHeight()) { return relative_to; } switch(direction) { case wxHORIZONTAL: size.SetHeight(relative_to.GetHeight()); break; case wxVERTICAL: size.SetWidth(relative_to.GetWidth()); break; default: break; } return size; }
sipXTabbedDlg::sipXTabbedDlg( wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style, long options ) : wxDialog( parent, id, title, position, size, style ) { sipXTabbedDlgFunc(this, TRUE, TRUE ); mXpos = position.x; mYpos = position.y; mWidth = size.GetWidth(); mHeight = size.GetHeight(); mOptions = options; mLastPage = 0; }
//================================================================================= void SliderControlBase::CalcContinuumGeometry( ContinuumGeometry& continuumGeometry, const wxSize& size ) { continuumGeometry.radius = size.GetHeight() / 2; continuumGeometry.leftMostPos.x = continuumGeometry.radius; continuumGeometry.leftMostPos.y = size.GetHeight() / 2; continuumGeometry.rightMostPos.x = size.GetWidth() - continuumGeometry.radius; continuumGeometry.rightMostPos.y = size.GetHeight() / 2; }