]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/bmpcombobox.cpp
return 0 (meaning the file is not seekable, as the docs now explain) instead of 4KB...
[wxWidgets.git] / samples / widgets / bmpcombobox.cpp
index e67dc103bbd22c9dd69c21520aedf05928049ba9..f5e73f7331aaf8c79cdcae85533068c4bbb96208 100644 (file)
 #include "wx/sizer.h"
 #include "wx/icon.h"
 #include "wx/dir.h"
 #include "wx/sizer.h"
 #include "wx/icon.h"
 #include "wx/dir.h"
+#include "wx/msgdlg.h"
 #include "wx/filename.h"
 #include "wx/image.h"
 #include "wx/imaglist.h"
 #include "wx/bmpcbox.h"
 
 #include "wx/filename.h"
 #include "wx/image.h"
 #include "wx/imaglist.h"
 #include "wx/bmpcbox.h"
 
-
+#include "itemcontainer.h"
 #include "widgets.h"
 
 #include "icons/bmpcombobox.xpm"
 
 // Images loaded from file are reduced this width and height, if larger
 #include "widgets.h"
 
 #include "icons/bmpcombobox.xpm"
 
 // Images loaded from file are reduced this width and height, if larger
-#define IMG_SIZE_TRUNC  150
+#define IMG_SIZE_TRUNC  256
 
 
 // ----------------------------------------------------------------------------
 
 
 // ----------------------------------------------------------------------------
@@ -82,20 +83,29 @@ enum
     BitmapComboBoxPage_Delete,
     BitmapComboBoxPage_DeleteText,
     BitmapComboBoxPage_DeleteSel,
     BitmapComboBoxPage_Delete,
     BitmapComboBoxPage_DeleteText,
     BitmapComboBoxPage_DeleteSel,
-    BitmapComboBoxPage_Combo
+    BitmapComboBoxPage_Combo,
+    BitmapComboBoxPage_ContainerTests
 };
 
 };
 
+// kinds of comboboxes
+enum
+{
+    ComboKind_Default,
+    ComboKind_Simple,
+    ComboKind_DropDown
+};
 
 // ----------------------------------------------------------------------------
 // BitmapComboBoxWidgetsPage
 // ----------------------------------------------------------------------------
 
 
 // ----------------------------------------------------------------------------
 // BitmapComboBoxWidgetsPage
 // ----------------------------------------------------------------------------
 
-class BitmapComboBoxWidgetsPage : public WidgetsPage
+class BitmapComboBoxWidgetsPage : public ItemContainerWidgetsPage
 {
 public:
     BitmapComboBoxWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
 
     virtual wxControl *GetWidget() const { return m_combobox; }
 {
 public:
     BitmapComboBoxWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
 
     virtual wxControl *GetWidget() const { return m_combobox; }
+    virtual wxItemContainer* GetContainer() const { return m_combobox; }
     virtual void RecreateWidget() { CreateCombo(); }
 
     // lazy creation of the content
     virtual void RecreateWidget() { CreateCombo(); }
 
     // lazy creation of the content
@@ -142,7 +152,6 @@ protected:
 
     // helpers for creating bitmaps
     wxBitmap CreateBitmap(const wxColour& colour);
 
     // helpers for creating bitmaps
     wxBitmap CreateBitmap(const wxColour& colour);
-    wxBitmap CreateRandomBitmap(wxString* pStr);
     wxBitmap LoadBitmap(const wxString& filepath);
     wxBitmap QueryBitmap(wxString* pStr);
 
     wxBitmap LoadBitmap(const wxString& filepath);
     wxBitmap QueryBitmap(wxString* pStr);
 
@@ -152,13 +161,19 @@ protected:
                                               wxWindowID id,
                                               wxTextCtrl **ppText);
 
                                               wxWindowID id,
                                               wxTextCtrl **ppText);
 
+#if wxUSE_IMAGE
+    void RescaleImage(wxImage& image, int w, int h);
+#endif
+
     // the controls
     // ------------
 
     // the controls
     // ------------
 
+    // the sel mode radiobox
+    wxRadioBox *m_radioKind;
+
     // the checkboxes for styles
     wxCheckBox *m_chkSort,
     // the checkboxes for styles
     wxCheckBox *m_chkSort,
