1// 2// This file is part of the aMule Project. 3// 4// Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org ) 5// Copyright (c) 2002-2011 Merkur ( devs@emule-project.net / http://www.emule-project.net ) 6// 7// Any parts of this program derived from the xMule, lMule or eMule project, 8// or contributed by third-party developers are copyrighted by their 9// respective authors. 10// 11// This program is free software; you can redistribute it and/or modify 12// it under the terms of the GNU General Public License as published by 13// the Free Software Foundation; either version 2 of the License, or 14// (at your option) any later version. 15// 16// This program is distributed in the hope that it will be useful, 17// but WITHOUT ANY WARRANTY; without even the implied warranty of 18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19// GNU General Public License for more details. 20// 21// You should have received a copy of the GNU General Public License 22// along with this program; if not, write to the Free Software 23// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 24// 25 26 27#include "CommentDialog.h" // Interface declarations 28#include "GuiEvents.h" 29#include "KnownFile.h" // Needed for CKnownFile 30#include "muuli_wdr.h" // Needed for commentDlg 31// CommentDialog dialog 32 33//IMPLEMENT_DYNAMIC(CCommentDialog, CDialog) 34CCommentDialog::CCommentDialog(wxWindow* parent,CKnownFile* file) 35: wxDialog(parent,-1,_("File Comments"), 36wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE|wxSYSTEM_MENU) 37{ 38 m_file = file; 39 wxSizer* content=commentDlg(this,TRUE); 40 content->SetSizeHints(this); 41 content->Show(this,TRUE); 42 Center(); 43 ratebox = CastChild( IDC_RATELIST, wxChoice ); 44 OnInitDialog(); 45} 46 47CCommentDialog::~CCommentDialog() 48{ 49} 50 51BEGIN_EVENT_TABLE(CCommentDialog,wxDialog) 52 EVT_TEXT_ENTER(IDC_CMT_TEXT, CCommentDialog::OnBnClickedApply) 53 EVT_BUTTON(IDCOK, CCommentDialog::OnBnClickedApply) 54 EVT_BUTTON(IDC_FC_CLEAR, CCommentDialog::OnBnClickedClear) 55 EVT_BUTTON(IDCCANCEL, CCommentDialog::OnBnClickedCancel) 56END_EVENT_TABLE() 57 58void CCommentDialog::OnBnClickedApply(wxCommandEvent& WXUNUSED(evt)) 59{ 60 wxString comment = CastChild( IDC_CMT_TEXT, wxTextCtrl )->GetValue(); 61 CoreNotify_KnownFile_Comment_Set(m_file, comment, (int8)ratebox->GetSelection()); 62 EndModal(0); 63} 64 65void CCommentDialog::OnBnClickedClear(wxCommandEvent& WXUNUSED(evt)) 66{ 67 CastChild(IDC_CMT_TEXT, wxTextCtrl)->SetValue(wxEmptyString); 68} 69 70void CCommentDialog::OnBnClickedCancel(wxCommandEvent& WXUNUSED(evt)) 71{ 72 EndModal(0); 73} 74 75bool CCommentDialog::OnInitDialog() 76{ 77 CastChild(IDC_CMT_TEXT, wxTextCtrl)->SetValue(m_file->GetFileComment()); 78 CastChild(IDC_CMT_TEXT, wxTextCtrl)->SetMaxLength(MAXFILECOMMENTLEN); 79 ratebox->SetSelection(m_file->GetFileRating()); 80 return TRUE; 81} 82// File_checked_for_headers 83