Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Version 0.18 release
[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"
21 DEFINE_EVENT_TYPE(XABSP_ENABLECONTROLS);
22 DEFINE_EVENT_TYPE(XABSP_DISABLECONTROLS);
24 BEGIN_EVENT_TABLE(XABSearchPanel, wxPanel)
25   EVT_COMMAND(wxID_ANY, XABSP_ENABLECONTROLS, XABSearchPanel::EnableControls)
26   EVT_COMMAND(wxID_ANY, XABSP_DISABLECONTROLS, XABSearchPanel::DisableControls)
27 END_EVENT_TABLE()
29 XABSearchPanel::XABSearchPanel( wxWindow* parent )
30 :
31 XABSearchPanelADT( parent )
32 {
34         // Setup the search panel.
35         
36         // Setup the images for the add and delete buttons.
37         
38         wxMemoryInputStream astream(buttons_add_png, sizeof(buttons_add_png));
39         wxImage buttons_add_png(astream, wxBITMAP_TYPE_PNG);
40         wxBitmap addbmp(buttons_add_png, -1);
41         
42         wxMemoryInputStream bstream(buttons_minus_png, sizeof(buttons_minus_png));
43         wxImage buttons_minus_png(bstream, wxBITMAP_TYPE_PNG);
44         wxBitmap delbmp(buttons_minus_png, -1);
46         btnAdd->SetBitmapLabel(addbmp);
47         btnDelete->SetBitmapLabel(delbmp);
49         // Insert the options into the combo box.
50         
51         choOption->Append(_("Forename begins with"));
52         choOption->Append(_("Forename ends with"));
53         choOption->Append(_("Forename contains"));
54         choOption->Append(_("Forename doesn't contain"));
55         choOption->Append(_("Surname begins with"));
56         choOption->Append(_("Surname ends with"));
57         choOption->Append(_("Surname contains"));
58         choOption->Append(_("Surname doesn't contain"));
59         choOption->Append(_("Nickname begins with"));
60         choOption->Append(_("Nickname ends with"));
61         choOption->Append(_("Nickname contains"));
62         choOption->Append(_("Nickname doesn't contain"));
63         choOption->Append(_("Does/Doesn't have photo"));
64         choOption->Append(_("Does/Doesn't have logo"));
65         choOption->Append(_("Does/Doesn't have sound"));
66         
67         chkActive->Hide();
68         chkActive->SetValue(FALSE);
69         txtSearch->Show();
70         szrSSet->Layout();
71         
72         choOption->SetSelection(0);
74 }
76 void XABSearchPanel::UpdateOptions( wxCommandEvent& event )
77 {
78         
79         // Update the options in the search panel.
80         
81         if (choOption->GetSelection() == 12 ||
82         choOption->GetSelection() == 13 ||
83         choOption->GetSelection() == 14 ){
84         
85                 chkActive->Show();
86                 txtSearch->Hide();
87                 txtSearch->Clear();
88                 szrSSet->Layout();
89         
90         } else {
91         
92                 chkActive->Hide();
93                 chkActive->SetValue(FALSE);
94                 txtSearch->Show();
95                 szrSSet->Layout();
96         
97         }
98         
99 }
101 void XABSearchPanel::AddSearchWidget( wxCommandEvent& event )
104         // Add the search panel.
105         
106         frmSearch *SCHWin = static_cast<frmSearch*>(SCHWinPtr);
108         wxCommandEvent eventsend(SE_ADDSEARCHSETTING);
109         wxPostEvent(SCHWin, eventsend);
113 void XABSearchPanel::RemoveSearchWidget( wxCommandEvent& event )
116         // Remove the search panel.
117         
118         frmSearch *SCHWin = static_cast<frmSearch*>(SCHWinPtr);
119         
120         wxCommandEvent eventsend(SE_REMOVESEARCHSETTING);
121         eventsend.SetInt(this->GetInteger());
122         wxPostEvent(SCHWin, eventsend);
123         
126 void XABSearchPanel::EnableButtons(bool AddButton, bool DeleteButton)
129         // Enable the buttons for the search panel.
130         
131         if (AddButton == TRUE){
132                 btnAdd->Enable();
133         } else {
134                 btnAdd->Disable();
135         }
136         
137         if (DeleteButton == TRUE){
138                 btnDelete->Enable();
139         } else {
140                 btnDelete->Disable();
141         }
145 void XABSearchPanel::SetupPointers(void* SCHWinPtrInc){
147         // Setup the pointers for the search panel.
148         
149         SCHWinPtr = SCHWinPtrInc;
153 void XABSearchPanel::SetupInteger(int IntInc){
155         // Set the ID of the search panel.
156         
157         SCHInt = IntInc;
161 int XABSearchPanel::GetInteger(){
163         // Get the ID of the search panel.
164         
165         return SCHInt;
169 void XABSearchPanel::DisableControls(wxCommandEvent &event){
171         // Disable the search controls.
172         
173         choOption->Disable();
174         chkActive->Disable();
175         txtSearch->Disable();
176         btnAdd->Disable();
177         btnDelete->Disable();
181 void XABSearchPanel::EnableControls(wxCommandEvent &event){
183         // Enable the search controls.
184         
185         choOption->Enable();
186         chkActive->Enable();
187         txtSearch->Enable();
188         btnAdd->Enable();
189         btnDelete->Enable();
193 int XABSearchPanel::GetSelectionOption(){
195         // Get the selection option.
196         
197         return choOption->GetSelection();
201 bool XABSearchPanel::GetCheckboxSetting(){
203         // Get the checkbox setting.
204         
205         return chkActive->IsChecked();
209 wxString XABSearchPanel::GetStringSetting(){
211         // Get the search string setting.
212         
213         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