1. wxMDIParentFrame::~wxMDIParentFrame() bug fixed
2. tooltips work with wxRadioBox 3. duplicated OnCtlColor()s moved to wxControl git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4693 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -62,6 +62,8 @@ public:
|
||||
private:
|
||||
void OnButtonMove(bool up);
|
||||
|
||||
void AdjustColour(size_t index);
|
||||
|
||||
wxCheckListBox *m_pListBox;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
@@ -157,13 +159,10 @@ CheckListBoxFrame::CheckListBoxFrame(wxFrame *frame,
|
||||
|
||||
delete [] astrChoices;
|
||||
|
||||
// not implemented in other ports yet
|
||||
#ifdef __WXMSW__
|
||||
// set grey background for every second entry
|
||||
for ( ui = 0; ui < WXSIZEOF(aszChoices); ui += 2 ) {
|
||||
m_pListBox->GetItem(ui)->SetBackgroundColour(wxColor(200, 200, 200));
|
||||
AdjustColour(ui);
|
||||
}
|
||||
#endif // wxGTK
|
||||
|
||||
m_pListBox->Check(2);
|
||||
|
||||
@@ -252,7 +251,7 @@ void CheckListBoxFrame::OnButtonMove(bool up)
|
||||
wxString label = m_pListBox->GetString(selection);
|
||||
|
||||
int positionNew = up ? selection - 1 : selection + 2;
|
||||
if ( positionNew < 0 || positionNew > m_pListBox->Number() )
|
||||
if ( positionNew < 0 || positionNew > m_pListBox->GetCount() )
|
||||
{
|
||||
wxLogStatus(this, _T("Can't move this item %s"), up ? _T("up") : _T("down"));
|
||||
}
|
||||
@@ -272,6 +271,9 @@ void CheckListBoxFrame::OnButtonMove(bool up)
|
||||
m_pListBox->Check(selectionNew, wasChecked);
|
||||
m_pListBox->SetSelection(selectionNew);
|
||||
|
||||
AdjustColour(selection);
|
||||
AdjustColour(selectionNew);
|
||||
|
||||
wxLogStatus(this, _T("Item moved %s"), up ? _T("up") : _T("down"));
|
||||
}
|
||||
}
|
||||
@@ -280,3 +282,13 @@ void CheckListBoxFrame::OnButtonMove(bool up)
|
||||
wxLogStatus(this, _T("Please select an item"));
|
||||
}
|
||||
}
|
||||
|
||||
void CheckListBoxFrame::AdjustColour(size_t index)
|
||||
{
|
||||
// not implemented in other ports yet
|
||||
#ifdef __WXMSW__
|
||||
// even items have grey backround, odd ones - white
|
||||
unsigned char c = index % 2 ? 255 : 200;
|
||||
m_pListBox->GetItem(index)->SetBackgroundColour(wxColor(c, c, c));
|
||||
#endif // wxMSW
|
||||
}
|
||||
|
@@ -61,11 +61,6 @@
|
||||
|
||||
#include "wx/progdlg.h"
|
||||
|
||||
// VZ: this is a temp. hack, will remove soon
|
||||
#ifndef wxUSE_SPINCTRL
|
||||
#define wxUSE_SPINCTRL 1
|
||||
#endif
|
||||
|
||||
#if wxUSE_SPINCTRL
|
||||
#include "wx/spinctrl.h"
|
||||
#endif // wxUSE_SPINCTRL
|
||||
@@ -167,6 +162,8 @@ public:
|
||||
void OnSize( wxSizeEvent& event );
|
||||
void OnMove( wxMoveEvent& event );
|
||||
|
||||
MyPanel *GetPanel() const { return m_panel; }
|
||||
|
||||
private:
|
||||
void UpdateStatusBar(const wxPoint& pos, const wxSize& size)
|
||||
{
|
||||
@@ -176,7 +173,7 @@ private:
|
||||
SetStatusText(msg, 1);
|
||||
}
|
||||
|
||||
wxPanel *m_panel;
|
||||
MyPanel *m_panel;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
@@ -259,6 +256,8 @@ bool MyApp::OnInit()
|
||||
frame->Show(TRUE);
|
||||
frame->SetCursor(wxCursor(wxCURSOR_HAND));
|
||||
|
||||
frame->GetPanel()->m_notebook->SetSelection(3);
|
||||
|
||||
SetTopWindow(frame);
|
||||
|
||||
return TRUE;
|
||||
@@ -504,7 +503,9 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
|
||||
m_notebook->AddPage(panel, "wxChoice", FALSE, Image_Choice);
|
||||
|
||||
panel = new wxPanel(m_notebook);
|
||||
m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(10,10), wxSize(120,-1), 5, choices, wxCB_READONLY );
|
||||
(void)new wxStaticBox( panel, -1, "Box around combobox",
|
||||
wxPoint(5, 5), wxSize(150, 100));
|
||||
m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(20,20), wxSize(120,-1), 5, choices, wxCB_READONLY );
|
||||
(void)new wxButton( panel, ID_COMBO_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
|
||||
(void)new wxButton( panel, ID_COMBO_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
|
||||
(void)new wxButton( panel, ID_COMBO_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );
|
||||
@@ -525,6 +526,11 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
|
||||
panel = new wxPanel(m_notebook);
|
||||
(void)new wxRadioBox( panel, ID_RADIOBOX, "That", wxPoint(10,160), wxSize(-1,-1), WXSIZEOF(choices2), choices2, 1, wxRA_SPECIFY_ROWS );
|
||||
m_radio = new wxRadioBox( panel, ID_RADIOBOX, "This", wxPoint(10,10), wxSize(-1,-1), WXSIZEOF(choices), choices, 1, wxRA_SPECIFY_COLS );
|
||||
|
||||
#if wxUSE_TOOLTIPS
|
||||
m_radio->SetToolTip("Ever seen a radiobox?");
|
||||
#endif // wxUSE_TOOLTIPS
|
||||
|
||||
(void)new wxButton( panel, ID_RADIOBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
|
||||
(void)new wxButton( panel, ID_RADIOBOX_SEL_STR, "Select 'This'", wxPoint(180,80), wxSize(140,30) );
|
||||
m_fontButton = new wxButton( panel, ID_SET_FONT, "Set more Italic font", wxPoint(340,30), wxSize(140,30) );
|
||||
@@ -584,7 +590,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
|
||||
|
||||
#ifndef __WXMOTIF__ // wxStaticBitmap not working under Motif yet. MB
|
||||
wxIcon icon = wxTheApp->GetStdIcon(wxICON_INFORMATION);
|
||||
wxStaticBitmap *bmpStatic = new wxStaticBitmap(panel, -1, icon, wxPoint(10, 10));
|
||||
wxStaticBitmap *bmpStatic = new wxStaticBitmap(panel, -1, icon,
|
||||
wxPoint(10, 10));
|
||||
|
||||
bmpStatic = new wxStaticBitmap(panel, -1, wxNullIcon, wxPoint(50, 10));
|
||||
bmpStatic->SetIcon(wxTheApp->GetStdIcon(wxICON_QUESTION));
|
||||
@@ -594,11 +601,25 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
|
||||
wxMemoryDC dc;
|
||||
dc.SelectObject( bitmap );
|
||||
dc.SetPen(*wxGREEN_PEN);
|
||||
dc.Clear();
|
||||
dc.DrawEllipse(5, 5, 90, 90);
|
||||
dc.DrawText("Bitmap", 20, 20);
|
||||
dc.DrawText("Bitmap", 30, 40);
|
||||
dc.SelectObject( wxNullBitmap );
|
||||
|
||||
(void)new wxBitmapButton(panel, -1, bitmap, wxPoint(100, 20));
|
||||
|
||||
wxBitmap bmp1(wxTheApp->GetStdIcon(wxICON_INFORMATION)),
|
||||
bmp2(wxTheApp->GetStdIcon(wxICON_WARNING)),
|
||||
bmp3(wxTheApp->GetStdIcon(wxICON_QUESTION));
|
||||
wxBitmapButton *bmpBtn = new wxBitmapButton
|
||||
(
|
||||
panel, -1,
|
||||
bmp1,
|
||||
wxPoint(30, 50)
|
||||
);
|
||||
bmpBtn->SetBitmapSelected(bmp2);
|
||||
bmpBtn->SetBitmapFocus(bmp3);
|
||||
|
||||
(void)new wxButton(panel, ID_BUTTON_LABEL, "Toggle label", wxPoint(250, 20));
|
||||
m_label = new wxStaticText(panel, -1, "Label with some long text",
|
||||
wxPoint(250, 60), wxDefaultSize,
|
||||
|
@@ -121,15 +121,15 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
|
||||
wxLogWarning("Can't find image files in either '.' or '..'!");
|
||||
|
||||
wxImage image( bitmap );
|
||||
|
||||
|
||||
if ( !image.SaveFile( dir + wxString("test.png"), wxBITMAP_TYPE_PNG ) )
|
||||
wxLogError("Can't save file");
|
||||
|
||||
|
||||
if ( !image.LoadFile( dir + wxString("horse.png"), wxBITMAP_TYPE_PNG ) )
|
||||
wxLogError("Can't load PNG image");
|
||||
else
|
||||
my_horse_png = new wxBitmap( image.ConvertToBitmap() );
|
||||
|
||||
|
||||
if ( !image.LoadFile( dir + wxString("horse.jpg") ) )
|
||||
wxLogError("Can't load JPG image");
|
||||
else
|
||||
@@ -160,10 +160,10 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
|
||||
else
|
||||
my_horse_pnm = new wxBitmap( image.ConvertToBitmap() );
|
||||
#endif
|
||||
|
||||
|
||||
image.LoadFile( dir + wxString("test.png") );
|
||||
my_square = new wxBitmap( image.ConvertToBitmap() );
|
||||
|
||||
|
||||
CreateAntiAliasedBitmap();
|
||||
}
|
||||
|
||||
@@ -186,20 +186,20 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
||||
|
||||
dc.DrawText( "Loaded image", 30, 10 );
|
||||
if (my_square && my_square->Ok()) dc.DrawBitmap( *my_square, 30, 30 );
|
||||
|
||||
|
||||
dc.DrawText( "Drawn directly", 150, 10 );
|
||||
dc.SetBrush( wxBrush( "orange", wxSOLID ) );
|
||||
dc.SetPen( *wxWHITE_PEN );
|
||||
dc.DrawRectangle( 150, 30, 100, 100 );
|
||||
|
||||
if (my_anti && my_anti->Ok()) dc.DrawBitmap( *my_anti, 250, 140 );
|
||||
|
||||
|
||||
dc.DrawText( "PNG handler", 30, 135 );
|
||||
if (my_horse_png && my_horse_png->Ok()) dc.DrawBitmap( *my_horse_png, 30, 150 );
|
||||
|
||||
|
||||
dc.DrawText( "JPEG handler", 30, 365 );
|
||||
if (my_horse_jpeg && my_horse_jpeg->Ok()) dc.DrawBitmap( *my_horse_jpeg, 30, 380 );
|
||||
|
||||
|
||||
dc.DrawText( "GIF handler", 30, 595 );
|
||||
if (my_horse_gif && my_horse_gif->Ok()) dc.DrawBitmap( *my_horse_gif, 30, 610 );
|
||||
|
||||
@@ -222,41 +222,41 @@ void MyCanvas::CreateAntiAliasedBitmap()
|
||||
dc.SelectObject( bitmap );
|
||||
|
||||
dc.Clear();
|
||||
|
||||
|
||||
dc.SetFont( wxFont( 24, wxDECORATIVE, wxNORMAL, wxNORMAL) );
|
||||
dc.SetTextForeground( "RED" );
|
||||
dc.DrawText( "This is anti-aliased Text.", 20, 20 );
|
||||
dc.DrawText( "And a Rectangle.", 20, 60 );
|
||||
|
||||
|
||||
dc.SetBrush( *wxRED_BRUSH );
|
||||
dc.SetPen( *wxTRANSPARENT_PEN );
|
||||
dc.DrawRoundedRectangle( 20, 100, 200, 180, 20 );
|
||||
|
||||
|
||||
wxImage original( bitmap );
|
||||
wxImage anti( 150, 150 );
|
||||
|
||||
/* This is quite slow, but safe. Use wxImage::GetData() for speed instead. */
|
||||
|
||||
|
||||
for (int y = 1; y < 149; y++)
|
||||
for (int x = 1; x < 149; x++)
|
||||
{
|
||||
int red = original.GetRed( x*2, y*2 ) +
|
||||
original.GetRed( x*2-1, y*2 ) +
|
||||
original.GetRed( x*2, y*2+1 ) +
|
||||
original.GetRed( x*2-1, y*2 ) +
|
||||
original.GetRed( x*2, y*2+1 ) +
|
||||
original.GetRed( x*2+1, y*2+1 );
|
||||
red = red/4;
|
||||
|
||||
red = red/4;
|
||||
|
||||
int green = original.GetGreen( x*2, y*2 ) +
|
||||
original.GetGreen( x*2-1, y*2 ) +
|
||||
original.GetGreen( x*2, y*2+1 ) +
|
||||
original.GetGreen( x*2-1, y*2 ) +
|
||||
original.GetGreen( x*2, y*2+1 ) +
|
||||
original.GetGreen( x*2+1, y*2+1 );
|
||||
green = green/4;
|
||||
|
||||
green = green/4;
|
||||
|
||||
int blue = original.GetBlue( x*2, y*2 ) +
|
||||
original.GetBlue( x*2-1, y*2 ) +
|
||||
original.GetBlue( x*2, y*2+1 ) +
|
||||
original.GetBlue( x*2-1, y*2 ) +
|
||||
original.GetBlue( x*2, y*2+1 ) +
|
||||
original.GetBlue( x*2+1, y*2+1 );
|
||||
blue = blue/4;
|
||||
blue = blue/4;
|
||||
anti.SetRGB( x, y, red, green, blue );
|
||||
}
|
||||
my_anti = new wxBitmap( anti.ConvertToBitmap() );
|
||||
|
Reference in New Issue
Block a user