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()); }
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; } }
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); }
// {{{ wxBitmap ArtProvider::CreateBitmap(const wxArtID &id, const wxArtClient &client, const wxSize &size) wxBitmap ArtProvider::CreateBitmap(const wxArtID &id, const wxArtClient &client, const wxSize &size) { #ifdef BUILTIN_IMAGES const Images::Image *img = Images::GetImage(id); if (img == NULL) { return wxNullBitmap; } wxMemoryInputStream mis(img->image, img->size); wxImage image(mis, wxBITMAP_TYPE_PNG); #elif __WXMAC__ wxString path(wxGetCwd()); path << wxT("/Dubnium.app/Contents/Resources/") << id << wxT(".png"); if (!wxFileExists(path)) { return wxNullBitmap; } wxImage image(path, wxBITMAP_TYPE_PNG); #elif DUBNIUM_DEBUG wxString path(wxT(__FILE__)); path = wxPathOnly(path); path << wxT("/../../images/") << id << wxT(".png"); if (!wxFileExists(path)) { /* This is a debug message only, since for built-in IDs like * wxART_DELETE this will just fall through to the wxWidgets * default provider and isn't an error. */ wxLogDebug(wxT("Requested image ID: %s; NOT FOUND as %s"), id.c_str(), path.c_str()); return wxNullBitmap; } wxLogDebug(wxT("Requested image ID: %s; found as %s"), id.c_str(), path.c_str()); wxImage image(path, wxBITMAP_TYPE_PNG); #else wxString path; path << wxT(PREFIX) << wxT("/share/dubnium/") << id << wxT(".png"); if (!wxFileExists(path)) { return wxNullBitmap; } wxImage image(path, wxBITMAP_TYPE_PNG); #endif /* There seems to be a tendency for wxArtProvider to request images of * size (-1, -1), so we need to avoid trying to rescale for them. */ if (wxSize(image.GetWidth(), image.GetHeight()) != size && size.GetWidth() > 0 && size.GetHeight() > 0) { wxLogDebug(wxT("Requested width: %d; height: %d"), size.GetWidth(), size.GetHeight()); image.Rescale(size.GetWidth(), size.GetHeight(), wxIMAGE_QUALITY_HIGH); } return wxBitmap(image); }
wxPoint Align(wxSize referenceSize, wxSize objectSize, AlignmentDefinition alignment) { int x = 0; int y = 0; if (alignment.GetHorizontal() == HA_LEFT) x = 0; if (alignment.GetHorizontal() == HA_CENTER) x = (referenceSize.GetWidth() - objectSize.GetWidth()) / 2; if (alignment.GetHorizontal() == HA_RIGHT) x = referenceSize.GetWidth() - objectSize.GetWidth(); if (alignment.GetVertical() == VA_TOP) y = 0; if (alignment.GetVertical() == VA_CENTER) y = (referenceSize.GetHeight() - objectSize.GetHeight()) / 2; if (alignment.GetVertical() == VA_BOTTOM) y = referenceSize.GetHeight() - objectSize.GetHeight(); return wxPoint(x, y); }
ConfigDialog::ConfigDialog ( wxWindow * parent, wxWindowID id, const wxString & title, config::Config *c, const wxPoint & position, const wxSize & size, long style ) : wxDialog( parent, id, title, position, size, style) { config = c; wxString dimensions = "", s; wxPoint p; wxSize sz, sizebox; sz.SetWidth(size.GetWidth() - 20); sz.SetHeight(size.GetHeight() - 70); sizebox.SetWidth(size.GetWidth()/2 - 10); sizebox.SetHeight(20); p.x = 6; p.y = 2; //s.Printf(_(" x = %d y = %d\n"), p.x, p.y); dimensions.append(s); // s.Printf(_(" width = %d height = %d\n"), sz.GetWidth(), sz.GetHeight()); dimensions.append(s); dimensions.append(""); raioText = new wxTextCtrl ( this, -1, dimensions, wxPoint(size.GetWidth()/2, 2), sizebox, wxTE_MULTILINE ); chkDesenhaPontos = new wxCheckBox (this, -1, "desenha pontos", p); p.y += sizebox.GetHeight() + 2; chkDesenhaContornos = new wxCheckBox (this, -1, "desenha contornos", p); p.y += sizebox.GetHeight() + 2; chkDesenhaMapa = new wxCheckBox (this, -1, "desenha mapa", p); p.y += sizebox.GetHeight() + 2; chkDesenhaVeiculos = new wxCheckBox (this, -1, "mostra veiculos", p); chkDesenhaPontos->SetValue(config->getBool(CONFIG_DESENHA_PONTOS)); chkDesenhaContornos->SetValue(config->getBool(CONFIG_DESENHA_CONTORNOS)); chkDesenhaMapa->SetValue(config->getBool(CONFIG_DESENHA_MAPA)); chkDesenhaVeiculos->SetValue(config->getBool(CONFIG_DESENHA_VEICULOS)); // // raioText = new wxTextCtrl ( this, -1, dimensions, wxPoint(size.GetWidth()/2, 2), // sizebox, wxTE_MULTILINE ); p.y += size.GetHeight() - 70; wxButton * b = new wxButton( this, wxID_OK, _("OK"), p, wxDefaultSize ); p.x += 100; wxButton * b2 = new wxButton( this, wxID_CANCEL, _("Cancel"), p, wxDefaultSize ); raio = ""; Bind(wxEVT_COMMAND_BUTTON_CLICKED, &ConfigDialog::OnOk, this, b->GetId()); }
static void DrawKDETheme(wxDC& dc,wxSize size) { wxPen pen; pen.SetStyle(wxSOLID); wxBrush brush(kdetheme[13],wxSOLID); dc.SetBackground(brush); dc.Clear(); for(int i=0;i<14;i++) { pen.SetColour(kdetheme[i]); dc.SetPen(pen); dc.DrawLine(0,i,size.GetWidth()-1,i); dc.DrawLine(0,size.GetHeight()-1-i, size.GetWidth()-1,size.GetHeight()-1-i); } };
wxBitmap ArtProvider::loadBitmapFromFile(const wxArtID& id, wxSize size) { wxString name(id.Lower()); if (name.substr(0, 4) == "art_") name.erase(0, 4); if (size == wxDefaultSize) size = wxSize(32, 32); wxFileName fname(config().getImagesPath() + name + wxString::Format("_%dx%d", size.GetWidth(), size.GetHeight())); wxArrayString imgExts; imgExts.Add("png"); imgExts.Add("xpm"); imgExts.Add("bmp"); for (size_t i = 0; i < imgExts.GetCount(); ++i) { fname.SetExt(imgExts[i]); wxLogDebug("Trying to load image file \"%s\"", fname.GetFullPath().c_str()); if (fname.FileExists()) { wxImage img(fname.GetFullPath()); if (img.IsOk() && wxSize(img.GetWidth(), img.GetHeight()) == size) return wxBitmap(img); } } return wxNullBitmap; }
void edSETTINGS::SetWindowSize(const wxSize& size) { if (size.GetWidth() > 0 || size.GetHeight() > 0) { mWindowSize = size; } }
std::list<wxString> CThemeProvider::GetSearchDirs(const wxSize& size) { const int s(size.GetWidth()); // Sort order: // - Current theme before general resource dir // - Try current size first // - Then try scale down next larger icon // - Then try scaling up next smaller icon int sizes[] = { 48,32,24,20,16 }; const int count = static_cast<int>(sizeof(sizes) / sizeof(int)); std::list<wxString> sizeStrings; for (int i = 0; i < count && sizes[i] > s; ++i) sizeStrings.push_front(SubdirFromSize(sizes[i])); for (int i = 0; i < count; ++i) if (sizes[i] < s) sizeStrings.push_back(SubdirFromSize(sizes[i])); sizeStrings.push_front(SubdirFromSize(s)); std::list<wxString> dirs; for (std::list<wxString>::const_iterator it = sizeStrings.begin(); it != sizeStrings.end(); ++it) dirs.push_back(m_themePath + *it); const wxString resourceDir(wxGetApp().GetResourceDir()); for (std::list<wxString>::const_iterator it = sizeStrings.begin(); it != sizeStrings.end(); ++it) dirs.push_back(resourceDir + *it); return dirs; }
ListaDialog::ListaDialog ( wxWindow * parent, wxWindowID id, const wxString & title, const std::string lista, const wxPoint & position, const wxSize & size, long style ) : wxDialog( parent, id, title, position, size, style) { wxPoint p; wxSize sz; wxString text = ""; text.append (lista); sz.SetWidth(size.GetWidth() - 20); sz.SetHeight(size.GetHeight() - 70); p.x = 6; p.y = 2; dialogText = new wxTextCtrl ( this, -1, text, p, sz, wxTE_MULTILINE ); p.y += sz.GetHeight() + 10; wxButton * b = new wxButton( this, wxID_OK, _("OK"), p, wxDefaultSize ); p.x += 110; Bind(wxEVT_COMMAND_BUTTON_CLICKED, &ListaDialog::OnOk, this, b->GetId()); }
void wxNotebook::SetPadding( const wxSize &padding ) { wxCHECK_RET( m_widget != NULL, wxT("invalid notebook") ); m_padding = padding.GetWidth(); int i; #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for (i=0; i<int(GetPageCount()); i++) { wxGtkNotebookPage* nb_page = GetNotebookPage(i); wxASSERT(nb_page != NULL); if (nb_page->m_image != -1) { // gtk_box_set_child_packing sets padding on BOTH sides // icon provides left padding, label provides center and right int image = nb_page->m_image; SetPageImage(i,-1); SetPageImage(i,image); } wxASSERT(nb_page->m_label); gtk_box_set_child_packing(GTK_BOX(nb_page->m_box), GTK_WIDGET(nb_page->m_label), FALSE, FALSE, m_padding, GTK_PACK_END); } }
tcGameOutcomePopup::tcGameOutcomePopup(const wxPoint& pos, const wxSize& size) : tc3DWindow2(parent, pos, size, "GameOutcome", parent) { SetBaseRenderBin(parent->GetBaseRenderBin() + 10); Raise(); birthCount = tcTime::Get()->Get30HzCount(); SetBorderDraw(true); int w = 70; int h = 15; int x = (size.GetWidth() - w) / 2; int y = size.GetHeight() - 25; tcButton* exitButton = new tcButton(this, wxPoint(x - w, y), wxSize(w, h), "XBUTTON"); exitButton->SetCaption("EXIT GAME"); exitButton->SetFontSize(fontSize + 2.0f); exitButton->SetOffColor(Vec4(0.2f, 0.2f, 0.2f, 0.5f)); exitButton->SetOverColor(Vec4(0.25f, 0.25f, 0.25f, 0.5f)); exitButton->SetCommand(86); tcButton* continueButton = new tcButton(this, wxPoint(x + w, y), wxSize(w, h), "XBUTTON"); continueButton->SetCaption("PLAY ON"); continueButton->SetFontSize(fontSize + 2.0f); continueButton->SetOffColor(Vec4(0.2f, 0.2f, 0.2f, 0.5f)); continueButton->SetOverColor(Vec4(0.25f, 0.25f, 0.25f, 0.5f)); continueButton->SetCommand(123); }
void ClippingBoxTestCaseBase::InitialState() { // Initial clipping box should be the same as the entire DC surface. m_dc->SetBackground(wxBrush(s_fgColour, wxBRUSHSTYLE_SOLID)); m_dc->Clear(); CheckBox(0, 0, s_dcSize.GetWidth(), s_dcSize.GetHeight()); }
cBitmap2ButtonEx::cBitmap2ButtonEx( wxWindow *parent, wxWindowID id, const wxString& fileName, const wxPoint& pos, const wxSize& size, long style, BUTTON2_TYPE::TYPE buttonImageType ) : cBitmap3ButtonEx(parent, id, pos, size, style) , m_buttonImgType(buttonImageType) { int w = size.GetWidth(); int h = size.GetHeight(); if (!fileName.IsEmpty()) { wxImage img(fileName + _("_0") + GetFileExt()); w = img.GetWidth(); h = img.GetHeight(); } SetMinSize(wxSize(w, h)); // 버튼이미지 업데이트 SetButton2Bitmap(fileName); }
static bool OutOfRoom(wxSize frameSize, double camX, double camY, int margin) { return camX < margin || camY < margin || camX >= frameSize.GetWidth() - margin || camY >= frameSize.GetHeight() - margin; }
void RenderCanvas::Init( ) { // must be called explicitly after the parent frame is opened const wxSize clientSize = GetClientSize(); m_RenderManager->GetRenderProfile()->OpenScreen( clientSize.GetWidth(), clientSize.GetHeight(), 0, "" ); Activate( true ); }
// returns true if the combo is constrained and false otherwise // @param toolbarWidth the width of the toolbar in pixels // @param ratio an in/out for the desired and resultant width ratio. // @param flex the amount of extra space allowed to have past the available. // the amount used is subtracted. static bool RepositionCombo(wxWindow *combo, int toolbarWidth, wxSize desiredSize, float &ratio, float &flex, int marginPixels, bool changesRatio) { float ratioChange; bool constrained = false; // push margin pixels desiredSize.x += marginPixels; // truncate the window size if necessary if (desiredSize.x > toolbarWidth * (flex + ratio)) { constrained = true; desiredSize.SetWidth(toolbarWidth * (flex + ratio)); if (desiredSize.GetWidth() - marginPixels < 0) desiredSize.SetWidth(marginPixels); } // keep track of how much space gained or lost so it can be used by other combos. if (changesRatio) { ratioChange = (desiredSize.x / ((float) toolbarWidth)) - ratio; ratio += ratioChange; flex -= ratioChange; } // pop the margin pixels desiredSize.x -= marginPixels; combo->SetMinSize(desiredSize); return constrained; }
QSize wxQtConvertSize( const wxSize &size ) { if (size == wxDefaultSize) return QSize(); return QSize(size.GetWidth(), size.GetHeight()); }
bool COptionsPage::CreatePage(COptions* pOptions, CSettingsDialog* pOwner, wxWindow* parent, wxSize& maxSize) { m_pOwner = pOwner; m_pOptions = pOptions; if (!wxXmlResource::Get()->LoadPanel(this, parent, GetResourceName())) return false; wxSize size = GetSize(); #ifdef __WXGTK__ // wxStaticBox draws its own border coords -1. // Adjust this window so that the left border is fully visible. Move(1, 0); size.x += 1; #endif if (size.GetWidth() > maxSize.GetWidth()) maxSize.SetWidth(size.GetWidth()); if (size.GetHeight() > maxSize.GetHeight()) maxSize.SetHeight(size.GetHeight()); m_was_selected = false; return true; }
LineChart::LineChart( wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size) : wxWindow(parent, id, pos, size), m_viewOffsetFactor(0), m_markerIndex(0), _zoomPercentage(DEFAULT_ZOOM), _currentWidth(0), _currentHeight(0), _memBitmap(NULL), _backgroundColor(*wxBLACK), m_showScale(true), m_showData(false), m_mouseX(0), m_mouseY(0), m_leftEdge(0) { if (parent){ SetBackgroundColour(parent->GetBackgroundColour()); } else{ SetBackgroundColour(*wxBLACK); } _currentWidth = size.GetWidth(); _currentHeight = size.GetHeight(); _memBitmap = new wxBitmap(_currentWidth, _currentHeight); m_leftEdge = 0; }
/* My frame constructor */ OSGPanel::OSGPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) { // create osg canvas // - initialize int width, height; width = size.GetWidth(); height = size.GetHeight(); int *attributes = new int[7]; attributes[0] = int(WX_GL_DOUBLEBUFFER); attributes[1] = WX_GL_RGBA; attributes[2] = WX_GL_DEPTH_SIZE; attributes[3] = 8; attributes[4] = WX_GL_STENCIL_SIZE; attributes[5] = 8; attributes[6] = 0; _canvas = new OSGCanvas(this, wxID_ANY, wxDefaultPosition, wxSize(width, height), wxNO_BORDER, wxT("osgviewerWX"), attributes); GraphicsWindowWX* gw = new GraphicsWindowWX(_canvas); _canvas->SetGraphicsWindow(gw); _viewer = new osgViewer::Viewer; _viewer->getCamera()->setGraphicsContext(gw); _viewer->getCamera()->setViewport(0, 0, width, height); _viewer->addEventHandler(new osgViewer::StatsHandler); _viewer->addEventHandler(SmartSingleton<KeyboardHandler>::getInstance()); _viewer->addEventHandler(new osgViewer::WindowSizeHandler); _viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded); }
wxlCan::wxlCan( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ): wxScrolledWindow( parent, id, pos, size, style ) { m_luastate = NULL; int w,h; GetVirtualSize( &w, &h ); m_buffer = wxBitmap( size.GetWidth(), size.GetHeight() ); m_pendingObjects = false; //set one to one mapping as default m_xpp = 1; m_ypp = 1; m_virt_minX = 0; m_virt_minY = 0; m_transx = 0; m_transy = 0; m_scalex = 1; m_scaley = 1; m_rootobject.SetCanvas( this ); m_hit = NULL; m_cmdh = new wxlLuaCanCmd( this ); }
bool usImage::Init(const wxSize& size) { // Allocates space for image and sets params up // returns true on error int prev = NPixels; NPixels = size.GetWidth() * size.GetHeight(); Size = size; Subframe = wxRect(0, 0, 0, 0); Min = Max = 0; if (NPixels != prev) { delete[] ImageData; if (NPixels) { ImageData = new unsigned short[NPixels]; if (!ImageData) { NPixels = 0; return true; } } else ImageData = NULL; } return false; }
void wxNotebook::SetPadding( const wxSize &padding ) { wxCHECK_RET( m_widget != NULL, wxT("invalid notebook") ); m_padding = padding.GetWidth(); int i; for (i=0; i<int(GetPageCount()); i++) { wxGtkNotebookPage* nb_page = GetNotebookPage(i); wxASSERT(nb_page != NULL); if (nb_page->m_image != -1) { // gtk_box_set_child_packing sets padding on BOTH sides // icon provides left padding, label provides center and right int image = nb_page->m_image; SetPageImage(i,-1); SetPageImage(i,image); } wxASSERT(nb_page->m_label); gtk_box_set_child_packing(GTK_BOX(nb_page->m_box), GTK_WIDGET(nb_page->m_label), FALSE, FALSE, m_padding, GTK_PACK_END); } }
void Canvas::resize( const wxSize& new_size ) { contents.reset( NULL ); contents.reset( new wxImage( new_size.GetWidth(), new_size.GetHeight() ) ); wxScrolledWindow::SetVirtualSize( canvas_coords( new_size ).GetSize() ); zoom_to( canvas_coords( new_size ) ); }
void TstLayer_t::setSize(const wxSize &sz) { if (sz == mDC->GetSize()) return; mSurface->SetWidth(sz.GetWidth()); mSurface->SetHeight(sz.GetHeight()); _updateDC(); }
wxSize wxRibbonToolBar::DoGetNextLargerSize(wxOrientation direction, wxSize relative_to) const { // Pick the smallest of our sizes which are larger than the given size wxSize result(relative_to); int area = INT_MAX; int nrows; for(nrows = m_nrows_min; nrows <= m_nrows_max; ++nrows) { wxSize size(m_sizes[nrows - m_nrows_min]); wxSize original(size); switch(direction) { case wxHORIZONTAL: if(size.GetWidth() > relative_to.GetWidth() && size.GetHeight() <= relative_to.GetHeight()) { size.SetHeight(relative_to.GetHeight()); break; } continue; case wxVERTICAL: if(size.GetWidth() <= relative_to.GetWidth() && size.GetHeight() > relative_to.GetHeight()) { size.SetWidth(relative_to.GetWidth()); break; } continue; case wxBOTH: if(size.GetWidth() > relative_to.GetWidth() && size.GetHeight() > relative_to.GetHeight()) { break; } continue; } if(GetSizeInOrientation(original, direction) < area) { result = size; area = GetSizeInOrientation(original, direction); } } return result; }
wxString Variant::MakeString (const wxSize & size) { wxString tmp; tmp << "{" << size.GetWidth() << ", " << size.GetHeight() << "}" ; return tmp; }
//================================================================================= 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; }