-               *m_chkReadonly,
-               *m_chkScaleimages;
+               *m_chkReadonly;
 
     // the combobox itself and the sizer it is in
     wxBitmapComboBox *m_combobox;
 
     // the combobox itself and the sizer it is in
     wxBitmapComboBox *m_combobox;
@@ -192,6 +207,7 @@ BEGIN_EVENT_TABLE(BitmapComboBoxWidgetsPage, WidgetsPage)
     EVT_BUTTON(BitmapComboBoxPage_AddMany, BitmapComboBoxWidgetsPage::OnButtonAddMany)
     EVT_BUTTON(BitmapComboBoxPage_LoadFromFile, BitmapComboBoxWidgetsPage::OnButtonLoadFromFile)
     EVT_BUTTON(BitmapComboBoxPage_SetFromFile, BitmapComboBoxWidgetsPage::OnButtonSetFromFile)
     EVT_BUTTON(BitmapComboBoxPage_AddMany, BitmapComboBoxWidgetsPage::OnButtonAddMany)
     EVT_BUTTON(BitmapComboBoxPage_LoadFromFile, BitmapComboBoxWidgetsPage::OnButtonLoadFromFile)
     EVT_BUTTON(BitmapComboBoxPage_SetFromFile, BitmapComboBoxWidgetsPage::OnButtonSetFromFile)
+    EVT_BUTTON(BitmapComboBoxPage_ContainerTests, ItemContainerWidgetsPage::OnButtonTestItemContainer)
 
     EVT_TEXT_ENTER(BitmapComboBoxPage_InsertText, BitmapComboBoxWidgetsPage::OnButtonInsert)
     EVT_TEXT(BitmapComboBoxPage_ChangeHeight, BitmapComboBoxWidgetsPage::OnTextChangeHeight)
 
     EVT_TEXT_ENTER(BitmapComboBoxPage_InsertText, BitmapComboBoxWidgetsPage::OnButtonInsert)
     EVT_TEXT(BitmapComboBoxPage_ChangeHeight, BitmapComboBoxWidgetsPage::OnTextChangeHeight)
@@ -221,24 +237,32 @@ END_EVENT_TABLE()
 // implementation
 // ============================================================================
 
 // implementation
 // ============================================================================
 
-
+#if defined(__WXMSW__) || defined(__WXGTK__)
+    #define NATIVE_OR_GENERIC_CTRLS     NATIVE_CTRLS
+#else
+    #define NATIVE_OR_GENERIC_CTRLS     GENERIC_CTRLS
+#endif
 
 IMPLEMENT_WIDGETS_PAGE(BitmapComboBoxWidgetsPage, _T("BitmapCombobox"),
 
 IMPLEMENT_WIDGETS_PAGE(BitmapComboBoxWidgetsPage, _T("BitmapCombobox"),
-                       GENERIC_CTRLS | WITH_ITEMS_CTRLS | COMBO_CTRLS
+                       NATIVE_OR_GENERIC_CTRLS | WITH_ITEMS_CTRLS | COMBO_CTRLS
                        );
 
 
 BitmapComboBoxWidgetsPage::BitmapComboBoxWidgetsPage(WidgetsBookCtrl *book,
                                              wxImageList *imaglist)
                        );
 
 
 BitmapComboBoxWidgetsPage::BitmapComboBoxWidgetsPage(WidgetsBookCtrl *book,
                                              wxImageList *imaglist)
-                  : WidgetsPage(book, imaglist, bmpcombobox_xpm)
+                  : ItemContainerWidgetsPage(book, imaglist, bmpcombobox_xpm)
 {
     // init everything
     m_chkSort =
 {
     // init everything
     m_chkSort =
-    m_chkReadonly =
-    m_chkScaleimages = (wxCheckBox *)NULL;
+    m_chkReadonly = NULL;
+
+    m_combobox = NULL;
+    m_sizerCombo = NULL;
 
 
-    m_combobox = (wxBitmapComboBox *)NULL;
-    m_sizerCombo = (wxSizer *)NULL;
+    m_textInsert =
+    m_textChangeHeight =
+    m_textChange =
+    m_textDelete = NULL;
 }
 
 // create a sizer containing a label and a small text ctrl
 }
 
 // create a sizer containing a label and a small text ctrl
