void wxCurlConnectionSettingsPanel::CreateControls(const wxString &msg) { wxBoxSizer* main = new wxBoxSizer(wxVERTICAL); // message row if (!msg.IsEmpty()) { wxStaticText *st = new wxStaticText( this, wxID_STATIC, msg ); main->Add(st, 0, wxLEFT|wxTOP|wxRIGHT|wxBOTTOM|wxGROW, BORDER); } wxFlexGridSizer *gs = new wxFlexGridSizer(0 /* calc automatically the # of rows */, 2, 0, 0); // authentication options if (HasFlag(wxCCSP_AUTHENTICATION_OPTIONS)) { m_pUsername = AddSizerRow(gs, _("Username:"******"Password:"******"Port:"), false); gs->AddStretchSpacer(1); gs->AddStretchSpacer(1); m_pPort->SetValue(wxS("-1")); } // column 1 contains the text controls: gs->AddGrowableCol(1); main->Add(gs, 1, wxGROW|wxALL, BORDER); // proxy options if (HasFlag(wxCCSP_PROXY_OPTIONS)) { wxSizer* proxy = new wxStaticBoxSizer(wxVERTICAL, this, wxS("Proxy settings")); m_pProxyCheckBox = new wxCheckBox(this, UseProxy, wxS("Use proxy")); m_pProxyCheckBox->SetValue(false); proxy->Add(m_pProxyCheckBox, 0, wxLEFT|wxTOP, BORDER); wxFlexGridSizer *gs = new wxFlexGridSizer(0 /* calc automatically the # of rows */, 2, 0, 0); m_pProxyHost = AddSizerRow(gs, _("Proxy host:")); m_pProxyUsername = AddSizerRow(gs, _("Proxy username:"******"Proxy password:"******"Proxy port:"), false); m_pProxyPort->SetValue(wxS("-1")); proxy->Add(gs, 0, wxGROW|wxALL, BORDER); // column 1 contains the text controls: gs->AddGrowableCol(1); main->AddSpacer(10); main->Add(proxy, 0, wxGROW|wxLEFT|wxRIGHT, BORDER); #if wxCHECK_VERSION(2,9,0) main->AddStretchSpacer(1); #endif // be default disable the proxy controls wxCommandEvent fake; fake.SetInt(0); OnUseProxy(fake); } this->SetSizerAndFit(main); main->SetSizeHints(this); }
void wxCurlTransferDialog::CreateControls(const wxString &url, const wxString &msg, const wxString &sizeLabel, const wxBitmap &bitmap) { wxBoxSizer* main = new wxBoxSizer(wxVERTICAL); // message row if (!msg.IsEmpty()) { wxStaticText *st = new wxStaticText( this, wxID_STATIC, msg ); st->SetMinSize(wxSize(MINWIDTH, -1)); main->Add(st, 0, wxLEFT|wxTOP|wxRIGHT|wxBOTTOM|wxGROW, OUTER_BORDER); } // URL row if (HasFlag(wxCTDS_URL)) { wxBoxSizer* downloading = new wxBoxSizer(wxHORIZONTAL); wxStaticText *st = new wxStaticText( this, wxID_STATIC, _("URL:") ); wxFont boldFont(st->GetFont()); boldFont.SetWeight(wxFONTWEIGHT_BOLD); st->SetFont(boldFont); downloading->Add(st, 0, wxRIGHT|wxTOP|wxALIGN_CENTER_VERTICAL, BORDER); m_pURL = new wxStaticText( this, wxID_STATIC, url, wxDefaultPosition, wxSize(MINWIDTH, -1));//, wxST_ELLIPSIZE_MIDDLE); downloading->Add(m_pURL, 1, wxALIGN_CENTER_VERTICAL|wxTOP, BORDER); main->Add(downloading, 0, wxGROW|wxLEFT|wxRIGHT, OUTER_BORDER); main->AddSpacer(5); } wxSizer *leftcolumn = new wxBoxSizer(wxVERTICAL); // speed & size row if (HasFlag(wxCTDS_SPEED)) m_pSpeed = AddSizerRow(leftcolumn, wxS("Speed:")); if (HasFlag(wxCTDS_SIZE)) m_pSize = AddSizerRow(leftcolumn, sizeLabel); // a spacer leftcolumn->AddSpacer(5); // the time rows if (HasFlag(wxCTDS_ELAPSED_TIME)) m_pElapsedTime = AddSizerRow(leftcolumn, wxS("Elapsed time:")); if (HasFlag(wxCTDS_ESTIMATED_TIME)) m_pEstimatedTime = AddSizerRow(leftcolumn, wxS("Estimated total time:")); if (HasFlag(wxCTDS_REMAINING_TIME)) m_pRemainingTime = AddSizerRow(leftcolumn, wxS("Estimated remaining time:")); if (bitmap.IsOk()) { wxSizer *rightcolumn = new wxBoxSizer(wxVERTICAL); rightcolumn->Add( new wxStaticBitmap(this, wxID_ANY, bitmap), 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, BORDER); wxSizer *both = new wxBoxSizer(wxHORIZONTAL); both->Add(leftcolumn); both->Add(rightcolumn, 1, wxGROW); main->Add(both, 0, wxGROW); } else main->Add(leftcolumn); // the gauge // VERY IMPORTANT: we set as range 101 so that when, because of some approximation, // the update event handler will SetValue(100), while the transfer // is not yet complete, the gauge will not appear completely filled. m_pGauge = new wxGauge( this, wxID_ANY, 101 ); main->AddSpacer(5); main->Add(m_pGauge, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, OUTER_BORDER); // do we need to use wxCurlConnectionSettingsDialog? bool needsConnSettings = HasFlag(wxCTDS_CONN_SETTINGS_AUTH) || HasFlag(wxCTDS_CONN_SETTINGS_PORT) || HasFlag(wxCTDS_CONN_SETTINGS_PROXY); // an horizontal line of buttons if (HasFlag(wxCTDS_CAN_ABORT) || HasFlag(wxCTDS_CAN_PAUSE) || HasFlag(wxCTDS_CAN_START) || needsConnSettings) { main->AddStretchSpacer(1); main->AddSpacer(BORDER*2); main->Add( new wxStaticLine(this), 0, wxGROW|wxLEFT|wxRIGHT, OUTER_BORDER); // the button row wxBoxSizer *btn = new wxBoxSizer(wxHORIZONTAL); if (HasFlag(wxCTDS_CAN_ABORT)) btn->Add(new wxButton( this, AbortButtonId, _("Abort") ), 0, wxRIGHT, BORDER); if (needsConnSettings) btn->Add(new wxButton( this, ConnSettingsButtonId, _("Settings") ), 0); btn->AddStretchSpacer(1); if (HasFlag(wxCTDS_CAN_PAUSE)) btn->Add(new wxButton( this, PauseResumeButtonId, _("Pause") ), 0); if (HasFlag(wxCTDS_CAN_START)) btn->Add(new wxButton( this, StartButtonId, _("Start") ), 0, wxLEFT, BORDER); main->Add(btn, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP|wxBOTTOM, OUTER_BORDER); } this->SetSizerAndFit(main); main->SetSizeHints(this); }