]> git.saurik.com Git - wxWidgets.git/blobdiff - src/univ/combobox.cpp
don't waste time initializing the memory of newly created wxImage before filling...
[wxWidgets.git] / src / univ / combobox.cpp
index 4f7263b30c95898eb3028d91d06af674ffc7ab89..494df2c0b84adea6972f7cd88dad4777e84a09c8 100644 (file)
@@ -17,7 +17,7 @@
 // headers
 // ----------------------------------------------------------------------------
 
 // headers
 // ----------------------------------------------------------------------------
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
     #pragma implementation "univcombobox.h"
 #endif
 
     #pragma implementation "univcombobox.h"
 #endif
 
@@ -93,7 +93,7 @@ public:
     }
 
 protected:
     }
 
 protected:
-    void OnButton(wxCommandEvent& event) { m_combo->ShowPopup(); }
+    void OnButton(wxCommandEvent& WXUNUSED(event)) { m_combo->ShowPopup(); }
 
     virtual wxSize DoGetBestClientSize() const
     {
 
     virtual wxSize DoGetBestClientSize() const
     {
@@ -123,9 +123,11 @@ public:
 
     // implement wxComboPopup methods
     virtual bool SetSelection(const wxString& value);
 
     // implement wxComboPopup methods
     virtual bool SetSelection(const wxString& value);
+    virtual void SetSelection(int n, bool select)
+        { wxListBox::SetSelection( n, select); };
     virtual wxControl *GetControl() { return this; }
     virtual void OnShow();
     virtual wxControl *GetControl() { return this; }
     virtual void OnShow();
-    virtual wxCoord wxComboListBox::GetBestWidth() const;
+    virtual wxCoord GetBestWidth() const;
 
 protected:
     // we shouldn't return height too big from here
 
 protected:
     // we shouldn't return height too big from here
@@ -278,7 +280,7 @@ wxComboControl::~wxComboControl()
 {
     // as the button and the text control are the parent's children and not
     // ours, we have to delete them manually - they are not deleted
 {
     // as the button and the text control are the parent's children and not
     // ours, we have to delete them manually - they are not deleted
-    // automatically by wxWindows when we're deleted
+    // automatically by wxWidgets when we're deleted
     delete m_btn;
     delete m_text;
 
     delete m_btn;
     delete m_text;
 
@@ -290,7 +292,7 @@ wxComboControl::~wxComboControl()
 // ----------------------------------------------------------------------------
 
 void wxComboControl::DoSetSize(int x, int y,
 // ----------------------------------------------------------------------------
 
 void wxComboControl::DoSetSize(int x, int y,
-                               int width, int height,
+                               int width, int WXUNUSED(height),
                                int sizeFlags)
 {
     // combo height is always fixed
                                int sizeFlags)
 {
     // combo height is always fixed
@@ -655,13 +657,44 @@ void wxComboBox::Init()
     m_lbox = (wxListBox *)NULL;
 }
 
     m_lbox = (wxListBox *)NULL;
 }
 
+wxComboBox::wxComboBox(wxWindow *parent,
+                       wxWindowID id,
+                       const wxString& value,
+                       const wxPoint& pos,
+                       const wxSize& size,
+                       const wxArrayString& choices,
+                       long style,
+                       const wxValidator& validator,
+                       const wxString& name)
+{
+    Init();
+
+    Create(parent, id, value, pos, size, choices, style, validator, name);
+}
+
+bool wxComboBox::Create(wxWindow *parent,
+                        wxWindowID id,
+                        const wxString& value,
+                        const wxPoint& pos,
+                        const wxSize& size,
+                        const wxArrayString& choices,
+                        long style,
+                        const wxValidator& validator,
+                        const wxString& name)
+{
+    wxCArrayString chs(choices);
+
+    return Create(parent, id, value, pos, size, chs.GetCount(),
+                  chs.GetStrings(), style, validator, name);
+}
+
 bool wxComboBox::Create(wxWindow *parent,
                         wxWindowID id,
                         const wxString& value,
                         const wxPoint& pos,
                         const wxSize& size,
                         int n,
 bool wxComboBox::Create(wxWindow *parent,
                         wxWindowID id,
                         const wxString& value,
                         const wxPoint& pos,
                         const wxSize& size,
                         int n,
-                        const wxString *choices,
+                        const wxString choices[],
                         long style,
                         const wxValidator& validator,
                         const wxString& name)
                         long style,
                         const wxValidator& validator,
                         const wxString& name)
@@ -825,6 +858,18 @@ int wxComboBox::DoAppend(const wxString& item)
     return GetLBox()->Append(item);
 }
 
     return GetLBox()->Append(item);
 }
 
+int wxComboBox::DoInsert(const wxString& item, int pos)
+{
+    wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list"));
+    wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index"));
+
+    if (pos == GetCount())
+        return DoAppend(item);
+
+    GetLBox()->Insert(item, pos);
+    return pos;
+}
+
 void wxComboBox::DoSetItemClientData(int n, void* clientData)
 {
     GetLBox()->SetClientData(n, clientData);
 void wxComboBox::DoSetItemClientData(int n, void* clientData)
 {
     GetLBox()->SetClientData(n, clientData);