@@ -249,7 +273,7 @@ wxSizer *BitmapComboBoxWidgetsPage::CreateSizerWithSmallTextAndLabel(const wxStr
     wxControl* control = new wxStaticText(this, wxID_ANY, label);
     wxSizer *sizerRow = new wxBoxSizer(wxHORIZONTAL);
     wxTextCtrl *text = new wxTextCtrl(this, id, wxEmptyString,
     wxControl* control = new wxStaticText(this, wxID_ANY, label);
     wxSizer *sizerRow = new wxBoxSizer(wxHORIZONTAL);
     wxTextCtrl *text = new wxTextCtrl(this, id, wxEmptyString,
-        wxDefaultPosition, wxSize(50,-1), wxTE_PROCESS_ENTER);
+        wxDefaultPosition, wxSize(50,wxDefaultCoord), wxTE_PROCESS_ENTER);
 
     sizerRow->Add(control, 0, wxRIGHT | wxALIGN_CENTRE_VERTICAL, 5);
     sizerRow->Add(text, 1, wxFIXED_MINSIZE | wxLEFT | wxALIGN_CENTRE_VERTICAL, 5);
 
     sizerRow->Add(control, 0, wxRIGHT | wxALIGN_CENTRE_VERTICAL, 5);
     sizerRow->Add(text, 1, wxFIXED_MINSIZE | wxLEFT | wxALIGN_CENTRE_VERTICAL, 5);
@@ -268,7 +292,6 @@ void BitmapComboBoxWidgetsPage::CreateContent()
        miscellaneous combobox operations and the pane containing the combobox
        itself to the right
     */
        miscellaneous combobox operations and the pane containing the combobox
        itself to the right
     */
-    //wxTextCtrl *text;
     wxSizer *sizerRow;
 
     wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
     wxSizer *sizerRow;
 
     wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
@@ -278,6 +301,20 @@ void BitmapComboBoxWidgetsPage::CreateContent()
     // left pane - style box
     wxStaticBox *box = new wxStaticBox(this, wxID_ANY, _T("&Set style"));
 
     // left pane - style box
     wxStaticBox *box = new wxStaticBox(this, wxID_ANY, _T("&Set style"));
 
+
+    // should be in sync with ComboKind_XXX values
+    static const wxString kinds[] =
+    {
+        _T("default"),
+        _T("simple"),
+        _T("drop down"),
+    };
+
+    m_radioKind = new wxRadioBox(this, wxID_ANY, _T("Combobox &kind:"),
+                                 wxDefaultPosition, wxDefaultSize,
+                                 WXSIZEOF(kinds), kinds,
+                                 1, wxRA_SPECIFY_COLS);
+
     wxSizer *sizerStyle = new wxStaticBoxSizer(box, wxVERTICAL);
 
     m_chkSort = CreateCheckBoxAndAddToSizer(sizerStyle, _T("&Sort items"));
     wxSizer *sizerStyle = new wxStaticBoxSizer(box, wxVERTICAL);
 
     m_chkSort = CreateCheckBoxAndAddToSizer(sizerStyle, _T("&Sort items"));
@@ -287,18 +324,17 @@ void BitmapComboBoxWidgetsPage::CreateContent()
     sizerStyle->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 3);
 
     sizerLeft->Add(sizerStyle, 0, wxGROW | wxALIGN_CENTRE_HORIZONTAL);
     sizerStyle->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 3);
 
     sizerLeft->Add(sizerStyle, 0, wxGROW | wxALIGN_CENTRE_HORIZONTAL);
+    sizerLeft->Add(m_radioKind, 0, wxGROW | wxALL, 5);
 
     // left pane - other options box
     box = new wxStaticBox(this, wxID_ANY, _T("Demo options"));
 
     wxSizer *sizerOptions = new wxStaticBoxSizer(box, wxVERTICAL);
 
 
     // left pane - other options box
     box = new wxStaticBox(this, wxID_ANY, _T("Demo options"));
 
     wxSizer *sizerOptions = new wxStaticBoxSizer(box, wxVERTICAL);
 
-    m_chkScaleimages = CreateCheckBoxAndAddToSizer(sizerOptions, _T("&Scale loaded images to fit"));
-
     sizerRow = CreateSizerWithSmallTextAndLabel(_T("Control &height:"),
                                                 BitmapComboBoxPage_ChangeHeight,
                                                 &m_textChangeHeight);
     sizerRow = CreateSizerWithSmallTextAndLabel(_T("Control &height:"),
                                                 BitmapComboBoxPage_ChangeHeight,
                                                 &m_textChangeHeight);
