NCBI C++ ToolKit
formattedqual_panel.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: formattedqual_panel.hpp 41013 2018-05-09 21:07:35Z 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: Colleen Bollin
27  */
28 #ifndef _CFORMATTEDQUALPANEL_H_
29 #define _CFORMATTEDQUALPANEL_H_
30 
31 #include <corelib/ncbistd.hpp>
32 #include <corelib/ncbiobj.hpp>
35 
36 /*!
37  * Includes
38  */
39 
40 ////@begin includes
41 ////@end includes
42 
43 #include <wx/panel.h>
44 #include <wx/frame.h>
45 #include <wx/sizer.h>
46 #include <wx/bitmap.h>
47 #include <wx/icon.h>
48 #include <wx/choice.h>
49 #include <wx/textctrl.h>
50 #include <wx/stattext.h>
51 #include <wx/valtext.h>
52 #include <wx/hyperlink.h>
53 
54 /*!
55  * Forward declarations
56  */
57 
58 ////@begin forward declarations
59 ////@end forward declarations
60 
62 
63 
64 class CQualListItemPanel : public wxPanel
65 {
66 public:
67  virtual void OnChildChange(wxWindow* wnd) {};
68  virtual void NotifyParentOfChange();
69  static void RemoveRepresentedQuals (objects::CSeq_feat& feat, const string& qual_name);
70  virtual void GetDimensions (int *width, int *height) { if (width != NULL) *width = -1; if (height != NULL) *height = -1; };
71 
72 protected:
73  virtual void x_AdjustForControl (CQualListItemPanel* panel, wxHyperlinkCtrl* itemHyperlinkCtrl);
74 
80  int m_NumRows;
82 };
83 
84 
85 inline
86 void CQualListItemPanel::x_AdjustForControl (CQualListItemPanel* panel, wxHyperlinkCtrl* itemHyperlinkCtrl)
87 {
88  int height, width;
89  panel->GetDimensions(&width, &height);
90  if (width < 0 || height < 0) {
91  panel->GetSize(&width, &height);
92  }
93  m_TotalHeight += height;
94  if (height > 0 && (m_ScrollRate == 0 || height < m_ScrollRate)) {
95  m_ScrollRate = height;
96  }
97  if (height > m_MinHeight) {
98  m_MinHeight = height;
99  }
100  int d_width, d_height;
101  int scroll_width = 20;
102  itemHyperlinkCtrl->GetSize(&d_width, &d_height);
103  int new_width = width + d_width + scroll_width;
104  if (new_width > m_TotalWidth) {
105  m_TotalWidth = new_width;
106  }
107  m_NumRows++;
108 }
109 
110 
111 
112 
113 inline
115 {
116  wxWindow* parent = this->GetParent();
117 
118  CQualListItemPanel* listpanel = dynamic_cast<CQualListItemPanel*>(parent);
119 
120  while (parent && !listpanel) {
121  parent = parent->GetParent();
122  listpanel = dynamic_cast<CQualListItemPanel*>(parent);
123  }
124 
125  if (!listpanel) {
126  return;
127  }
128  listpanel->OnChildChange((wxWindow*)this);
129 }
130 
131 
132 inline
133 void CQualListItemPanel::RemoveRepresentedQuals (objects::CSeq_feat& feat, const string& qual_name)
134 {
135  objects::CSeq_feat::TQual::iterator qual = feat.SetQual().begin();
136  while (qual != feat.SetQual().end()) {
137  if ((*qual)->IsSetQual() && NStr::EqualNocase((*qual)->GetQual(), qual_name)) {
138  qual = feat.SetQual().erase(qual);
139  } else {
140  qual++;
141  }
142  }
143 }
144 
145 
146 /*!
147  * CFormattedQualPanel class declaration
148  */
149 
151 {
152 public:
153 
154  virtual void SetValue(string val) {};
155  virtual string GetValue() { return ""; };
156  virtual void OnChildChange(wxWindow* wnd) {};
157  virtual void GetDimensions (int *width, int *height) { if (width != NULL) *width = -1; if (height != NULL) *height = -1; };
158 };
159 
160 
162 
163 #endif
164 // _CFORMATTEDQUALPANEL_H_
virtual void OnChildChange(wxWindow *wnd)
virtual void GetDimensions(int *width, int *height)
virtual void SetValue(string val)
virtual void GetDimensions(int *width, int *height)
virtual void NotifyParentOfChange()
static void RemoveRepresentedQuals(objects::CSeq_feat &feat, const string &qual_name)
virtual void x_AdjustForControl(CQualListItemPanel *panel, wxHyperlinkCtrl *itemHyperlinkCtrl)
virtual void OnChildChange(wxWindow *wnd)
Include a standard set of the NCBI C++ Toolkit most basic headers.
#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
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5347
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Modified on Fri Sep 20 14:58:12 2024 by modify_doxy.py rev. 669887