]> Creatis software - creaImageIO.git/blob - src/creaImageIOWxListenerPanel.cpp
#3185 creaImageIO Feature New Normal - Clean code
[creaImageIO.git] / src / creaImageIOWxListenerPanel.cpp
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5 #                        pour la Santé)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 #
10 #  This software is governed by the CeCILL-B license under French law and 
11 #  abiding by the rules of distribution of free software. You can  use, 
12 #  modify and/ or redistribute the software under the terms of the CeCILL-B 
13 #  license as circulated by CEA, CNRS and INRIA at the following URL 
14 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
15 #  or in the file LICENSE.txt.
16 #
17 #  As a counterpart to the access to the source code and  rights to copy,
18 #  modify and redistribute granted by the license, users are provided only
19 #  with a limited warranty  and the software's author,  the holder of the
20 #  economic rights,  and the successive licensors  have only  limited
21 #  liability. 
22 #
23 #  The fact that you are presently reading this means that you have had
24 #  knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
26 */
27
28
29 #include <creaImageIOWxListenerPanel.h>
30 #include <creaImageIOSystem.h>
31
32 namespace creaImageIO
33 {
34   // CTor
35   WxListenerPanel::WxListenerPanel(wxWindow *parent, wxDialog* dial, WxGimmickView* view, bool stat)
36  :   wxPanel( parent, 
37                   -1, wxDefaultPosition, 
38                   wxDefaultSize,
39                   wxRESIZE_BORDER | 
40               wxSYSTEM_MENU  |
41                   wxCLOSE_BOX |
42                   wxMAXIMIZE_BOX | 
43                   wxMINIMIZE_BOX | 
44                   wxCAPTION  
45                ),       
46                    dialog(dial),
47                    mView(view)
48   {
49     GimmickDebugMessage(1,"WxListener::WxListener"
50                         <<std::endl);
51         state=stat;
52         /// \TODO fix warning: unused variable cp
53         wxStaticText * cp=new wxStaticText(this,-1,_T(" Drive to monitor: "), wxPoint(5,15));
54         const wxString choices[] = { _T("D:"), 
55                 _T("E:"), 
56                 _T("F:"), 
57                 _T("G:") };
58         drives=new wxComboBox(this, -1,crea::std2wx("E:"),wxPoint(100, 10),wxDefaultSize,4,choices);
59
60         addCheckBox = new wxCheckBox(this, -1, _T("Automatically add images to the database when CD/DVD is mounted?"), wxPoint(5,45) );
61         addCheckBox->SetValue(true);
62         removeCheckBox = new wxCheckBox(this, -1, _T("Automatically remove images from the database when CD/DVD is unmounted?"), wxPoint(5,75) );
63         removeCheckBox->SetValue(true);
64         Connect( addCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WxListenerPanel::OnAdd );
65         Connect( removeCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &WxListenerPanel::OnRemove );
66         std::string name;
67         if (state){name="Start Monitoring Drive";}
68         else {name="Stop Monitoring Drive";}
69         wxButton *start = new wxButton(this,wxID_ANY,crea::std2wx(name), wxPoint(5,110) );
70         Connect( start->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxListenerPanel::OnChangeThreadState ); 
71
72         wxButton *save = new wxButton(this,wxID_ANY,_T("Save Changes"), wxPoint(130,110) );
73         Connect( save->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxListenerPanel::OnChangeListenState ); 
74   
75
76     //topsizer->Add( mView,1,wxGROW,0);
77
78 //    SetSizer( topsizer );     
79     Layout(); 
80   }
81
82   /// Destructor
83   WxListenerPanel::~WxListenerPanel()
84   {
85     GimmickDebugMessage(1,"WxCustomizeConfigPanel::~WxCustomizeConfigPanel"
86                         <<std::endl);
87   }
88
89   void WxListenerPanel::OnAdd(wxCommandEvent& event)
90   {
91                 addFiles = addCheckBox->GetValue();
92   }
93
94   void WxListenerPanel::OnRemove(wxCommandEvent& event)
95   {
96                 removeFiles = removeCheckBox->GetValue();
97   }
98
99   void WxListenerPanel::OnChangeListenState(wxCommandEvent& event)
100   {
101           mView->OnListenerCallback(crea::wx2std(drives->GetValue()),addFiles, removeFiles);
102           dialog->Destroy();
103   }
104
105   void WxListenerPanel::OnChangeThreadState(wxCommandEvent& event)
106   {
107           if(state)
108           {
109                 mView->StartListeningThread();
110           }
111           else
112           {
113                 mView->StopListeningThread();
114           }
115           dialog->Destroy();
116   }
117   
118 //======================================================================
119   
120 //====================================================================== 
121
122 } // EO namespace creaImageIO
123
124