Esempio n. 1
1
wxRect GetVirtualScreenGeometry()
{
  wxRect geometry;
  for (unsigned int i = 0, end = wxDisplay::GetCount(); i < end; ++i)
    geometry.Union(wxDisplay(i).GetGeometry());
  return geometry;
}
wxSize GetCurrentUsableDisplaySize(wxWindow* win) 
{
  const int disp_id = wxDisplay::GetFromPoint(win->GetScreenPosition());
  const wxSize disp_size = (disp_id == wxNOT_FOUND? ::wxGetClientDisplayRect().GetSize()
                                                    : wxDisplay(disp_id).GetClientArea().GetSize());
  return disp_size;
}
Esempio n. 3
1
wxSize wxGetDisplayPPI()
{
    return wxDisplay().GetPPI();
}
Esempio n. 4
0
wxSize wxGTKCairoDCImpl::GetPPI() const
{
    if ( m_window )
    {
        return wxDisplay(m_window).GetPPI();
    }

    // For a non-window-based DC the concept of PPI doesn't make much sense
    // anyhow, so just return the hardcoded value used by the base class.
    return wxGCDCImpl::GetPPI();
}
Esempio n. 5
0
PersistLocation::PersistLocation(wxDialog *dialog, std::string options_prefix, bool size_too)
: x_opt(OPT_SET(options_prefix + "/Last/X"))
, y_opt(OPT_SET(options_prefix + "/Last/Y"))
, w_opt(size_too ? OPT_SET(options_prefix + "/Last/Width") : nullptr)
, h_opt(size_too ? OPT_SET(options_prefix + "/Last/Height") : nullptr)
, maximize_opt(OPT_SET(options_prefix + "/Maximized"))
, dialog(dialog)
{
	int x = x_opt->GetInt();
	int y = y_opt->GetInt();
	if (x == -1 && y == -1)
		dialog->CenterOnParent();
	else {
		// First move to the saved place so that it ends up on the right monitor
		dialog->Move(x, y);

		if (size_too && w_opt->GetInt() > 0 && h_opt->GetInt() > 0)
			dialog->SetSize(w_opt->GetInt(), h_opt->GetInt());

		int display_index = wxDisplay::GetFromWindow(dialog);

		// If it's moved offscreen center on the parent and try again
		if (display_index == wxNOT_FOUND) {
			dialog->CenterOnParent();
			display_index = wxDisplay::GetFromWindow(dialog);
		}

		// If it's still offscreen just give up
		if (display_index == wxNOT_FOUND) return;

		wxRect display_area = wxDisplay(display_index).GetClientArea();
		wxSize dialog_size = dialog->GetSize();

		// Ensure that the top-left corner is onscreen
		if (x < display_area.x) x = display_area.x;
		if (y < display_area.y) y = display_area.y;

		// Ensure that the bottom-right corner is onscreen as long as doing so
		// wouldn't force the top-left corner offscreen
		if (x + dialog_size.x > display_area.GetRight())
			x = std::max(display_area.x, display_area.GetRight() - dialog_size.x);
		if (y + dialog_size.y > display_area.GetBottom())
			y = std::max(display_area.y, display_area.GetBottom() - dialog_size.y);

		dialog->Move(x, y);
	}

	dialog->Bind(wxEVT_MOVE, &PersistLocation::OnMove, this);

	dialog->Bind(wxEVT_SIZE, &PersistLocation::OnSize, this);
	if ((dialog->GetWindowStyle() & wxMAXIMIZE_BOX) && maximize_opt->GetBool())
		dialog->Maximize();
}
Esempio n. 6
0
void RestoreWindowState(wxTopLevelWindow *win, const wxSize& defaultSize, int flags)
{
    wxConfigBase *cfg = wxConfig::Get();
    const wxString path = WindowStatePath(win);

    if ( flags & WinState_Size )
    {
        int width = cfg->Read(path + _T("w"), defaultSize.x);
        int height = cfg->Read(path + _T("h"), defaultSize.y);
        if ( width != -1 || height != -1 )
            win->SetClientSize(width, height);
    }

#ifndef __WXGTK__
    if ( flags & WinState_Pos )
    {
        int posx = cfg->Read(path + _T("x"), -1);
        int posy = cfg->Read(path + _T("y"), -1);
        if ( posx != -1 || posy != -1 )
            win->Move(posx, posy);
    }

    // If the window is completely out of all screens (e.g. because
    // screens configuration changed), move it to primary screen:
    if ( wxDisplay::GetFromWindow(win) == wxNOT_FOUND )
        win->Move(0, 0);
#endif // !__WXGTK__

    // If the window is larger than current screen, resize it to fit:
    int display = wxDisplay::GetFromWindow(win);
    wxCHECK_RET( display != wxNOT_FOUND, _T("window not on screen") );
    wxRect screenRect = wxDisplay(display).GetClientArea();

    wxRect winRect = win->GetRect();
    if ( winRect.GetPosition() == wxDefaultPosition )
        winRect.SetPosition(screenRect.GetPosition()); // not place yet, fake it

    if ( !screenRect.Contains(winRect) )
    {
        winRect.Intersect(screenRect);
        win->SetSize(winRect);
    }

    // Maximize if it should be
    if ( cfg->Read(path + _T("maximized"), long(0)) )
    {
        win->Maximize();
    }
}
Esempio n. 7
0
// Find whether scrolling will be necessary for the dialog, returning wxVERTICAL, wxHORIZONTAL or both
int wxStandardDialogLayoutAdapter::DoMustScroll(wxDialog* dialog, wxSize& windowSize, wxSize& displaySize)
{
    wxSize minWindowSize = dialog->GetSizer()->GetMinSize();
    windowSize = dialog->GetSize();
    windowSize = wxSize(wxMax(windowSize.x, minWindowSize.x), wxMax(windowSize.y, minWindowSize.y));
    displaySize = wxDisplay(wxDisplay::GetFromWindow(dialog)).GetClientArea().GetSize();

    int flags = 0;

    if (windowSize.y >= (displaySize.y - wxEXTRA_DIALOG_HEIGHT))
        flags |= wxVERTICAL;
    if (windowSize.x >= displaySize.x)
        flags |= wxHORIZONTAL;

    return flags;
}
DialogDetachedVideo::DialogDetachedVideo(agi::Context *context)
: wxDialog(context->parent, -1, "Detached Video", wxDefaultPosition, wxSize(400,300), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX | wxWANTS_CHARS)
, context(context)
, old_display(context->videoDisplay)
, old_slider(context->videoSlider)
, video_open(context->videoController->AddVideoOpenListener(&DialogDetachedVideo::OnVideoOpen, this))
{
	// Set obscure stuff
	SetExtraStyle((GetExtraStyle() & ~wxWS_EX_BLOCK_EVENTS) | wxWS_EX_PROCESS_UI_UPDATES);

	SetTitle(wxString::Format(_("Video: %s"), wxFileName(context->videoController->GetVideoName()).GetFullName()));

	old_display->Unload();

	// Video area;
	VideoBox *videoBox = new VideoBox(this, true, context);
	context->videoDisplay->SetMinClientSize(old_display->GetClientSize());
	videoBox->Layout();

	// Set sizer
	wxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
	mainSizer->Add(videoBox,1,wxEXPAND | wxALL,5);
	SetSizerAndFit(mainSizer);

	// Ensure we can grow smaller, without these the window is locked to at least the initial size
	context->videoDisplay->SetMinSize(wxSize(1,1));
	videoBox->SetMinSize(wxSize(1,1));
	SetMinSize(wxSize(1,1));

	persist.reset(new PersistLocation(this, "Video/Detached"));

	int display_index = wxDisplay::GetFromWindow(this);
	// Ensure that the dialog is no larger than the screen
	if (display_index != wxNOT_FOUND) {
		wxRect bounds_rect = GetRect();
		wxRect disp_rect = wxDisplay(display_index).GetClientArea();
		SetSize(std::min(bounds_rect.width, disp_rect.width), std::min(bounds_rect.height, disp_rect.height));
	}

	OPT_SET("Video/Detached/Enabled")->SetBool(true);

	Bind(wxEVT_CLOSE_WINDOW, &DialogDetachedVideo::OnClose, this);
	Bind(wxEVT_ICONIZE, &DialogDetachedVideo::OnMinimize, this);
	Bind(wxEVT_CHAR_HOOK, &DialogDetachedVideo::OnKeyDown, this);

	AddFullScreenButton(this);
}
Esempio n. 9
0
void MyFrame::OnDisplayChanged(wxDisplayChangedEvent& event)
{
    // update the current mode text
    for ( size_t n = 0; n < m_book->GetPageCount(); n++ )
    {
        wxStaticText *label = wxDynamicCast(m_book->GetPage(n)->
                                                FindWindow(Display_CurrentMode),
                                            wxStaticText);
        if ( label )
            label->SetLabel(VideoModeToText(wxDisplay(n).GetCurrentMode()));
    }


    wxLogStatus(this, wxT("Display resolution was changed."));

    event.Skip();
}
Esempio n. 10
0
ManNotification::ManNotification()
: 	_frameNotify(nullptr), _frameNotifyNearCursor(nullptr),
	_useNotification(USE_NOTIFICATION_RICH),
	_notificationPosition(NOTIFICATION_POSITION_TOP_RIGHT),
	_nearCursor(true), _multipleNotifications(true), _border(SIZE_BORDER),
	_colourBackground((unsigned long)0x000000), _colourText((unsigned long)0xd2d2d2)
{
	#ifdef __UNIX__
	//Initialisation de la lib Libnotify.
	if(!notify_init(PROJECT_NAME))
	{
		wxLogError(_("Libnotify could not be initialized."));
	}
	#endif
		
	_workarea = wxDisplay().GetGeometry();
}
Esempio n. 11
0
wxPoint GetWindowOriginSoThatItFits(int display, const wxRect& windowRect)
{
    wxPoint pos = windowRect.GetTopLeft();
    wxRect desktop = wxDisplay(display).GetClientArea();
    if (!desktop.Contains(windowRect))
    {
        if (pos.x < desktop.x)
            pos.x = desktop.x;
        if (pos.y < desktop.y)
            pos.y = desktop.y;
       wxPoint bottomRightDiff = windowRect.GetBottomRight() - desktop.GetBottomRight();
       if (bottomRightDiff.x > 0)
           pos.x -= bottomRightDiff.x;
       if (bottomRightDiff.y > 0)
           pos.y -= bottomRightDiff.y;
    }
    return pos;
}
Esempio n. 12
0
void ManNotification::manLoad(wxFileConfig& fileConfig)
{
	//On détruis les fenêtres de notification au préalable.
	deleteAllFramesNotify();
	
	_useNotification = (UseNotification_e)fileConfig.ReadLong("useNotification", (long)USE_NOTIFICATION_RICH);
	_notificationPosition = (NotificationPosition_e)fileConfig.ReadLong("notificationPosition", (long)NOTIFICATION_POSITION_TOP_RIGHT);
	_nearCursor = fileConfig.ReadBool("nearCursor", true);
	_multipleNotifications = fileConfig.ReadBool("multipleNotifications", true);
	_border = fileConfig.ReadLong("border", (long)SIZE_BORDER);
		
	_colourBackground.SetRGB(fileConfig.ReadLong("colourBackground", (long)0x000000));
	_colourText.SetRGB(fileConfig.ReadLong("colourText", (long)0xd2d2d2));
	
	
	fileConfig.SetPath("workarea/");
	
	//On lie -1 pour les valeur par défaut.
	_workarea = wxDisplay().GetGeometry();
	long readVal = -1;
	
		readVal = fileConfig.ReadLong("x", -1);
		if(readVal != -1)
			_workarea.x = readVal;
			
		readVal = fileConfig.ReadLong("y", -1);
		if(readVal != -1)
			_workarea.y = readVal;
			
			
		readVal = fileConfig.ReadLong("height", -1);
		if(readVal != -1)
			_workarea.height = readVal;
		else
			_workarea.height -= _workarea.y;
			
		readVal = fileConfig.ReadLong("width", -1);
		if(readVal != -1)
			_workarea.width = readVal;
		else
			_workarea.width -= _workarea.x;
	
	fileConfig.SetPath("..");
}
Esempio n. 13
0
void CCManager::OnAutocompleteSelect(wxListEvent& event)
{
    event.Skip();
    m_AutocompSelectTimer.Start(AUTOCOMP_SELECT_DELAY, wxTIMER_ONE_SHOT);
    wxObject* evtObj = event.GetEventObject();
#ifdef __WXMSW__
    m_pAutocompPopup = static_cast<wxListView*>(evtObj);
#endif // __WXMSW__
    if (!evtObj)
        return;
    wxWindow* evtWin = static_cast<wxWindow*>(evtObj)->GetParent();
    if (!evtWin)
        return;
    m_DocPos = m_pPopup->GetParent()->ScreenToClient(evtWin->GetScreenPosition());
    m_DocPos.x += evtWin->GetSize().x;
    cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
    wxRect edRect = ed->GetRect();
    if (!m_pPopup->IsShown())
    {
        cbStyledTextCtrl* stc = ed->GetControl();
        int acMaxHeight = stc->AutoCompGetMaxHeight() + 1;
        int textHeight = stc->TextHeight(stc->GetCurrentLine());
        m_DocSize.x = edRect.width * 5 / 12;
        m_DocSize.y = acMaxHeight * textHeight;
        evtWin->Connect(wxEVT_SHOW, wxShowEventHandler(CCManager::OnAutocompleteHide), nullptr, this);

        const int idx = wxDisplay::GetFromWindow(evtWin);
        m_WindowBound = m_DocPos.x + m_DocSize.x;
        if (idx != wxNOT_FOUND)
        {
            const wxPoint& corner = m_pPopup->GetParent()->ScreenToClient(wxDisplay(idx).GetGeometry().GetBottomRight());
            m_DocSize.y = std::max(9 * textHeight,      std::min(m_DocSize.y, corner.y - m_DocPos.y - 2));
            m_DocSize.x = std::max(m_DocSize.y * 2 / 3, std::min(m_DocSize.x, corner.x - m_DocPos.x - 2));
            m_WindowBound = std::min(corner.x - 2, m_WindowBound);
        }
    }
    if ((m_DocPos.x + m_DocSize.x) > m_WindowBound)
        m_DocPos.x -= evtWin->GetSize().x + m_DocSize.x; // show to the left instead
    else
        m_DocSize.x = std::min(m_WindowBound - m_DocPos.x, edRect.width * 5 / 12);
}
Esempio n. 14
0
void AboutDialog::UponReadLicense(wxCommandEvent&)
{
    wxDialog dialog
        (this
        ,wxID_ANY
        ,std::string("GNU General Public License")
        ,wxDefaultPosition
        ,wxDefaultSize
        ,wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX
        );
    wxHtmlWindow* html_window = new(wx) wxHtmlWindow
        (&dialog
        ,wxID_ANY
        ,wxDefaultPosition
        ,wxDefaultSize
        ,wxHW_SCROLLBAR_AUTO | wxHW_NO_SELECTION
        );
    html_window->SetBorders(0);
    html_window->SetPage(license_as_html());

    wxButton* button = new(wx) wxButton(&dialog, wxID_CANCEL, "Close");
    button->SetDefault();

    wxBoxSizer* sizer = new(wx) wxBoxSizer(wxVERTICAL);
    sizer->Add(html_window, 1, wxALL | wxEXPAND     , 0);
    sizer->Add(button     , 0, wxALL | wxALIGN_RIGHT, 6);
    dialog.SetSizerAndFit(sizer);

    wxRect r = wxDisplay(wxDisplay::GetFromWindow(this)).GetClientArea();
    int const minimum_width  = 60 * dialog.GetCharWidth();
    int const default_width  = r.GetWidth () * 4 / 5;
    int const default_height = r.GetHeight() * 4 / 5;
    dialog.SetInitialSize(wxSize(minimum_width, default_height));
    dialog.SetSize       (wxSize(default_width, default_height));
    dialog.Center();
    dialog.ShowModal();
}
Esempio n. 15
0
    // Choose the correct orientation depending on the window position.
    //
    // Also use the tip kind appropriate for the current environment. For MSW
    // the right triangles are used and for Mac the equilateral ones as this is
    // the prevailing kind under these systems. For everything else we go with
    // right triangles as well but without any real rationale so this could be
    // tweaked in the future.
    wxTipKind GetBestTipKind() const
    {
        const wxPoint pos = GetTipPoint();

        // Use GetFromWindow() and not GetFromPoint() here to try to get the
        // correct display even if the tip point itself is not visible.
        int dpy = wxDisplay::GetFromWindow(GetParent());
        if ( dpy == wxNOT_FOUND )
            dpy = 0; // What else can we do?

        const wxRect rectDpy = wxDisplay(dpy).GetClientArea();

#ifdef __WXMAC__
        return pos.y > rectDpy.height/2 ? wxTipKind_Bottom : wxTipKind_Top;
#else // !__WXMAC__
        return pos.y > rectDpy.height/2
                    ? pos.x > rectDpy.width/2
                        ? wxTipKind_BottomRight
                        : wxTipKind_BottomLeft
                    : pos.x > rectDpy.width/2
                        ? wxTipKind_TopRight
                        : wxTipKind_TopLeft;
#endif // __WXMAC__/!__WXMAC__
    }
