Esempio n. 1
0
wxSize wxWizardExSizer::GetMaxChildSize()
{
#if !defined(__WXDEBUG__)
    if ( m_childSize.IsFullySpecified() )
        return m_childSize;
#endif

    wxSize maxOfMin;

    for ( wxSizerItemList::compatibility_iterator childNode = m_children.GetFirst();
          childNode;
          childNode = childNode->GetNext() )
    {
        wxSizerItem *child = childNode->GetData();
        maxOfMin.IncTo(child->CalcMin());
        maxOfMin.IncTo(SiblingSize(child));
    }

#ifdef __WXDEBUG__
    if ( m_childSize.IsFullySpecified() && m_childSize != maxOfMin )
    {
        wxFAIL_MSG( _T("Size changed in wxWizard::GetPageAreaSizer()")
                    _T("after RunWizard().\n")
                    _T("Did you forget to call GetSizer()->Fit(this) ")
                    _T("for some page?")) ;

        return m_childSize;
    }
#endif // __WXDEBUG__

    if ( m_owner->m_started )
    {
        m_childSize = maxOfMin;
    }

    return maxOfMin;
}
Esempio n. 2
0
int wxAuiGenericTabArt::GetBestTabCtrlSize(wxWindow* wnd,
                                           const wxAuiNotebookPageArray& pages,
                                           const wxSize& requiredBmp_size)
{
    wxClientDC dc(wnd);
    dc.SetFont(m_measuringFont);

    // sometimes a standard bitmap size needs to be enforced, especially
    // if some tabs have bitmaps and others don't.  This is important because
    // it prevents the tab control from resizing when tabs are added.
    wxBitmap measureBmp;
    if (requiredBmp_size.IsFullySpecified())
    {
        measureBmp.Create(requiredBmp_size.x,
                           requiredBmp_size.y);
    }


    int max_y = 0;
    size_t i, page_count = pages.GetCount();
    for (i = 0; i < page_count; ++i)
    {
        wxAuiNotebookPage& page = pages.Item(i);

        wxBitmap bmp;
        if (measureBmp.IsOk())
            bmp = measureBmp;
        else
            bmp = page.bitmap;

        // we don't use the caption text because we don't
        // want tab heights to be different in the case
        // of a very short piece of text on one tab and a very
        // tall piece of text on another tab
        int x_ext = 0;
        wxSize s = GetTabSize(dc,
                              wnd,
                              wxT("ABCDEFGHIj"),
                              bmp,
                              true,
                              wxAUI_BUTTON_STATE_HIDDEN,
                              &x_ext);

        max_y = wxMax(max_y, s.y);
    }

    return max_y+2;
}
Esempio n. 3
0
bool FrameManager::CreateFrame(const wxString &prefix, const wxString& set, PeriodType pt, time_t time, const wxSize& size, const wxPoint &position, int selected_draw, bool try_load_layout, bool full_screen) {
	DrawFrame *frame = new DrawFrame(this, database_manager, config_manager, remarks_handler, NULL, free_frame_number, _T(""), prefix);

	if(!(try_load_layout && frame->LoadLayout())) {
		if (!frame->AddDrawPanel(prefix, set, pt, time, selected_draw)) {
			frame->Destroy();
			return false;
		}
	}

	frames.Add(frame);

	int fn = free_frame_number;

	int width, height;
	if (size.IsFullySpecified()) {
		width = size.GetWidth();
		height = size.GetHeight();
	} else {
		width = wxConfig::Get()->Read(wxString::Format(_T("DrawFrameWidth_%d"), fn), 850);
		height = wxConfig::Get()->Read(wxString::Format(_T("DrawFrameHeight_%d"), fn), 600);
	}

	int x,y;
	if (position.x != -1 && position.y != -1) {
		x = position.x;
		y = position.y;
	} else {
		x = wxConfig::Get()->Read(wxString::Format(_T("DrawFrameX_%d"), fn), 0L);
		y = wxConfig::Get()->Read(wxString::Format(_T("DrawFrameY_%d"), fn), 0L);
	}

	frame->SetSize(width, height);
	frame->SetPosition(wxPoint(x, y));

	if (free_frame_number == std::numeric_limits<int>::max())
		free_frame_number = 0;
	else
		free_frame_number++;

	if (full_screen)
		frame->SwitchFullScreen();

	frame->Show(true);
	frame->Raise();
	return true;

}
Esempio n. 4
0
wxBitmap CThemeProvider::CreateBitmap(const wxArtID& id, const wxArtClient& /*client*/, const wxSize& size)
{
	if (id.Left(4) != _T("ART_"))
		return wxNullBitmap;
	wxASSERT(size.GetWidth() == size.GetHeight());

	std::list<wxString> dirs = GetSearchDirs(size);

	wxString name = id.Mid(4);

	// The ART_* IDs are always given in uppercase ASCII,
	// all filenames used by FileZilla for the resources
	// are lowercase ASCII. Locale-independent transformation
	// needed e.g. if using Turkish locale.
	MakeLowerAscii(name);

	wxLogNull logNull;

	for (std::list<wxString>::const_iterator iter = dirs.begin(); iter != dirs.end(); iter++)
	{
		wxString fileName = *iter + name + _T(".png");
//#ifdef __WXMSW__
		// MSW toolbar only greys out disabled buttons in a visually
		// pleasing way if the bitmap has an alpha channel. 
		wxImage img(fileName, wxBITMAP_TYPE_PNG);
		if (!img.Ok())
			continue;

		if (img.HasMask() && !img.HasAlpha())
			img.InitAlpha();
		if (size.IsFullySpecified())
			img.Rescale(size.x, size.y, wxIMAGE_QUALITY_HIGH);
		return wxBitmap(img);
/*#else
		wxBitmap bmp(fileName, wxBITMAP_TYPE_PNG);
		if (bmp.Ok())
			return bmp;
#endif*/
	}

	return wxNullBitmap;
}
Esempio n. 5
0
bool wxBitmapButton::Create(wxWindow *parent,
                            wxWindowID id,
                            const wxBitmap& bitmap,
                            const wxPoint& pos,
                            const wxSize& size, long style,
                            const wxValidator& validator,
                            const wxString& name)
{
    if ( !wxBitmapButtonBase::Create(parent, id, pos, size, style,
                                     validator, name) )
        return false;

    if ( bitmap.IsOk() )
        SetBitmapLabel(bitmap);

    if ( !size.IsFullySpecified() )
    {
        // As our bitmap has just changed, our best size has changed as well so
        // reset the initial size using the new value.
        SetInitialSize(size);
    }

    return true;
}
Esempio n. 6
0
void SetWindowSizeAndFitToScreen(wxTopLevelWindow* tlw, wxPoint pos, wxSize size,
                                 wxSize default_size)
{
  if (tlw->IsMaximized())
    return;

  // NOTE: Positions can be negative and still be valid. Coordinates are relative to the
  //   primary monitor so if the primary monitor is in the middle then (-1000, 10) is a
  //   valid position on the monitor to the left of the primary. (This does not apply to
  //   sizes obviously)
  wxRect screen_geometry;
  wxRect window_geometry{pos, size};

  if (wxDisplay::GetCount() > 1)
    screen_geometry = GetVirtualScreenGeometry();
  else
    screen_geometry = wxDisplay(0).GetClientArea();

  // Initialize the default size if it is wxDefaultSize or otherwise negative.
  default_size.DecTo(screen_geometry.GetSize());
  default_size.IncTo(tlw->GetMinSize());
  if (!default_size.IsFullySpecified())
    default_size.SetDefaults(wxDisplay(0).GetClientArea().GetSize() / 2);

  // If the position we're given doesn't make sense then go with the current position.
  // (Assuming the window was created with wxDefaultPosition then this should be reasonable)
  if (pos.x - screen_geometry.GetLeft() < -1000 || pos.y - screen_geometry.GetTop() < -1000 ||
      pos.x - screen_geometry.GetRight() > 1000 || pos.y - screen_geometry.GetBottom() > 1000)
  {
    window_geometry.SetPosition(tlw->GetPosition());
  }

  // If the window is bigger than all monitors combined, or negative (uninitialized) then reset it.
  if (window_geometry.IsEmpty() || window_geometry.GetWidth() > screen_geometry.GetWidth() ||
      window_geometry.GetHeight() > screen_geometry.GetHeight())
  {
    window_geometry.SetSize(default_size);
  }

  // Check if the window entirely lives on a single monitor without spanning.
  // If the window does not span multiple screens then we should constrain it within that
  // single monitor instead of the entire virtual desktop space.
  // The benefit to doing this is that we can account for the OS X menu bar and Windows task
  // bar which are treated as invisible when only looking at the virtual desktop instead of
  // an individual screen.
  if (wxDisplay::GetCount() > 1)
  {
    // SPECIAL CASE: If the window is entirely outside the visible area of the desktop then we
    //   put it back on the primary (zero) monitor.
    wxRect monitor_intersection{window_geometry};
    int the_monitor = 0;
    if (!monitor_intersection.Intersect(screen_geometry).IsEmpty())
    {
      std::array<int, 4> monitors{{wxDisplay::GetFromPoint(monitor_intersection.GetTopLeft()),
                                   wxDisplay::GetFromPoint(monitor_intersection.GetTopRight()),
                                   wxDisplay::GetFromPoint(monitor_intersection.GetBottomLeft()),
                                   wxDisplay::GetFromPoint(monitor_intersection.GetBottomRight())}};
      the_monitor = wxNOT_FOUND;
      bool intersected = false;
      for (int one_monitor : monitors)
      {
        if (one_monitor == the_monitor || one_monitor == wxNOT_FOUND)
          continue;
        if (the_monitor != wxNOT_FOUND)
        {
          // The window is spanning multiple screens.
          the_monitor = wxNOT_FOUND;
          break;
        }
        the_monitor = one_monitor;
        intersected = true;
      }
      // If we get wxNOT_FOUND for all corners then there are holes in the virtual desktop and the
      // entire window is lost in one. (e.g. 3 monitors in an 'L', window in top-right)
      if (!intersected)
        the_monitor = 0;
    }
    if (the_monitor != wxNOT_FOUND)
    {
      // We'll only use the client area of this monitor if the window will actually fit.
      // (It may not fit if the window is spilling off the edge so it isn't entirely visible)
      wxRect client_area{wxDisplay(the_monitor).GetClientArea()};
      if (client_area.GetWidth() >= window_geometry.GetWidth() &&
          client_area.GetHeight() >= window_geometry.GetHeight())
      {
        screen_geometry = client_area;
      }
    }
  }

  // The window SHOULD be small enough to fit on the screen, but it might be spilling off an edge
  // so we'll snap it to the nearest edge as necessary.
  if (!screen_geometry.Contains(window_geometry))
  {
    // NOTE: The order is important here, if the window *is* too big to fit then it will snap to
    //   the top-left corner.
    int spill_x = std::max(0, window_geometry.GetRight() - screen_geometry.GetRight());
    int spill_y = std::max(0, window_geometry.GetBottom() - screen_geometry.GetBottom());
    window_geometry.Offset(-spill_x, -spill_y);
    if (window_geometry.GetTop() < screen_geometry.GetTop())
      window_geometry.SetTop(screen_geometry.GetTop());
    if (window_geometry.GetLeft() < screen_geometry.GetLeft())
      window_geometry.SetLeft(screen_geometry.GetLeft());
  }

  tlw->SetSize(window_geometry, wxSIZE_ALLOW_MINUS_ONE);
}