| 1 | ///////////////////////////////////////////////////////////////////////////// |
| 2 | // Name: choice.cpp |
| 3 | // Purpose: wxChoice |
| 4 | // Author: AUTHOR |
| 5 | // Modified by: |
| 6 | // Created: ??/??/98 |
| 7 | // RCS-ID: $Id$ |
| 8 | // Copyright: (c) AUTHOR |
| 9 | // Licence: wxWindows licence |
| 10 | ///////////////////////////////////////////////////////////////////////////// |
| 11 | |
| 12 | #ifdef __GNUG__ |
| 13 | #pragma implementation "choice.h" |
| 14 | #endif |
| 15 | |
| 16 | // For compilers that support precompilation, includes "wx.h". |
| 17 | #include "wx/choice.h" |
| 18 | |
| 19 | IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl) |
| 20 | |
| 21 | bool wxChoice::Create(wxWindow *parent, wxWindowID id, |
| 22 | const wxPoint& pos, |
| 23 | const wxSize& size, |
| 24 | int n, const wxString choices[], |
| 25 | long style, |
| 26 | const wxValidator& validator, |
| 27 | const wxString& name) |
| 28 | { |
| 29 | SetName(name); |
| 30 | SetValidator(validator); |
| 31 | m_noStrings = n; |
| 32 | m_windowStyle = style; |
| 33 | |
| 34 | if (parent) parent->AddChild(this); |
| 35 | |
| 36 | if ( id == -1 ) |
| 37 | m_windowId = (int)NewControlId(); |
| 38 | else |
| 39 | m_windowId = id; |
| 40 | |
| 41 | // TODO: create choice control |
| 42 | return FALSE; |
| 43 | } |
| 44 | |
| 45 | void wxChoice::Append(const wxString& item) |
| 46 | { |
| 47 | // TODO |
| 48 | m_noStrings ++; |
| 49 | } |
| 50 | |
| 51 | void wxChoice::Delete(int n) |
| 52 | { |
| 53 | // TODO |
| 54 | m_noStrings --; |
| 55 | } |
| 56 | |
| 57 | void wxChoice::Clear() |
| 58 | { |
| 59 | // TODO |
| 60 | m_noStrings = 0; |
| 61 | } |
| 62 | |
| 63 | int wxChoice::GetSelection() const |
| 64 | { |
| 65 | // TODO |
| 66 | return 0; |
| 67 | } |
| 68 | |
| 69 | void wxChoice::SetSelection(int n) |
| 70 | { |
| 71 | // TODO |
| 72 | } |
| 73 | |
| 74 | int wxChoice::FindString(const wxString& s) const |
| 75 | { |
| 76 | // TODO |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | wxString wxChoice::GetString(int n) const |
| 81 | { |
| 82 | // TODO |
| 83 | return wxString(""); |
| 84 | } |
| 85 | |
| 86 | void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags) |
| 87 | { |
| 88 | // TODO |
| 89 | } |
| 90 | |
| 91 | wxString wxChoice::GetStringSelection () const |
| 92 | { |
| 93 | int sel = GetSelection (); |
| 94 | if (sel > -1) |
| 95 | return wxString(this->GetString (sel)); |
| 96 | else |
| 97 | return wxString(""); |
| 98 | } |
| 99 | |
| 100 | bool wxChoice::SetStringSelection (const wxString& s) |
| 101 | { |
| 102 | int sel = FindString (s); |
| 103 | if (sel > -1) |
| 104 | { |
| 105 | SetSelection (sel); |
| 106 | return TRUE; |
| 107 | } |
| 108 | else |
| 109 | return FALSE; |
| 110 | } |
| 111 | |
| 112 | void wxChoice::Command(wxCommandEvent & event) |
| 113 | { |
| 114 | SetSelection (event.GetInt()); |
| 115 | ProcessCommand (event); |
| 116 | } |
| 117 | |