void EDA_BASE_FRAME::SaveSettings( wxConfigBase* aCfg ) { wxString text; if( IsIconized() ) return; wxString baseCfgName = ConfigBaseName(); m_FrameSize = GetSize(); m_FramePos = GetPosition(); text = baseCfgName + wxT( "Pos_x" ); aCfg->Write( text, (long) m_FramePos.x ); text = baseCfgName + wxT( "Pos_y" ); aCfg->Write( text, (long) m_FramePos.y ); text = baseCfgName + wxT( "Size_x" ); aCfg->Write( text, (long) m_FrameSize.x ); text = baseCfgName + wxT( "Size_y" ); aCfg->Write( text, (long) m_FrameSize.y ); text = baseCfgName + wxT( "Maximized" ); aCfg->Write( text, IsMaximized() ); if( m_hasAutoSave ) { text = baseCfgName + entryAutoSaveInterval; aCfg->Write( text, m_autoSaveInterval ); } // Once this is fully implemented, wxAuiManager will be used to maintain // the persistance of the main frame and all it's managed windows and // all of the legacy frame persistence position code can be removed. wxString perspective = m_auimgr.SavePerspective(); // printf( "perspective(%s): %s\n", // TO_UTF8( m_FrameName + entryPerspective ), TO_UTF8( perspective ) ); aCfg->Write( baseCfgName + entryPerspective, perspective ); aCfg->Write( baseCfgName + entryMruPath, m_mruPath ); }
void GSFrame::OnMove( wxMoveEvent& evt ) { if( IsBeingDeleted() ) return; evt.Skip(); g_Conf->GSWindow.IsMaximized = IsMaximized(); // evt.GetPosition() returns the client area position, not the window frame position. if( !g_Conf->GSWindow.IsMaximized && !IsFullScreen() && !IsIconized() && IsVisible() ) g_Conf->GSWindow.WindowPos = GetScreenPosition(); // wxGTK note: X sends gratuitous amounts of OnMove messages for various crap actions // like selecting or deselecting a window, which muck up docking logic. We filter them // out using 'lastpos' here. :) //static wxPoint lastpos( wxDefaultCoord, wxDefaultCoord ); //if( lastpos == evt.GetPosition() ) return; //lastpos = evt.GetPosition(); }
void wxTopLevelWindowGTK::DoGetClientSize( int *width, int *height ) const { wxASSERT_MSG(m_widget, wxT("invalid frame")); if ( IsIconized() ) { // for consistency with wxMSW, client area is supposed to be empty for // the iconized windows if ( width ) *width = 0; if ( height ) *height = 0; } else if (m_useCachedClientSize) base_type::DoGetClientSize(width, height); else { GTKDoGetSize(width, height); } }
void MainFrame::AdjustSystemTrayIcon(wxCommandEvent& WXUNUSED(event)) { if(CheckOption(wxT("UD_MINIMIZE_TO_SYSTEM_TRAY"))){ if(!m_systemTrayIcon->IsIconInstalled()){ wxString icon(wxT("tray")); if(m_busy){ if(m_paused) icon = wxT("tray_paused"); else icon = wxT("tray_running"); } SetSystemTrayIcon(icon,wxT("UltraDefrag")); if(m_systemTrayIcon->IsIconInstalled()){ if(IsIconized()) Hide(); } } } else { if(m_systemTrayIcon->IsIconInstalled()){ m_systemTrayIcon->RemoveIcon(); Show(); } } }
void WinEDA_BasicFrame::SaveSettings(void) /*****************************************/ { wxString text; if ( !m_Parent || !m_Parent->m_EDA_Config ) return; if( ! m_Parent->m_EDA_Config || IsIconized() ) return; m_FrameSize = GetSize(); m_FramePos = GetPosition(); text = m_FrameName + "Pos_x"; m_Parent->m_EDA_Config->Write(text, (long)m_FramePos.x); text = m_FrameName + "Pos_y"; m_Parent->m_EDA_Config->Write(text, (long)m_FramePos.y); text = m_FrameName + "Size_x"; m_Parent->m_EDA_Config->Write(text, (long)m_FrameSize.x); text = m_FrameName + "Size_y"; m_Parent->m_EDA_Config->Write(text, (long)m_FrameSize.y); }
void wxTopLevelWindowMSW::DoGetPosition(int *x, int *y) const { if ( IsIconized() ) { WINDOWPLACEMENT wp; wp.length = sizeof(WINDOWPLACEMENT); if ( ::GetWindowPlacement(GetHwnd(), &wp) ) { RECT& rc = wp.rcNormalPosition; // the position returned by GetWindowPlacement() is in workspace // coordinates except for windows with WS_EX_TOOLWINDOW style if ( !HasFlag(wxFRAME_TOOL_WINDOW) ) { // we must use the correct display for the translation as the // task bar might be shown on one display but not the other one int n = wxDisplay::GetFromWindow(this); wxDisplay dpy(n == wxNOT_FOUND ? 0 : n); const wxPoint ptOfs = dpy.GetClientArea().GetPosition() - dpy.GetGeometry().GetPosition(); rc.left += ptOfs.x; rc.top += ptOfs.y; } if ( x ) *x = rc.left; if ( y ) *y = rc.top; return; } wxLogLastError(wxT("GetWindowPlacement")); } //else: normal case wxTopLevelWindowBase::DoGetPosition(x, y); }
bool CamuleDlg::SaveGUIPrefs() { /* Razor 1a - Modif by MikaelB Save client size and position */ // Create a config base for saving razor preferences wxConfigBase *config = wxConfigBase::Get(); // If config haven't been created exit without saving if (config == NULL) { return false; } // The section where to save in in file wxString section = wxT("/Razor_Preferences/"); if (!IsIconized()) { // Main window location and size int x1, y1, x2, y2; GetPosition(&x1, &y1); GetSize(&x2, &y2); // Saving window size and position config->Write(section+wxT("MAIN_X_POS"), (long) x1); config->Write(section+wxT("MAIN_Y_POS"), (long) y1); config->Write(section+wxT("MAIN_X_SIZE"), (long) x2); config->Write(section+wxT("MAIN_Y_SIZE"), (long) y2); config->Write(section+wxT("Maximized"), (long) (IsMaximized() ? 1 : 0)); } // Saving sash position of splitter in server window config->Write(section+wxT("SRV_SPLITTER_POS"), (long) m_srv_split_pos); config->Flush(true); /* End modif */ return true; }
void ConsoleLogFrame::OnMoveAround( wxMoveEvent& evt ) { if( IsBeingDeleted() || !IsVisible() || IsIconized() ) return; // Docking check! If the window position is within some amount // of the main window, enable docking. if( wxWindow* main = GetParent() ) { wxPoint topright( main->GetRect().GetTopRight() ); wxRect snapzone( topright - wxSize( 8,8 ), wxSize( 16,16 ) ); m_conf.AutoDock = snapzone.Contains( GetPosition() ); //Console.WriteLn( "DockCheck: %d", g_Conf->ConLogBox.AutoDock ); if( m_conf.AutoDock ) { SetPosition( topright + wxSize( 1,0 ) ); m_conf.AutoDock = true; } } m_conf.DisplayPosition = GetPosition(); evt.Skip(); }
void wxTopLevelWindowMSW::DoGetSize(int *width, int *height) const { if ( IsIconized() ) { WINDOWPLACEMENT wp; wp.length = sizeof(WINDOWPLACEMENT); if ( ::GetWindowPlacement(GetHwnd(), &wp) ) { const RECT& rc = wp.rcNormalPosition; if ( width ) *width = rc.right - rc.left; if ( height ) *height = rc.bottom - rc.top; return; } wxLogLastError(wxT("GetWindowPlacement")); } //else: normal case wxTopLevelWindowBase::DoGetSize(width, height); }
void MainEmuFrame::OnMoveAround( wxMoveEvent& evt ) { if( IsBeingDeleted() || !IsVisible() || IsIconized() ) return; // Uncomment this when doing logger stress testing (and then move the window around // while the logger spams itself) // ... makes for a good test of the message pump's responsiveness. if( EnableThreadedLoggingTest ) Console.Warning( "Threaded Logging Test! (a window move event)" ); // evt.GetPosition() returns the client area position, not the window frame position. // So read the window's screen-relative position directly. g_Conf->MainGuiPosition = GetScreenPosition(); // wxGTK note: X sends gratuitous amounts of OnMove messages for various crap actions // like selecting or deselecting a window, which muck up docking logic. We filter them // out using 'lastpos' here. :) static wxPoint lastpos( wxDefaultCoord, wxDefaultCoord ); if( lastpos == evt.GetPosition() ) return; lastpos = evt.GetPosition(); if( g_Conf->ProgLogBox.AutoDock ) { if (ConsoleLogFrame* proglog = wxGetApp().GetProgramLog()) { if (!proglog->IsMaximized()) { g_Conf->ProgLogBox.DisplayPosition = GetRect().GetTopRight(); proglog->SetPosition(g_Conf->ProgLogBox.DisplayPosition); } } } evt.Skip(); }
void wxTopLevelWindowMac::Iconize(bool iconize) { if ( IsIconized() != iconize ) m_nowpeer->Iconize(iconize); }
bool CCamFrame::Destroy() { // Before anything else let's set Document::Current and DocView::Current properly... // This "event" doesn't refer to any particular doc or view so we'll set them both NULL Document::SetNoCurrent(); DocView::SetNoCurrent(); // Update the window position and state preferences // This doesn't work as well as in Xtreme due to the lack of GetWindowPlacement // GetRect returns the current size of the window even when maximised or iconised // so some effort will be needed to correctly save the normal position bool bMin = IsIconized(); bool bMax = IsMaximized(); wxSize ScreenSize = wxGetDisplaySize(); CCamApp::MainWndPosString._MakeMsg( _T("#1%d #2%d #3%d #4%d #5%d #6%d"), m_WndRect.x, m_WndRect.y, m_WndRect.width, m_WndRect.height, ScreenSize.x, ScreenSize.y ); CCamApp::MainWndMaximized = bMax ? TRUE : FALSE; CCamApp::MainWndMinimized = bMin ? TRUE : FALSE; PORTNOTE("other","Removed WindowPlacement saving") #if !defined(EXCLUDE_FROM_XARALX) #ifndef EXCLUDE_FROM_RALPH // lets write out our non-maximised window position to the .ini file WINDOWPLACEMENT wPlace; wPlace.length = sizeof(WINDOWPLACEMENT); if (GetWindowPlacement( &wPlace )) { // we must save last normal position if in full screen mode if (FullScreenMode) { wPlace = NormalModePlace; } CCamApp::MainWndPosString._MakeMsg( "#1%d #2%d #3%d #4%d #5%d #6%d", wPlace.rcNormalPosition.left, wPlace.rcNormalPosition.top, wPlace.rcNormalPosition.right - wPlace.rcNormalPosition.left, wPlace.rcNormalPosition.bottom - wPlace.rcNormalPosition.top, GetSystemMetrics( SM_CXSCREEN ), GetSystemMetrics( SM_CYSCREEN ) ); CCamApp::MainWndMaximized = (wPlace.showCmd == SW_SHOWMAXIMIZED) ? TRUE : FALSE; CCamApp::MainWndMinimized = (wPlace.showCmd == SW_SHOWMINIMIZED) ? TRUE : FALSE; } else { CCamApp::MainWndPosString = ""; // so uses default next time CCamApp::MainWndMaximized = FALSE; CCamApp::MainWndMinimized = FALSE; } #endif // EXCLUDE_FROM_RALPH #endif // Make sure that the currently selected tool is "de-initialised" before the // main window is destroyed, or it will try to use a dead info bar. // NB. Docs say that this function can be safely called more than once. Tool::DeinitTools(); // DeathMsg is the last message sent before camelot shuts down BROADCAST_TO_ALL(DeathMsg()); PORTNOTE("other","Removed ExternalClipboard usage") #if !defined(EXCLUDE_FROM_XARALX) #ifndef EXCLUDE_FROM_RALPH // And make sure we're no longer on the clipboard viewer chain ChangeClipboardChain(NextClipboardViewer); #endif #endif return wxDocMDIParentFrame::Destroy(); }
//------------------------------------------------------------------------------ void GmatMdiChildFrame::UpdateGuiItem(int updateEdit, int updateAnimation) { #ifdef DEBUG_UPDATE_GUI_ITEM MessageInterface::ShowMessage ("GmatMdiChildFrame::UpdateGuiItem() entered, name='%s'\n updateEdit=%d, " "updateAnimation=%d, iconized=%d\n", mChildName.c_str(), updateEdit, updateAnimation, IsIconized()); #endif wxToolBar *toolBar = theParent->GetToolBar(); if (toolBar == NULL) return; bool isAnimatable = ((GmatMainFrame*)theParent)->IsAnimatable(); #ifdef DEBUG_UPDATE_GUI_ITEM bool isAnimationRunning = ((GmatMainFrame*)theParent)->IsAnimationRunning(); MessageInterface::ShowMessage (" IsMissionRunning=%d, IsAnimationRunning=%d, isAnimatable=%d\n", isMissionRunning, isAnimationRunning, isAnimatable); #endif int editIndex = theMenuBar->FindMenu("Edit"); //------------------------------------------------------------ // update edit from menubar and toolbar //------------------------------------------------------------ // Update MenuBar for this child if (updateEdit == 1 && !IsIconized() && (mItemType == GmatTree::SCRIPT_FILE || mItemType == GmatTree::GMAT_FUNCTION || mItemType == GmatTree::SCRIPT_EVENT)) { theMenuBar->EnableTop(editIndex, true); toolBar->EnableTool(GmatMenu::MENU_EDIT_CUT, true); toolBar->EnableTool(GmatMenu::MENU_EDIT_COPY, true); toolBar->EnableTool(GmatMenu::MENU_EDIT_PASTE, true); } else { theMenuBar->EnableTop(editIndex, false); toolBar->EnableTool(GmatMenu::MENU_EDIT_CUT, false); toolBar->EnableTool(GmatMenu::MENU_EDIT_COPY, false); toolBar->EnableTool(GmatMenu::MENU_EDIT_PASTE, false); } //------------------------------------------------------------ // update animation icons from toolbar //------------------------------------------------------------ // If mission is running, ignore if (updateAnimation == 1 && !IsIconized() && (mItemType == GmatTree::OUTPUT_ORBIT_VIEW || mItemType == GmatTree::OUTPUT_GROUND_TRACK_PLOT)) { // If mission is not running, enable screen shot and animation tools if (isAnimatable) { toolBar->EnableTool(GmatMenu::TOOL_SCREENSHOT, true); toolBar->EnableTool(GmatMenu::TOOL_ANIMATION_PLAY, true); toolBar->EnableTool(GmatMenu::TOOL_ANIMATION_STOP, true); toolBar->EnableTool(GmatMenu::TOOL_ANIMATION_FAST, true); toolBar->EnableTool(GmatMenu::TOOL_ANIMATION_SLOW, true); #ifdef DEBUG_UPDATE_GUI_ITEM MessageInterface::ShowMessage(" Animation tools enabled\n"); #endif } else { #ifdef DEBUG_UPDATE_GUI_ITEM MessageInterface::ShowMessage (" Cannot enable animation tools, mission is still running\n"); #endif } } else { toolBar->EnableTool(GmatMenu::TOOL_SCREENSHOT, false); toolBar->EnableTool(GmatMenu::TOOL_ANIMATION_PLAY, false); toolBar->EnableTool(GmatMenu::TOOL_ANIMATION_STOP, false); toolBar->EnableTool(GmatMenu::TOOL_ANIMATION_FAST, false); toolBar->EnableTool(GmatMenu::TOOL_ANIMATION_SLOW, false); } #ifdef DEBUG_UPDATE_GUI_ITEM MessageInterface::ShowMessage ("GmatMdiChildFrame::UpdateGuiItem() exiting\n"); #endif }
//------------------------------------------------------------------------------ // void SaveChildPositionAndSize() //------------------------------------------------------------------------------ void GmatMdiChildFrame::SaveChildPositionAndSize() { if (mCanSaveLocation == false) return; if (IsIconized()) return; // Get the position and size of the window first #ifdef __WXMAC__ Integer screenWidth = wxSystemSettings::GetMetric(wxSYS_SCREEN_X); Integer screenHeight = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y); #else Integer screenWidth; Integer screenHeight; GmatAppData::Instance()->GetMainFrame()->GetActualClientSize(&screenWidth, &screenHeight, true); // Since GmatMainFrame::GetActualClientSize() subtracts one, add one here (LOJ: 2012.07.23) screenWidth++; screenHeight++; #endif bool isMinimized = IsIconized(), isMaximized = IsMaximized(); if (isMinimized) Iconize(false); else if (isMaximized) Maximize(false); int tmpX = -1, tmpY = -1; int tmpW = -1, tmpH = -1; GetPosition(&tmpX, &tmpY); GetSize(&tmpW, &tmpH); Rvector upperLeft(2, ((Real) tmpX /(Real) screenWidth), ((Real) tmpY /(Real) screenHeight)); Rvector childSize(2, ((Real) tmpW /(Real) screenWidth), ((Real) tmpH /(Real) screenHeight)); if (isMinimized) Iconize(); else if (isMaximized) Maximize(); #ifdef DEBUG_PERSISTENCE // ======================= begin temporary ============================== MessageInterface::ShowMessage("*** Size of SCREEN %s is: width = %d, height = %d\n", mChildName.WX_TO_C_STRING, screenWidth, screenHeight); MessageInterface::ShowMessage("Position of View plot %s is: x = %d, y = %d\n", mChildName.WX_TO_C_STRING, tmpX, tmpY); MessageInterface::ShowMessage("Size of View plot %s is: width = %d, height = %d\n", mChildName.WX_TO_C_STRING, tmpW, tmpH); // ======================= end temporary ============================== #endif if ((mItemType == GmatTree::OUTPUT_REPORT) || (mItemType == GmatTree::OUTPUT_CCSDS_OEM_FILE ) || (mItemType == GmatTree::OUTPUT_ORBIT_VIEW) || (mItemType == GmatTree::OUTPUT_XY_PLOT) || (mItemType == GmatTree::OUTPUT_GROUND_TRACK_PLOT) // We'll want to add the event reports eventually, but they are not subscriber based //|| (mItemType == GmatTree::EVENT_REPORT) ) { GmatBase *obj = theGuiInterpreter->GetConfiguredObject(mChildName.c_str()); #ifdef DEBUG_FUNCTION // Check if child name is the configured object name MessageInterface::ShowMessage ("GmatMdiChildFrame::SaveChildPositionAndSize() the child '%s' %s a " "configured object, obj = <%p>[%s]'%s'\n", mChildName.WX_TO_C_STRING, obj ? "is" : "is not", obj, obj ? obj->GetTypeName().c_str() : "NULL", obj ? obj->GetName().c_str() : "NULL"); #endif if (!obj) { // Just return if child is not a configured subscriber,ie, // plotting from GMAT function (LOJ: 2015.06.26) #ifdef DEBUG_FUNCTION MessageInterface::ShowMessage ("**** WARNING **** GmatMdiChildFrame::SaveChildPositionAndSize() " "will not save position and size for unconfigured subscriber '%s'\n", mChildName.WX_TO_C_STRING); #endif return; } else if (!obj->IsOfType("Subscriber")) { #ifdef DEBUG_PERSISTENCE MessageInterface::ShowMessage ("**** WARNING **** GmatMdiChildFrame::SaveChildPositionAndSize() " "cannot not save position and size for non-subscriber '%s'\n", mChildName.WX_TO_C_STRING); #endif SubscriberException se; se.SetDetails("Cannot set position and size for non-subscriber '%s'"); throw se; } Subscriber *sub = (Subscriber*) obj; #ifdef DEBUG_PERSISTENCE MessageInterface::ShowMessage("...... Now saving plot data to %s:\n", (sub->GetName()).c_str()); MessageInterface::ShowMessage(" Upper left = %12.10f %12.10f\n", upperLeft[0], upperLeft[1]); MessageInterface::ShowMessage(" Size = %12.10f %12.10f\n", childSize[0], childSize[1]); MessageInterface::ShowMessage(" RelativeZOrder = %d\n", relativeZOrder); #endif sub->SetRvectorParameter(sub->GetParameterID("UpperLeft"), upperLeft); sub->SetRvectorParameter(sub->GetParameterID("Size"), childSize); sub->SetIntegerParameter(sub->GetParameterID("RelativeZOrder"), relativeZOrder); sub->SetBooleanParameter(sub->GetParameterID("Maximized"), isMaximized); } else if (mItemType == GmatTree::MISSION_TREE_UNDOCKED) { // get the config object wxFileConfig *pConfig; pConfig = (wxFileConfig *) GmatAppData::Instance()->GetPersonalizationConfig(); std::stringstream location(""); location << upperLeft[0] << " " << upperLeft[1]; std::stringstream size(""); size << childSize[0] << " " << childSize[1]; pConfig->Write("/MissionTree/UpperLeft", location.str().c_str()); pConfig->Write("/MissionTree/Size", size.str().c_str()); pConfig->Write("/MissionTree/IsMaximized", isMaximized); pConfig->Write("/MissionTree/IsMinimized", isMinimized); } else if (mItemType == GmatTree::SCRIPT_FILE) { // get the config object wxFileConfig *pConfig; pConfig = (wxFileConfig *) GmatAppData::Instance()->GetPersonalizationConfig(); std::stringstream location(""); location << upperLeft[0] << " " << upperLeft[1]; std::stringstream size(""); size << childSize[0] << " " << childSize[1]; pConfig->Write("/ScriptEditor/UpperLeft", location.str().c_str()); pConfig->Write("/ScriptEditor/Size", size.str().c_str()); pConfig->Write("/ScriptEditor/IsMaximized", isMaximized); pConfig->Write("/ScriptEditor/IsMinimized", isMinimized); } }