-    m_textChangeHeight->SetSize(20, -1);
+    m_textChangeHeight->SetSize(20, wxDefaultCoord);
     sizerOptions->Add(sizerRow, 0, wxALL | wxFIXED_MINSIZE /*| wxGROW*/, 5);
 
     sizerLeft->Add(sizerOptions, 0, wxGROW | wxALIGN_CENTRE_HORIZONTAL | wxTOP, 2);
     sizerOptions->Add(sizerRow, 0, wxALL | wxFIXED_MINSIZE /*| wxGROW*/, 5);
 
     sizerLeft->Add(sizerOptions, 0, wxGROW | wxALIGN_CENTRE_HORIZONTAL | wxTOP, 2);
@@ -308,6 +344,9 @@ void BitmapComboBoxWidgetsPage::CreateContent()
         _T("&Change wxBitmapComboBox contents"));
     wxSizer *sizerMiddle = new wxStaticBoxSizer(box2, wxVERTICAL);
 
         _T("&Change wxBitmapComboBox contents"));
     wxSizer *sizerMiddle = new wxStaticBoxSizer(box2, wxVERTICAL);
 
+    btn = new wxButton(this, BitmapComboBoxPage_ContainerTests, _T("Run &tests"));
+    sizerMiddle->Add(btn, 0, wxALL | wxGROW, 5);
+
 #if wxUSE_IMAGE
     btn = new wxButton(this, BitmapComboBoxPage_AddWidgetIcons, _T("Add &widget icons"));
     sizerMiddle->Add(btn, 0, wxALL | wxGROW, 5);
 #if wxUSE_IMAGE
     btn = new wxButton(this, BitmapComboBoxPage_AddWidgetIcons, _T("Add &widget icons"));
     sizerMiddle->Add(btn, 0, wxALL | wxGROW, 5);
@@ -370,8 +409,6 @@ void BitmapComboBoxWidgetsPage::CreateContent()
     Reset();
 
     SetSizer(sizerTop);
     Reset();
 
     SetSizer(sizerTop);
-
-    sizerTop->Fit(this);
 }
 
 // ----------------------------------------------------------------------------
 }
 
 // ----------------------------------------------------------------------------
@@ -382,7 +419,6 @@ void BitmapComboBoxWidgetsPage::Reset()
 {
     m_chkSort->SetValue(false);
     m_chkReadonly->SetValue(true);
 {
     m_chkSort->SetValue(false);
     m_chkReadonly->SetValue(true);
-    m_chkScaleimages->SetValue(true);
 }
 
 void BitmapComboBoxWidgetsPage::CreateCombo()
 }
 
 void BitmapComboBoxWidgetsPage::CreateCombo()
@@ -394,6 +430,24 @@ void BitmapComboBoxWidgetsPage::CreateCombo()
     if ( m_chkReadonly->GetValue() )
         flags |= wxCB_READONLY;
 
     if ( m_chkReadonly->GetValue() )
         flags |= wxCB_READONLY;
 
+    switch ( m_radioKind->GetSelection() )
+    {
+        default:
+            wxFAIL_MSG( _T("unknown combo kind") );
+            // fall through
+
+        case ComboKind_Default:
+            break;
+
+        case ComboKind_Simple:
+            flags |= wxCB_SIMPLE;
+            break;
+
+        case ComboKind_DropDown:
+            flags = wxCB_DROPDOWN;
+            break;
+    }
+
     wxArrayString items;
     wxArrayPtrVoid bitmaps;
     if ( m_combobox )
     wxArrayString items;
     wxArrayPtrVoid bitmaps;
     if ( m_combobox )
@@ -436,7 +490,7 @@ void BitmapComboBoxWidgetsPage::CreateCombo()
     long h = 0;
     m_textChangeHeight->GetValue().ToLong(&h);
     if ( h >= 5 )
     long h = 0;
     m_textChangeHeight->GetValue().ToLong(&h);
     if ( h >= 5 )
-        m_combobox->SetSize(-1, h);
+        m_combobox->SetSize(wxDefaultCoord, h);
 }
 
 // ----------------------------------------------------------------------------
 }
 
 // ----------------------------------------------------------------------------
