/** * Initializes the main game frame. */ void GcbApp::InitializeGameFrame() { try { tcDisplayModes::Get()->LoadModeFromOptions(); int windowedMode = tcOptions::Get()->windowedMode; if (windowedMode) { int x, y; wxSize size; wxClientDisplayRect(&x, &y, &size.x, &size.y); // account for task bar size long frameStyle = wxDEFAULT_FRAME_STYLE; gameFrame = new tcGame(wxPoint(0,0), size, frameStyle); } else { long frameStyle = wxNO_FULL_REPAINT_ON_RESIZE; gameFrame = new tcGame(wxPoint(0,0), wxGetDisplaySize(), frameStyle); } gameFrame->Init(); } catch(...) { wxMessageBox("The game frame failed to initialize."); WTL("The game frame failed to initialize."); throw std::exception(); } }
void utils_controls::read_dialog_position_and_size( wxWindow* target_window, const wxString& configuration_key_basename, wxPoint default_position, wxSize default_size ) { wxPoint new_position; wxSize new_size; wxPoint screen_lower_left; int unused; // Read settings from configuration new_position.x = the_configuration->Read( "/PLUCKER_DESKTOP/" + configuration_key_basename + "_position_x", default_position.x ); new_position.y = the_configuration->Read( "/PLUCKER_DESKTOP/" + configuration_key_basename + "_position_y", default_position.y ); new_size.x = the_configuration->Read( "/PLUCKER_DESKTOP/" + configuration_key_basename + "_size_x", default_size.x ); new_size.y = the_configuration->Read( "/PLUCKER_DESKTOP/" + configuration_key_basename + "_size_y", default_size.y ); // If the window is now totally offscreen (this could happen for example by: // putting the dialog all the way to the lower right corner of the screen in 800x600, // cosing the dialog, dropping the display size down to 680x480, then reopening. // If so, just rewind back to the defaults that were passed. // First, get the point of the lower left part of the viewable part of the screen, // taking into account a MSW taskbar, banner applications running on the computer, etc. wxClientDisplayRect( &unused, &unused, &screen_lower_left.x, &screen_lower_left.y ); // Now if the new position would be to the left of the width of the viewable area, // or below the viewable area... if ( ( screen_lower_left.x < new_size.x ) || ( screen_lower_left.y < new_size.y ) ) { // ...then wind back to the defaults. new_position = default_position; new_size = default_size; } // Set the window to the new size. target_window->SetSize( new_size ); // Different user-defined behaviour of how want the windows to behave. long window_placement_type= the_configuration->Read( "/PLUCKER_DESKTOP/window_placement_type", 0L ); switch ( window_placement_type ) { case plkrWINDOW_PLACEMENT_STYLE_CENTER_ON_PARENT: target_window->CenterOnParent(); break; case plkrWINDOW_PLACEMENT_STYLE_CENTER_ON_SCREEN: target_window->CenterOnScreen(); break; case plkrWINDOW_PLACEMENT_STYLE_LAST_LOCATION: target_window->Move( new_position ); break; default: wxLogDebug( "Error: unknown window_placement type" ); break; } }
TranslDlg::TranslDlg(wxWindow *parent) : wxPanel(parent) {//===================================================== int height; int width; int x,y; int font_size; int height_ph = 350; wxTextAttr attr; wxFont font = wxFont(12,wxFONTFAMILY_ROMAN,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_LIGHT,false,_T(""),wxFONTENCODING_SYSTEM); attr.SetFont(font); wxClientDisplayRect(&x,&y,&width, &height); #ifdef PLATFORM_WINDOWS if(height <= 768) height_ph = height - 416; #else if(height <= 800) height_ph = 280; #endif t_source = new wxTextCtrl(this,T_SOURCE,_T(""),wxPoint(0,4), wxSize(298,250),wxTE_MULTILINE,wxDefaultValidator,_T("Text input window")); t_source->SetDefaultStyle(attr); t_phonetic = new wxTextCtrl(this,T_PHONETIC,_T(""),wxPoint(0,262), wxSize(298,height_ph),wxTE_MULTILINE | wxTE_READONLY, wxDefaultValidator,_T("Phoneme translation window")); style_phonetic = t_phonetic->GetDefaultStyle(); font_phonetic = style_phonetic.GetFont(); font_size = font_phonetic.GetPointSize(); font_phonetic_large = font_phonetic; style_phonetic_large = style_phonetic; //font_phonetic_large.SetFamily(wxFONTFAMILY_SWISS); font_phonetic_large.SetPointSize(font_size+1); style_phonetic_large.SetFont(font_phonetic_large); y = height_ph + 270; t_translate = new wxButton(this,T_TRANSLATE,_T("Translate"),wxPoint(4,y)); t_translate = new wxButton(this,T_RULES,_T("Show Rules"),wxPoint(4,y+32)); t_translate = new wxButton(this,T_TRANSLATE_IPA,_T("Show IPA"),wxPoint(100,y+32)); t_process = new wxButton(this,T_PROCESS,_T("Speak"),wxPoint(100,y)); t_source->SetFocus(); } // end of TransDlg::TransDlg
wxSize wxTopLevelWindowBase::GetMaxSize() const { wxSize size( GetMaxWidth(), GetMaxHeight() ); int w, h; wxClientDisplayRect( 0, 0, &w, &h ); if( size.GetWidth() == wxDefaultCoord ) size.SetWidth( w ); if( size.GetHeight() == wxDefaultCoord ) size.SetHeight( h ); return size; }
void progress_dialog::show_listbox() { int screen_height; int screen_top; int dialog_top; int unused; // This gets the pixels of the usable part of the screen, and the screen height. // This accounts for an MSW taskbar taking up part of the real estate, and the // task bar could be at the top. wxClientDisplayRect( &unused, &screen_top, &unused, &screen_height ); // Get the y position of the dialog dialog_top = GetPosition().y; // If the expanded listbox would go past the drawable screen height. if ( screen_height < ( dialog_top + m_dialog_height_with_listbox ) ) { // Start at the bottom and move it up accordingly. dialog_top = screen_height; dialog_top -= m_dialog_height_with_listbox; // However, if the top would now impinge into a top taskbar, then set it // down to top of the the usable screen area, so the caption is at least visible. // and let the bottom part disappear. if ( dialog_top < screen_top ) { dialog_top = screen_top; } // Set the y position of the dialog, ready for expansion. (-1 means default x) // The function is called Move() instead of SetPosition() for some reason. Move( -1, dialog_top ); } // Now set y the size of the dialog to expand the width of the listbox, thus showing // it. (-1 means default x). SetSize( -1, m_dialog_height_with_listbox ); // Update the caption on the "Details" button XMLCTRL( *this, "progress_dialog_details_button", wxButton )->SetLabel( _( "<< Details" ) ); // Mark the listbox as shown. m_progress_listbox_is_shown = TRUE; }
void wxTopLevelWindowDFB::Maximize(bool maximize) { int x, y, w, h; wxClientDisplayRect(&x, &y, &w, &h); if ( maximize && !m_isMaximized ) { m_isMaximized = true; GetPosition(&m_savedFrame.x, &m_savedFrame.y); GetSize(&m_savedFrame.width, &m_savedFrame.height); SetSize(x, y, w, h); } else if ( !maximize && m_isMaximized ) { m_isMaximized = false; SetSize(m_savedFrame.x, m_savedFrame.y, m_savedFrame.width, m_savedFrame.height); } }
void wxTopLevelWindowMGL::Maximize(bool maximize) { int x, y, w, h; wxClientDisplayRect(&x, &y, &w, &h); rect_t screenRect = MGL_defRect(x, y, w, h); MGL_wmInvalidateRect(g_winMng, &screenRect); if ( maximize && !m_isMaximized ) { m_isMaximized = true; GetPosition(&m_savedFrame.x, &m_savedFrame.y); GetSize(&m_savedFrame.width, &m_savedFrame.height); SetSize(x, y, w, h); } else if ( !maximize && m_isMaximized ) { m_isMaximized = false; SetSize(m_savedFrame.x, m_savedFrame.y, m_savedFrame.width, m_savedFrame.height); } }
wxRect wxGetClientDisplayRect() { int x, y, width, height; wxClientDisplayRect(&x, &y, &width, &height); // call plat-specific version return wxRect(x, y, width, height); }
void BubbleParam::onParamLeftDown(wxMouseEvent& event) { // wxMessageDialog dialog0(parent, _("Debug:"), _("Debug:")); //##Debug. // dialog0.ShowModal(); if (parent) { BubbleExpressionPicker *picker = NULL; if ( ((BubbleBlock*)parent)->getCanvas() ) { if ( (((BubbleBlock*)parent)->getCanvas())->getBubble() ) { Bubble *bubble = (((BubbleBlock*)parent)->getCanvas())->getBubble(); if (bubble) { picker = bubble->getExpressionPicker(dataType); bubble->closeTemporalPickers(); } } //(((BubbleBlock*)parent)->getCanvas())->setCurrentBlock((BubbleBlock*)parent); } if (picker) { //picker->ShowModal(); picker->setParamSlot(this); //Prevents the picker to appear outside the visible screen area: int x = 0, y = 0; int screenOrigX = 0, screenOrigY = 0; int screenWidth = 0, screenHeight = 0; int pickerWidth = picker->GetSize().GetWidth(); int pickerHeight = picker->GetSize().GetHeight(); int xOffset = 0, yOffset = 0; int xPos = 0, yPos = 0; wxClientDisplayRect(&screenOrigX, &screenOrigY, &screenWidth, &screenHeight); //Obtains the paramSlot's screen position: GetScreenPosition(&x, &y); //Shows the picker in it's proper place: x = x + GetSize().GetWidth(); if ( (x + pickerWidth) > screenWidth ) { //The picker goes outside the right margin: xOffset = screenWidth - (x + pickerWidth); yOffset = GetSize().GetHeight(); } //screenHeight*0.x is the security margin, because in some systems wxClientDisplayRect() does //not properly detect the OS taskbar: if ( (y + pickerHeight) > screenHeight ) { //The picker goes outside the bottom margin too, so it's showed OVER the paramslot, no //matter the previous calcs for the yOffset: yOffset = -pickerHeight; } if ( (y + yOffset) > 0 ) yPos = y + yOffset; xPos = x + xOffset; //##See if the correction in x becomes necessary: // if (xPos < 0) // xPos = 0; picker->Move(xPos, yPos); picker->Show(); } //##Borrar esto: ((BubbleCanvas *)parent)->setCurrentBlock(this); } event.Skip(); }