![]() |
wxIScan
|
The text input box with history for an options dialog. More...
#include <wxoptionsdialog.h>
Public Member Functions | |
| wxOptionComboBox (const wxString &strText, wxString *pstrValue, int nWidth=400) | |
| Default constructor. | |
| virtual | ~wxOptionComboBox () |
| Virtual destructor. | |
| virtual bool | AddToSizer (wxBoxSizer *poSizer) |
| ... | |
| virtual void | Setup (wxWindow *poWindow, int nId) |
| ... | |
| virtual void | StoreValue () |
| Store the value in the connected variables. | |
Protected Attributes | |
| wxWindow * | m_poWindow |
| ... | |
| wxString | m_strText |
| ... | |
| wxString * | m_pstrValue |
| ... | |
| wxComboBox * | m_poComboBox |
| ComboBox control. | |
| int | m_nWidth |
| ... | |
| int | m_nId |
| ID of the control (for the config section). | |
| wxArrayString | m_astrValueHistory |
| Array of historical entries for the drop down list. | |
The text input box with history for an options dialog.
This class represents a text option with history (wxComboBox) used in an options dialog.
Definition at line 150 of file wxoptionsdialog.h.
| wxOptionComboBox::wxOptionComboBox | ( | const wxString & | strText, |
| wxString * | pstrValue, | ||
| int | nWidth = 400 |
||
| ) |
Default constructor.
| strText | ... |
| pstrValue | ... |
| nWidth | ... |
Definition at line 143 of file wxoptionsdialog.cpp.
References m_nWidth, m_pstrValue, and m_strText.
{
m_strText= strText;
m_pstrValue= pstrValue;
m_nWidth= nWidth;
}
| wxOptionComboBox::~wxOptionComboBox | ( | ) | [virtual] |
Virtual destructor.
Definition at line 150 of file wxoptionsdialog.cpp.
References m_astrValueHistory, and m_nId.
{
// Get the global configuration object and set path.
wxConfigBase *poConfig = wxConfigBase::Get();
poConfig->SetPath( wxString::Format( wxT( "/wxOptionComboBox/%d" ), m_nId ) );
// Write history to config (file/registry).
int nCount= m_astrValueHistory.GetCount();
for( int i= 0; i < nCount; i++ )
{
poConfig->Write( wxString::Format( wxT( "Text%d" ), i ), m_astrValueHistory[i] );
}
}
| bool wxOptionComboBox::AddToSizer | ( | wxBoxSizer * | poSizer | ) | [virtual] |
...
Implements wxOptionBase.
Definition at line 165 of file wxoptionsdialog.cpp.
References m_poComboBox, m_poWindow, and m_strText.
{
if( !m_poComboBox )
{
return false;
}
wxBoxSizer *poHSizer= new wxBoxSizer( wxHORIZONTAL );
if( !poHSizer )
{
return false;
}
if( !poHSizer->Add( new wxStaticText( m_poWindow, wxID_ANY, m_strText ), 0,
wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT )
|| !poHSizer->Add( m_poComboBox, 0,
wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT )
)
{
delete poHSizer;
return false;
}
return (bool)poSizer->Add( poHSizer, 0, wxALIGN_RIGHT | wxALL, 1 );
}
| void wxOptionComboBox::Setup | ( | wxWindow * | poWindow, |
| int | nId | ||
| ) | [virtual] |
...
Implements wxOptionBase.
Definition at line 190 of file wxoptionsdialog.cpp.
References m_astrValueHistory, m_nId, m_nWidth, m_poComboBox, m_poWindow, and m_pstrValue.
{
// ...
m_poWindow= poWindow;
m_nId= nId;
// Get the global configuration object and set path.
wxConfigBase *poConfig = wxConfigBase::Get();
poConfig->SetPath( wxString::Format( wxT( "/wxOptionComboBox/%d" ), m_nId ) );
// ...
wxString strTextId;
int i= 0;
for( strTextId.Printf( wxT( "Text%d" ), i );
poConfig->HasEntry( strTextId );
i++, strTextId.Printf( wxT( "Text%d" ), i ) )
{
wxString strTemp= poConfig->Read( strTextId, wxT( "" ) );
m_astrValueHistory.Add( strTemp );
}
// Create the combobox.
m_poComboBox= new wxComboBox( m_poWindow, m_nId, *m_pstrValue, wxDefaultPosition, wxSize( m_nWidth, -1 ),
m_astrValueHistory, wxCB_DROPDOWN | wxCB_SORT );
if( !m_poComboBox )
{
wxLogError( _( "Cannot create option combobox." ) );
return;
}
}
| void wxOptionComboBox::StoreValue | ( | ) | [virtual] |
Store the value in the connected variables.
Implements wxOptionBase.
Definition at line 222 of file wxoptionsdialog.cpp.
References m_astrValueHistory, m_poComboBox, and m_pstrValue.
{
// Get the text from the edit control.
(*m_pstrValue)= m_poComboBox->GetValue();
// Check if the text is already in the history list and add it if not.
int nCount= m_astrValueHistory.GetCount();
int i= 0;
for( ; i < nCount; i++ )
{
if( m_astrValueHistory[i] == (*m_pstrValue) )
{
return;
}
}
m_astrValueHistory.Add( (*m_pstrValue) );
}
wxArrayString wxOptionComboBox::m_astrValueHistory [protected] |
Array of historical entries for the drop down list.
Definition at line 176 of file wxoptionsdialog.h.
Referenced by Setup(), StoreValue(), and ~wxOptionComboBox().
int wxOptionComboBox::m_nId [protected] |
ID of the control (for the config section).
Definition at line 175 of file wxoptionsdialog.h.
Referenced by Setup(), and ~wxOptionComboBox().
int wxOptionComboBox::m_nWidth [protected] |
...
Definition at line 174 of file wxoptionsdialog.h.
Referenced by Setup(), and wxOptionComboBox().
wxComboBox* wxOptionComboBox::m_poComboBox [protected] |
ComboBox control.
Definition at line 173 of file wxoptionsdialog.h.
Referenced by AddToSizer(), Setup(), and StoreValue().
wxWindow* wxOptionComboBox::m_poWindow [protected] |
wxString* wxOptionComboBox::m_pstrValue [protected] |
...
Definition at line 172 of file wxoptionsdialog.h.
Referenced by Setup(), StoreValue(), and wxOptionComboBox().
wxString wxOptionComboBox::m_strText [protected] |
...
Definition at line 171 of file wxoptionsdialog.h.
Referenced by AddToSizer(), and wxOptionComboBox().