@@ -500,23 +554,31 @@ void BitmapComboBoxWidgetsPage::OnButtonInsert(wxCommandEvent& WXUNUSED(event))
         m_textInsert->SetValue(wxString::Format(_T("test item %u"), ++s_item));
     }
 
         m_textInsert->SetValue(wxString::Format(_T("test item %u"), ++s_item));
     }
 
-    if (m_combobox->GetSelection() >= 0)
-        m_combobox->Insert(s, wxNullBitmap, m_combobox->GetSelection());
+    int sel = m_combobox->GetSelection();
+    if ( sel == wxNOT_FOUND )
+        sel = m_combobox->GetCount();
+
+    m_combobox->Insert(s, wxNullBitmap, m_combobox->GetSelection());
 }
 
 void BitmapComboBoxWidgetsPage::OnTextChangeHeight(wxCommandEvent& WXUNUSED(event))
 {
     long h = 0;
 }
 
 void BitmapComboBoxWidgetsPage::OnTextChangeHeight(wxCommandEvent& WXUNUSED(event))
 {
     long h = 0;
-    m_textChangeHeight->GetValue().ToLong(&h);
+    if ( m_textChangeHeight )
+        m_textChangeHeight->GetValue().ToLong(&h);
     if ( h < 5 )
         return;
     if ( h < 5 )
         return;
-    m_combobox->SetSize(-1, h);
+    m_combobox->SetSize(wxDefaultCoord, h);
 }
 
 void BitmapComboBoxWidgetsPage::OnButtonLoadFromFile(wxCommandEvent& WXUNUSED(event))
 {
     wxString s;
 }
 
 void BitmapComboBoxWidgetsPage::OnButtonLoadFromFile(wxCommandEvent& WXUNUSED(event))
 {
     wxString s;
-    m_combobox->Insert(s, QueryBitmap(&s), m_combobox->GetSelection());
+    int sel = m_combobox->GetSelection();
+    if ( sel == wxNOT_FOUND )
+        sel = m_combobox->GetCount();
+
+    m_combobox->Insert(s, QueryBitmap(&s), sel);
 }
 
 void BitmapComboBoxWidgetsPage::OnButtonSetFromFile(wxCommandEvent& WXUNUSED(event))
 }
 
 void BitmapComboBoxWidgetsPage::OnButtonSetFromFile(wxCommandEvent& WXUNUSED(event))
