Upstream tarball 20080928
[amule.git] / src / CommentDialog.cpp
blob3a1b00a55eb781a687c6ef2e1a435a7a6d02454b
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002-2008 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.
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.
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
27 #include "CommentDialog.h" // Interface declarations
28 #include "KnownFile.h" // Needed for CKnownFile
29 #include "muuli_wdr.h" // Needed for commentDlg
30 // CommentDialog dialog
32 //IMPLEMENT_DYNAMIC(CCommentDialog, CDialog)
33 CCommentDialog::CCommentDialog(wxWindow* parent,CKnownFile* file)
34 : wxDialog(parent,-1,_("File Comments"),
35 wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE|wxSYSTEM_MENU)
37 m_file = file;
38 wxSizer* content=commentDlg(this,TRUE);
39 content->SetSizeHints(this);
40 content->Show(this,TRUE);
41 Center();
42 ratebox = CastChild( IDC_RATELIST, wxChoice );
43 OnInitDialog();
46 CCommentDialog::~CCommentDialog()
50 BEGIN_EVENT_TABLE(CCommentDialog,wxDialog)
51 EVT_TEXT_ENTER(IDC_CMT_TEXT, CCommentDialog::OnBnClickedApply)
52 EVT_BUTTON(IDCOK, CCommentDialog::OnBnClickedApply)
53 EVT_BUTTON(IDC_FC_CLEAR, CCommentDialog::OnBnClickedClear)
54 EVT_BUTTON(IDCCANCEL, CCommentDialog::OnBnClickedCancel)
55 END_EVENT_TABLE()
57 void CCommentDialog::OnBnClickedApply(wxCommandEvent& WXUNUSED(evt))
59 wxString SValue;
60 SValue = CastChild( IDC_CMT_TEXT, wxTextCtrl )->GetValue();
61 m_file->SetFileComment(SValue);
62 m_file->SetFileRating((int8)ratebox->GetSelection());
63 EndModal(0);
66 void CCommentDialog::OnBnClickedClear(wxCommandEvent& WXUNUSED(evt))
68 CastChild(IDC_CMT_TEXT, wxTextCtrl)->SetValue(wxEmptyString);
71 void CCommentDialog::OnBnClickedCancel(wxCommandEvent& WXUNUSED(evt))
73 EndModal(0);
76 bool CCommentDialog::OnInitDialog()
78 CastChild(IDC_CMT_TEXT, wxTextCtrl)->SetValue(m_file->GetFileComment());
79 CastChild(IDC_CMT_TEXT, wxTextCtrl)->SetMaxLength(MAXFILECOMMENTLEN);
80 ratebox->SetSelection(m_file->GetFileRating());
81 return TRUE;
83 // File_checked_for_headers