bool CCommentDialog::OnInitDialog() { CastChild(IDC_CMT_TEXT, wxTextCtrl)->SetValue(m_file->GetFileComment()); CastChild(IDC_CMT_TEXT, wxTextCtrl)->SetMaxLength(MAXFILECOMMENTLEN); ratebox->SetSelection(m_file->GetFileRating()); return TRUE; }
void CFileDetailDialog::setEnableForApplyButton() { bool enabled = m_file->GetStatus() != PS_COMPLETE && m_file->GetStatus() != PS_COMPLETING && m_filenameChanged; CastChild(IDC_APPLY, wxControl)->Enable(enabled); // Make OK button default so Text can be applied by hitting return CastChild(enabled ? IDC_APPLY_AND_CLOSE : ID_CLOSEWNDFD, wxButton)->SetDefault(); }
void CFileDetailDialog::setEnableForApplyButton() { bool enabled = m_file->IsPartFile() && // Currently renaming of completed files causes problem with kad m_file->GetStatus() != PS_COMPLETE && m_file->GetStatus() != PS_COMPLETING && m_filenameChanged; CastChild(IDC_APPLY, wxControl)->Enable(enabled); // Make OK button default so Text can be applied by hitting return CastChild(enabled ? IDC_APPLY_AND_CLOSE : ID_CLOSEWNDFD, wxButton)->SetDefault(); }
void CChatWnd::SendMessage(const wxString& message, const wxString& client_name, uint64 to_id) { if (chatselector->SendMessage( message, client_name, to_id )) { CastChild(IDC_CMESSAGE, wxTextCtrl)->Clear(); } // Check to enable the window controls if needed CheckNewButtonsState(); CastChild(IDC_CMESSAGE, wxTextCtrl)->SetFocus(); }
void CSearchDlg::OnBnClickedStart(wxCommandEvent& WXUNUSED(evt)) { wxString searchString = CastChild( IDC_SEARCHNAME, wxTextCtrl )->GetValue(); searchString.Trim(true); searchString.Trim(false); if ( searchString.IsEmpty() ) { return; } wxChoice* choice = CastChild( ID_SEARCHTYPE, wxChoice ); // Magic. int searchtype = choice->GetSelection(); if (!thePrefs::GetNetworkED2K()) { searchtype += 2; } if (!thePrefs::GetNetworkKademlia()) { searchtype += 1; } switch ( searchtype ) { // Local Search case 0: // Global Search case 1: // Kad Search case 2: // We musn't search more often than once every 2 secs if ((GetTickCount() - m_last_search_time) > 2000) { m_last_search_time = GetTickCount(); OnBnClickedStop(nullEvent); StartNewSearch(); } break; // Web Search (FileHash.com) case 3: theApp->amuledlg->LaunchUrl(theApp->amuledlg->GenWebSearchUrl(searchString, CamuleDlg::WS_FILEHASH)); break; // Error default: wxFAIL; } }
CChatWnd::CChatWnd(wxWindow* pParent) : wxPanel(pParent, -1) { wxSizer* content = messagePage(this, true); content->Show(this, true); chatselector = CastChild( IDC_CHATSELECTOR, CChatSelector ); // We want to use our own popup menu chatselector->SetPopupHandler(this); m_menu = NULL; friendlistctrl = CastChild( ID_FRIENDLIST, CFriendListCtrl ); }
CHTTPDownloadDialog(CHTTPDownloadThread* thread) : wxDialog(wxTheApp->GetTopWindow(), -1, _("Downloading..."), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxSYSTEM_MENU) { downloadDlg(this, true)->Show(this, true); m_progressbar = CastChild(ID_HTTPDOWNLOADPROGRESS, wxGaugeControl); m_progressbar->SetRange(100); m_ani = CastChild(ID_ANIMATE, MuleGifCtrl); m_ani->LoadData((const char*)inetDownload, sizeof(inetDownload)); m_ani->Start(); m_thread = thread; }
CPartFileConvertDlg::CPartFileConvertDlg(wxWindow* parent) : wxDialog(parent, -1, _("Import partfiles"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER) { convertDlg(this, true, true); m_joblist = CastChild(IDC_JOBLIST, wxListCtrl); m_pb_current = CastChild(IDC_CONV_PB_CURRENT, wxGauge); m_joblist->InsertColumn(0, _("File name"), wxLIST_FORMAT_LEFT, 200); m_joblist->InsertColumn(1, _("State"), wxLIST_FORMAT_LEFT, 100); m_joblist->InsertColumn(2, _("Size"), wxLIST_FORMAT_LEFT, 100); m_joblist->InsertColumn(3, _("Filehash"), wxLIST_FORMAT_LEFT, 100); SetIcon(wxICON(convert)); }
void CSearchDlg::ResetControls() { m_progressbar->SetValue(0); FindWindow(IDC_CANCELS)->Disable(); FindWindow(IDC_STARTS)->Enable(!CastChild( IDC_SEARCHNAME, wxTextCtrl )->GetValue().IsEmpty()); }
void CamuleDlg::AddLogLine(const wxString& line) { bool addtostatusbar = line[0] == '!'; wxString bufferline = line.Mid(1); // Add the message to the log-view wxTextCtrl* ct = CastByID( ID_LOGVIEW, m_serverwnd, wxTextCtrl ); if ( ct ) { // Bold critical log-lines // Works in Windows too thanks to wxTE_RICH2 style in muuli wxTextAttr style = ct->GetDefaultStyle(); wxFont font = style.GetFont(); font.SetWeight(addtostatusbar ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL); style.SetFont(font); #if wxCHECK_VERSION(2, 9, 0) style.SetFontSize(8); #endif ct->SetDefaultStyle(style); ct->AppendText(bufferline); ct->ShowPosition( ct->GetLastPosition() - 1 ); } // Set the status-bar if the event warrents it if ( addtostatusbar ) { // Escape "&"s, which would otherwise not show up bufferline.Replace( wxT("&"), wxT("&&") ); wxStaticText* text = CastChild( wxT("infoLabel"), wxStaticText ); // Only show the first line if multiple lines text->SetLabel( bufferline.BeforeFirst( wxT('\n') ) ); text->SetToolTip( bufferline ); text->GetParent()->Layout(); } }
void CKadDlg::UpdateNodeCount(unsigned nodeCount) { wxStaticText* label = CastChild( wxT("nodesListLabel"), wxStaticText ); wxCHECK_RET(label, wxT("Failed to find kad-nodes label")); label->SetLabel(CFormat(_("Nodes (%u)")) % nodeCount); label->GetParent()->Layout(); }
void CSearchDlg::OnFieldChanged( wxEvent& WXUNUSED(evt) ) { bool enable = false; // These are the IDs of the search-fields int textfields[] = { IDC_SEARCHNAME, IDC_EDITSEARCHEXTENSION }; for ( uint16 i = 0; i < itemsof(textfields); i++ ) { enable |= !CastChild( textfields[i], wxTextCtrl )->GetValue().IsEmpty(); } // Check if either of the dropdowns have been changed enable |= (CastChild(IDC_SEARCHMINSIZE, wxChoice)->GetSelection() != 2); enable |= (CastChild(IDC_SEARCHMAXSIZE, wxChoice)->GetSelection() != 2); enable |= (CastChild(IDC_TypeSearch, wxChoice)->GetSelection() > 0); enable |= (CastChild(ID_AUTOCATASSIGN, wxChoice)->GetSelection() > 0); // These are the IDs of the search-fields int spinfields[] = { IDC_SPINSEARCHMIN, IDC_SPINSEARCHMAX, IDC_SPINSEARCHAVAIBILITY }; for ( uint16 i = 0; i < itemsof(spinfields); i++ ) { enable |= (CastChild( spinfields[i], wxSpinCtrl )->GetValue() > 0); } // Enable the "Reset" button if any fields contain text FindWindow(IDC_SEARCH_RESET)->Enable( enable ); // Enable the Server Search button if the Name field contains text enable = !CastChild( IDC_SEARCHNAME, wxTextCtrl )->GetValue().IsEmpty(); FindWindow(IDC_STARTS)->Enable( enable ); }
CServerWnd::CServerWnd(wxWindow* pParent /*=NULL*/, int splitter_pos) : wxPanel(pParent, -1) { wxSizer* sizer = serverListDlg(this,TRUE); // init serverlist // no use now. too early. serverlistctrl = CastChild( ID_SERVERLIST, CServerListCtrl ); CastChild( ID_SRV_SPLITTER, wxSplitterWindow )->SetSashPosition(splitter_pos, true); CastChild( ID_SRV_SPLITTER, wxSplitterWindow )->SetSashGravity(0.5f); CastChild( IDC_NODESLISTURL, wxTextCtrl )->SetValue(thePrefs::GetKadNodesUrl()); CastChild( IDC_SERVERLISTURL, wxTextCtrl )->SetValue(thePrefs::GetEd2kServersUrl()); // Insert two columns, currently without a header wxListCtrl* ED2KInfoList = CastChild( ID_ED2KINFO, wxListCtrl ); wxASSERT(ED2KInfoList); ED2KInfoList->InsertColumn(0, wxEmptyString); ED2KInfoList->InsertColumn(1, wxEmptyString); wxListCtrl* KadInfoList = CastChild( ID_KADINFO, wxListCtrl ); wxASSERT(KadInfoList); KadInfoList->InsertColumn(0, wxEmptyString); KadInfoList->InsertColumn(1, wxEmptyString); sizer->Show(this,TRUE); }
void CamuleDlg::ShowTransferRate() { float kBpsUp = theStats::GetUploadRate() / 1024.0; float kBpsDown = theStats::GetDownloadRate() / 1024.0; wxString buffer; if( thePrefs::ShowOverhead() ) { buffer = CFormat(_("Up: %.1f(%.1f) | Down: %.1f(%.1f)")) % kBpsUp % (theStats::GetUpOverheadRate() / 1024.0) % kBpsDown % (theStats::GetDownOverheadRate() / 1024.0); } else { buffer = CFormat(_("Up: %.1f | Down: %.1f")) % kBpsUp % kBpsDown; } buffer.Truncate(50); // Max size 50 wxStaticText* label = CastChild( wxT("speedLabel"), wxStaticText ); label->SetLabel(buffer); label->GetParent()->Layout(); // Show upload/download speed in title if (thePrefs::GetShowRatesOnTitle()) { wxString UpDownSpeed = CFormat(wxT("Up: %.1f | Down: %.1f")) % kBpsUp % kBpsDown; if (thePrefs::GetShowRatesOnTitle() == 1) { SetTitle(theApp->m_FrameTitle + wxT(" -- ") + UpDownSpeed); } else { SetTitle(UpDownSpeed + wxT(" -- ") + theApp->m_FrameTitle); } } wxASSERT((m_wndTaskbarNotifier != NULL) == thePrefs::UseTrayIcon()); if (m_wndTaskbarNotifier) { // set trayicon-icon int percentDown = (int)ceil((kBpsDown*100) / thePrefs::GetMaxGraphDownloadRate()); UpdateTrayIcon( ( percentDown > 100 ) ? 100 : percentDown); wxString buffer2; if ( theApp->IsConnected() ) { buffer2 = CFormat(_("aMule (%s | Connected)")) % buffer; } else { buffer2 = CFormat(_("aMule (%s | Disconnected)")) % buffer; } m_wndTaskbarNotifier->SetTrayToolTip(buffer2); } wxStaticBitmap* bmp = CastChild( wxT("transferImg"), wxStaticBitmap ); bmp->SetBitmap(dlStatusImages((kBpsUp>0.01 ? 2 : 0) + (kBpsDown>0.01 ? 1 : 0))); }
void CSearchDlg::OnBnClickedReset(wxCommandEvent& WXUNUSED(evt)) { CastChild( IDC_SEARCHNAME, wxTextCtrl )->Clear(); CastChild( IDC_EDITSEARCHEXTENSION, wxTextCtrl )->Clear(); CastChild( IDC_SPINSEARCHMIN, wxSpinCtrl )->SetValue(0); CastChild( IDC_SEARCHMINSIZE, wxChoice )->SetSelection(2); CastChild( IDC_SPINSEARCHMAX, wxSpinCtrl )->SetValue(0); CastChild( IDC_SEARCHMAXSIZE, wxChoice )->SetSelection(2); CastChild( IDC_SPINSEARCHAVAIBILITY, wxSpinCtrl )->SetValue(0); CastChild( IDC_TypeSearch, wxChoice )->SetSelection(0); CastChild( ID_AUTOCATASSIGN, wxChoice )->SetSelection(0); FindWindow(IDC_SEARCH_RESET)->Enable(FALSE); }
void CSearchDlg::CreateNewTab(const wxString& searchString, wxUIntPtr nSearchID) { CSearchListCtrl* list = new CSearchListCtrl(m_notebook, ID_SEARCHLISTCTRL, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxNO_BORDER); m_notebook->AddPage(list, searchString, true, 0); // Ensure that new results are filtered bool enable = CastChild(IDC_FILTERCHECK, wxCheckBox)->GetValue(); wxString filter = CastChild(ID_FILTER_TEXT, wxTextCtrl)->GetValue(); bool invert = CastChild(ID_FILTER_INVERT, wxCheckBox)->GetValue(); bool known = CastChild(ID_FILTER_KNOWN, wxCheckBox)->GetValue(); list->SetFilter(filter, invert, known); list->EnableFiltering(enable); list->ShowResults(nSearchID); Layout(); FindWindow(IDC_CLEAR_RESULTS)->Enable(true); }
void CamuleDlg::ShowUserCount(const wxString& info) { wxStaticText* label = CastChild( wxT("userLabel"), wxStaticText ); // Update Kad tab m_serverwnd->UpdateKadInfo(); label->SetLabel(info); label->GetParent()->Layout(); }
void CSearchDlg::OnFilteringChange(wxCommandEvent& WXUNUSED(evt)) { wxString filter = CastChild(ID_FILTER_TEXT, wxTextCtrl)->GetValue(); bool invert = CastChild(ID_FILTER_INVERT, wxCheckBox)->GetValue(); bool known = CastChild(ID_FILTER_KNOWN, wxCheckBox)->GetValue(); // Check that the expression compiles before we try to assign it // Otherwise we will get an error-dialog for each result-list. if (wxRegEx(filter, wxRE_DEFAULT | wxRE_ICASE).IsValid()) { int nPages = m_notebook->GetPageCount(); for ( int i = 0; i < nPages; i++ ) { CSearchListCtrl* page = dynamic_cast<CSearchListCtrl*>(m_notebook->GetPage(i)); page->SetFilter(filter, invert, known); UpdateHitCount(page); } } }
void CFileDetailDialog::OnBnClickedTakeOver(wxCommandEvent& WXUNUSED(evt)) { CFileDetailListCtrl* pmyListCtrl; pmyListCtrl = CastChild( IDC_LISTCTRLFILENAMES, CFileDetailListCtrl ); if (pmyListCtrl->GetSelectedItemCount() > 0) { // get first selected item (there is only one) long pos = pmyListCtrl->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); if (pos != -1) { // shouldn't happen, we checked if something is selected setValueForFilenameTextEdit(pmyListCtrl->GetItemText(pos)); } } }
//IMPLEMENT_DYNAMIC(CCommentDialog, CDialog) CCommentDialog::CCommentDialog(wxWindow* parent,CKnownFile* file) : wxDialog(parent,-1,_("File Comments"), wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE|wxSYSTEM_MENU) { m_file = file; wxSizer* content=commentDlg(this,TRUE); content->SetSizeHints(this); content->Show(this,TRUE); Center(); ratebox = CastChild( IDC_RATELIST, wxChoice ); OnInitDialog(); }
// Enables or disables the node connect button depending on the conents of the text fields void CKadDlg::OnFieldsChange(wxCommandEvent& WXUNUSED(evt)) { // These are the IDs of the search-fields int textfields[] = { ID_NODE_IP1, ID_NODE_IP2, ID_NODE_IP3, ID_NODE_IP4, ID_NODE_PORT}; bool enable = true; for ( uint16 i = 0; i < itemsof(textfields); i++ ) { enable &= !CastChild(textfields[i], wxTextCtrl)->GetValue().IsEmpty(); } // Enable the node connect button if all fields contain text FindWindowById(ID_NODECONNECT)->Enable( enable ); }
void CSearchDlg::UpdateCatChoice() { wxChoice* c_cat = CastChild( ID_AUTOCATASSIGN, wxChoice ); c_cat->Clear(); c_cat->Append(_("Main")); for ( unsigned i = 1; i < theApp->glob_prefs->GetCatCount(); i++ ) { c_cat->Append( theApp->glob_prefs->GetCategory( i )->title ); } c_cat->SetSelection( 0 ); }
void CKadDlg::Init() { m_kad_scope = CastChild( wxT("kadScope"), COScopeCtrl ); m_kad_scope->SetRanges(0.0, thePrefs::GetStatsMax()); m_kad_scope->SetYUnits(wxT("Nodes")); #ifndef __WXMSW__ // // Get label with line breaks out of muuli.wdr, because generated code fails // to compile in Windows. // // In Windows, setting a button label with a newline fails (the newline is ignored). // Creating a button with such a label works however. :-/ // So leave the label from the muuli (without line breaks) here, // so it can still be fixed in the translation. // wxButton* bootstrap = CastChild(ID_KNOWNNODECONNECT, wxButton); bootstrap->SetLabel(_("Bootstrap from \nknown clients")); #endif SetUpdatePeriod(thePrefs::GetTrafficOMeterInterval()); SetGraphColors(); }
void CamuleDlg::OnMainGUISizeChange(wxSizeEvent& evt) { wxFrame::OnSize(evt); if (m_transferwnd && m_transferwnd->clientlistctrl) { // Transfer window's splitter set again if it's hidden. if (!m_transferwnd->clientlistctrl->GetShowing()) { int height = m_transferwnd->clientlistctrl->GetSize().GetHeight(); wxSplitterWindow* splitter = CastChild(wxT("splitterWnd"), wxSplitterWindow); height += splitter->GetWindow1()->GetSize().GetHeight(); splitter->SetSashPosition( height ); } } }
void CamuleDlg::ResetLog(int id) { wxTextCtrl* ct = CastByID(id, m_serverwnd, wxTextCtrl); wxCHECK_RET(ct, wxT("Resetting unknown log")); ct->Clear(); if (id == ID_LOGVIEW) { // Also clear the log line wxStaticText* text = CastChild(wxT("infoLabel"), wxStaticText); text->SetLabel(wxEmptyString); text->GetParent()->Layout(); } }
void CamuleDlg::OnBnClickedFast(wxCommandEvent& WXUNUSED(evt)) { wxTextCtrl* ctl = CastChild( wxT("FastEd2kLinks"), wxTextCtrl ); for ( int i = 0; i < ctl->GetNumberOfLines(); i++ ) { wxString strlink = ctl->GetLineText(i); strlink.Trim(true); strlink.Trim(false); if ( !strlink.IsEmpty() ) { theApp->downloadqueue->AddLink( strlink, m_transferwnd->downloadlistctrl->GetCategory() ); } } ctl->SetValue(wxEmptyString); }
void CFileDetailDialog::OnListClickedTakeOver(wxListEvent& WXUNUSED(evt)) { CFileDetailListCtrl* pmyListCtrl; pmyListCtrl = CastChild( IDC_LISTCTRLFILENAMES, CFileDetailListCtrl ); if (pmyListCtrl->GetSelectedItemCount() > 0) { long pos=-1; for(;;) { pos=pmyListCtrl->GetNextItem(pos,wxLIST_NEXT_ALL,wxLIST_STATE_SELECTED); if(pos==-1) { break; } setValueForFilenameTextEdit(pmyListCtrl->GetItemText(pos)); } } }
void CFileDetailDialog::OnBnClickedApply(wxCommandEvent& WXUNUSED(evt)) { CPath fileName = CPath(CastChild(IDC_FILENAME, wxTextCtrl)->GetValue()); if (fileName.IsOk() && (fileName != m_file->GetFileName())) { if (theApp->sharedfiles->RenameFile(m_file, fileName)) { FindWindow(IDC_FNAME)->SetLabel(MakeStringEscaped(m_file->GetFileName().GetPrintable())); FindWindow(IDC_METFILE)->SetLabel(m_file->GetFullName().GetPrintable()); resetValueForFilenameTextEdit(); Layout(); } } }
void CKadDlg::SetGraphColors() { static const char aTrend[] = { 2, 1, 0 }; static const int aRes[] = { IDC_C0, IDC_C0_3, IDC_C0_2 }; m_kad_scope->SetBackgroundColor(CStatisticsDlg::getColors(0)); m_kad_scope->SetGridColor(CStatisticsDlg::getColors(1)); for (size_t i = 0; i < 3; ++i) { m_kad_scope->SetPlotColor(CStatisticsDlg::getColors(12 + i), aTrend[i]); CColorFrameCtrl* ctrl = CastChild(aRes[i], CColorFrameCtrl); ctrl->SetBackgroundBrushColour(CMuleColour(CStatisticsDlg::getColors(12 + i))); ctrl->SetFrameBrushColour(*wxBLACK); } }
/* * Constructor */ CCommentDialogLst::CCommentDialogLst(wxWindow*parent, CPartFile* file) : wxDialog(parent, -1, wxString(_("File Comments")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), m_file(file) { wxSizer* content = commentLstDlg(this, true); content->Show(this, true); m_list = CastChild(IDC_LST, CMuleListCtrl); m_list->InsertColumn(0, _("Username"), wxLIST_FORMAT_LEFT, 130); m_list->InsertColumn(1, _("File Name"), wxLIST_FORMAT_LEFT, 130); m_list->InsertColumn(2, _("Rating"), wxLIST_FORMAT_LEFT, 80); m_list->InsertColumn(3, _("Comment"), wxLIST_FORMAT_LEFT, 340); m_list->SetSortFunc(SortProc); UpdateList(); }