wxTextCtrl * ShuttleGuiBase::AddTextBox(const wxString &Caption, const wxString &Value, const int nChars) { UseUpId(); if( mShuttleMode != eIsCreating ) return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxTextCtrl); wxTextCtrl * pTextCtrl; wxSize Size(wxDefaultSize); if( nChars > 0 ) { Size.SetWidth( nChars *5 ); } AddPrompt( Caption ); miProp=0; #ifdef RIGHT_ALIGNED_TEXTBOXES long flags = wxTE_RIGHT; #else long flags = wxTE_LEFT; #endif mpWind = pTextCtrl = new wxTextCtrl(mpParent, miId, Value, wxDefaultPosition, Size, Style( flags )); UpdateSizers(); return pTextCtrl; }
wxComboBox * ShuttleGuiBase::AddCombo( const wxString &Prompt, const wxString &Selected,const wxArrayString * pChoices ) { UseUpId(); if( mShuttleMode != eIsCreating ) return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxComboBox); wxComboBox * pCombo; miProp=0; int n = pChoices->GetCount(); if( n>50 ) n=50; int i; wxString Choices[50]; for(i=0;i<n;i++) { Choices[i] = (*pChoices)[i]; } AddPrompt( Prompt ); mpWind = pCombo = new wxComboBox(mpParent, miId, Selected, wxDefaultPosition, wxDefaultSize, n, Choices, Style( 0 )); UpdateSizers(); return pCombo; }
UserPromptView::UserPromptView(session::Manager::Ptr const& session_manager) : nux::View(NUX_TRACKER_LOCATION) , session_manager_(session_manager) , caps_lock_on_(false) { user_authenticator_.echo_on_requested.connect([this](std::string const& message, PromiseAuthCodePtr const& promise){ AddPrompt(message, /* visible */ true, promise); }); user_authenticator_.echo_off_requested.connect([this](std::string const& message, PromiseAuthCodePtr const& promise){ AddPrompt(message, /* visible */ false, promise); }); user_authenticator_.message_requested.connect([this](std::string const& message){ AddMessage(message, nux::color::White); }); user_authenticator_.error_requested.connect([this](std::string const& message){ AddMessage(message, nux::color::Red); }); user_authenticator_.clear_prompts.connect([this](){ ResetLayout(); }); dash::previews::Style& preview_style = dash::previews::Style::Instance(); warning_ = preview_style.GetWarningIcon(); ResetLayout(); user_authenticator_.AuthenticateStart(session_manager_->UserName(), sigc::mem_fun(this, &UserPromptView::AuthenticationCb)); // When we get to HiDPI changes here, we will need to update this width dash::Style& style = dash::Style::Instance(); spin_icon_width_ = style.GetSearchSpinIcon()->GetWidth(); CheckIfCapsLockOn(); }
/// Single line text box of fixed size. void ShuttleGuiBase::AddConstTextBox(const wxString &Prompt, const wxString &Value) { UseUpId(); if( mShuttleMode != eIsCreating ) return; // return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wx); miProp=0; AddPrompt( Prompt ); UpdateSizers(); miProp=0; mpWind = new wxStaticText(mpParent, miId, Value, wxDefaultPosition, wxDefaultSize, Style( 0 )); UpdateSizers(); }
/// For a consistant two-column layout we want labels on the left and /// controls on the right. CheckBoxes break that rule, so we fake it by /// placing a static text label and then a tick box with an empty label. wxCheckBox * ShuttleGuiBase::AddCheckBoxOnRight( const wxString &Prompt, const wxString &Selected) { UseUpId(); if( mShuttleMode != eIsCreating ) return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxCheckBox); wxCheckBox * pCheckBox; miProp=0; AddPrompt( Prompt ); mpWind = pCheckBox = new wxCheckBox(mpParent, miId, wxT(""), wxDefaultPosition, wxDefaultSize, Style( 0 )); pCheckBox->SetValue(Selected==wxT("true")); UpdateSizers(); return pCheckBox; }
UserPromptView::UserPromptView(session::Manager::Ptr const& session_manager) : nux::View(NUX_TRACKER_LOCATION) , scale(1.0) , session_manager_(session_manager) , username_(nullptr) , msg_layout_(nullptr) , prompt_layout_(nullptr) { user_authenticator_.echo_on_requested.connect([this](std::string const& message, PromiseAuthCodePtr const& promise){ AddPrompt(message, /* visible */ true, promise); }); user_authenticator_.echo_off_requested.connect([this](std::string const& message, PromiseAuthCodePtr const& promise){ AddPrompt(message, /* visible */ false, promise); }); user_authenticator_.message_requested.connect([this](std::string const& message){ AddMessage(message, nux::color::White); }); user_authenticator_.error_requested.connect([this](std::string const& message){ AddMessage(message, nux::color::Red); }); user_authenticator_.clear_prompts.connect([this](){ ResetLayout(); }); scale.changed.connect(sigc::hide(sigc::mem_fun(this, &UserPromptView::UpdateSize))); UpdateSize(); ResetLayout(); user_authenticator_.AuthenticateStart(session_manager_->UserName(), sigc::mem_fun(this, &UserPromptView::AuthenticationCb)); }
wxSlider * ShuttleGuiBase::AddSlider(const wxString &Prompt, int pos, int Max) { UseUpId(); if( mShuttleMode != eIsCreating ) return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxSlider); AddPrompt( Prompt ); wxSlider * pSlider; mpWind = pSlider = new wxSlider( mpParent, miId, pos, 0, Max, wxDefaultPosition, wxDefaultSize, Style( wxSL_HORIZONTAL | wxSL_LABELS | wxSL_AUTOTICKS ) ); miProp=1; UpdateSizers(); return pSlider; }
wxChoice * ShuttleGuiBase::AddChoice( const wxString &Prompt, const wxString &Selected, const wxArrayString * pChoices ) { UseUpId(); if( mShuttleMode != eIsCreating ) return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wxChoice); wxChoice * pChoice; miProp=0; AddPrompt( Prompt ); mpWind = pChoice = new wxChoice( mpParent, miId, wxDefaultPosition, wxDefaultSize, *pChoices, Style( 0 ) ); pChoice->SetSizeHints( 180,-1);// Use -1 for 'default size' - Platform specific. pChoice->SetStringSelection( Selected ); UpdateSizers(); return pChoice; }