don't use rand() for selecting the colour of the bitmaps to append, this results in 2 pairs of identical colours here without srand() and looks too much like a bug
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50896 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		| @@ -145,7 +145,6 @@ protected: | |||||||
|  |  | ||||||
|     // helpers for creating bitmaps |     // helpers for creating bitmaps | ||||||
|     wxBitmap CreateBitmap(const wxColour& colour); |     wxBitmap CreateBitmap(const wxColour& colour); | ||||||
|     wxBitmap CreateRandomBitmap(wxString* pStr); |  | ||||||
|     wxBitmap LoadBitmap(const wxString& filepath); |     wxBitmap LoadBitmap(const wxString& filepath); | ||||||
|     wxBitmap QueryBitmap(wxString* pStr); |     wxBitmap QueryBitmap(wxString* pStr); | ||||||
|  |  | ||||||
| @@ -553,13 +552,22 @@ void BitmapComboBoxWidgetsPage::OnButtonAddSeveral(wxCommandEvent& WXUNUSED(even | |||||||
|  |  | ||||||
| void BitmapComboBoxWidgetsPage::OnButtonAddSeveralWithImages(wxCommandEvent& WXUNUSED(event)) | void BitmapComboBoxWidgetsPage::OnButtonAddSeveralWithImages(wxCommandEvent& WXUNUSED(event)) | ||||||
| { | { | ||||||
|     int i; |     static const struct TestEntry | ||||||
|  |  | ||||||
|     for ( i=0; i<4; i++ ) |  | ||||||
|     { |     { | ||||||
|         wxString s; |         const char *text; | ||||||
|         wxBitmap bmp = CreateRandomBitmap(&s); |         unsigned long rgb; | ||||||
|         m_combobox->Append(s, bmp); |     } s_entries[] = | ||||||
|  |     { | ||||||
|  |         { "Red circle",     0x0000ff }, | ||||||
|  |         { "Blue circle",    0xff0000 }, | ||||||
|  |         { "Green circle",   0x00ff00 }, | ||||||
|  |         { "Black circle",   0x000000 }, | ||||||
|  |     }; | ||||||
|  |  | ||||||
|  |     for ( int i = 0; i < WXSIZEOF(s_entries); i++ ) | ||||||
|  |     { | ||||||
|  |         const TestEntry& e = s_entries[i]; | ||||||
|  |         m_combobox->Append(e.text, CreateBitmap(wxColour(e.rgb))); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -870,47 +878,4 @@ wxBitmap BitmapComboBoxWidgetsPage::CreateBitmap(const wxColour& colour) | |||||||
|     return bmp; |     return bmp; | ||||||
| } | } | ||||||
|  |  | ||||||
| wxBitmap BitmapComboBoxWidgetsPage::CreateRandomBitmap( wxString* pStr ) | #endif // wxUSE_BITMAPCOMBOBOX | ||||||
| { |  | ||||||
|     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 |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user