Now problem: I can`t find the reason why every element in array of wxBitmapButton(s) show bitmap assigned to the first bitmapbutton.
Here my code:
Initialization of colours:
Code: Select all
for( i = 0; i < 9; ++i)
fun_colours[ i] = wxColour( 255/ ( i + 1), 0, 0);
fun_colours[ 7] = wxColour( 30, 140, 49);
Code: Select all
const int bitmap_width( 75);
const int bitmap_height( 25);
int bitmap_width1( bitmap_width);
--bitmap_width1;
int bitmap_height1( bitmap_height);
--bitmap_height1;
wxPanel* Main_panel;
Main_panel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxSize( 85, 300));
button_mas = new wxBitmapButton*[ fun_quantity_e];
bitmap_mas = new wxBitmap*[ fun_quantity_e];
wxMemoryDC fill_bitmap_dc;
wxPen* fill_pen = new wxPen( fun_colours_e[ 0]);
wxBrush* fill_brush = new wxBrush( fun_colours_e[ 0]);
int i( 0);
for( ; i < fun_quantity_e; ++i)
{
bitmap_mas[ i] = new wxBitmap( bitmap_width, bitmap_height, -1);
fill_pen -> SetColour( fun_colours_e[ i]);
fill_bitmap_dc. SetPen( *fill_pen);
fill_brush -> SetColour( fun_colours_e[ i]);
fill_bitmap_dc. SetBrush( *fill_brush);
fill_bitmap_dc. SelectObject( *( bitmap_mas[ i]));
fill_bitmap_dc. DrawRectangle( 0, 0, bitmap_width1, bitmap_height1/ 2 + i * bitmap_height1/ ( 2 * fun_quantity_e));
if( i != 0)
{
fill_bitmap_dc. SetPen( *wxWHITE_PEN);
fill_bitmap_dc. DrawLine( 0, 0, bitmap_width1, bitmap_height1/ 2 + i * bitmap_height1/ ( 2 * fun_quantity_e));
}
button_mas[ i] = new wxBitmapButton( Main_panel, FIRST_COLOUR_BUTTON_PRESS, *( bitmap_mas[ i]));
fill_bitmap_dc. SelectObject( wxNullBitmap);
}
fill_bitmap_dc. SetPen( wxNullPen);
fill_bitmap_dc. SetBrush( wxNullBrush);
fill_bitmap_dc. SelectObject( wxNullBitmap);
wxBitmap* bitmap_s_a = new wxBitmap( bitmap_width, bitmap_height);
fill_bitmap_dc. SelectObject( *bitmap_s_a);
fill_pen -> SetColour( 134, 20, 120);
fill_brush -> SetColour( 255 - 134, 255 - 20, 255 - 120);
--bitmap_width1;
--bitmap_height1;
fill_bitmap_dc. DrawRectangle( 1, 1, bitmap_width1, bitmap_height1);
wxBitmapButton* button_s_a = new wxBitmapButton( this, FIRST_COLOUR_BUTTON_PRESS, *bitmap_s_a);
Main_sizer = new wxBoxSizer( wxVERTICAL);
Main_sizer -> AddSpacer( 5);
for( i = 0; i < fun_quantity_e; ++i)
Main_sizer -> Add( button_mas[ i]);
wxBoxSizer* top_sizer;
top_sizer = new wxBoxSizer( wxHORIZONTAL);
top_sizer -> Add( Main_sizer);
Main_panel -> SetSizer( Main_sizer);
Main_sizer -> Fit( Main_panel);
Main_sizer -> SetSizeHints( this);
Main_sizer -> AddSpacer( 15);
Main_sizer -> Add( button_s_a);
SetSizer( top_sizer);
Code: Select all
void Colour_Frame :: On_paint( wxPaintEvent& event)
{
wxPaintDC paint_dc( this);
int width( 200);
int height( 0);
const int bitmap_width( 75);
const int bitmap_height( 25);
for( int i( 0); i < 9; ++i)
paint_dc. DrawBitmap( *( bitmap_mas[ i]), width, height + i * bitmap_height + i);
wxPen debug_pen( *wxWHITE_PEN);
paint_dc. SetPen( debug_pen);
paint_dc. DrawLine( width, 0, width + bitmap_width, height + 9 * bitmap_height + 9);
paint_dc. SetPen( wxNullPen);
// event. Skip( );
return;
}