Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added copyright and licence header to the C++ source and headers in the search directory.
[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 images for the add and delete buttons.
40         
41         wxMemoryInputStream astream(buttons_add_png, sizeof(buttons_add_png));
42         wxImage buttons_add_png(astream, wxBITMAP_TYPE_PNG);
43         wxBitmap addbmp(buttons_add_png, -1);
44         
45         wxMemoryInputStream bstream(buttons_minus_png, sizeof(buttons_minus_png));
46         wxImage buttons_minus_png(bstream, wxBITMAP_TYPE_PNG);
47         wxBitmap delbmp(buttons_minus_png, -1);
49         btnAdd->SetBitmapLabel(addbmp);
50         btnDelete->SetBitmapLabel(delbmp);
52         // Insert the options into the combo box.
53         
54         choOption->Append(_("Forename begins with"));
55         choOption->Append(_("Forename ends with"));
56         choOption->Append(_("Forename contains"));
57         choOption->Append(_("Forename doesn't contain"));
58         choOption->Append(_("Surname begins with"));
59         choOption->Append(_("Surname ends with"));
60         choOption->Append(_("Surname contains"));
61         choOption->Append(_("Surname doesn't contain"));
62         choOption->Append(_("Nickname begins with"));
63         choOption->Append(_("Nickname ends with"));
64         choOption->Append(_("Nickname contains"));
65         choOption->Append(_("Nickname doesn't contain"));
66         choOption->Append(_("Does/Doesn't have photo"));
67         choOption->Append(_("Does/Doesn't have logo"));
68         choOption->Append(_("Does/Doesn't have sound"));
69         
70         chkActive->Hide();
71         chkActive->SetValue(FALSE);
72         txtSearch->Show();
73         szrSSet->Layout();
74         
75         choOption->SetSelection(0);
77 }
79 void XABSearchPanel::UpdateOptions( wxCommandEvent& event )
80 {
81         
82         if (choOption->GetSelection() == 12 ||
83         choOption->GetSelection() == 13 ||
84         choOption->GetSelection() == 14 ){
85         
86                 chkActive->Show();
87                 txtSearch->Hide();
88                 txtSearch->Clear();
89                 szrSSet->Layout();
90         
91         } else {
92         
93                 chkActive->Hide();
94                 chkActive->SetValue(FALSE);
95                 txtSearch->Show();
96                 szrSSet->Layout();
97         
98         }
99         
102 void XABSearchPanel::AddSearchWidget( wxCommandEvent& event )
105         frmSearch *SCHWin = static_cast<frmSearch*>(SCHWinPtr);
107         wxCommandEvent eventsend(SE_ADDSEARCHSETTING);
108         wxPostEvent(SCHWin, eventsend);
112 void XABSearchPanel::RemoveSearchWidget( wxCommandEvent& event )
115         frmSearch *SCHWin = static_cast<frmSearch*>(SCHWinPtr);
116         
117         wxCommandEvent eventsend(SE_REMOVESEARCHSETTING);
118         eventsend.SetInt(this->GetInteger());
119         wxPostEvent(SCHWin, eventsend);
120         
123 void XABSearchPanel::EnableButtons(bool AddButton, bool DeleteButton)
126         if (AddButton == TRUE){
127                 btnAdd->Enable();
128         } else {
129                 btnAdd->Disable();
130         }
131         
132         if (DeleteButton == TRUE){
133                 btnDelete->Enable();
134         } else {
135                 btnDelete->Disable();
136         }
140 void XABSearchPanel::SetupPointers(void* SCHWinPtrInc){
142         SCHWinPtr = SCHWinPtrInc;
146 void XABSearchPanel::SetupInteger(int IntInc){
148         SCHInt = IntInc;
152 int XABSearchPanel::GetInteger(){
154         return SCHInt;
158 void XABSearchPanel::DisableControls(wxCommandEvent &event){
160         choOption->Disable();
161         chkActive->Disable();
162         txtSearch->Disable();
163         btnAdd->Disable();
164         btnDelete->Disable();
168 void XABSearchPanel::EnableControls(wxCommandEvent &event){
170         choOption->Enable();
171         chkActive->Enable();
172         txtSearch->Enable();
173         btnAdd->Enable();
174         btnDelete->Enable();
178 int XABSearchPanel::GetSelectionOption(){
180         return choOption->GetSelection();
184 bool XABSearchPanel::GetCheckboxSetting(){
186         return chkActive->IsChecked();
190 wxString XABSearchPanel::GetStringSetting(){
192         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