NCBI C++ ToolKit
existingtextdlg.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: existingtextdlg.cpp 34945 2016-03-03 20:31:51Z asztalos $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Colleen Bollin
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 
32 ////@begin includes
33 ////@end includes
34 
35 #include <wx/stattext.h>
36 #include <wx/sizer.h>
37 #include <wx/button.h>
39 
40 ////@begin XPM images
41 ////@end XPM images
42 
46 
47 /*!
48  * CExistingTextDlg type definition
49  */
50 
51 IMPLEMENT_DYNAMIC_CLASS( CExistingTextDlg, wxDialog )
52 
53 
54 /*!
55  * CExistingTextDlg event table definition
56  */
57 
58 BEGIN_EVENT_TABLE( CExistingTextDlg, wxDialog )
59 
60 ////@begin CExistingTextDlg event table entries
62 
64 
66 
68 
69 ////@end CExistingTextDlg event table entries
70 
72 
73 
74 /*!
75  * CExistingTextDlg constructors
76  */
77 
79 {
80  Init();
81 }
82 
83 CExistingTextDlg::CExistingTextDlg( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
84 {
85  Init();
86  Create(parent, id, caption, pos, size, style);
87 }
88 
89 
90 /*!
91  * CExistingTextDlg creator
92  */
93 
94 bool CExistingTextDlg::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
95 {
96 ////@begin CExistingTextDlg creation
97  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
98  wxDialog::Create( parent, id, caption, pos, size, style );
99 
100  CreateControls();
101  if (GetSizer())
102  {
103  GetSizer()->SetSizeHints(this);
104  }
105  Centre();
106 ////@end CExistingTextDlg creation
107  return true;
108 }
109 
110 
111 /*!
112  * CExistingTextDlg destructor
113  */
114 
116 {
117 ////@begin CExistingTextDlg destruction
118 ////@end CExistingTextDlg destruction
119 }
120 
121 
122 /*!
123  * Member initialisation
124  */
125 
127 {
128 ////@begin CExistingTextDlg member initialisation
129  m_Position = NULL;
130  m_Append = NULL;
131  m_Prefix = NULL;
132  m_LeaveOld = NULL;
133  m_AddQual = NULL;
134  m_Delimiters = NULL;
135  m_Semicolon = NULL;
136  m_Space = NULL;
137  m_Colon = NULL;
138  m_Comma = NULL;
140 ////@end CExistingTextDlg member initialisation
141 }
142 
143 
144 /*!
145  * Control creation for CExistingTextDlg
146  */
147 
149 {
150 ////@begin CExistingTextDlg content construction
151  CExistingTextDlg* itemDialog1 = this;
152 
153  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
154  itemDialog1->SetSizer(itemBoxSizer2);
155 
156  m_Position = new wxBoxSizer(wxVERTICAL);
157  itemBoxSizer2->Add(m_Position, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
158 
159  m_Append = new wxRadioButton( itemDialog1, ID_APPEND_BTN, _("Append"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
160  m_Append->SetValue(true);
161  m_Position->Add(m_Append, 0, wxALIGN_LEFT|wxALL, 5);
162 
163  m_Prefix = new wxRadioButton( itemDialog1, ID_PREFIX_BTN, _("Prefix"), wxDefaultPosition, wxDefaultSize, 0 );
164  m_Prefix->SetValue(false);
165  m_Position->Add(m_Prefix, 0, wxALIGN_LEFT|wxALL, 5);
166 
167  m_LeaveOld = new wxRadioButton( itemDialog1, ID_IGNORE_BTN, _("Ignore new text"), wxDefaultPosition, wxDefaultSize, 0 );
168  m_LeaveOld->SetValue(false);
169  m_Position->Add(m_LeaveOld, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
170 
171  m_AddQual = new wxRadioButton( itemDialog1, ID_ADD_QUAL_BTN, _("Add new qual"), wxDefaultPosition, wxDefaultSize, 0 );
172  m_AddQual->SetValue(false);
173  m_AddQual->Show(false);
174  m_Position->Add(m_AddQual, 0, wxALIGN_LEFT|wxALL, 5);
175 
176  wxStaticText* itemStaticText8 = new wxStaticText( itemDialog1, wxID_STATIC, _("Separate new text and old text with"), wxDefaultPosition, wxDefaultSize, 0 );
177  itemBoxSizer2->Add(itemStaticText8, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
178 
179  m_Delimiters = new wxBoxSizer(wxVERTICAL);
180  itemBoxSizer2->Add(m_Delimiters, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
181 
182  m_Semicolon = new wxRadioButton( itemDialog1, ID_SEMICOLON_BTN, _("Semicolon"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
183  m_Semicolon->SetValue(true);
184  m_Delimiters->Add(m_Semicolon, 0, wxALIGN_LEFT|wxALL, 5);
185 
186  m_Space = new wxRadioButton( itemDialog1, ID_SPACE_BTN, _("Space"), wxDefaultPosition, wxDefaultSize, 0 );
187  m_Space->SetValue(false);
188  m_Delimiters->Add(m_Space, 0, wxALIGN_LEFT|wxALL, 5);
189 
190  m_Colon = new wxRadioButton( itemDialog1, ID_COLON_BTN, _("Colon"), wxDefaultPosition, wxDefaultSize, 0 );
191  m_Colon->SetValue(false);
192  m_Delimiters->Add(m_Colon, 0, wxALIGN_LEFT|wxALL, 5);
193 
194  m_Comma = new wxRadioButton( itemDialog1, ID_COMMA_BTN, _("Comma"), wxDefaultPosition, wxDefaultSize, 0 );
195  m_Comma->SetValue(false);
196  m_Delimiters->Add(m_Comma, 0, wxALIGN_LEFT|wxALL, 5);
197 
198  m_NoDelimiter = new wxRadioButton( itemDialog1, ID_NODELIMITER_BTN, _("Do not separate"), wxDefaultPosition, wxDefaultSize, 0 );
199  m_NoDelimiter->SetValue(false);
200  m_Delimiters->Add(m_NoDelimiter, 0, wxALIGN_LEFT|wxALL, 5);
201 
202  wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxHORIZONTAL);
203  itemBoxSizer2->Add(itemBoxSizer15, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
204 
205  wxButton* itemButton16 = new wxButton( itemDialog1, wxID_OK, _("Accept"), wxDefaultPosition, wxDefaultSize, 0 );
206  itemBoxSizer15->Add(itemButton16, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
207 
208  wxButton* itemButton17 = new wxButton( itemDialog1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
209  itemBoxSizer15->Add(itemButton17, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
210 
211 ////@end CExistingTextDlg content construction
212 }
213 
214 
215 /*!
216  * Should we show tooltips?
217  */
218 
220 {
221  return true;
222 }
223 
224 /*!
225  * Get bitmap resources
226  */
227 
228 wxBitmap CExistingTextDlg::GetBitmapResource( const wxString& name )
229 {
230  // Bitmap retrieval
231 ////@begin CExistingTextDlg bitmap retrieval
232  wxUnusedVar(name);
233  return wxNullBitmap;
234 ////@end CExistingTextDlg bitmap retrieval
235 }
236 
237 /*!
238  * Get icon resources
239  */
240 
241 wxIcon CExistingTextDlg::GetIconResource( const wxString& name )
242 {
243  // Icon retrieval
244 ////@begin CExistingTextDlg icon retrieval
245  wxUnusedVar(name);
246  return wxNullIcon;
247 ////@end CExistingTextDlg icon retrieval
248 }
249 
250 
252 {
253  EExistingText existing_text = eExistingText_cancel;
254  if (m_LeaveOld->GetValue()) {
255  existing_text = eExistingText_leave_old;
256  } else if (m_Append->GetValue()) {
257  if (m_Semicolon->GetValue()) {
258  existing_text = eExistingText_append_semi;
259  } else if (m_Space->GetValue()) {
260  existing_text = eExistingText_append_space;
261  } else if (m_Colon->GetValue()) {
262  existing_text = eExistingText_append_colon;
263  } else if (m_Comma->GetValue()) {
264  existing_text = eExistingText_append_comma;
265  } else if (m_NoDelimiter->GetValue()) {
266  existing_text = eExistingText_append_none;
267  }
268  } else if (m_Prefix->GetValue()) {
269  if (m_Semicolon->GetValue()) {
270  existing_text = eExistingText_prefix_semi;
271  } else if (m_Space->GetValue()) {
272  existing_text = eExistingText_prefix_space;
273  } else if (m_Colon->GetValue()) {
274  existing_text = eExistingText_prefix_colon;
275  } else if (m_Comma->GetValue()) {
276  existing_text = eExistingText_prefix_comma;
277  } else if (m_NoDelimiter->GetValue()) {
278  existing_text = eExistingText_prefix_none;
279  }
280  } else if (m_AddQual->GetValue()) {
281  existing_text = eExistingText_add_qual;
282  }
283 
284  return existing_text;
285 }
286 
287 
289 {
290  for (size_t pos = 0; pos < m_Delimiters->GetItemCount(); pos++) {
291  wxWindow* w = m_Delimiters->GetItem(pos)->GetWindow();
292  wxRadioButton* but = dynamic_cast<wxRadioButton *>(w);
293  if (but) {
294  but->Enable(val);
295  }
296  }
297 }
298 
299 
300 /*!
301  * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_APPEND_BTN
302  */
303 
304 void CExistingTextDlg::OnAppendBtnSelected( wxCommandEvent& event )
305 {
306  x_EnableDelimiters (true);
307 }
308 
309 
310 /*!
311  * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_PREFIX_BTN
312  */
313 
314 void CExistingTextDlg::OnPrefixBtnSelected( wxCommandEvent& event )
315 {
316  x_EnableDelimiters (true);
317 }
318 
319 
320 /*!
321  * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_IGNORE_BTN
322  */
323 
324 void CExistingTextDlg::OnIgnoreBtnSelected( wxCommandEvent& event )
325 {
326  x_EnableDelimiters (false);
327 }
328 
329 
331 {
332  bool was_shown = m_AddQual->IsShown();
333  if (was_shown == val) {
334  return;
335  }
336  m_AddQual->Show(val);
337 
338  wxSize min_size = this->GetMinClientSize();
339  wxSize add_size = m_Append->GetSize();
340  if (val) {
341  min_size.SetHeight(min_size.GetHeight() + add_size.GetHeight() + 10);
342  } else {
343  min_size.SetHeight(min_size.GetHeight() - add_size.GetHeight() - 10);
344  }
345 
346  this->SetMinClientSize(min_size);
347  Layout();
348  Fit();
349  Refresh();
350 }
351 
352 
353 /*!
354  * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_ADD_QUAL_BTN
355  */
356 
357 void CExistingTextDlg::OnAddQualBtnSelected( wxCommandEvent& event )
358 {
359  x_EnableDelimiters (false);
360 }
361 
362 
wxRadioButton * m_LeaveOld
wxRadioButton * m_Comma
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
wxRadioButton * m_Space
~CExistingTextDlg()
Destructor.
void x_EnableDelimiters(bool val)
wxRadioButton * m_Prefix
void OnIgnoreBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_IGNORE_BTN
wxBoxSizer * m_Position
void OnPrefixBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_PREFIX_BTN
wxBoxSizer * m_Delimiters
static bool ShowToolTips()
Should we show tooltips?
objects::edit::EExistingText GetExistingTextHandler()
void OnAppendBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_APPEND_BTN
wxRadioButton * m_AddQual
bool Create(wxWindow *parent, wxWindowID id=10131, const wxString &caption=_("How to Add New Text"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
wxRadioButton * m_Colon
wxRadioButton * m_NoDelimiter
CExistingTextDlg()
Constructors.
void OnAddQualBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_ADD_QUAL_BTN
wxRadioButton * m_Append
void AllowAdditionalQual(bool val)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
wxRadioButton * m_Semicolon
void Init()
Initialises member variables.
void CreateControls()
Creates the controls and sizers.
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
USING_SCOPE(objects)
#define ID_PREFIX_BTN
#define ID_COMMA_BTN
#define ID_NODELIMITER_BTN
#define ID_SPACE_BTN
#define ID_ADD_QUAL_BTN
#define ID_COLON_BTN
#define ID_IGNORE_BTN
#define ID_APPEND_BTN
#define ID_SEMICOLON_BTN
#define NULL
Definition: ncbistd.hpp:225
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
END_EVENT_TABLE()
Definition: fix_pub.hpp:45
const struct ncbi::grid::netcache::search::fields::SIZE size
EExistingText
@ eExistingText_cancel
@ eExistingText_append_semi
@ eExistingText_append_space
@ eExistingText_prefix_colon
@ eExistingText_add_qual
@ eExistingText_append_none
@ eExistingText_leave_old
@ eExistingText_prefix_none
@ eExistingText_prefix_space
@ eExistingText_append_colon
@ eExistingText_prefix_comma
@ eExistingText_append_comma
@ eExistingText_prefix_semi
Modified on Fri Mar 01 10:07:15 2024 by modify_doxy.py rev. 669887