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

Go to the SVN repository for this file.

1 /* $Id: seqtextviewoptions.cpp 33746 2015-09-11 19:58:46Z shkeda $
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  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
34 #include "seqtextviewoptions.h"
35 
37 
38 #include <wx/sizer.h>
39 #include <wx/stattext.h>
40 #include <wx/statbox.h>
41 
42 #include <wx/radiobut.h>
43 #include <wx/choice.h>
44 #include <wx/button.h>
45 #include <wx/icon.h>
46 
47 
49 
50 IMPLEMENT_DYNAMIC_CLASS( CwxSeqTextViewOptions, wxDialog )
51 
52 
53 BEGIN_EVENT_TABLE( CwxSeqTextViewOptions, wxDialog )
54 
55 ////@begin CwxSeqTextViewOptions event table entries
57 
59 
60 ////@end CwxSeqTextViewOptions event table entries
61 
63 
64 
66 {
67  m_Config.Reset (new CSeqTextConfig());
68 
69  Init();
70  x_LoadSettings ();
71 }
72 
73 CwxSeqTextViewOptions::CwxSeqTextViewOptions( wxWindow* parent, CRef<CSeqTextConfig> cfg, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
74 {
75  if (cfg) {
76  m_Config.Reset (cfg);
77  } else {
79  }
80 
81  Init();
82  Create(parent, id, caption, pos, size, style);
83  x_LoadSettings ();
84 }
85 
86 
87 /*!
88  * CwxSeqTextViewOptions creator
89  */
90 
91 bool CwxSeqTextViewOptions::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
92 {
93 ////@begin CwxSeqTextViewOptions creation
94  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
95  wxDialog::Create( parent, id, caption, pos, size, style );
96 
98  if (GetSizer())
99  {
100  GetSizer()->SetSizeHints(this);
101  }
102  Centre();
103 ////@end CwxSeqTextViewOptions creation
104  return true;
105 }
106 
107 
108 /*!
109  * CwxSeqTextViewOptions destructor
110  */
111 
113 {
114 ////@begin CwxSeqTextViewOptions destruction
115 ////@end CwxSeqTextViewOptions destruction
116 }
117 
118 
119 /*!
120  * Member initialisation
121  */
122 
124 {
125 ////@begin CwxSeqTextViewOptions member initialisation
126  m_FontSize = NULL;
127  m_FeatColor = NULL;
129  m_DispCoord = NULL;
130 ////@end CwxSeqTextViewOptions member initialisation
131 }
132 
133 
134 /*!
135  * Control creation for CwxSeqTextViewOptions
136  */
137 
139 {
140 
141 ////@begin CwxSeqTextViewOptions content construction
142  CwxSeqTextViewOptions* itemDialog1 = this;
143 
144  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
145  itemDialog1->SetSizer(itemBoxSizer2);
146 
147  wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
148  itemBoxSizer2->Add(itemBoxSizer3, 0, 0, 0);
149 
150  wxStaticBox* itemStaticBoxSizer4Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Settings"));
151  wxStaticBoxSizer* itemStaticBoxSizer4 = new wxStaticBoxSizer(itemStaticBoxSizer4Static, wxVERTICAL);
152  itemBoxSizer3->Add(itemStaticBoxSizer4, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
153 
154  wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL);
155  itemStaticBoxSizer4->Add(itemBoxSizer5, 1, wxALIGN_LEFT|wxALL, 5);
156 
157  wxStaticText* itemStaticText6 = new wxStaticText( itemDialog1, wxID_STATIC, _("Font Size:"), wxDefaultPosition, wxDefaultSize, 0 );
158  itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
159 
160  wxArrayString m_FontSizeStrings;
161  m_FontSizeStrings.Add(_("6"));
162  m_FontSizeStrings.Add(_("8"));
163  m_FontSizeStrings.Add(_("10"));
164  m_FontSizeStrings.Add(_("12"));
165  m_FontSizeStrings.Add(_("14"));
166  m_FontSizeStrings.Add(_("18"));
167  m_FontSizeStrings.Add(_("20"));
168  m_FontSizeStrings.Add(_("24"));
169  m_FontSize = new wxChoice( itemDialog1, ID_SEQTEXTDLG_FONTSIZE, wxDefaultPosition, wxDefaultSize, m_FontSizeStrings, 0 );
170  m_FontSize->SetStringSelection(_("12"));
171  itemBoxSizer5->Add(m_FontSize, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
172 
173  wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxHORIZONTAL);
174  itemStaticBoxSizer4->Add(itemBoxSizer8, 0, wxALIGN_LEFT|wxALL, 5);
175 
176  wxStaticText* itemStaticText9 = new wxStaticText( itemDialog1, wxID_STATIC, _("Feature Coloration:"), wxDefaultPosition, wxDefaultSize, 0 );
177  itemBoxSizer8->Add(itemStaticText9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
178 
179  wxArrayString m_FeatColorStrings;
180  m_FeatColorStrings.Add(_("None"));
181  m_FeatColorStrings.Add(_("All"));
182  m_FeatColorStrings.Add(_("Selected"));
183  m_FeatColorStrings.Add(_("MouseOver"));
184  m_FeatColor = new wxChoice( itemDialog1, ID_SEQTEXTDLG_FEATCOLOR, wxDefaultPosition, wxDefaultSize, m_FeatColorStrings, 0 );
185  m_FeatColor->SetStringSelection(_("All"));
186  itemBoxSizer8->Add(m_FeatColor, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
187 
188  wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxHORIZONTAL);
189  itemStaticBoxSizer4->Add(itemBoxSizer11, 0, wxALIGN_LEFT|wxALL, 5);
190 
191  wxStaticText* itemStaticText12 = new wxStaticText( itemDialog1, wxID_STATIC, _("Codon Display:"), wxDefaultPosition, wxDefaultSize, 0 );
192  itemBoxSizer11->Add(itemStaticText12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
193 
194  wxArrayString m_CodonDisplayStrings;
195  m_CodonDisplayStrings.Add(_("None"));
196  m_CodonDisplayStrings.Add(_("All"));
197  m_CodonDisplayStrings.Add(_("Selected"));
198  m_CodonDisplayStrings.Add(_("MouseOver"));
199  m_CodonDisplay = new wxChoice( itemDialog1, ID_SEQTEXTDLG_CODONDISPLAY, wxDefaultPosition, wxDefaultSize, m_CodonDisplayStrings, 0 );
200  m_CodonDisplay->SetStringSelection(_("None"));
201  itemBoxSizer11->Add(m_CodonDisplay, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
202 
203  wxBoxSizer* itemBoxSizer14 = new wxBoxSizer(wxHORIZONTAL);
204  itemStaticBoxSizer4->Add(itemBoxSizer14, 0, wxALIGN_LEFT|wxALL, 5);
205 
206  wxStaticText* itemStaticText15 = new wxStaticText( itemDialog1, wxID_STATIC, _("Display Coordinates:"), wxDefaultPosition, wxDefaultSize, 0 );
207  itemBoxSizer14->Add(itemStaticText15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
208 
209  wxArrayString m_DispCoordStrings;
210  m_DispCoordStrings.Add(_("Absolute"));
211  m_DispCoordStrings.Add(_("Relative"));
212  m_DispCoord = new wxChoice( itemDialog1, ID_SEQTEXTDLG_DISPLAYCOORD, wxDefaultPosition, wxDefaultSize, m_DispCoordStrings, 0 );
213  m_DispCoord->SetStringSelection(_("Absolute"));
215  m_DispCoord->SetToolTip(_("Display coordinates relative to start of sequence or to start of selection"));
216  itemBoxSizer14->Add(m_DispCoord, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
217 
218  wxGridSizer* itemGridSizer17 = new wxGridSizer(0, 2, 0, 0);
219  itemBoxSizer2->Add(itemGridSizer17, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
220 
221  wxButton* itemButton18 = new wxButton( itemDialog1, ID_SEQTEXTDLG_OK, _("Ok"), wxDefaultPosition, wxDefaultSize, 0 );
222  itemGridSizer17->Add(itemButton18, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
223 
224  wxButton* itemButton19 = new wxButton( itemDialog1, ID_SEQTEXTDLG_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
225  itemGridSizer17->Add(itemButton19, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
226 
227 ////@end CwxSeqTextViewOptions content construction
228 }
229 
230 
231 /*!
232  * Should we show tooltips?
233  */
234 
236 {
237  return true;
238 }
239 
240 /*!
241  * Get bitmap resources
242  */
243 
244 wxBitmap CwxSeqTextViewOptions::GetBitmapResource( const wxString& name )
245 {
246  // Bitmap retrieval
247 ////@begin CwxSeqTextViewOptions bitmap retrieval
248  wxUnusedVar(name);
249  return wxNullBitmap;
250 ////@end CwxSeqTextViewOptions bitmap retrieval
251 }
252 
253 /*!
254  * Get icon resources
255  */
256 
257 wxIcon CwxSeqTextViewOptions::GetIconResource( const wxString& name )
258 {
259  // Icon retrieval
260 ////@begin CwxSeqTextViewOptions icon retrieval
261  wxUnusedVar(name);
262  return wxNullIcon;
263 ////@end CwxSeqTextViewOptions icon retrieval
264 }
265 
266 
268 {
269  // case for selected feature type
270  //m_Config->SetShowFeatAsLower(m_LowerCase->GetValue());
271 
272  //display coordinates
273  if (m_DispCoord->GetSelection() == 0) {
275  } else {
277  }
278 
279  // font size
280  string str(ToStdString(m_FontSize->GetStringSelection()));
281  int font_size = NStr::StringToInt (str);
282  m_Config->SetFontSize(font_size);
283 
284  // feat coloring choice
286 
287  // codon display choice
289 }
290 
291 
293 {
294  // case for selected feature type
295  // m_LowerCase->SetValue(m_Config->GetShowFeatAsLower());
296 
297  //display coordinates
299  m_DispCoord->SetSelection(0);
300  } else {
301  m_DispCoord->SetSelection(1);
302  }
303 
304  // font size
305  int font_size = m_Config->GetFontSize ();
306  string str = NStr::IntToString (font_size);
307  m_FontSize->SetStringSelection(ToWxString(str));
308 
309  // feat coloring choice
310  m_FeatColor->SetSelection (m_Config->GetFeatureColorationChoice ());
311 
312  // codon display choice
313  m_CodonDisplay->SetSelection (m_Config->GetCodonDrawChoice ());
314 
315 }
316 
317 
318 /*!
319 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_SEQTEXTDLG_OK
320 */
321 
323 {
324  x_SaveSettings();
325  EndModal(ID_SEQTEXTDLG_OK);
326 }
327 
328 
329 /*!
330 * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_SEQTEXTDLG_CANCEL
331 */
332 
334 {
335  EndModal(ID_SEQTEXTDLG_CANCEL);
336 }
337 
338 
339 
341 
342 
343 
344 
void SetFeatureColorationChoice(CSeqTextPaneConfig::EFeatureDisplayType ftype)
void SetShowAbsolutePosition(bool show_abs)
void SetFontSize(int font_size)
void SetCodonDrawChoice(CSeqTextPaneConfig::EFeatureDisplayType ftype)
CSeqTextPaneConfig::EFeatureDisplayType GetFeatureColorationChoice()
CSeqTextPaneConfig::EFeatureDisplayType GetCodonDrawChoice()
bool GetShowAbsolutePosition()
CwxSeqTextViewOptions()
Constructors.
static bool ShowToolTips()
Should we show tooltips?
void Init()
Initialises member variables.
void OnSeqtextdlgOkClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_SEQTEXTDLG_OK
CRef< CSeqTextConfig > m_Config
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
bool Create(wxWindow *parent, wxWindowID id=10000, const wxString &caption=_("Sequence Text View Options"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX)
Creation.
void CreateControls()
Creates the controls and sizers.
void OnSeqtextdlgCancelClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_SEQTEXTDLG_CANCEL
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
static const char * str(char *buf, int n)
Definition: stats.c:84
#define NULL
Definition: ncbistd.hpp:225
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
Definition: ncbistr.cpp:630
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5086
END_EVENT_TABLE()
const struct ncbi::grid::netcache::search::fields::SIZE size
static static static wxID_ANY
#define ID_SEQTEXTDLG_DISPLAYCOORD
#define ID_SEQTEXTDLG_OK
#define ID_SEQTEXTDLG_FEATCOLOR
#define ID_SEQTEXTDLG_CANCEL
#define ID_SEQTEXTDLG_CODONDISPLAY
#define ID_SEQTEXTDLG_FONTSIZE
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Wed Sep 04 15:01:21 2024 by modify_doxy.py rev. 669887