Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
7a22155af51f763d34b274f42ea65d0bb4e92f49
[xestiaab/.git] / source / search / XABSearchPanel.cpp
1 // XABSearchPanel.cpp - XABSearchPanel widget.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "XABSearchPanel.h"
20 #include "../bitmaps.h"
22 #include <wx/mstream.h>
26 DEFINE_EVENT_TYPE(XABSP_ENABLECONTROLS);
27 DEFINE_EVENT_TYPE(XABSP_DISABLECONTROLS);
29 BEGIN_EVENT_TABLE(XABSearchPanel, wxPanel)
30   EVT_COMMAND(wxID_ANY, XABSP_ENABLECONTROLS, XABSearchPanel::EnableControls)
31   EVT_COMMAND(wxID_ANY, XABSP_DISABLECONTROLS, XABSearchPanel::DisableControls)
32 END_EVENT_TABLE()
34 XABSearchPanel::XABSearchPanel( wxWindow* parent )
35 :
36 XABSearchPanelADT( parent )
37 {
39         // Setup the search panel.
40         
41         // Setup the images for the add and delete buttons.
42         
43         wxMemoryInputStream astream(buttons_add_png, sizeof(buttons_add_png));
44         wxImage buttons_add_png(astream, wxBITMAP_TYPE_PNG);
45         wxBitmap addbmp(buttons_add_png, -1);
46         
47         wxMemoryInputStream bstream(buttons_minus_png, sizeof(buttons_minus_png));
48         wxImage buttons_minus_png(bstream, wxBITMAP_TYPE_PNG);
49         wxBitmap delbmp(buttons_minus_png, -1);
51         btnAdd->SetBitmapLabel(addbmp);
52         btnDelete->SetBitmapLabel(delbmp);
54         // Insert the options into the combo box.
55         
56         choOption->Append(_("Forename begins with"));
57         choOption->Append(_("Forename ends with"));
58         choOption->Append(_("Forename contains"));
59         choOption->Append(_("Forename doesn't contain"));
60         choOption->Append(_("Surname begins with"));
61         choOption->Append(_("Surname ends with"));
62         choOption->Append(_("Surname contains"));
63         choOption->Append(_("Surname doesn't contain"));
64         choOption->Append(_("Nickname begins with"));
65         choOption->Append(_("Nickname ends with"));
66         choOption->Append(_("Nickname contains"));
67         choOption->Append(_("Nickname doesn't contain"));
68         choOption->Append(_("Does/Doesn't have photo"));
69         choOption->Append(_("Does/Doesn't have logo"));
70         choOption->Append(_("Does/Doesn't have sound"));
71         
72         chkActive->Hide();
73         chkActive->SetValue(FALSE);
74         txtSearch->Show();
75         szrSSet->Layout();
76         
77         choOption->SetSelection(0);
79 }
81 void XABSearchPanel::UpdateOptions( wxCommandEvent& event )
82 {
83         
84         // Update the options in the search panel.
85         
86         if (choOption->GetSelection() == 12 ||
87         choOption->GetSelection() == 13 ||
88         choOption->GetSelection() == 14 ){
89         
90                 chkActive->Show();
91                 txtSearch->Hide();
92                 txtSearch->Clear();
93                 szrSSet->Layout();
94         
95         } else {
96         
97                 chkActive->Hide();
98                 chkActive->SetValue(FALSE);
99                 txtSearch->Show();
100                 szrSSet->Layout();
101         
102         }
103         
106 void XABSearchPanel::AddSearchWidget( wxCommandEvent& event )
109         // Add the search panel.
110         
111         frmSearch *SCHWin = static_cast<frmSearch*>(SCHWinPtr);
113         wxCommandEvent eventsend(SE_ADDSEARCHSETTING);
114         wxPostEvent(SCHWin, eventsend);
118 void XABSearchPanel::RemoveSearchWidget( wxCommandEvent& event )
121         // Remove the search panel.
122         
123         frmSearch *SCHWin = static_cast<frmSearch*>(SCHWinPtr);
124         
125         wxCommandEvent eventsend(SE_REMOVESEARCHSETTING);
126         eventsend.SetInt(this->GetInteger());
127         wxPostEvent(SCHWin, eventsend);
128         
131 void XABSearchPanel::EnableButtons(bool AddButton, bool DeleteButton)
134         // Enable the buttons for the search panel.
135         
136         if (AddButton == TRUE){
137                 btnAdd->Enable();
138         } else {
139                 btnAdd->Disable();
140         }
141         
142         if (DeleteButton == TRUE){
143                 btnDelete->Enable();
144         } else {
145                 btnDelete->Disable();
146         }
150 void XABSearchPanel::SetupPointers(void* SCHWinPtrInc){
152         // Setup the pointers for the search panel.
153         
154         SCHWinPtr = SCHWinPtrInc;
158 void XABSearchPanel::SetupInteger(int IntInc){
160         // Set the ID of the search panel.
161         
162         SCHInt = IntInc;
166 int XABSearchPanel::GetInteger(){
168         // Get the ID of the search panel.
169         
170         return SCHInt;
174 void XABSearchPanel::DisableControls(wxCommandEvent &event){
176         // Disable the search controls.
177         
178         choOption->Disable();
179         chkActive->Disable();
180         txtSearch->Disable();
181         btnAdd->Disable();
182         btnDelete->Disable();
186 void XABSearchPanel::EnableControls(wxCommandEvent &event){
188         // Enable the search controls.
189         
190         choOption->Enable();
191         chkActive->Enable();
192         txtSearch->Enable();
193         btnAdd->Enable();
194         btnDelete->Enable();
198 int XABSearchPanel::GetSelectionOption(){
200         // Get the selection option.
201         
202         return choOption->GetSelection();
206 bool XABSearchPanel::GetCheckboxSetting(){
208         // Get the checkbox setting.
209         
210         return chkActive->IsChecked();
214 wxString XABSearchPanel::GetStringSetting(){
216         // Get the search string setting.
217         
218         return txtSearch->GetValue();
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy