1 //**************************************************************************************************
2 //                                          PnlLblTxt.cpp                                          *
3 //                                         ---------------                                         *
4 // Started     : 2014-02-22                                                                        *
5 // Last Update : 2014-11-28                                                                        *
6 // Copyright   : (C) 2014 by MSWaters                                                              *
7 //**************************************************************************************************
8 
9 //**************************************************************************************************
10 //                                                                                                 *
11 //      This program is free software; you can redistribute it and/or modify it under the          *
12 //      terms of the GNU General Public License as published by the Free Software Foundation;      *
13 //      either version 3 of the License, or (at your option) any later version.                    *
14 //                                                                                                 *
15 //**************************************************************************************************
16 
17 #include "PnlLblTxt.hpp"
18 
19 //**************************************************************************************************
20 // Implement an event table.
21 
22 //wxBEGIN_EVENT_TABLE( PnlLblTxt, wxPanel )
23 
24 //  EVT_CHOICE( ID_TXTCTRL, PnlLblTxt::OnText )
25 
26 //wxEND_EVENT_TABLE( )
27 
28 //**************************************************************************************************
29 // Constructor.
30 
PnlLblTxt(void)31 PnlLblTxt::PnlLblTxt( void ) : wxPanel( )
32 {
33 }
34 
35 //**************************************************************************************************
36 // Destructor.
37 
~PnlLblTxt()38 PnlLblTxt::~PnlLblTxt( )
39 {
40 }
41 
42 //**************************************************************************************************
43 // Layout the display objects.
44 
DoLayout(void)45 void  PnlLblTxt::DoLayout( void )
46 {
47   wxBoxSizer * poSzr;
48   wxSizerFlags  oFlags;
49 
50   poSzr = new wxBoxSizer( wxHORIZONTAL );
51 
52   oFlags.Proportion( 1 );
53   oFlags.Border( wxTOP, 8 );
54   poSzr->Add( &m_oLblName, oFlags );
55 
56   oFlags.Proportion( 0 );
57   oFlags.Border( wxTOP, 0 );
58   poSzr->Add( &m_oTxtCtrl, oFlags );
59 
60   // Set the panel sizer and the min. & init. sizes as calculated by the sizer
61   SetSizer( poSzr );
62   poSzr->SetSizeHints( this );
63 }
64 
65 //**************************************************************************************************
66 // Create an instance of this object.
67 //
68 // Argument List :
69 //   poWin   - The parent window
70 //   oWinID  - The window identifier
71 //   iNameWd - The width of the name label   in pixels
72 //   iTextWd - The width of the text control in pixels
73 //   roPosn  - The position
74 //
75 // Return Values :
76 //   true  - Success
77 //   false - Failure
78 
bCreate(wxWindow * poWin,wxWindowID oWinID,int iNameWd,int iTextWd,const wxPoint & roPosn)79 bool  PnlLblTxt::bCreate( wxWindow * poWin, wxWindowID oWinID, int iNameWd, int iTextWd,
80                           const wxPoint & roPosn )
81 {
82   if( bIsCreated( ) )                              return( true );
83 
84   // Create the base class (wxPanel)
85   if( ! wxPanel::Create( poWin, oWinID, roPosn ) ) return( false );
86 
87   // Create the variable name label
88   m_oLblName.Create( this, ID_UNUSED, wxT("Unknown"), wxDefaultPosition,
89                      wxSize( iNameWd, GUI_CTRL_HT ), wxALIGN_LEFT );
90 
91   // Create the text control
92   m_oTxtCtrl.Create( this, ID_TXTCTRL, wxT("")      , wxDefaultPosition,
93                      wxSize( iTextWd, GUI_CTRL_HT ), wxTE_LEFT );
94 
95   // Layout the display objects
96   DoLayout( );
97 
98   return( true );
99 }
100 
101 //**************************************************************************************************
102 // Set the name label.
103 //
104 // Argument List :
105 //   rosName - The name of the variable
106 //
107 // Return Values :
108 //   Success - true
109 //   Failure - false
110 
bSetName(const wxString & rosName)111 bool  PnlLblTxt::bSetName( const wxString & rosName )
112 {
113   if( ! bIsCreated( ) )    return( false );
114   if( rosName.IsEmpty( ) ) return( false );
115 
116   m_oLblName.SetLabel( rosName );
117 
118   return( true );
119 }
120 
121 //**************************************************************************************************
122 // Set the text control contents.
123 //
124 // Argument List :
125 //   rosText - The text control contents
126 //
127 // Return Values :
128 //   Success - true
129 //   Failure - false
130 
bSetText(const wxString & rosText)131 bool  PnlLblTxt::bSetText( const wxString & rosText )
132 {
133   if( ! bIsCreated( ) ) return( false );
134 
135   m_oTxtCtrl.SetValue( rosText );
136 
137   return( true );
138 }
139 
140 //**************************************************************************************************
141 // Get the control contents as a string.
142 //
143 // Return Values :
144 //   A reference to the control string contents
145 
rosGetText(void)146 const  wxString & PnlLblTxt::rosGetText( void )
147 {
148   static  wxString  os1;
149 
150   os1 = m_oTxtCtrl.GetValue( );
151 
152   return( os1 );
153 }
154 
155 //**************************************************************************************************
156 //                                         Event Handlers                                          *
157 //**************************************************************************************************
158 // Choice control an item on the list is selected event handler.
159 //
160 // Argument List :
161 //   roEvtCmd - An object holding information about the event
162 /*
163 void  PnlLblTxt::OnText( wxCommandEvent & roEvtCmd )
164 {
165 }
166 */
167 //**************************************************************************************************
168