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

Go to the SVN repository for this file.

1 /* $Id: unpublished_panel.cpp 37431 2017-01-10 16:55:15Z filippov $
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: Roman Katargin
27  */
28 
29 
30 #include <ncbi_pch.hpp>
32 
34 ////@begin includes
35 ////@end includes
36 ////@begin includes
37 ////@end includes
38 
40 
41 #include <wx/sizer.h>
42 #include <wx/bitmap.h>
43 #include <wx/icon.h>
44 #include <wx/stattext.h>
45 #include <wx/button.h>
46 #include <wx/utils.h>
47 #include <wx/uri.h>
48 
51 
52 ////@begin XPM images
53 ////@end XPM images
54 
55 
56 /*
57  * CUnpublishedPanel type definition
58  */
59 
60 IMPLEMENT_DYNAMIC_CLASS( CUnpublishedPanel, wxPanel )
61 
62 
63 /*
64  * CUnpublishedPanel event table definition
65  */
66 
67 BEGIN_EVENT_TABLE( CUnpublishedPanel, wxPanel )
68 
69 ////@begin CUnpublishedPanel event table entries
71 ////@end CUnpublishedPanel event table entries
72 
74 
75 
76 /*
77  * CUnpublishedPanel constructors
78  */
79 
81 {
82  Init();
83 }
84 
85 CUnpublishedPanel::CUnpublishedPanel( wxWindow* parent, const string &title,
86  wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) :
87  m_title(title)
88 {
89  Init();
90  Create(parent, id, pos, size, style);
91 }
92 
93 
94 /*
95  * CUnpublishedPanel creator
96  */
97 
98 bool CUnpublishedPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
99 {
100 ////@begin CUnpublishedPanel creation
101  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
102  wxPanel::Create( parent, id, pos, size, style );
103 
104  CreateControls();
105  if (GetSizer())
106  {
107  GetSizer()->SetSizeHints(this);
108  }
109  Centre();
110 ////@end CUnpublishedPanel creation
111  return true;
112 }
113 
114 
115 /*
116  * CUnpublishedPanel destructor
117  */
118 
120 {
121 ////@begin CUnpublishedPanel destruction
122 ////@end CUnpublishedPanel destruction
123 }
124 
125 
126 /*
127  * Member initialisation
128  */
129 
131 {
132 ////@begin CUnpublishedPanel member initialisation
133  m_TextCtrl = NULL;
134 ////@end CUnpublishedPanel member initialisation
135 }
136 
137 
138 /*
139  * Control creation for CUnpublishedPanel
140  */
141 
143 {
144 ////@begin CUnpublishedPanel content construction
145  CUnpublishedPanel* itemPanel1 = this;
146 
147  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
148  itemPanel1->SetSizer(itemBoxSizer2);
149 
150  wxStaticText* itemStaticText3 = new wxStaticText( itemPanel1, wxID_STATIC, _("Tentative title for manuscript"), wxDefaultPosition, wxDefaultSize, 0 );
151  itemBoxSizer2->Add(itemStaticText3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
152 
153  m_TextCtrl = new CRichTextCtrl(itemPanel1, ID_UNPUB_TITLE, wxString(m_title), wxDefaultPosition, wxSize(400, 85), wxTE_MULTILINE);
154  itemBoxSizer2->Add(m_TextCtrl, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
155 
156  wxButton* itemButton1 = new wxButton( itemPanel1, ID_UNPUB_TITLE_SEARCH, _("Search Title on the Web"), wxDefaultPosition, wxDefaultSize, 0 );
157  itemBoxSizer2->Add(itemButton1, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
158 
159 ////@end CUnpublishedPanel content construction
160 
161 }
162 
163 
164 /*
165  * Should we show tooltips?
166  */
167 
169 {
170  return true;
171 }
172 
173 /*
174  * Get bitmap resources
175  */
176 
177 wxBitmap CUnpublishedPanel::GetBitmapResource( const wxString& name )
178 {
179  // Bitmap retrieval
180 ////@begin CUnpublishedPanel bitmap retrieval
181  wxUnusedVar(name);
182  return wxNullBitmap;
183 ////@end CUnpublishedPanel bitmap retrieval
184 }
185 
186 /*
187  * Get icon resources
188  */
189 
190 wxIcon CUnpublishedPanel::GetIconResource( const wxString& name )
191 {
192  // Icon retrieval
193 ////@begin CUnpublishedPanel icon retrieval
194  wxUnusedVar(name);
195  return wxNullIcon;
196 ////@end CUnpublishedPanel icon retrieval
197 }
198 
199 void CUnpublishedPanel::OnSearchTitle( wxCommandEvent& event )
200 {
201  wxString title = m_TextCtrl->GetValue();
202  if (title.IsEmpty())
203  return;
204 
205  wxURI google_url (wxT("http://www.google.com/search?q=") + title);
206  wxString google_encoded_url = google_url.BuildURI();
207  wxLaunchDefaultBrowser(google_encoded_url, 0); // wxBROWSER_NEW_WINDOW
208  wxSleep(3);
209  wxURI pubmed_url (wxT("https://www.ncbi.nlm.nih.gov/pubmed/?term=") + title);
210  wxString pubmed_encoded_url = pubmed_url.BuildURI();
211  wxLaunchDefaultBrowser(pubmed_encoded_url, 0); // wxBROWSER_NEW_WINDOW
212 }
213 
214 
215 void CUnpublishedPanel::SetTitle(const string &title)
216 {
217  m_TextCtrl->SetValue(wxString(title));
218 }
219 
221 {
222  return ToAsciiStdString(m_TextCtrl->GetValue());
223 }
224 
CRichTextCtrl - a wrapper for wxRichTextCtrl that handles additional keyboard events (such as Clipboa...
void CreateControls()
Creates the controls and sizers.
bool Create(wxWindow *parent, wxWindowID id=10011, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
void Init()
Initialises member variables.
CUnpublishedPanel()
Constructors.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
CRichTextCtrl * m_TextCtrl
void SetTitle(const string &title)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
void OnSearchTitle(wxCommandEvent &event)
static bool ShowToolTips()
Should we show tooltips?
~CUnpublishedPanel()
Destructor.
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
#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()
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
USING_SCOPE(objects)
#define ID_UNPUB_TITLE
#define ID_UNPUB_TITLE_SEARCH
string ToAsciiStdString(const wxString &input)
Definition: wx_utils.hpp:166
Modified on Fri Sep 20 14:57:44 2024 by modify_doxy.py rev. 669887