Esempio n. 16
0
void ManNotification::manSave(wxFileConfig& fileConfig)const
{	
	fileConfig.Write("useNotification", (long)_useNotification);
	fileConfig.Write("notificationPosition", (long)_notificationPosition);
	fileConfig.Write("nearCursor", _nearCursor);
	fileConfig.Write("multipleNotifications", _multipleNotifications);
	fileConfig.Write("border", (long)_border);
	
	fileConfig.Write("colourBackground", (long)_colourBackground.GetRGB());
	fileConfig.Write("colourText", (long)_colourText.GetRGB());
	
	
	fileConfig.SetPath("workarea/");
	
	//On écrit -1 pour les valeur par défaut.
	wxRect workarea = wxDisplay().GetGeometry();
	
		if(workarea.x == _workarea.x)
			fileConfig.Write("x", (long)-1);
		else
			fileConfig.Write("x", (long)_workarea.x);
		if(workarea.y == _workarea.y)
			fileConfig.Write("y", (long)-1);
		else
			fileConfig.Write("y", (long)_workarea.y);
		if(workarea.height == _workarea.height)	
			fileConfig.Write("height", (long)-1);
		else
			fileConfig.Write("height", (long)_workarea.height);
		if(workarea.width == _workarea.width)	
			fileConfig.Write("width", (long)-1);
		else
			fileConfig.Write("width", (long)_workarea.width);
	
	fileConfig.SetPath("..");
}
Esempio n. 17
0
void SCH_EDIT_FRAME::OnFindItems( wxCommandEvent& aEvent )
{
    wxCHECK_RET( m_findReplaceData != NULL,
                 wxT( "Forgot to create find/replace data.  Bad Programmer!" ) );

    if( m_dlgFindReplace )
    {
        delete m_dlgFindReplace;
        m_dlgFindReplace = NULL;
    }

    // Verify the find dialog is not drawn off the visible display area in case the
    // display configuration has changed since the last time the dialog position was
    // saved.
    wxRect displayRect = wxDisplay().GetGeometry();
    wxRect dialogRect = wxRect( m_findDialogPosition, m_findDialogSize );

    wxPoint position = m_findDialogPosition;

    if( !displayRect.Contains( dialogRect ) )
    {
        position = wxDefaultPosition;
    }

    int style = 0;

    if( aEvent.GetId() == wxID_REPLACE )
        style = wxFR_REPLACEDIALOG;

    m_dlgFindReplace = new DIALOG_SCH_FIND( this, m_findReplaceData, position, m_findDialogSize,
                                            style );

    m_dlgFindReplace->SetFindEntries( m_findStringHistoryList );
    m_dlgFindReplace->SetReplaceEntries( m_replaceStringHistoryList );
    m_dlgFindReplace->Show( true );
}
Esempio n. 18
0
wxRect wxGetClientDisplayRect()
{
    return wxDisplay().GetClientArea();
}
Esempio n. 19
0
SetupDialog::SetupDialog(setup_data* sdata, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) {
    setupdata = sdata;

    this->SetSizeHints( wxDefaultSize, wxDefaultSize );

	wxBoxSizer* bSizer0;
	bSizer0 = new wxBoxSizer( wxVERTICAL );

	m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
	bSizer0->Add( m_staticline2, 0, wxEXPAND | wxALL, 5 );

	lbResolution2 = new wxStaticText( this, wxID_ANY, wxT("------- Resolution -------"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE );
	lbResolution2->Wrap( -1 );
	lbResolution2->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, true, wxT("Comic Sans MS") ) );

	bSizer0->Add( lbResolution2, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );

    /// try to analyse the right resolution for screen and set it as default
    unsigned int resX = wxDisplay(0).GetGeometry().GetSize().GetWidth();
    unsigned int resY = wxDisplay(0).GetGeometry().GetSize().GetHeight();
    short stdChoice = -1;

    if (wxSize(resX, resY) == wxSize(1920, 1200)) {
        stdChoice = 0;
    }
    else if (wxSize(resX, resY) == wxSize(1920, 1080)) {
        stdChoice = 1;
    }
    else if (wxSize(resX, resY) == wxSize(1680, 1050)) {
        stdChoice = 2;
    }
    else if (wxSize(resX, resY) == wxSize(1680, 900)) {
        stdChoice = 3;
    }
    else if (wxSize(resX, resY) == wxSize(1440, 900)) {
        stdChoice = 4;
    }
    else if (wxSize(resX, resY) == wxSize(1400, 1050)) {
        stdChoice = 5;
    }
    else if (wxSize(resX, resY) == wxSize(1280, 1024)) {
        stdChoice = 6;
    }
    else if (wxSize(resX, resY) == wxSize(1280, 800)) {
        stdChoice = 7;
    }
    else if (wxSize(resX, resY) == wxSize(1280, 768)) {
        stdChoice = 8;
    }
    else if (wxSize(resX, resY) == wxSize(1024, 768)) {
        stdChoice = 9;
    }
    else {  // nothing found set the resolution to 800x600
        stdChoice = 10;
    }


	wxString ResolutionChoiceChoices[] = { wxT("1920x1200"), wxT("1920x1080"), wxT("1680x1050"), wxT("1600x900"), wxT("1440x900"), wxT("1400x1050"), wxT("1280x1024"), wxT("1280x800"), wxT("1280x768"), wxT("1024x768"), wxT("800x600") };
	int ResolutionChoiceNChoices = sizeof( ResolutionChoiceChoices ) / sizeof( wxString );
	ResolutionChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, ResolutionChoiceNChoices, ResolutionChoiceChoices, 0 );
	ResolutionChoice->SetSelection( stdChoice );
	ResolutionChoice->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxT("Comic Sans MS") ) );

	bSizer0->Add( ResolutionChoice, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxSHAPED, 5 );


	bSizer0->Add( 0, 0, 1, wxEXPAND, 5 );

	m_staticline3 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
	bSizer0->Add( m_staticline3, 0, wxEXPAND | wxALL, 5 );

	lbSound = new wxStaticText( this, wxID_ANY, wxT("------- Volume -------"), wxDefaultPosition, wxDefaultSize, 0 );
	lbSound->Wrap( -1 );
	lbSound->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 92, false, wxT("Comic Sans MS") ) );

	bSizer0->Add( lbSound, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );

	SoundSlider = new wxSlider( this, wxID_ANY, 60, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS );
	SoundSlider->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxT("Droid Sans") ) );

	bSizer0->Add( SoundSlider, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 5 );

	m_staticline4 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
	bSizer0->Add( m_staticline4, 0, wxEXPAND | wxALL, 5 );

	FullscreenCheck = new wxCheckBox( this, wxID_ANY, wxT("Play in fullscreen"), wxDefaultPosition, wxDefaultSize, 0 );
	FullscreenCheck->SetValue(true);
	bSizer0->Add( FullscreenCheck, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );

	m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
	bSizer0->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );


	bSizer0->Add( 0, 0, 0, wxEXPAND, 5 );

	ButtonSizer = new wxStdDialogButtonSizer();
	ButtonSizerOK = new wxButton( this, wxID_OK );
	ButtonSizer->AddButton( ButtonSizerOK );
	ButtonSizerCancel = new wxButton( this, wxID_CANCEL );
	ButtonSizer->AddButton( ButtonSizerCancel );
	ButtonSizer->Realize();
	bSizer0->Add( ButtonSizer, 3, wxALIGN_BOTTOM|wxALIGN_CENTER_HORIZONTAL, 5 );

	this->SetSizer( bSizer0 );
	this->Layout();

	// Connect Events
	ButtonSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( SetupDialog::OnCancelButtonClick ), NULL, this );
	ButtonSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( SetupDialog::OnOKButtonClick ), NULL, this );

	Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(SetupDialog::OnClose));
}
Esempio n. 20
0
void wxMessageDialog::ReplaceStaticWithEdit()
{
    // check if the message box fits the display
    int nDisplay = wxDisplay::GetFromWindow(this);
    if ( nDisplay == wxNOT_FOUND )
        nDisplay = 0;
    const wxRect rectDisplay = wxDisplay(nDisplay).GetClientArea();

    if ( rectDisplay.Contains(GetRect()) )
    {
        // nothing to do
        return;
    }


    // find the static control to replace: normally there are two of them, the
    // icon and the text itself so search for all of them and ignore the icon
    // ones
    HWND hwndStatic = ::FindWindowEx(GetHwnd(), NULL, wxT("STATIC"), NULL);
    if ( ::GetWindowLong(hwndStatic, GWL_STYLE) & SS_ICON )
        hwndStatic = ::FindWindowEx(GetHwnd(), hwndStatic, wxT("STATIC"), NULL);

    if ( !hwndStatic )
    {
        wxLogDebug("Failed to find the static text control in message box.");
        return;
    }

    // set the right font for GetCharHeight() call below
    wxWindowBase::SetFont(GetMessageFont());

    // put the new edit control at the same place
    RECT rc = wxGetWindowRect(hwndStatic);
    ScreenRectToClient(GetHwnd(), rc);

    // but make it less tall so that the message box fits on the screen: we try
    // to make the message box take no more than 7/8 of the screen to leave
    // some space above and below it
    const int hText = (7*rectDisplay.height)/8 -
                      (
                         2*::GetSystemMetrics(SM_CYFIXEDFRAME) +
                         ::GetSystemMetrics(SM_CYCAPTION) +
                         5*GetCharHeight() // buttons + margins
                      );
    const int dh = (rc.bottom - rc.top) - hText; // vertical space we save
    rc.bottom -= dh;

    // and it also must be wider as it needs a vertical scrollbar (in order
    // to preserve the word wrap, otherwise the number of lines would change
    // and we want the control to look as similar as possible to the original)
    //
    // NB: you would have thought that 2*SM_CXEDGE would be enough but it
    //     isn't, somehow, and the text control breaks lines differently from
    //     the static one so fudge by adding some extra space
    const int dw = ::GetSystemMetrics(SM_CXVSCROLL) +
                        4*::GetSystemMetrics(SM_CXEDGE);
    rc.right += dw;


    // chop of the trailing new line(s) from the message box text, they are
    // ignored by the static control but result in extra lines and hence extra
    // scrollbar position in the edit one
    wxString text(wxGetWindowText(hwndStatic));
    for ( wxString::reverse_iterator i = text.rbegin(); i != text.rend(); ++i )
    {
        if ( *i != '\n' )
        {
            // found last non-newline char, remove everything after it and stop
            text.erase(i.base() + 1, text.end());
            break;
        }
    }

    // do create the new control
    HWND hwndEdit = ::CreateWindow
                      (
                        wxT("EDIT"),
                        wxTextBuffer::Translate(text).wx_str(),
                        WS_CHILD | WS_VSCROLL | WS_VISIBLE |
                        ES_MULTILINE | ES_READONLY | ES_AUTOVSCROLL,
                        rc.left, rc.top,
                        rc.right - rc.left, rc.bottom - rc.top,
                        GetHwnd(),
                        NULL,
                        wxGetInstance(),
                        NULL
                      );

    if ( !hwndEdit )
    {
        wxLogDebug("Creation of replacement edit control failed in message box");
        return;
    }

    // copy the font from the original control
    LRESULT hfont = ::SendMessage(hwndStatic, WM_GETFONT, 0, 0);
    ::SendMessage(hwndEdit, WM_SETFONT, hfont, 0);

    // and get rid of it
    ::DestroyWindow(hwndStatic);


    // shrink and centre the message box vertically and widen it box to account
    // for the extra scrollbar
    RECT rcBox = wxGetWindowRect(GetHwnd());
    const int hMsgBox = rcBox.bottom - rcBox.top - dh;
    rcBox.top = (rectDisplay.height - hMsgBox)/2;
    rcBox.bottom = rcBox.top + hMsgBox + (rectDisplay.height - hMsgBox)%2;
    rcBox.left -= dw/2;
    rcBox.right += dw - dw/2;
    SetWindowRect(GetHwnd(), rcBox);

    // and adjust all the buttons positions
    for ( unsigned n = 0; n < WXSIZEOF(ms_buttons); n++ )
    {
        const HWND hwndBtn = ::GetDlgItem(GetHwnd(), ms_buttons[n].id);
        if ( !hwndBtn )
            continue;   // it's ok, not all buttons are always present

        RECT rc = wxGetWindowRect(hwndBtn);
        rc.top -= dh;
        rc.bottom -= dh;
        rc.left += dw/2;
        rc.right += dw/2;
        MoveWindowToScreenRect(hwndBtn, rc);
    }
}
Esempio n. 21
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);
}
Esempio n. 22
0
int wxDisplayDepth()
{
    return wxDisplay().GetDepth();
}
Esempio n. 23
0
bool mainFrame::ReadConfig()
{
    if(!m_pFnConfig)
        return false; //Configuration path not configured
    wxString sGroup, sTmp;
    long lCookie;

    //Populate map of MCU types
    unsigned int nMcuIndex = 0;
    while(AddDeviceType(wxAvr::GetMcuNames(nMcuIndex++)));
    wxLogMessage("%d MCU core types supported", nMcuIndex - 1);

    if(0 == m_mDevices.size())
        return false; //No supported device types

    //Populate map of profiles
    wxConfig* pConfig = new wxConfig("wxSimAVRGui", "riban", m_pFnConfig->GetPath() + "/profile.cfg");
    bool bMore = pConfig->GetFirstGroup(sGroup, lCookie);
    while(bMore)
    {
        wxString sName, sDeviceType, sDescription;
        long lFrequency;
        pConfig->Read(sGroup + "/device", &sDeviceType, wxEmptyString);
        pConfig->Read(sGroup + "/description", &sDescription, wxEmptyString);
        pConfig->Read(sGroup + "/frequency", &lFrequency, 0l);
        if(!AddProfile(sGroup, sDeviceType, lFrequency, sDescription))
            wxLogError("Configuration error: Bad configuration of profile [%s]", sGroup.c_str());
        bMore = pConfig->GetNextGroup(sGroup, lCookie);
    }
    delete pConfig;

    //Read application configuration
    pConfig = new wxConfig("wxSimAVRGui", "riban", m_pFnConfig->GetPath() + ("/config.cfg"));
    pConfig->Read("/state/mcu", &m_sDeviceType, "test");
    if(m_sDeviceType.IsEmpty())
    {
        std::map<long,wxString>::iterator it = m_mDevices.begin();
        m_sDeviceType = it->second; //This exists because it is specifically created above if m_pDeviceType is empty
        wxLogMessage("MCU device type not configured - using first defined (%s)", m_sDeviceType);
    }
    pConfig->Read("/state/frequency", &m_lFrequency);
    if(pConfig->Read("/state/firmware", &sTmp))
        m_pFnFirmware = new wxFileName(sTmp);
    if(pConfig->Read("/state/ihex", &sTmp))
        m_pFnHex = new wxFileName(sTmp);
    pConfig->Read("/state/serial", &m_bSerialEnabled, false);
    pConfig->Read("/state/vcdfile", &sTmp, "wxSimAVR.vcd");
    m_pFnVcd = new wxFileName(sTmp);
    pConfig->Read("/state/vcd", &m_bVcdEnabled, false);
    m_pMenuitemSerial->Check(m_bSerialEnabled);
    m_pMenuitemVcd->Check(m_bVcdEnabled);

    int nWidth = 600;
    int nHeight = 400;
    int nX = 10;
    int nY = 10;
    long lTmp;
    bool bTmp;
    if(pConfig->Read(wxT("/Layout/Width"), &lTmp))
		nWidth = lTmp;
	if(pConfig->Read(wxT("/Layout/Height"), &lTmp))
		nHeight = lTmp;
	if(pConfig->Read(wxT("/Layout/PosX"), &lTmp))
		nX = lTmp;
	if(pConfig->Read(wxT("/Layout/PosY"), &lTmp))
		nY = lTmp;
	if(pConfig->Read(wxT("/Layout/Maximised"), &bTmp))
		Maximize(bTmp);
	SetSize(nWidth, nHeight);
    //Check saved location is visible
    bool bCanSee = false;
	for(unsigned int nDisplay = 0; nDisplay < wxDisplay::GetCount(); nDisplay++)
    {
        bCanSee |= wxDisplay(nDisplay).GetGeometry().Intersects(wxRect(nX, nY, nWidth, nHeight));
    }
    if(bCanSee)
        Move(nX, nY);
    //AUI manager perspective (layout management)
    wxString sPerspective;
    if(pConfig->Read("/Layout/Perspective", &sPerspective, wxEmptyString))
        m_pAuiManager->LoadPerspective(sPerspective);
    m_pMenuitemToolbarControl->Check(m_pAuiManager->GetPane("ToolbarControl").IsShown());
    m_pMenuitemToolbarFile->Check(m_pAuiManager->GetPane("ToolbarFile").IsShown());

	bTmp = false;
	pConfig->Read(wxT("/Log/File"), &bTmp, false);
	EnableLogToFile(bTmp);
	pConfig->Read(wxT("/Log/Verbose"), &bTmp, false);
	wxLog::SetVerbose(bTmp);
	m_pMenuitemLogVerbose->Check(bTmp);


    delete pConfig;
    return true;
}
Esempio n. 24
0
wxRect wxRibbonPanel::GetExpandedPosition(wxRect panel,
                                          wxSize expanded_size,
                                          wxDirection direction)
{
    // Strategy:
    // 1) Determine primary position based on requested direction
    // 2) Move the position so that it sits entirely within a display
    //    (for single monitor systems, this moves it into the display region,
    //     but for multiple monitors, it does so without splitting it over
    //     more than one display)
    // 2.1) Move in the primary axis
    // 2.2) Move in the secondary axis

    wxPoint pos;
    bool primary_x = false;
    int secondary_x = 0;
    int secondary_y = 0;
    switch(direction)
    {
    case wxNORTH:
        pos.x = panel.GetX() + (panel.GetWidth() - expanded_size.GetWidth()) / 2;
        pos.y = panel.GetY() - expanded_size.GetHeight();
        primary_x = true;
        secondary_y = 1;
        break;
    case wxEAST:
        pos.x = panel.GetRight();
        pos.y = panel.GetY() + (panel.GetHeight() - expanded_size.GetHeight()) / 2;
        secondary_x = -1;
        break;
    case wxSOUTH:
        pos.x = panel.GetX() + (panel.GetWidth() - expanded_size.GetWidth()) / 2;
        pos.y = panel.GetBottom();
        primary_x = true;
        secondary_y = -1;
        break;
    case wxWEST:
    default:
        pos.x = panel.GetX() - expanded_size.GetWidth();
        pos.y = panel.GetY() + (panel.GetHeight() - expanded_size.GetHeight()) / 2;
        secondary_x = 1;
        break;
    }
    wxRect expanded(pos, expanded_size);

    wxRect best(expanded);
    int best_distance = INT_MAX;

    const unsigned display_n = wxDisplay::GetCount();
    unsigned display_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(display_i = 0; display_i < display_n; ++display_i)
    {
        wxRect display = wxDisplay(display_i).GetGeometry();

        if(display.Contains(expanded))
        {
            return expanded;
        }
        else if(display.Intersects(expanded))
        {
            wxRect new_rect(expanded);
            int distance = 0;

            if(primary_x)
            {
                if(expanded.GetRight() > display.GetRight())
                {
                    distance = expanded.GetRight() - display.GetRight();
                    new_rect.x -= distance;
                }
                else if(expanded.GetLeft() < display.GetLeft())
                {
                    distance = display.GetLeft() - expanded.GetLeft();
                    new_rect.x += distance;
                }
            }
            else
            {
                if(expanded.GetBottom() > display.GetBottom())
                {
                    distance = expanded.GetBottom() - display.GetBottom();
                    new_rect.y -= distance;
                }
                else if(expanded.GetTop() < display.GetTop())
                {
                    distance = display.GetTop() - expanded.GetTop();
                    new_rect.y += distance;
                }
            }
            if(!display.Contains(new_rect))
            {
                // Tried moving in primary axis, but failed.
                // Hence try moving in the secondary axis.
                int dx = secondary_x * (panel.GetWidth() + expanded_size.GetWidth());
                int dy = secondary_y * (panel.GetHeight() + expanded_size.GetHeight());
                new_rect.x += dx;
                new_rect.y += dy;

                // Squaring makes secondary moves more expensive (and also
                // prevents a negative cost)
                distance += dx * dx + dy * dy;
            }
            if(display.Contains(new_rect) && distance < best_distance)
            {
                best = new_rect;
                best_distance = distance;
            }
        }
    }

    return best;
}
Esempio n. 25
0
wxSize wxGetDisplaySize()
{
    return wxDisplay().GetGeometry().GetSize();
}
Esempio n. 26
0
bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style)
{
    if ( show == IsFullScreen() )
    {
        // nothing to do
        return true;
    }

    m_fsIsShowing = show;

    if ( show )
    {
        m_fsStyle = style;

        // zap the frame borders

        // save the 'normal' window style
        m_fsOldWindowStyle = GetWindowLong(GetHwnd(), GWL_STYLE);

        // save the old position, width & height, maximize state
        m_fsOldSize = GetRect();
        m_fsIsMaximized = IsMaximized();

        // decide which window style flags to turn off
        LONG newStyle = m_fsOldWindowStyle;
        LONG offFlags = 0;

        if (style & wxFULLSCREEN_NOBORDER)
        {
            offFlags |= WS_BORDER;
#ifndef __WXWINCE__
            offFlags |= WS_THICKFRAME;
#endif
        }
        if (style & wxFULLSCREEN_NOCAPTION)
            offFlags |= WS_CAPTION | WS_SYSMENU;

        newStyle &= ~offFlags;

        // Full screen windows should logically be popups as they don't have
        // decorations (and are definitely not children) and while not using
        // this style doesn't seem to make any difference for most windows, it
        // breaks wxGLCanvas in some cases, see #15434, so just always use it.
        newStyle |= WS_POPUP;

        // change our window style to be compatible with full-screen mode
        ::SetWindowLong(GetHwnd(), GWL_STYLE, newStyle);

        wxRect rect;
#if wxUSE_DISPLAY
        // resize to the size of the display containing us
        int dpy = wxDisplay::GetFromWindow(this);
        if ( dpy != wxNOT_FOUND )
        {
            rect = wxDisplay(dpy).GetGeometry();
        }
        else // fall back to the main desktop
#endif // wxUSE_DISPLAY
        {
            // resize to the size of the desktop
            wxCopyRECTToRect(wxGetWindowRect(::GetDesktopWindow()), rect);
#ifdef __WXWINCE__
            // FIXME: size of the bottom menu (toolbar)
            // should be taken in account
            rect.height += rect.y;
            rect.y       = 0;
#endif
        }

        SetSize(rect);

        // now flush the window style cache and actually go full-screen
        long flags = SWP_FRAMECHANGED;

        // showing the frame full screen should also show it if it's still
        // hidden
        if ( !IsShown() )
        {
            // don't call wxWindow version to avoid flicker from calling
            // ::ShowWindow() -- we're going to show the window at the correct
            // location directly below -- but do call the wxWindowBase version
            // to sync the internal m_isShown flag
            wxWindowBase::Show();

            flags |= SWP_SHOWWINDOW;
        }

        SetWindowPos(GetHwnd(), HWND_TOP,
                     rect.x, rect.y, rect.width, rect.height,
                     flags);

#if !defined(__HANDHELDPC__) && (defined(__WXWINCE__) && (_WIN32_WCE < 400))
        ::SHFullScreen(GetHwnd(), SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON);
#endif

        // finally send an event allowing the window to relayout itself &c
        wxSizeEvent event(rect.GetSize(), GetId());
        event.SetEventObject(this);
        HandleWindowEvent(event);
    }
    else // stop showing full screen
    {
#if !defined(__HANDHELDPC__) && (defined(__WXWINCE__) && (_WIN32_WCE < 400))
        ::SHFullScreen(GetHwnd(), SHFS_SHOWTASKBAR | SHFS_SHOWSIPBUTTON);
#endif
        Maximize(m_fsIsMaximized);
        SetWindowLong(GetHwnd(),GWL_STYLE, m_fsOldWindowStyle);
        SetWindowPos(GetHwnd(),HWND_TOP,m_fsOldSize.x, m_fsOldSize.y,
            m_fsOldSize.width, m_fsOldSize.height, SWP_FRAMECHANGED);
    }

    return true;
}
Esempio n. 27
0
bool wxColourDisplay()
{
    // If GetDepth() returns 0, meaning unknown, we assume it's a colour
    // display, hence the use of "!=" rather than ">" here.
    return wxDisplay().GetDepth() != 1;
}
Esempio n. 28
0
void wxPopupWindowBase::Position(const wxPoint& ptOrigin,
                                 const wxSize& size)
{
    // determine the position and size of the screen we clamp the popup to
    wxPoint posScreen;
    wxSize sizeScreen;

    const int displayNum = wxDisplay::GetFromPoint(ptOrigin);
    if ( displayNum != wxNOT_FOUND )
    {
        const wxRect rectScreen = wxDisplay(displayNum).GetGeometry();
        posScreen = rectScreen.GetPosition();
        sizeScreen = rectScreen.GetSize();
    }
    else // outside of any display?
    {
        // just use the primary one then
        posScreen = wxPoint(0, 0);
        sizeScreen = wxGetDisplaySize();
    }


    const wxSize sizeSelf = GetSize();

    // is there enough space to put the popup below the window (where we put it
    // by default)?
    wxCoord y = ptOrigin.y + size.y;
    if ( y + sizeSelf.y > posScreen.y + sizeScreen.y )
    {
        // check if there is enough space above
        if ( ptOrigin.y > sizeSelf.y )
        {
            // do position the control above the window
            y -= size.y + sizeSelf.y;
        }
        //else: not enough space below nor above, leave below
    }

    // now check left/right too
    wxCoord x = ptOrigin.x;

    if ( wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft )
    {
        // shift the window to the left instead of the right.
        x -= size.x;
        x -= sizeSelf.x;        // also shift it by window width.
    }
    else
        x += size.x;


    if ( x + sizeSelf.x > posScreen.x + sizeScreen.x )
    {
        // check if there is enough space to the left
        if ( ptOrigin.x > sizeSelf.x )
        {
            // do position the control to the left
            x -= size.x + sizeSelf.x;
        }
        //else: not enough space there neither, leave in default position
    }

    Move(x, y, wxSIZE_NO_ADJUSTMENTS);
}