@@ -542,22 +604,58 @@ void BitmapComboBoxWidgetsPage::OnButtonAddSeveral(wxCommandEvent& WXUNUSED(even
 
 void BitmapComboBoxWidgetsPage::OnButtonAddSeveralWithImages(wxCommandEvent& WXUNUSED(event))
 {
 
 void BitmapComboBoxWidgetsPage::OnButtonAddSeveralWithImages(wxCommandEvent& WXUNUSED(event))
 {
-    int i;
+    static const struct TestEntry
+    {
+        const char *text;
+        unsigned long rgb;
+    } s_entries[] =
+    {
+        { "Red circle",     0x0000ff },
+        { "Blue circle",    0xff0000 },
+        { "Green circle",   0x00ff00 },
+        { "Black circle",   0x000000 },
+    };
+
+    for ( unsigned i = 0; i < WXSIZEOF(s_entries); i++ )
+    {
+        const TestEntry& e = s_entries[i];
+        m_combobox->Append(e.text, CreateBitmap(wxColour(e.rgb)));
+    }
+}
+
+#if wxUSE_IMAGE
+void BitmapComboBoxWidgetsPage::RescaleImage(wxImage& image, int w, int h)
+{
+    if ( image.GetWidth() == w && image.GetHeight() == h )
+        return;
+
+    if ( w <= 0 || h <= 0 )
+        return;
+
+    static bool isFirstScale = true;
 
 
-    for ( i=0; i<4; i++ )
+    if ( isFirstScale && m_combobox->GetCount() > 0 )
     {
     {
-        wxString s;
-        wxBitmap bmp = CreateRandomBitmap(&s);
-        m_combobox->Append(s, bmp);
+        wxMessageBox( wxT("wxBitmapComboBox normally only supports images of one size. ")
+                      wxT("However, for demonstration purposes, loaded bitmaps are scaled to fit ")
+                      wxT("using wxImage::Rescale."),
+                      wxT("Notice"),
+                      wxOK,
+                      this );
+
+        isFirstScale = false;
     }
     }
+
+    image.Rescale(w, h);
 }
 }
+#endif
 
 void BitmapComboBoxWidgetsPage::LoadWidgetImages( wxArrayString* strings, wxImageList* images )
 {
     wxFileName fn;
     fn.AssignCwd();
     fn.AppendDir(wxT("icons"));
 
 void BitmapComboBoxWidgetsPage::LoadWidgetImages( wxArrayString* strings, wxImageList* images )
 {
     wxFileName fn;
     fn.AssignCwd();
     fn.AppendDir(wxT("icons"));
-    
+
     wxSetCursor(*wxHOURGLASS_CURSOR);
 
     if ( !wxDir::Exists(fn.GetFullPath()) ||
     wxSetCursor(*wxHOURGLASS_CURSOR);
 
     if ( !wxDir::Exists(fn.GetFullPath()) ||
@@ -609,8 +707,7 @@ void BitmapComboBoxWidgetsPage::LoadWidgetImages( wxArrayString* strings, wxImag
             wxASSERT(fn.FileExists());
             wxImage image(fn.GetFullPath());
             wxASSERT(image.Ok());
             wxASSERT(fn.FileExists());
             wxImage image(fn.GetFullPath());
             wxASSERT(image.Ok());
-            if ( m_chkScaleimages->GetValue() && foundSize.x > 0 )
-                image.Rescale(foundSize.x, foundSize.y);
+            RescaleImage(image, foundSize.x, foundSize.y);
             wxBitmap bmp(image);
             wxASSERT( bmp.Ok() );
 #else
             wxBitmap bmp(image);
             wxASSERT( bmp.Ok() );
 #else
@@ -628,11 +725,14 @@ void BitmapComboBoxWidgetsPage::OnButtonAddWidgetIcons(wxCommandEvent& WXUNUSED(
 {
     wxArrayString strings;
 
 {
     wxArrayString strings;
 
-    int sz = 32;
-    //if ( m_chkScaleimages->GetValue() )
-    //    sz = 16;
+    wxSize sz = m_combobox->GetBitmapSize();
+    if ( sz.x <= 0 )
+    {
+        sz.x = 32;
+        sz.y = 32;
+    }
 
 
-    wxImageList images(sz, sz);
+    wxImageList images(sz.x, sz.y);
 
     LoadWidgetImages(&strings, &images);
 
 
     LoadWidgetImages(&strings, &images);
 
@@ -731,6 +831,13 @@ wxBitmap BitmapComboBoxWidgetsPage::LoadBitmap(const wxString& filepath)
     // Get size of existing images in list
     wxSize foundSize = m_combobox->GetBitmapSize();
 
     // Get size of existing images in list
     wxSize foundSize = m_combobox->GetBitmapSize();
 
+    // Have some reasonable maximum size
+    if ( foundSize.x <= 0 )
+    {
+        foundSize.x = IMG_SIZE_TRUNC;
+        foundSize.y = IMG_SIZE_TRUNC;
+    }
+
     wxImage image(filepath);
     if ( image.Ok() )
     {
     wxImage image(filepath);
     if ( image.Ok() )
     {
@@ -748,7 +855,7 @@ wxBitmap BitmapComboBoxWidgetsPage::LoadBitmap(const wxString& filepath)
             if ( h > foundSize.y )
                 h = foundSize.y;
 
             if ( h > foundSize.y )
                 h = foundSize.y;
 
-            image.Rescale(w, h);
+            RescaleImage(image, w, h);
         }
 
         return wxBitmap(image);
         }
 
         return wxBitmap(image);
@@ -766,9 +873,9 @@ wxBitmap BitmapComboBoxWidgetsPage::LoadBitmap(const wxString& WXUNUSED(filepath
 wxBitmap BitmapComboBoxWidgetsPage::QueryBitmap(wxString* pStr)
 {
     wxString filepath = wxFileSelector(wxT("Choose image file"),
 wxBitmap BitmapComboBoxWidgetsPage::QueryBitmap(wxString* pStr)
 {
     wxString filepath = wxFileSelector(wxT("Choose image file"),
-                                       wxT(""),
-                                       wxT(""),
-                                       wxT(""),
+                                       wxEmptyString,
+                                       wxEmptyString,
+                                       wxEmptyString,
                                        wxT("*.*"),
                                        wxFD_OPEN | wxFD_FILE_MUST_EXIST,
                                        this);
                                        wxT("*.*"),
                                        wxFD_OPEN | wxFD_FILE_MUST_EXIST,
                                        this);
@@ -787,6 +894,8 @@ wxBitmap BitmapComboBoxWidgetsPage::QueryBitmap(wxString* pStr)
         bitmap = LoadBitmap(filepath);
     }
 
         bitmap = LoadBitmap(filepath);
     }
 
+    wxLogDebug(wxT("%i, %i"),bitmap.GetWidth(), bitmap.GetHeight());
+
     ::wxSetCursor( *wxSTANDARD_CURSOR );
 
     return bitmap;
     ::wxSetCursor( *wxSTANDARD_CURSOR );
 
     return bitmap;
@@ -794,33 +903,23 @@ wxBitmap BitmapComboBoxWidgetsPage::QueryBitmap(wxString* pStr)
 
 wxBitmap BitmapComboBoxWidgetsPage::CreateBitmap(const wxColour& colour)
 {
 
 wxBitmap BitmapComboBoxWidgetsPage::CreateBitmap(const wxColour& colour)
 {
-    int ch = m_combobox->GetBitmapSize().y;
-    int h0 = ch - 5;
-
-    long w = ch;
-    long h = ch;
-
-    if ( w <= 0 )
-        w = h0 - 1;
-    if ( h <= 0 )
-        h = h0;
-    if ( h > ch )
-        h = ch;
+    const int w = 10,
+              h = 10;
 
     wxMemoryDC dc;
 
     wxMemoryDC dc;
-    wxBitmap bmp(w,h);
+    wxBitmap bmp(w, h);
     dc.SelectObject(bmp);
 
     // Draw transparent background
     dc.SelectObject(bmp);
 
     // Draw transparent background
-    wxColour magic(255,0,255);
+    wxColour magic(255, 0, 255);
     wxBrush magicBrush(magic);
     dc.SetBrush(magicBrush);
     dc.SetPen(*wxTRANSPARENT_PEN);
     wxBrush magicBrush(magic);
     dc.SetBrush(magicBrush);
     dc.SetPen(*wxTRANSPARENT_PEN);
-    dc.DrawRectangle(0,0,bmp.GetWidth(),bmp.GetHeight());
+    dc.DrawRectangle(0, 0, w, h);
 
     // Draw image content
     dc.SetBrush(wxBrush(colour));
 
     // Draw image content
     dc.SetBrush(wxBrush(colour));
-    dc.DrawCircle(h/2,h/2+1,(h/2));
+    dc.DrawCircle(h/2, h/2+1, h/2);
 
     dc.SelectObject(wxNullBitmap);
 
 
     dc.SelectObject(wxNullBitmap);
 
@@ -831,47 +930,4 @@ wxBitmap BitmapComboBoxWidgetsPage::CreateBitmap(const wxColour& colour)
     return bmp;
 }
 
     return bmp;
 }
 
-wxBitmap BitmapComboBoxWidgetsPage::CreateRandomBitmap( wxString* pStr )
-{
-    int i = rand() % 6;
-    const wxChar* str = wxT("");
-    wxBitmap bmp;
-
-    if ( i == 0 )
-    {
-        str = wxT("Red Circle");
-        bmp = CreateBitmap( *wxRED );
-    }
-    else if ( i == 1 )
-    {
-        str = wxT("Green Circle");
-        bmp = CreateBitmap( *wxGREEN );
-    }
-    else if ( i == 2 )
-    {
-        str = wxT("Blue Circle");
-        bmp = CreateBitmap( *wxBLUE );
-    }
-    else if ( i == 3 )
-    {
-        str = wxT("Black Circle");
-        bmp = CreateBitmap( *wxBLACK );
-    }
-    else if ( i == 4 )
-    {
-        str = wxT("Cyan Circle");
-        bmp = CreateBitmap( *wxCYAN );
-    }
-    else if ( i == 5 )
-    {
-        str = wxT("Light Grey Circle");
-        bmp = CreateBitmap( *wxLIGHT_GREY );
-    }
-
-    if ( pStr )
-        *pStr = str;
-
-    return bmp;
-}
-
-#endif //wxUSE_BITMAPCOMBOBOX
+#endif // wxUSE_BITMAPCOMBOBOX