bool grib_pi::QualifyCtrlBarPosition( wxPoint position, wxSize size ) { // Make sure drag bar (title bar) or grabber always screen bool b_reset_pos = false; #ifdef __WXMSW__ // Support MultiMonitor setups which an allow negative window positions. // If the requested window does not intersect any installed monitor, // then default to simple primary monitor positioning. RECT frame_title_rect; frame_title_rect.left = position.x; frame_title_rect.top = position.y; frame_title_rect.right = position.x + size.x; frame_title_rect.bottom = m_DialogStyle == ATTACHED_HAS_CAPTION ? position.y + 30 : position.y + size.y; if(NULL == MonitorFromRect(&frame_title_rect, MONITOR_DEFAULTTONULL)) b_reset_pos = true; #else wxRect window_title_rect; // conservative estimate window_title_rect.x = position.x; window_title_rect.y = position.y; window_title_rect.width = size.x; window_title_rect.height = m_DialogStyle == ATTACHED_HAS_CAPTION ? 30 : size.y; wxRect ClientRect = wxGetClientDisplayRect(); if(!ClientRect.Intersects(window_title_rect)) b_reset_pos = true; #endif return !b_reset_pos; }
virtual wxRect GetClientArea() const { // we intentionally don't cache the result here because the client // display area may change (e.g. the user resized or hid a panel) and // we don't currently react to its changes return IsPrimary() ? wxGetClientDisplayRect() : m_rect; }
void wxTopLevelWindowMSW::Maximize(bool maximize) { if ( IsShown() ) { // just maximize it directly DoShowWindow(maximize ? SW_MAXIMIZE : SW_RESTORE); } else // hidden { // we can't maximize the hidden frame because it shows it as well, // so just remember that we should do it later in this case m_maximizeOnShow = maximize; #if wxUSE_DEFERRED_SIZING // after calling Maximize() the client code expects to get the frame // "real" size and doesn't want to know that, because of implementation // details, the frame isn't really maximized yet but will be only once // it's shown, so return our size as it will be then in this case if ( maximize ) { // we must only change pending size here, and not call SetSize() // because otherwise Windows would think that this (full screen) // size is the natural size for the frame and so would use it when // the user clicks on "restore" title bar button instead of the // correct initial frame size // // NB: unfortunately we don't know which display we're on yet so we // have to use the default one m_pendingSize = wxGetClientDisplayRect().GetSize(); } //else: can't do anything in this case, we don't have the old size #endif // wxUSE_DEFERRED_SIZING } }
void compute_window_positions() { auto area = wxGetClientDisplayRect(); control_position.x = area.x + 10; control_position.y = area.y + 5; if (control_position.x + 470 + 500 < area.x + area.width) { editor_position.x = control_position.x + 470; editor_position.y = control_position.y; } else if (control_position.y + 410 + 500 < area.y + area.height) { editor_position.x = control_position.x; editor_position.y = control_position.y + 410; } else { editor_position.x = wxDefaultPosition.x; editor_position.y = wxDefaultPosition.y; } if (editor_position.x + 505 + 500 < area.x + area.width) { viewer_position.x = editor_position.x + 505; viewer_position.y = editor_position.y; } else if (editor_position.y + 505 + 500 < area.y + area.height) { viewer_position.x = editor_position.x; viewer_position.y = editor_position.y + 505; } else { viewer_position.x = wxDefaultPosition.x; viewer_position.y = wxDefaultPosition.y; } }
bool wxNonOwnedWindow::Create(wxWindow *parent, wxWindowID id, const wxPoint& posOrig, const wxSize& sizeOrig, long style, const wxString& name) { m_windowStyle = style; SetName( name ); m_windowId = id == -1 ? NewControlId() : id; m_windowStyle = style; m_isShown = false; // use the appropriate defaults for the position and size if necessary wxSize size(sizeOrig); if ( !size.IsFullySpecified() ) size.SetDefaults(wxTopLevelWindow::GetDefaultSize()); wxPoint pos(posOrig); if ( !pos.IsFullySpecified() ) { wxRect rectWin = wxRect(size).CentreIn(wxGetClientDisplayRect()); // The size of the window is often not really known yet, TLWs are often // created with some small initial size and later are fitted to contain // their children so centering the window will show it too much to the // right and bottom, adjust for it by putting it more to the left and // center. rectWin.x /= 2; rectWin.y /= 2; pos.SetDefaults(rectWin.GetPosition()); } // create frame. m_nowpeer = wxNonOwnedWindowImpl::CreateNonOwnedWindow ( this, parent, pos , size, style, GetExtraStyle(), name ); wxNonOwnedWindowImpl::Associate( m_nowpeer->GetWXWindow() , m_nowpeer ) ; SetPeer(wxWidgetImpl::CreateContentView(this)); DoSetWindowVariant( m_windowVariant ) ; wxWindowCreateEvent event(this); HandleWindowEvent(event); SetBackgroundColour(wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE )); if ( parent ) parent->AddChild(this); return true; }
//--------------------------------------------------------- wxRect DLG_Get_Def_Rect(void) { wxRect r(wxGetClientDisplayRect()); r.Deflate((int)(0.15 * r.GetWidth()), (int)(0.15 * r.GetHeight())); return( r ); }
wxRect wxDisplayImplMacOSX::GetClientArea() const { // VZ: I don't know how to get client area for arbitrary display but // wxGetClientDisplayRect() does work correctly for at least the main // one (TODO: do it correctly for the other displays too) if ( IsPrimary() ) return wxGetClientDisplayRect(); return wxDisplayImpl::GetClientArea(); }
void wxClientDisplayRect(int *x, int *y, int *width, int *height) { const wxRect rect = wxGetClientDisplayRect(); if ( x ) *x = rect.x; if ( y ) *y = rect.y; if ( width ) *width = rect.width; if ( height ) *height = rect.height; }
// Formerly known as LoadRazorPrefs() bool CamuleDlg::LoadGUIPrefs(bool override_pos, bool override_size) { // Create a config base for loading razor preferences wxConfigBase *config = wxConfigBase::Get(); // If config haven't been created exit without loading if (config == NULL) { return false; } // The section where to save in in file wxString section = wxT("/Razor_Preferences/"); // Get window size and position int x1 = config->Read(section + wxT("MAIN_X_POS"), -1); int y1 = config->Read(section + wxT("MAIN_Y_POS"), -1); int x2 = config->Read(section + wxT("MAIN_X_SIZE"), -1); int y2 = config->Read(section + wxT("MAIN_Y_SIZE"), -1); int maximized = config->Read(section + wxT("Maximized"), 01); // Kry - Random usable pos for m_srv_split_pos m_srv_split_pos = config->Read(section + wxT("SRV_SPLITTER_POS"), 463l); if (!override_size) { if (x2 > 0 && y2 > 0) { SetSize(x2, y2); } else { #ifndef __WXGTK__ // Probably first run. Maximize(); #endif } } if (!override_pos) { // If x1 and y1 != -1 Redefine location if(x1 != -1 && y1 != -1) { wxRect display = wxGetClientDisplayRect(); if (x1 <= display.GetRightTop().x && y1 <= display.GetRightBottom().y) { Move(x1, y1); } else { // It's offscreen... so let's not. } } } if (!override_size && !override_pos && maximized) { Maximize(); } return true; }
void wxFrame_SetInitialPosition(wxFrame* wnd, const wxPoint& pos, const wxSize& size, int margin_pct) { if (size == wxDefaultSize) { wxRect rect = wxGetClientDisplayRect(); wxSize size( (rect.width * (100 - margin_pct*2))/100, (rect.height * (100 - margin_pct*2))/100); wnd->SetSize(size); } if (pos == wxDefaultPosition) wnd->Center(); }
//*************************************** mainFrame wxSize mainFrame::GetChildSize(int nPct) { #ifdef __NO_MDI__ wxSize sz = wxGetClientDisplayRect().GetSize(); #else wxSize sz = GetClientWindow()->GetSize(); wxStatusBar *pBar = GetStatusBar(); if(pBar) { wxSize szBar = pBar->GetSize(); int y = sz.GetHeight() - szBar.GetHeight(); sz.SetHeight(y); } #endif sz.SetHeight(sz.GetHeight() * nPct / 100); sz.SetWidth(sz.GetWidth() * nPct / 100); return sz; }
/// 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)); #if wxUSE_DISPLAY displaySize = wxDisplay(wxDisplay::GetFromWindow(dialog)).GetClientArea().GetSize(); #else displaySize = wxGetClientDisplayRect().GetSize(); #endif int flags = 0; if (windowSize.y >= (displaySize.y - wxEXTRA_DIALOG_HEIGHT)) flags |= wxVERTICAL; if (windowSize.x >= displaySize.x) flags |= wxHORIZONTAL; return flags; }
void SjDialog::EnsureRectDisplayVisibility(wxRect& r) { // check against the available displays // at least a 128 x 128 pixel area should fit on any display! // // otherwise we align the rect to the primary display, in this case the // skin may be misaligned, however, there is no more space bool alignToPrimaryWorkspace = true; size_t displayCount = wxDisplay::GetCount(), d; if( displayCount > 1 ) { for( d = 0; d < displayCount; d++ ) { wxDisplay currDisplay(d); wxRect currDisplayRect = currDisplay.GetGeometry(); wxRect intersection = currDisplayRect.Intersect(r); if( intersection.width*intersection.height > 128*128 ) { alignToPrimaryWorkspace = false; break; // done } } } if( alignToPrimaryWorkspace ) { wxRect displRect = wxGetClientDisplayRect(); if( r.width > displRect.width ) r.width = displRect.width; if( r.height > displRect.height ) r.height = displRect.height; if( r.x < displRect.x ) r.x = displRect.x; if( r.x > displRect.x + displRect.width - r.width ) r.x = displRect.x + displRect.width - r.width; if( r.y < displRect.y ) r.y = displRect.y; if( r.y > displRect.y + displRect.height - r.height ) r.y = displRect.y + displRect.height - r.height; } }
SplashDialog::SplashDialog(wxWindow * parent) : wxDialog(parent, -1, #if ((AUDACITY_BRANDING == BRAND_JAMLING__EASY) || (AUDACITY_BRANDING == BRAND_JAMLING__FULL)) _NoAcc("&Jamling Audacity"), wxPoint(640 - kWidth, 120), wxSize(kWidth, kWidth * 1.61803399), // the golden ratio = 1.61803399 #else _NoAcc("&Welcome to Audacity!"), wxPoint( -1, 60 ), // default x position, y position 60 pixels from top of screen. wxDefaultSize, #endif wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) { // loads either the XPM or the windows resource, depending on the platform #if !defined(__WXMAC__) && !defined(__WXX11__) #ifdef __WXMSW__ wxIcon ic(wxICON(AudacityLogo)); #else wxIcon ic(wxICON(AudacityLogo48x48)); #endif SetIcon(ic); #endif // This seems to have no effect when called here, on Windows. this->SetBackgroundColour(theTheme.Colour( clrAboutBoxBackground )); mButton_Logo = NULL; ShuttleGui S( this, eIsCreating ); Populate( S ); #if ((AUDACITY_BRANDING == BRAND_JAMLING__EASY) || (AUDACITY_BRANDING == BRAND_JAMLING__FULL)) wxRect screenRect = wxGetClientDisplayRect();; this->Move(screenRect.GetWidth() - kWidth - 24, 120); // off to the right, below the ruler #else Fit(); this->Centre(); int x,y; GetPosition( &x, &y ); Move( x, 60 ); #endif }
/* static */ wxSize wxTopLevelWindowBase::GetDefaultSize() { wxSize size = wxGetClientDisplayRect().GetSize(); // create proportionally bigger windows on small screens if ( size.x >= 1024 ) size.x = 400; else if ( size.x >= 800 ) size.x = 300; else if ( size.x >= 320 ) size.x = 240; if ( size.y >= 768 ) size.y = 250; else if ( size.y > 200 ) { size.y *= 2; size.y /= 3; } return size; }
bool DropDownBase::ShowPopup() { int x = 0, y = GetSize().y; ClientToScreen( &x, &y ); // control too low, can't show scrollbar, don't bother displaying wxRect displayRect = wxGetClientDisplayRect(); if (displayRect.GetBottom() - y < DROPDOWN_DROP_HEIGHT) return false; int width = GetSize().x; int height = DoGetBestDropHeight(displayRect.GetBottom() - y); if (height < 1) return false; m_popupWin = new DropDownPopup(this); m_popupWin->SetSize(x, y, width, height); if (m_popupWin->GetChild()) m_popupWin->GetChild()->SetSize(width, height); //wxPrintf(wxT("ShowPopup %d %d, %d %d -- %d\n"), width, height, m_popupWin->GetSize().x, m_popupWin->GetSize().y, m_popupWin->GetMinHeight()); return DoShowPopup(); }
void wxSTEditorFrame::LoadConfig(wxConfigBase &config, const wxString &configPath_) { wxString configPath = wxSTEditorOptions::FixConfigPath(configPath_, false); if (GetMenuBar() && GetMenuBar()->FindItem(ID_STF_SHOW_SIDEBAR)) { long val = 0; if (config.Read(configPath + "/ShowSidebar", &val)) { wxSTEditorMenuManager::DoCheckItem(NULL, GetMenuBar(), NULL, ID_STF_SHOW_SIDEBAR, val != 0); // send fake event to HandleEvent wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, ID_STF_SHOW_SIDEBAR); evt.SetInt(int(val)); HandleMenuEvent(evt); } } wxString str; if (config.Read(configPath + "/FrameSize", &str)) { wxRect rect = GetRect(); long lrect[4] = { rect.x, rect.y, rect.width, rect.height }; wxArrayString arrStr = wxStringTokenize(str, ","); if (arrStr.GetCount() == 4u) { for (size_t n = 0; n < 4; n++) arrStr[n].ToLong(&lrect[n]); wxRect cfgRect((int)lrect[0], (int)lrect[1], (int)lrect[2], (int)lrect[3]); cfgRect = cfgRect.Intersect(wxGetClientDisplayRect()); if ((cfgRect != rect) && (cfgRect.width>=100) && (cfgRect.height>=100)) SetSize(cfgRect); } } }
void mainFrame::SetupSize() { if(!g_size80.GetHeight()) { wxRect r = wxGetClientDisplayRect(); int nw = r.GetWidth(); int nh = r.GetHeight(); int nx = (nw << 2) / 5; int ny = (nh << 2) / 5; g_size80.SetHeight(ny); g_size80.SetWidth(nx); g_point50.x = (nw >> 1) + r.GetX(); g_point50.y = (nh >> 1) + r.GetY(); nx = nw * 9 / 10; ny = nh * 9 / 10; g_size90.SetHeight(ny); g_size90.SetWidth(nx); g_point5.x = ((nw - nx) >> 1) + r.GetX(); g_point5.y = ((nh - ny) >> 1) + r.GetY(); int nws = wxSystemSettings::GetMetric(wxSYS_SCREEN_X); int nhs = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y); g_point100.x = nws + 1; g_point100.y = nhs + 1; }
wxProgressDialog::wxProgressDialog(const wxString& title, const wxString& message, int maximum, wxWindow *parent, int style) : wxDialog(GetParentForModalDialog(parent), wxID_ANY, title), m_skip(false), m_delay(3), m_hasAbortButton(false), m_hasSkipButton(false) { // we may disappear at any moment, let the others know about it SetExtraStyle(GetExtraStyle() | wxWS_EX_TRANSIENT); m_windowStyle |= style; m_hasAbortButton = (style & wxPD_CAN_ABORT) != 0; m_hasSkipButton = (style & wxPD_CAN_SKIP) != 0; #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) // we have to remove the "Close" button from the title bar then as it is // confusing to have it - it doesn't work anyhow // // FIXME: should probably have a (extended?) window style for this if ( !m_hasAbortButton ) { EnableCloseButton(false); } #endif // wxMSW #if defined(__SMARTPHONE__) SetLeftMenu(); #endif m_state = m_hasAbortButton ? Continue : Uncancelable; m_maximum = maximum; #if defined(__WXMSW__) || defined(__WXPM__) // we can't have values > 65,536 in the progress control under Windows, so // scale everything down m_factor = m_maximum / 65536 + 1; m_maximum /= m_factor; #endif // __WXMSW__ m_parentTop = wxGetTopLevelParent(parent); wxClientDC dc(this); dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); wxCoord widthText = 0; dc.GetTextExtent(message, &widthText, NULL, NULL, NULL, NULL); // top-level sizerTop wxSizer * const sizerTop = new wxBoxSizer(wxVERTICAL); m_msg = new wxStaticText(this, wxID_ANY, message); sizerTop->Add(m_msg, 0, wxLEFT | wxTOP, 2*LAYOUT_MARGIN); if ( maximum > 0 ) { int gauge_style = wxGA_HORIZONTAL; if ( style & wxPD_SMOOTH ) gauge_style |= wxGA_SMOOTH; m_gauge = new wxGauge ( this, wxID_ANY, m_maximum, wxDefaultPosition, // make the progress bar sufficiently long wxSize(wxMin(wxGetClientDisplayRect().width/3, 300), -1), gauge_style ); sizerTop->Add(m_gauge, 0, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 2*LAYOUT_MARGIN); m_gauge->SetValue(0); } else { m_gauge = NULL; } // create the estimated/remaining/total time zones if requested m_elapsed = m_estimated = m_remaining = NULL; m_display_estimated = m_last_timeupdate = m_break = 0; m_ctdelay = 0; // also count how many labels we really have size_t nTimeLabels = 0; wxSizer * const sizerLabels = new wxFlexGridSizer(2); if ( style & wxPD_ELAPSED_TIME ) { nTimeLabels++; m_elapsed = CreateLabel(_("Elapsed time:"), sizerLabels); } if ( style & wxPD_ESTIMATED_TIME ) { nTimeLabels++; m_estimated = CreateLabel(_("Estimated time:"), sizerLabels); } if ( style & wxPD_REMAINING_TIME ) { nTimeLabels++; m_remaining = CreateLabel(_("Remaining time:"), sizerLabels); } sizerTop->Add(sizerLabels, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, LAYOUT_MARGIN); if ( nTimeLabels > 0 ) { // set it to the current time m_timeStart = wxGetCurrentTime(); } #if defined(__SMARTPHONE__) if ( m_hasSkipButton ) SetRightMenu(wxID_SKIP, _("Skip")); if ( m_hasAbortButton ) SetLeftMenu(wxID_CANCEL); #else m_btnAbort = m_btnSkip = NULL; wxBoxSizer *buttonSizer = new wxBoxSizer(wxHORIZONTAL); // Windows dialogs usually have buttons in the lower right corner const int sizerFlags = #if defined(__WXMSW__) || defined(__WXPM__) wxALIGN_RIGHT | wxALL #else // !MSW wxALIGN_CENTER_HORIZONTAL | wxBOTTOM | wxTOP #endif // MSW/!MSW ; if ( m_hasSkipButton ) { m_btnSkip = new wxButton(this, wxID_SKIP, _("&Skip")); buttonSizer->Add(m_btnSkip, 0, sizerFlags, LAYOUT_MARGIN); } if ( m_hasAbortButton ) { m_btnAbort = new wxButton(this, wxID_CANCEL); buttonSizer->Add(m_btnAbort, 0, sizerFlags, LAYOUT_MARGIN); } sizerTop->Add(buttonSizer, 0, sizerFlags, LAYOUT_MARGIN ); #endif // __SMARTPHONE__/!__SMARTPHONE__ SetSizerAndFit(sizerTop); Centre(wxCENTER_FRAME | wxBOTH); if ( style & wxPD_APP_MODAL ) { m_winDisabler = new wxWindowDisabler(this); } else { if ( m_parentTop ) m_parentTop->Disable(); m_winDisabler = NULL; } Show(); Enable(); // this one can be initialized even if the others are unknown for now // // NB: do it after calling Layout() to keep the labels correctly aligned if ( m_elapsed ) { SetTimeLabel(0, m_elapsed); } Update(); }
AISTargetListDialog::AISTargetListDialog( wxWindow *parent, wxAuiManager *auimgr, AIS_Decoder *pdecoder ) : wxPanel( parent, wxID_ANY, wxDefaultPosition, wxSize( 780, 250 ), wxBORDER_NONE ) { m_pparent = parent; m_pAuiManager = auimgr; m_pdecoder = pdecoder; wxFont *qFont = GetOCPNScaledFont(_T("Dialog"), 12); SetFont( *qFont ); // Make an estimate of the default dialog size // for the case when the AUI Perspective for this dialog is undefined wxSize esize; esize.x = 700; esize.y = GetCharHeight() * 18; SetSize( esize ); // SetMinSize( wxSize(400,240)); s_p_sort_decoder = pdecoder; m_pMMSI_array = new ArrayOfMMSI( ArrayItemCompareMMSI ); wxBoxSizer* topSizer = new wxBoxSizer( wxHORIZONTAL ); SetSizer( topSizer ); // Parse the global column width string as read from config file wxStringTokenizer tkz( g_AisTargetList_column_spec, _T(";") ); wxString s_width = tkz.GetNextToken(); int width; long lwidth; m_pListCtrlAISTargets = new OCPNListCtrl( this, ID_AIS_TARGET_LIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_HRULES | wxLC_VRULES | wxBORDER_SUNKEN | wxLC_VIRTUAL ); wxImageList *imglist = new wxImageList( 16, 16, true, 2 ); ocpnStyle::Style* style = g_StyleManager->GetCurrentStyle(); imglist->Add( style->GetIcon( _T("sort_asc") ) ); imglist->Add( style->GetIcon( _T("sort_desc") ) ); m_pListCtrlAISTargets->AssignImageList( imglist, wxIMAGE_LIST_SMALL ); m_pListCtrlAISTargets->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( AISTargetListDialog::OnTargetSelected ), NULL, this ); m_pListCtrlAISTargets->Connect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( AISTargetListDialog::OnTargetSelected ), NULL, this ); m_pListCtrlAISTargets->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( AISTargetListDialog::OnTargetDefaultAction ), NULL, this ); m_pListCtrlAISTargets->Connect( wxEVT_COMMAND_LIST_COL_CLICK, wxListEventHandler( AISTargetListDialog::OnTargetListColumnClicked ), NULL, this ); int dx = GetCharWidth(); width = dx * 4; if( s_width.ToLong( &lwidth ) ) { width = wxMax(dx * 2, lwidth); width = wxMin(width, dx * 30); } m_pListCtrlAISTargets->InsertColumn( tlTRK, _("Trk"), wxLIST_FORMAT_LEFT, width ); s_width = tkz.GetNextToken(); width = dx * 12; if( s_width.ToLong( &lwidth ) ) { width = wxMax(dx * 2, lwidth); width = wxMin(width, dx * 30); } m_pListCtrlAISTargets->InsertColumn( tlNAME, _("Name"), wxLIST_FORMAT_LEFT, width ); s_width = tkz.GetNextToken(); width = dx * 7; if( s_width.ToLong( &lwidth ) ) { width = wxMax(dx * 2, lwidth); width = wxMin(width, dx * 30); } m_pListCtrlAISTargets->InsertColumn( tlCALL, _("Call"), wxLIST_FORMAT_LEFT, width ); s_width = tkz.GetNextToken(); width = dx * 10; if( s_width.ToLong( &lwidth ) ) { width = wxMax(dx * 2, lwidth); width = wxMin(width, dx * 30); } m_pListCtrlAISTargets->InsertColumn( tlMMSI, _("MMSI"), wxLIST_FORMAT_LEFT, width ); s_width = tkz.GetNextToken(); width = dx * 7; if( s_width.ToLong( &lwidth ) ) { width = wxMax(dx * 2, lwidth); width = wxMin(width, dx * 30); } m_pListCtrlAISTargets->InsertColumn( tlCLASS, _("Class"), wxLIST_FORMAT_CENTER, width ); s_width = tkz.GetNextToken(); width = dx * 10; if( s_width.ToLong( &lwidth ) ) { width = wxMax(dx * 2, lwidth); width = wxMin(width, dx * 30); } m_pListCtrlAISTargets->InsertColumn( tlTYPE, _("Type"), wxLIST_FORMAT_LEFT, width ); s_width = tkz.GetNextToken(); width = dx * 12; if( s_width.ToLong( &lwidth ) ) { width = wxMax(dx * 2, lwidth); width = wxMin(width, dx * 30); } m_pListCtrlAISTargets->InsertColumn( tlNAVSTATUS, _("Nav Status"), wxLIST_FORMAT_LEFT, width ); s_width = tkz.GetNextToken(); width = dx * 6; if( s_width.ToLong( &lwidth ) ) { width = wxMax(dx * 2, lwidth); width = wxMin(width, dx * 30); } m_pListCtrlAISTargets->InsertColumn( tlBRG, _("Brg"), wxLIST_FORMAT_RIGHT, width ); s_width = tkz.GetNextToken(); width = dx * 8; if( s_width.ToLong( &lwidth ) ) { width = wxMax(dx * 2, lwidth); width = wxMin(width, dx * 30); } m_pListCtrlAISTargets->InsertColumn( tlRNG, _("Range"), wxLIST_FORMAT_RIGHT, width ); s_width = tkz.GetNextToken(); width = dx * 6; if( s_width.ToLong( &lwidth ) ) { width = wxMax(dx * 2, lwidth); width = wxMin(width, dx * 30); } m_pListCtrlAISTargets->InsertColumn( tlCOG, _("CoG"), wxLIST_FORMAT_RIGHT, width ); s_width = tkz.GetNextToken(); width = dx * 6; if( s_width.ToLong( &lwidth ) ) { width = wxMax(dx * 2, lwidth); width = wxMin(width, dx * 30); } m_pListCtrlAISTargets->InsertColumn( tlSOG, _("SoG"), wxLIST_FORMAT_RIGHT, width ); width = dx * 7; if( s_width.ToLong( &lwidth ) ) { width = wxMax(dx * 2, lwidth); width = wxMin(width, dx * 30); } m_pListCtrlAISTargets->InsertColumn( tlCPA, _("CPA"), wxLIST_FORMAT_RIGHT, width ); width = dx * 8; if( s_width.ToLong( &lwidth ) ) { width = wxMax(dx * 2, lwidth); width = wxMin(width, dx * 30); } m_pListCtrlAISTargets->InsertColumn( tlTCPA, _("TCPA"), wxLIST_FORMAT_RIGHT, width ); wxListItem item; item.SetMask( wxLIST_MASK_IMAGE ); item.SetImage( g_bAisTargetList_sortReverse ? 1 : 0 ); g_AisTargetList_sortColumn = wxMax(g_AisTargetList_sortColumn, 0); m_pListCtrlAISTargets->SetColumn( g_AisTargetList_sortColumn, item ); topSizer->Add( m_pListCtrlAISTargets, 1, wxEXPAND | wxALL, 0 ); wxBoxSizer* boxSizer02 = new wxBoxSizer( wxVERTICAL ); boxSizer02->AddSpacer( 22 ); m_pButtonInfo = new wxButton( this, wxID_ANY, _("Target info"), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); m_pButtonInfo->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( AISTargetListDialog::OnTargetQuery ), NULL, this ); boxSizer02->Add( m_pButtonInfo, 0, wxEXPAND | wxALL, 0 ); boxSizer02->AddSpacer( 5 ); m_pButtonJumpTo = new wxButton( this, wxID_ANY, _("Center View"), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); m_pButtonJumpTo->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( AISTargetListDialog::OnTargetScrollTo ), NULL, this ); boxSizer02->Add( m_pButtonJumpTo, 0, wxEXPAND | wxALL, 0 ); m_pButtonCreateWpt = new wxButton( this, wxID_ANY, _("Create WPT"), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); m_pButtonCreateWpt->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( AISTargetListDialog::OnTargetCreateWpt ), NULL, this ); boxSizer02->Add( m_pButtonCreateWpt, 0, wxEXPAND | wxALL, 0 ); m_pButtonHideAllTracks = new wxButton( this, wxID_ANY, _("Hide All Tracks"), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); m_pButtonHideAllTracks->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( AISTargetListDialog::OnHideAllTracks ), NULL, this ); boxSizer02->Add( m_pButtonHideAllTracks, 0, wxEXPAND | wxALL, 0 ); m_pButtonShowAllTracks = new wxButton( this, wxID_ANY, _("Show All Tracks"), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); m_pButtonShowAllTracks->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( AISTargetListDialog::OnShowAllTracks ), NULL, this ); boxSizer02->Add( m_pButtonShowAllTracks, 0, wxEXPAND | wxALL, 0 ); m_pButtonToggleTrack = new wxButton( this, wxID_ANY, _("Toggle track"), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); m_pButtonToggleTrack->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( AISTargetListDialog::OnToggleTrack ), NULL, this ); boxSizer02->Add( m_pButtonToggleTrack, 0, wxEXPAND | wxALL, 0 ); boxSizer02->AddSpacer( 10 ); m_pStaticTextRange = new wxStaticText( this, wxID_ANY, _("Limit range: NM"), wxDefaultPosition, wxDefaultSize, 0 ); boxSizer02->Add( m_pStaticTextRange, 0, wxALL, 0 ); boxSizer02->AddSpacer( 2 ); m_pSpinCtrlRange = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 50, -1 ), wxSP_ARROW_KEYS, 1, 20000, g_AisTargetList_range ); m_pSpinCtrlRange->Connect( wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler( AISTargetListDialog::OnLimitRange ), NULL, this ); m_pSpinCtrlRange->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( AISTargetListDialog::OnLimitRange ), NULL, this ); boxSizer02->Add( m_pSpinCtrlRange, 0, wxEXPAND | wxALL, 0 ); topSizer->Add( boxSizer02, 0, wxEXPAND | wxALL, 2 ); boxSizer02->AddSpacer( 10 ); m_pStaticTextCount = new wxStaticText( this, wxID_ANY, _("Target Count"), wxDefaultPosition, wxDefaultSize, 0 ); boxSizer02->Add( m_pStaticTextCount, 0, wxALL, 0 ); boxSizer02->AddSpacer( 2 ); m_pTextTargetCount = new wxTextCtrl( this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); boxSizer02->Add( m_pTextTargetCount, 0, wxALL, 0 ); boxSizer02->AddSpacer( 10 ); m_pButtonOK = new wxButton( this, wxID_ANY, _("Close"), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); m_pButtonOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( AISTargetListDialog::OnCloseButton ), NULL, this ); boxSizer02->Add( m_pButtonOK, 0, wxEXPAND | wxALL, 0 ); topSizer->Layout(); // This is silly, but seems to be required for __WXMSW__ build // If not done, the SECOND invocation of AISTargetList fails to expand the list to the full wxSizer size.... SetSize( GetSize().x, GetSize().y - 1 ); SetColorScheme(); UpdateButtons(); if( m_pAuiManager ) { wxAuiPaneInfo pane = wxAuiPaneInfo().Name( _T("AISTargetList") ).CaptionVisible( true ). DestroyOnClose( true ).Float().FloatingPosition( 50, 50 ).TopDockable( false ). BottomDockable( true ).LeftDockable( false ).RightDockable( false ).Show( true ); m_pAuiManager->LoadPaneInfo( g_AisTargetList_perspective, pane ); bool b_reset_pos = false; if( (pane.floating_size.x != -1) && (pane.floating_size.y != -1)){ #ifdef __WXMSW__ // Support MultiMonitor setups which an allow negative window positions. // If the requested window title bar does not intersect any installed monitor, // then default to simple primary monitor positioning. RECT frame_title_rect; frame_title_rect.left = pane.floating_pos.x; frame_title_rect.top = pane.floating_pos.y; frame_title_rect.right = pane.floating_pos.x + pane.floating_size.x; frame_title_rect.bottom = pane.floating_pos.y + 30; if( NULL == MonitorFromRect( &frame_title_rect, MONITOR_DEFAULTTONULL ) ) b_reset_pos = true; #else // Make sure drag bar (title bar) of window intersects wxClient Area of screen, with a little slop... wxRect window_title_rect;// conservative estimate window_title_rect.x = pane.floating_pos.x; window_title_rect.y = pane.floating_pos.y; window_title_rect.width = pane.floating_size.x; window_title_rect.height = 30; wxRect ClientRect = wxGetClientDisplayRect(); ClientRect.Deflate(60, 60);// Prevent the new window from being too close to the edge if(!ClientRect.Intersects(window_title_rect)) b_reset_pos = true; #endif if( b_reset_pos ) pane.FloatingPosition( 50, 50 ); } // If the list got accidentally dropped on top of the chart bar, move it away.... if( pane.IsDocked() && ( pane.dock_row == 0 ) ) { pane.Float(); pane.Row( 1 ); pane.Position( 0 ); g_AisTargetList_perspective = m_pAuiManager->SavePaneInfo( pane ); pConfig->UpdateSettings(); } pane.Caption( wxGetTranslation( _("AIS target list") ) ); m_pAuiManager->AddPane( this, pane ); m_pAuiManager->Update(); m_pAuiManager->Connect( wxEVT_AUI_PANE_CLOSE, wxAuiManagerEventHandler( AISTargetListDialog::OnPaneClose ), NULL, this ); } }
wxCheckboxPage(wxWizard *parent, wxWizardPage *prev, wxWizardPage *next) : wxWizardPage(parent) { m_prev = prev; m_next = next; wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); mainSizer->Add( new wxStaticText(this, wxID_ANY, wxT("Try checking the box below and\n") wxT("then going back and clearing it")), 0, // No vertical stretching wxALL, 5 // Border width ); m_checkbox = new wxCheckBox(this, wxID_ANY, wxT("&Skip the next page")); mainSizer->Add( m_checkbox, 0, // No vertical stretching wxALL, 5 // Border width ); #if wxUSE_CHECKLISTBOX static const wxChar *aszChoices[] = { wxT("Zeroth"), wxT("First"), wxT("Second"), wxT("Third"), wxT("Fourth"), wxT("Fifth"), wxT("Sixth"), wxT("Seventh"), wxT("Eighth"), wxT("Nineth") }; m_checklistbox = new wxCheckListBox ( this, wxID_ANY, wxDefaultPosition, wxSize(100,100), wxArrayString(WXSIZEOF(aszChoices), aszChoices) ); mainSizer->Add( m_checklistbox, 0, // No vertical stretching wxALL, 5 // Border width ); #endif // wxUSE_CHECKLISTBOX wxSize textSize = wxSize(150, 200); if (((wxFrame*) wxTheApp->GetTopWindow())->GetMenuBar()->IsChecked(Wizard_LargeWizard)) textSize = wxSize(150, wxGetClientDisplayRect().GetHeight() - 200); wxTextCtrl* textCtrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, textSize, wxTE_MULTILINE); mainSizer->Add(textCtrl, 0, wxALL|wxEXPAND, 5); SetSizerAndFit(mainSizer); }
AISTargetListDialog::AISTargetListDialog( wxWindow *parent, wxAuiManager *auimgr, AIS_Decoder *pdecoder ) : wxPanel( parent, wxID_ANY, wxDefaultPosition, wxSize( -1, -1/*780, 250*/ ), wxBORDER_NONE ) { m_pparent = parent; m_pAuiManager = auimgr; m_pdecoder = pdecoder; g_bsort_once = false; m_bautosort_force = false; wxFont *qFont = GetOCPNScaledFont(_("Dialog")); SetFont( *qFont ); s_p_sort_decoder = pdecoder; m_pMMSI_array = new ArrayOfMMSI( ArrayItemCompareMMSI ); CreateControls(); SetColorScheme(); UpdateButtons(); if( m_pAuiManager ) { wxAuiPaneInfo pane = wxAuiPaneInfo().Name( _T("AISTargetList") ).CaptionVisible( true ).Float().FloatingPosition( 50, 50 ) .FloatingSize(400, 200).BestSize(700, GetCharHeight() * 10); m_pAuiManager->LoadPaneInfo( g_AisTargetList_perspective, pane ); // Force and/or override any perspective information that is not applicable pane.Name( _T("AISTargetList") ); pane.DestroyOnClose( true ); pane.TopDockable( false ).BottomDockable( true ).LeftDockable( false ).RightDockable( false ); pane.Show( true ); bool b_reset_pos = false; if( (pane.floating_size.x != -1) && (pane.floating_size.y != -1)){ #ifdef __WXMSW__ // Support MultiMonitor setups which an allow negative window positions. // If the requested window title bar does not intersect any installed monitor, // then default to simple primary monitor positioning. RECT frame_title_rect; frame_title_rect.left = pane.floating_pos.x; frame_title_rect.top = pane.floating_pos.y; frame_title_rect.right = pane.floating_pos.x + pane.floating_size.x; frame_title_rect.bottom = pane.floating_pos.y + 30; if( NULL == MonitorFromRect( &frame_title_rect, MONITOR_DEFAULTTONULL ) ) b_reset_pos = true; #else // Make sure drag bar (title bar) of window intersects wxClient Area of screen, with a little slop... wxRect window_title_rect;// conservative estimate window_title_rect.x = pane.floating_pos.x; window_title_rect.y = pane.floating_pos.y; window_title_rect.width = pane.floating_size.x; window_title_rect.height = 30; wxRect ClientRect = wxGetClientDisplayRect(); ClientRect.Deflate(60, 60);// Prevent the new window from being too close to the edge if(!ClientRect.Intersects(window_title_rect)) b_reset_pos = true; #endif if( b_reset_pos ) pane.FloatingPosition( 50, 50 ); } // If the list got accidentally dropped on top of the chart bar, move it away.... if( pane.IsDocked() && ( pane.dock_row == 0 ) ) { pane.Float(); pane.Row( 1 ); pane.Position( 0 ); } pane.Caption( wxGetTranslation( _("AIS target list") ) ); pane.Show(); // Some special setup for touch screens if(g_btouch){ pane.Float(); pane.Dockable( false ); wxSize screen_size = ::wxGetDisplaySize(); pane.FloatingSize(screen_size.x * 6/10, screen_size.y * 8/10); pane.FloatingPosition(screen_size.x * 2/10, screen_size.y * 1/10); } m_pAuiManager->AddPane( this, pane ); m_pAuiManager->Update(); g_AisTargetList_perspective = m_pAuiManager->SavePaneInfo( pane ); pConfig->UpdateSettings(); m_pAuiManager->Connect( wxEVT_AUI_PANE_CLOSE, wxAuiManagerEventHandler( AISTargetListDialog::OnPaneClose ), NULL, this ); } else { // Make an estimate of the default dialog size // for the case when the AUI Perspective for this dialog is undefined wxSize esize; esize.x = 700; esize.y = GetCharHeight() * 10; //18; SetSize( esize ); } RecalculateSize(); }
void wxToolTip::Add(WXHWND hWnd) { HWND hwnd = (HWND)hWnd; wxToolInfo ti(hwnd, m_id, m_rect); // another possibility would be to specify LPSTR_TEXTCALLBACK here as we // store the tooltip text ourselves anyhow, and provide it in response to // TTN_NEEDTEXT (sent via WM_NOTIFY), but then we would be limited to 79 // character tooltips as this is the size of the szText buffer in // NMTTDISPINFO struct -- and setting the tooltip here we can have tooltips // of any length ti.hwnd = hwnd; ti.lpszText = const_cast<wxChar *>(m_text.wx_str()); if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, &ti) ) { wxLogDebug(wxT("Failed to create the tooltip '%s'"), m_text.c_str()); return; } #ifdef TTM_SETMAXTIPWIDTH if ( wxApp::GetComCtl32Version() >= 470 ) { // use TTM_SETMAXTIPWIDTH to make tooltip multiline using the // extent of its first line as max value HFONT hfont = (HFONT) SendTooltipMessage(GetToolTipCtrl(), WM_GETFONT, 0); if ( !hfont ) { hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); if ( !hfont ) { wxLogLastError(wxT("GetStockObject(DEFAULT_GUI_FONT)")); } } MemoryHDC hdc; if ( !hdc ) { wxLogLastError(wxT("CreateCompatibleDC(NULL)")); } if ( !SelectObject(hdc, hfont) ) { wxLogLastError(wxT("SelectObject(hfont)")); } // find the width of the widest line int maxWidth = 0; wxStringTokenizer tokenizer(m_text, wxT("\n")); while ( tokenizer.HasMoreTokens() ) { const wxString token = tokenizer.GetNextToken(); SIZE sz; if ( !::GetTextExtentPoint32(hdc, token.wx_str(), token.length(), &sz) ) { wxLogLastError(wxT("GetTextExtentPoint32")); } if ( sz.cx > maxWidth ) maxWidth = sz.cx; } // limit size to ms_maxWidth, if set if ( ms_maxWidth == 0 ) { // this is more or less arbitrary but seems to work well static const int DEFAULT_MAX_WIDTH = 400; ms_maxWidth = wxGetClientDisplayRect().width / 2; if ( ms_maxWidth > DEFAULT_MAX_WIDTH ) ms_maxWidth = DEFAULT_MAX_WIDTH; } if ( ms_maxWidth != -1 && maxWidth > ms_maxWidth ) maxWidth = ms_maxWidth; // only set a new width if it is bigger than the current setting: // otherwise adding a tooltip with shorter line(s) than a previous // one would result in breaking the longer lines unnecessarily as // all our tooltips share the same maximal width if ( maxWidth > SendTooltipMessage(GetToolTipCtrl(), TTM_GETMAXTIPWIDTH, 0) ) { SendTooltipMessage(GetToolTipCtrl(), TTM_SETMAXTIPWIDTH, wxUIntToPtr(maxWidth)); } } else #endif // TTM_SETMAXTIPWIDTH { // replace the '\n's with spaces because otherwise they appear as // unprintable characters in the tooltip string m_text.Replace(wxT("\n"), wxT(" ")); ti.lpszText = const_cast<wxChar *>(m_text.wx_str()); if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, &ti) ) { wxLogDebug(wxT("Failed to create the tooltip '%s'"), m_text.c_str()); } } }
virtual wxRect GetClientArea() const { return wxGetClientDisplayRect(); }
int CamuleGuiBase::InitGui(bool geometry_enabled, wxString &geom_string) { // Standard size is 800x600 at position (0,0) int geometry_x = 0; int geometry_y = 0; unsigned int geometry_width = 800; unsigned int geometry_height = 600; if ( geometry_enabled ) { // I plan on moving this to a separate function, as it just clutters up OnInit() /* This implementation might work with mac, provided that the SetSize() function works as expected. */ // Remove possible prefix if ( geom_string.GetChar(0) == '=' ) { geom_string.Remove( 0, 1 ); } // Stupid ToLong functions forces me to use longs =( long width = geometry_width; long height = geometry_height; // Get the avilable display area wxRect display = wxGetClientDisplayRect(); // We want to place aMule inside the client area by default long x = display.x; long y = display.y; // Tokenize the string wxStringTokenizer tokens(geom_string, wxT("xX+-")); // First part: Program width if ( tokens.GetNextToken().ToLong( &width ) ) { wxString prefix = geom_string[ tokens.GetPosition() - 1 ]; if ( prefix == wxT("x") || prefix == wxT("X") ) { // Second part: Program height if ( tokens.GetNextToken().ToLong( &height ) ) { prefix = geom_string[ tokens.GetPosition() - 1 ]; if ( prefix == wxT("+") || prefix == wxT("-") ) { // Third part: X-Offset if ( tokens.GetNextToken().ToLong( &x ) ) { if ( prefix == wxT("-") ) x = display.GetRight() - ( width + x ); prefix = geom_string[ tokens.GetPosition() - 1 ]; if ( prefix == wxT("+") || prefix == wxT("-") ) { // Fourth part: Y-Offset if ( tokens.GetNextToken().ToLong( &y ) ) { if ( prefix == wxT("-") ) y = display.GetBottom() - ( height + y ); } } } } // We need at least height and width to override default geometry geometry_enabled = true; geometry_x = x; geometry_y = y; geometry_width = width; geometry_height = height; } } } } ResetTitle(); // Should default/last-used position be overridden? if ( geometry_enabled ) { amuledlg = new CamuleDlg(NULL, m_FrameTitle, wxPoint(geometry_x,geometry_y), wxSize( geometry_width, geometry_height - 58 )); } else { amuledlg = new CamuleDlg(NULL, m_FrameTitle); } return 0; }
void osm_pi::OnToolbarToolCallback(int id) { wxLogMessage (_T("OSM_PI: OnToolbarToolCallback\n")); // Qualify the GRIB dialog position bool b_reset_pos = false; #ifdef __WXMSW__ // Support MultiMonitor setups which an allow negative window positions. // If the requested window does not intersect any installed monitor, // then default to simple primary monitor positioning. RECT frame_title_rect; frame_title_rect.left = m_osm_dialog_x; frame_title_rect.top = m_osm_dialog_y; frame_title_rect.right = m_osm_dialog_x + m_osm_dialog_sx; frame_title_rect.bottom = m_osm_dialog_y + 30; if(NULL == MonitorFromRect(&frame_title_rect, MONITOR_DEFAULTTONULL)) b_reset_pos = true; #else // Make sure drag bar (title bar) of window on Client Area of screen, with a little slop... wxRect window_title_rect; // conservative estimate window_title_rect.x = m_osm_dialog_x; window_title_rect.y = m_osm_dialog_y; window_title_rect.width = m_osm_dialog_sx; window_title_rect.height = 30; wxRect ClientRect = wxGetClientDisplayRect(); ClientRect.Deflate(60, 60); // Prevent the new window from being too close to the edge if(!ClientRect.Intersects(window_title_rect)) b_reset_pos = true; #endif if(b_reset_pos) { m_osm_dialog_x = 20; m_osm_dialog_y = 170; m_osm_dialog_sx = 200; m_osm_dialog_sy = 200; } // show the OSM dialog if(NULL == m_pOsmDialog) { m_pOsmDialog = new OsmDlg(m_parent_window, -1, _("OSM Display Control"), wxPoint( m_osm_dialog_x, m_osm_dialog_y), wxSize( m_osm_dialog_sx, m_osm_dialog_sy)); m_pOsmDialog->plugin = this; //m_pOsmDialog->Create ( m_parent_window, this, -1, _("OSM Display Control"), m_grib_dir, // wxPoint( m_osm_dialog_x, m_osm_dialog_y), wxSize( m_osm_dialog_sx, m_osm_dialog_sy)); } //Toggle OSM overlay display m_bShowOsm = !m_bShowOsm; // Toggle dialog? m_pOsmDialog->Show(m_bShowOsm); // Toggle is handled by the toolbar but we must keep plugin manager b_toggle updated // to actual status to ensure correct status upon toolbar rebuild SetToolbarItemState( m_leftclick_tool_id, m_bShowOsm ); /* OLD CODE // OSM Dialog (here we can select what types of objects to show) if(NULL == m_pOsmDialog) { m_pOsmDialog = new OsmDlg(m_parent_window); m_pOsmDialog->plugin = this; m_pOsmDialog->Move(wxPoint(m_osm_dialog_x, m_osm_dialog_y)); } m_pOsmDialog->Show(!m_pOsmDialog->IsShown()); */ // // TODO: this needs to show a dialog which allow the user // to update their local database by pressing a button? Maybe? //DownloadUrl(m_api_url); /* double x1 = m_pastVp.lon_min; double y1 = m_pastVp.lat_min; double x2 = m_pastVp.lon_max; double y2 = m_pastVp.lat_max; bool success = m_pDownloader->Download(x1,y1,x2,y2); if (success) { wxLogMessage (_T("OSM_PI: We have a file to play with....")); m_pOsmDb->ConsumeOsm(OsmDownloader::m_osm_path); } */ }
bool wxToolTip::AdjustMaxWidth() { // use TTM_SETMAXTIPWIDTH to make tooltip multiline using the // extent of its first line as max value HFONT hfont = (HFONT) SendTooltipMessage(GetToolTipCtrl(), WM_GETFONT, 0); if ( !hfont ) { hfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); if ( !hfont ) { wxLogLastError(wxT("GetStockObject(DEFAULT_GUI_FONT)")); } } MemoryHDC hdc; if ( !hdc ) { wxLogLastError(wxT("CreateCompatibleDC(NULL)")); } if ( !SelectObject(hdc, hfont) ) { wxLogLastError(wxT("SelectObject(hfont)")); } // find the width of the widest line int maxWidth = 0; wxStringTokenizer tokenizer(m_text, wxT("\n")); while ( tokenizer.HasMoreTokens() ) { const wxString token = tokenizer.GetNextToken(); SIZE sz; if ( !::GetTextExtentPoint32(hdc, token.t_str(), token.length(), &sz) ) { wxLogLastError(wxT("GetTextExtentPoint32")); } if ( sz.cx > maxWidth ) maxWidth = sz.cx; } // limit size to ms_maxWidth, if set if ( ms_maxWidth == 0 ) { // this is more or less arbitrary but seems to work well static const int DEFAULT_MAX_WIDTH = 400; ms_maxWidth = wxGetClientDisplayRect().width / 2; if ( ms_maxWidth > DEFAULT_MAX_WIDTH ) ms_maxWidth = DEFAULT_MAX_WIDTH; } if ( ms_maxWidth != -1 && maxWidth > ms_maxWidth ) maxWidth = ms_maxWidth; // only set a new width if it is bigger than the current setting: // otherwise adding a tooltip with shorter line(s) than a previous // one would result in breaking the longer lines unnecessarily as // all our tooltips share the same maximal width if ( maxWidth > SendTooltipMessage(GetToolTipCtrl(), TTM_GETMAXTIPWIDTH, 0) ) { SendTooltipMessage(GetToolTipCtrl(), TTM_SETMAXTIPWIDTH, wxUIntToPtr(maxWidth)); } return true; }
bool MadEditApp::OnInit() { xm::EncodingManager::PreInit(); xm::RemoteAccessInit(); wxm::AppPath::Instance().Init(GetAppName()); // parse commandline to filelist wxm::FileList filelist; for(int i=1; i<argc; i++) { wxFileName filename(argv[i]); filename.MakeAbsolute(); filelist.Append(filename.GetFullPath()); } // init wxConfig wxFileConfig *cfg=new wxFileConfig(wxEmptyString, wxEmptyString, wxm::AppPath::Instance().ConfigPath(), wxEmptyString, wxCONFIG_USE_RELATIVE_PATH|wxCONFIG_USE_NO_ESCAPE_CHARACTERS); cfg->SetExpandEnvVars(false); cfg->SetRecordDefaults(true); wxFileConfig::Set(cfg); bool bSingleInstance=true; cfg->Read(wxT("/wxMEdit/SingleInstance"), &bSingleInstance, true); // check SingleInstance and send filelist to previous instance if(bSingleInstance && OpenFilesInPrevInst(filelist.String())) return false; #ifdef __WXGTK__ bool bDisableWarningMessage = true; cfg->Read(wxT("/wxMEdit/DisableWarningMessage"), &bDisableWarningMessage, true); if(bDisableWarningMessage) { // redirect "IPP request failed" message to /dev/null int fdnull = open ("/dev/null", O_WRONLY, 0); if(fdnull >= 0) { dup2(fdnull, STDERR_FILENO); } } #endif // init locale wxString strlang; cfg->Read(wxT("/wxMEdit/Language"), &strlang); int lang=g_LanguageValue[0]; if(!strlang.IsEmpty()) { strlang.MakeLower(); for(size_t idx=1; idx<g_LanguageCount; idx++) { if(strlang == wxString(g_LanguageString[idx]).Lower()) { lang=g_LanguageValue[idx]; break; } } } wxm::AppPath& path = wxm::AppPath::Instance(); g_Locale.Init(lang); g_Locale.AddCatalogLookupPathPrefix(wxT("./locale/")); g_Locale.AddCatalogLookupPathPrefix(path.AppDir() + wxT("locale/")); if (path.AppDir() != path.HomeDir()) g_Locale.AddCatalogLookupPathPrefix(path.HomeDir() + wxT("locale/")); #ifndef __WXMSW__ # ifdef DATA_DIR g_Locale.AddCatalogLookupPathPrefix(wxT(DATA_DIR"/locale/")); # endif #endif g_Locale.AddCatalog(wxT("wxmedit")); // set colors wxm::SetL10nHtmlColors(); wxm::UpdatePeriods::Instance().Initialize(); #if defined(__WXMSW__) || defined(__WXGTK__) bool maximize=false; cfg->Read(wxT("/wxMEdit/WindowMaximize"), &maximize, false); #endif wxPoint pos=wxDefaultPosition; wxSize size; wxRect rect = wxGetClientDisplayRect(); // FIXME: multi-monitor size.x = std::min(rect.width, wxm::DEFAULT_WINDOW_WIDTH); size.y = std::min(rect.height, wxm::DEFAULT_WINDOW_HEIGHT); long x=0,y=0,w=0,h=0; cfg->Read(wxT("/wxMEdit/WindowLeft"), &x); cfg->Read(wxT("/wxMEdit/WindowTop"), &y); cfg->Read(wxT("/wxMEdit/WindowWidth"), &w); cfg->Read(wxT("/wxMEdit/WindowHeight"), &h); if(x+w>0 && y+h>0) //if(w>0 && h>0) { size.x=w; size.y=h; pos.x=x; pos.y=y; } // load FontWidth buffers cfg->Read(wxT("/wxMEdit/FontWidthBufferMaxCount"), &FontWidthManager::MaxCount, 10); if(FontWidthManager::MaxCount < 4) FontWidthManager::MaxCount=4; else if(FontWidthManager::MaxCount>40) FontWidthManager::MaxCount=40; FontWidthManager::Init(wxm::AppPath::Instance().HomeDir()); // create the main frame MadEditFrame *myFrame = new MadEditFrame(nullptr, 1 , wxEmptyString, pos, size); SetTopWindow(myFrame); #if defined(__WXMSW__) || defined(__WXGTK__) if (maximize) myFrame->Maximize(true); #endif myFrame->Show(true); #if defined(__WXGTK__) && wxMAJOR_VERSION == 2 if(bSingleInstance) { GtkPizza *pizza = GTK_PIZZA(myFrame->m_mainWidget); Window win=GDK_WINDOW_XWINDOW(pizza->bin_window); XSetSelectionOwner(g_Display, g_MadEdit_atom, win, CurrentTime); gdk_window_add_filter(nullptr, my_gdk_filter, nullptr); } #endif wxm::AutoCheckUpdates(cfg); // reload files previously opened wxString files; cfg->Read(wxT("/wxMEdit/ReloadFilesList"), &files); files += filelist.String(); if(!files.IsEmpty()) { // use OnReceiveMessage() to open the files OnReceiveMessage(files.c_str(), (files.size()+1)*sizeof(wxChar)); } if(myFrame->OpenedFileCount()==0) { myFrame->OpenFile(wxEmptyString, false); } return true; }
bool wxGenericProgressDialog::Create( const wxString& title, const wxString& message, int maximum, wxWindow *parent, int style ) { SetTopParent(parent); m_parentTop = wxGetTopLevelParent(parent); m_pdStyle = style; wxWindow* const realParent = GetParentForModalDialog(parent, GetWindowStyle()); if (!wxDialog::Create(realParent, wxID_ANY, title)) return false; SetMaximum(maximum); // We need a running event loop in order to update the dialog and be able // to process clicks on its buttons, so ensure that there is one running // even if this means we have to start it ourselves (this happens most // commonly during the program initialization, e.g. for the progress // dialogs shown from overridden wxApp::OnInit()). if ( !wxEventLoopBase::GetActive() ) { m_tempEventLoop = new wxEventLoop; wxEventLoop::SetActive(m_tempEventLoop); } #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) // we have to remove the "Close" button from the title bar then as it is // confusing to have it - it doesn't work anyhow // // FIXME: should probably have a (extended?) window style for this if ( !HasPDFlag(wxPD_CAN_ABORT) ) { EnableCloseButton(false); } #endif // wxMSW #if defined(__SMARTPHONE__) SetLeftMenu(); #endif m_state = HasPDFlag(wxPD_CAN_ABORT) ? Continue : Uncancelable; // top-level sizerTop wxSizer * const sizerTop = new wxBoxSizer(wxVERTICAL); m_msg = new wxStaticText(this, wxID_ANY, message); sizerTop->Add(m_msg, 0, wxLEFT | wxTOP, 2*LAYOUT_MARGIN); int gauge_style = wxGA_HORIZONTAL; if ( style & wxPD_SMOOTH ) gauge_style |= wxGA_SMOOTH; #ifdef __WXMSW__ maximum /= m_factor; #endif m_gauge = new wxGauge ( this, wxID_ANY, maximum, wxDefaultPosition, // make the progress bar sufficiently long wxSize(wxMin(wxGetClientDisplayRect().width/3, 300), -1), gauge_style ); sizerTop->Add(m_gauge, 0, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 2*LAYOUT_MARGIN); m_gauge->SetValue(0); // create the estimated/remaining/total time zones if requested m_elapsed = m_estimated = m_remaining = NULL; // also count how many labels we really have size_t nTimeLabels = 0; wxSizer * const sizerLabels = new wxFlexGridSizer(2); if ( style & wxPD_ELAPSED_TIME ) { nTimeLabels++; m_elapsed = CreateLabel(GetElapsedLabel(), sizerLabels); } if ( style & wxPD_ESTIMATED_TIME ) { nTimeLabels++; m_estimated = CreateLabel(GetEstimatedLabel(), sizerLabels); } if ( style & wxPD_REMAINING_TIME ) { nTimeLabels++; m_remaining = CreateLabel(GetRemainingLabel(), sizerLabels); } sizerTop->Add(sizerLabels, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, LAYOUT_MARGIN); #if defined(__SMARTPHONE__) if ( HasPDFlag(wxPD_CAN_SKIP) ) SetRightMenu(wxID_SKIP, _("Skip")); if ( HasPDFlag(wxPD_CAN_ABORT) ) SetLeftMenu(wxID_CANCEL); #else m_btnAbort = m_btnSkip = NULL; wxBoxSizer *buttonSizer = new wxBoxSizer(wxHORIZONTAL); // Windows dialogs usually have buttons in the lower right corner const int sizerFlags = #if defined(__WXMSW__) || defined(__WXPM__) || defined(__WXOSX__) wxALIGN_RIGHT | wxALL #else // !MSW wxALIGN_CENTER_HORIZONTAL | wxBOTTOM | wxTOP #endif // MSW/!MSW ; if ( HasPDFlag(wxPD_CAN_SKIP) ) { m_btnSkip = new wxButton(this, wxID_SKIP, _("&Skip")); buttonSizer->Add(m_btnSkip, 0, sizerFlags, LAYOUT_MARGIN); } if ( HasPDFlag(wxPD_CAN_ABORT) ) { m_btnAbort = new wxButton(this, wxID_CANCEL); buttonSizer->Add(m_btnAbort, 0, sizerFlags, LAYOUT_MARGIN); } if ( !HasPDFlag(wxPD_CAN_SKIP | wxPD_CAN_ABORT) ) buttonSizer->AddSpacer(LAYOUT_MARGIN); sizerTop->Add(buttonSizer, 0, sizerFlags, LAYOUT_MARGIN ); #endif // __SMARTPHONE__/!__SMARTPHONE__ SetSizerAndFit(sizerTop); Centre(wxCENTER_FRAME | wxBOTH); DisableOtherWindows(); Show(); Enable(); // this one can be initialized even if the others are unknown for now // // NB: do it after calling Layout() to keep the labels correctly aligned if ( m_elapsed ) { SetTimeLabel(0, m_elapsed); } Update(); return true; }