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:
Vadim Zeitlin
1999-11-25 23:28:41 +00:00
parent 1e7215e676
commit f048e32fcd
29 changed files with 435 additions and 503 deletions

View File

@@ -1,5 +1,5 @@
# #
# This file was automatically generated by tmake at 20:10, 1999/11/21 # This file was automatically generated by tmake at 13:22, 1999/11/24
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T! # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T!
# #
@@ -514,6 +514,7 @@ MSW_HEADERS = \
msw/gauge.h \ msw/gauge.h \
msw/gauge95.h \ msw/gauge95.h \
msw/gaugemsw.h \ msw/gaugemsw.h \
msw/gdiimage.h \
msw/gdiobj.h \ msw/gdiobj.h \
msw/helpwin.h \ msw/helpwin.h \
msw/icon.h \ msw/icon.h \
@@ -1657,6 +1658,7 @@ MSW_GUIOBJS = \
fontutil.o \ fontutil.o \
frame.o \ frame.o \
gauge95.o \ gauge95.o \
gdiimage.o \
gdiobj.o \ gdiobj.o \
gsocket.o \ gsocket.o \
helpwin.o \ helpwin.o \
@@ -1746,6 +1748,7 @@ MSW_GUIDEPS = \
fontutil.d \ fontutil.d \
frame.d \ frame.d \
gauge95.d \ gauge95.d \
gdiimage.d \
gdiobj.d \ gdiobj.d \
gsocket.d \ gsocket.d \
helpwin.d \ helpwin.d \

View File

@@ -16,6 +16,8 @@ all:
wxMSW: wxMSW:
- tooltips work with wxRadioBox
- arbitrary controls (and not only buttons) can be put into a toolbar - arbitrary controls (and not only buttons) can be put into a toolbar
wxGTK: wxGTK:

View File

@@ -55,12 +55,6 @@ public:
virtual void Command(wxCommandEvent& event); virtual void Command(wxCommandEvent& event);
virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
virtual bool MSWCommand(WXUINT param, WXWORD id); virtual bool MSWCommand(WXUINT param, WXWORD id);
virtual WXHBRUSH OnCtlColor(WXHDC pDC,
WXHWND pWnd,
WXUINT nCtlColor,
WXUINT message,
WXWPARAM wParam,
WXLPARAM lParam);
protected: protected:
// send a notification event, return TRUE if processed // send a notification event, return TRUE if processed

View File

@@ -49,8 +49,6 @@ public:
virtual bool MSWCommand(WXUINT param, WXWORD id); virtual bool MSWCommand(WXUINT param, WXWORD id);
virtual void SetLabel(const wxString& label); virtual void SetLabel(const wxString& label);
virtual void Command(wxCommandEvent& event); virtual void Command(wxCommandEvent& event);
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
protected: protected:
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;

View File

@@ -43,10 +43,13 @@ public:
virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *WXUNUSED(item)) { return FALSE; }; virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *WXUNUSED(item)) { return FALSE; };
virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *WXUNUSED(item)) { return FALSE; }; virtual bool MSWOnMeasure(WXMEASUREITEMSTRUCT *WXUNUSED(item)) { return FALSE; };
wxList& GetSubcontrols() { return m_subControls; } wxArrayLong GetSubcontrols() { return m_subControls; }
void OnEraseBackground(wxEraseEvent& event); void OnEraseBackground(wxEraseEvent& event);
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
#if WXWIN_COMPATIBILITY #if WXWIN_COMPATIBILITY
virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { } virtual void SetButtonColour(const wxColour& WXUNUSED(col)) { }
wxColour* GetButtonColour() const { return NULL; } wxColour* GetButtonColour() const { return NULL; }
@@ -66,8 +69,9 @@ protected:
#endif // WXWIN_COMPATIBILITY #endif // WXWIN_COMPATIBILITY
protected: protected:
// For controls like radiobuttons which are really composite // for controls like radiobuttons which are really composite this array
wxList m_subControls; // holds the ids (not HWNDs!) of the sub controls
wxArrayLong m_subControls;
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;

View File

@@ -108,10 +108,6 @@ public:
virtual void SetHorizontalExtent(const wxString& s = wxEmptyString); virtual void SetHorizontalExtent(const wxString& s = wxEmptyString);
// Windows callbacks // Windows callbacks
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message,
WXWPARAM wParam, WXLPARAM lParam);
bool MSWCommand(WXUINT param, WXWORD id); bool MSWCommand(WXUINT param, WXWORD id);
virtual void SetupColours(); virtual void SetupColours();

View File

@@ -47,8 +47,6 @@ public:
const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr); const wxValidator& val = wxDefaultValidator, const wxString& name = wxRadioBoxNameStr);
virtual bool MSWCommand(WXUINT param, WXWORD id); virtual bool MSWCommand(WXUINT param, WXWORD id);
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
int FindString(const wxString& s) const; int FindString(const wxString& s) const;
void SetSelection(int N); void SetSelection(int N);

View File

@@ -49,8 +49,6 @@ class WXDLLEXPORT wxRadioButton: public wxControl
bool MSWCommand(WXUINT param, WXWORD id); bool MSWCommand(WXUINT param, WXWORD id);
void Command(wxCommandEvent& event); void Command(wxCommandEvent& event);
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
}; };
// Not implemented // Not implemented

View File

@@ -50,9 +50,6 @@ public:
virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
// overriden base class virtuals // overriden base class virtuals
virtual bool AcceptsFocus() const { return FALSE; } virtual bool AcceptsFocus() const { return FALSE; }

View File

@@ -51,8 +51,6 @@ public:
virtual bool AcceptsFocus() const { return FALSE; } virtual bool AcceptsFocus() const { return FALSE; }
// callbacks // callbacks
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
protected: protected:

View File

@@ -128,10 +128,6 @@ public:
void SetRichEdit(bool isRich) { m_isRich = isRich; } void SetRichEdit(bool isRich) { m_isRich = isRich; }
#endif // wxUSE_RICHEDIT #endif // wxUSE_RICHEDIT
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam,
WXLPARAM lParam);
virtual void AdoptAttributesFromHWND(); virtual void AdoptAttributesFromHWND();
virtual void SetupColours(); virtual void SetupColours();

View File

@@ -35,14 +35,17 @@ public:
void RelayEvent(WXMSG *msg); void RelayEvent(WXMSG *msg);
private: private:
static WXHWND hwndTT; static WXHWND ms_hwndTT;
// create the tooltip ctrl for our parent frame if it doesn't exist yet
// and return its window handle // create the tooltip ctrl if it doesn't exist yet and return its HWND
WXHWND GetToolTipCtrl(); WXHWND GetToolTipCtrl();
// remove this tooltip from the tooltip control // remove this tooltip from the tooltip control
void Remove(); void Remove();
// add a window to the tooltip control
void Add(WXHWND hwnd);
wxString m_text; // tooltip text wxString m_text; // tooltip text
wxWindow *m_window; // window we're associated with wxWindow *m_window; // window we're associated with
}; };

View File

@@ -62,6 +62,8 @@ public:
private: private:
void OnButtonMove(bool up); void OnButtonMove(bool up);
void AdjustColour(size_t index);
wxCheckListBox *m_pListBox; wxCheckListBox *m_pListBox;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
@@ -157,13 +159,10 @@ CheckListBoxFrame::CheckListBoxFrame(wxFrame *frame,
delete [] astrChoices; delete [] astrChoices;
// not implemented in other ports yet
#ifdef __WXMSW__
// set grey background for every second entry // set grey background for every second entry
for ( ui = 0; ui < WXSIZEOF(aszChoices); ui += 2 ) { 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); m_pListBox->Check(2);
@@ -252,7 +251,7 @@ void CheckListBoxFrame::OnButtonMove(bool up)
wxString label = m_pListBox->GetString(selection); wxString label = m_pListBox->GetString(selection);
int positionNew = up ? selection - 1 : selection + 2; 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")); 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->Check(selectionNew, wasChecked);
m_pListBox->SetSelection(selectionNew); m_pListBox->SetSelection(selectionNew);
AdjustColour(selection);
AdjustColour(selectionNew);
wxLogStatus(this, _T("Item moved %s"), up ? _T("up") : _T("down")); 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")); 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
}

View File

@@ -61,11 +61,6 @@
#include "wx/progdlg.h" #include "wx/progdlg.h"
// VZ: this is a temp. hack, will remove soon
#ifndef wxUSE_SPINCTRL
#define wxUSE_SPINCTRL 1
#endif
#if wxUSE_SPINCTRL #if wxUSE_SPINCTRL
#include "wx/spinctrl.h" #include "wx/spinctrl.h"
#endif // wxUSE_SPINCTRL #endif // wxUSE_SPINCTRL
@@ -167,6 +162,8 @@ public:
void OnSize( wxSizeEvent& event ); void OnSize( wxSizeEvent& event );
void OnMove( wxMoveEvent& event ); void OnMove( wxMoveEvent& event );
MyPanel *GetPanel() const { return m_panel; }
private: private:
void UpdateStatusBar(const wxPoint& pos, const wxSize& size) void UpdateStatusBar(const wxPoint& pos, const wxSize& size)
{ {
@@ -176,7 +173,7 @@ private:
SetStatusText(msg, 1); SetStatusText(msg, 1);
} }
wxPanel *m_panel; MyPanel *m_panel;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
@@ -259,6 +256,8 @@ bool MyApp::OnInit()
frame->Show(TRUE); frame->Show(TRUE);
frame->SetCursor(wxCursor(wxCURSOR_HAND)); frame->SetCursor(wxCursor(wxCURSOR_HAND));
frame->GetPanel()->m_notebook->SetSelection(3);
SetTopWindow(frame); SetTopWindow(frame);
return TRUE; 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); m_notebook->AddPage(panel, "wxChoice", FALSE, Image_Choice);
panel = new wxPanel(m_notebook); 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_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_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
(void)new wxButton( panel, ID_COMBO_CLEAR, "Clear", wxPoint(180,80), 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); 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 ); (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 ); 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_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) ); (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) ); 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 #ifndef __WXMOTIF__ // wxStaticBitmap not working under Motif yet. MB
wxIcon icon = wxTheApp->GetStdIcon(wxICON_INFORMATION); 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 = new wxStaticBitmap(panel, -1, wxNullIcon, wxPoint(50, 10));
bmpStatic->SetIcon(wxTheApp->GetStdIcon(wxICON_QUESTION)); bmpStatic->SetIcon(wxTheApp->GetStdIcon(wxICON_QUESTION));
@@ -594,11 +601,25 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
wxMemoryDC dc; wxMemoryDC dc;
dc.SelectObject( bitmap ); dc.SelectObject( bitmap );
dc.SetPen(*wxGREEN_PEN); dc.SetPen(*wxGREEN_PEN);
dc.Clear();
dc.DrawEllipse(5, 5, 90, 90); dc.DrawEllipse(5, 5, 90, 90);
dc.DrawText("Bitmap", 20, 20); dc.DrawText("Bitmap", 30, 40);
dc.SelectObject( wxNullBitmap ); dc.SelectObject( wxNullBitmap );
(void)new wxBitmapButton(panel, -1, bitmap, wxPoint(100, 20)); (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)); (void)new wxButton(panel, ID_BUTTON_LABEL, "Toggle label", wxPoint(250, 20));
m_label = new wxStaticText(panel, -1, "Label with some long text", m_label = new wxStaticText(panel, -1, "Label with some long text",
wxPoint(250, 60), wxDefaultSize, wxPoint(250, 60), wxDefaultSize,

View File

@@ -121,15 +121,15 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
wxLogWarning("Can't find image files in either '.' or '..'!"); wxLogWarning("Can't find image files in either '.' or '..'!");
wxImage image( bitmap ); wxImage image( bitmap );
if ( !image.SaveFile( dir + wxString("test.png"), wxBITMAP_TYPE_PNG ) ) if ( !image.SaveFile( dir + wxString("test.png"), wxBITMAP_TYPE_PNG ) )
wxLogError("Can't save file"); wxLogError("Can't save file");
if ( !image.LoadFile( dir + wxString("horse.png"), wxBITMAP_TYPE_PNG ) ) if ( !image.LoadFile( dir + wxString("horse.png"), wxBITMAP_TYPE_PNG ) )
wxLogError("Can't load PNG image"); wxLogError("Can't load PNG image");
else else
my_horse_png = new wxBitmap( image.ConvertToBitmap() ); my_horse_png = new wxBitmap( image.ConvertToBitmap() );
if ( !image.LoadFile( dir + wxString("horse.jpg") ) ) if ( !image.LoadFile( dir + wxString("horse.jpg") ) )
wxLogError("Can't load JPG image"); wxLogError("Can't load JPG image");
else else
@@ -160,10 +160,10 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
else else
my_horse_pnm = new wxBitmap( image.ConvertToBitmap() ); my_horse_pnm = new wxBitmap( image.ConvertToBitmap() );
#endif #endif
image.LoadFile( dir + wxString("test.png") ); image.LoadFile( dir + wxString("test.png") );
my_square = new wxBitmap( image.ConvertToBitmap() ); my_square = new wxBitmap( image.ConvertToBitmap() );
CreateAntiAliasedBitmap(); CreateAntiAliasedBitmap();
} }
@@ -186,20 +186,20 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
dc.DrawText( "Loaded image", 30, 10 ); dc.DrawText( "Loaded image", 30, 10 );
if (my_square && my_square->Ok()) dc.DrawBitmap( *my_square, 30, 30 ); if (my_square && my_square->Ok()) dc.DrawBitmap( *my_square, 30, 30 );
dc.DrawText( "Drawn directly", 150, 10 ); dc.DrawText( "Drawn directly", 150, 10 );
dc.SetBrush( wxBrush( "orange", wxSOLID ) ); dc.SetBrush( wxBrush( "orange", wxSOLID ) );
dc.SetPen( *wxWHITE_PEN ); dc.SetPen( *wxWHITE_PEN );
dc.DrawRectangle( 150, 30, 100, 100 ); dc.DrawRectangle( 150, 30, 100, 100 );
if (my_anti && my_anti->Ok()) dc.DrawBitmap( *my_anti, 250, 140 ); if (my_anti && my_anti->Ok()) dc.DrawBitmap( *my_anti, 250, 140 );
dc.DrawText( "PNG handler", 30, 135 ); dc.DrawText( "PNG handler", 30, 135 );
if (my_horse_png && my_horse_png->Ok()) dc.DrawBitmap( *my_horse_png, 30, 150 ); if (my_horse_png && my_horse_png->Ok()) dc.DrawBitmap( *my_horse_png, 30, 150 );
dc.DrawText( "JPEG handler", 30, 365 ); dc.DrawText( "JPEG handler", 30, 365 );
if (my_horse_jpeg && my_horse_jpeg->Ok()) dc.DrawBitmap( *my_horse_jpeg, 30, 380 ); if (my_horse_jpeg && my_horse_jpeg->Ok()) dc.DrawBitmap( *my_horse_jpeg, 30, 380 );
dc.DrawText( "GIF handler", 30, 595 ); dc.DrawText( "GIF handler", 30, 595 );
if (my_horse_gif && my_horse_gif->Ok()) dc.DrawBitmap( *my_horse_gif, 30, 610 ); 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.SelectObject( bitmap );
dc.Clear(); dc.Clear();
dc.SetFont( wxFont( 24, wxDECORATIVE, wxNORMAL, wxNORMAL) ); dc.SetFont( wxFont( 24, wxDECORATIVE, wxNORMAL, wxNORMAL) );
dc.SetTextForeground( "RED" ); dc.SetTextForeground( "RED" );
dc.DrawText( "This is anti-aliased Text.", 20, 20 ); dc.DrawText( "This is anti-aliased Text.", 20, 20 );
dc.DrawText( "And a Rectangle.", 20, 60 ); dc.DrawText( "And a Rectangle.", 20, 60 );
dc.SetBrush( *wxRED_BRUSH ); dc.SetBrush( *wxRED_BRUSH );
dc.SetPen( *wxTRANSPARENT_PEN ); dc.SetPen( *wxTRANSPARENT_PEN );
dc.DrawRoundedRectangle( 20, 100, 200, 180, 20 ); dc.DrawRoundedRectangle( 20, 100, 200, 180, 20 );
wxImage original( bitmap ); wxImage original( bitmap );
wxImage anti( 150, 150 ); wxImage anti( 150, 150 );
/* This is quite slow, but safe. Use wxImage::GetData() for speed instead. */ /* This is quite slow, but safe. Use wxImage::GetData() for speed instead. */
for (int y = 1; y < 149; y++) for (int y = 1; y < 149; y++)
for (int x = 1; x < 149; x++) for (int x = 1; x < 149; x++)
{ {
int red = original.GetRed( x*2, y*2 ) + int red = original.GetRed( x*2, y*2 ) +
original.GetRed( x*2-1, y*2 ) + original.GetRed( x*2-1, y*2 ) +
original.GetRed( x*2, y*2+1 ) + original.GetRed( x*2, y*2+1 ) +
original.GetRed( x*2+1, 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 ) + int green = original.GetGreen( x*2, y*2 ) +
original.GetGreen( x*2-1, y*2 ) + original.GetGreen( x*2-1, y*2 ) +
original.GetGreen( x*2, y*2+1 ) + original.GetGreen( x*2, y*2+1 ) +
original.GetGreen( x*2+1, 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 ) + int blue = original.GetBlue( x*2, y*2 ) +
original.GetBlue( x*2-1, y*2 ) + original.GetBlue( x*2-1, y*2 ) +
original.GetBlue( x*2, y*2+1 ) + original.GetBlue( x*2, y*2+1 ) +
original.GetBlue( x*2+1, y*2+1 ); original.GetBlue( x*2+1, y*2+1 );
blue = blue/4; blue = blue/4;
anti.SetRGB( x, y, red, green, blue ); anti.SetRGB( x, y, red, green, blue );
} }
my_anti = new wxBitmap( anti.ConvertToBitmap() ); my_anti = new wxBitmap( anti.ConvertToBitmap() );

View File

@@ -242,29 +242,6 @@ bool wxButton::MSWCommand(WXUINT param, WXWORD id)
return processed; return processed;
} }
WXHBRUSH wxButton::OnCtlColor(WXHDC pDC,
WXHWND pWnd,
WXUINT nCtlColor,
WXUINT message,
WXWPARAM wParam,
WXLPARAM lParam)
{
const HDC& hdc = (HDC)pDC;
const wxColour& colBack = GetBackgroundColour();
::SetBkColor(hdc, RGB(colBack.Red(), colBack.Green(), colBack.Blue()));
const wxColour& colFor = GetForegroundColour();
::SetTextColor(hdc, RGB(colFor.Red(), colFor.Green(), colFor.Blue()));
::SetBkMode(hdc, OPAQUE);
wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(colBack,
wxSOLID);
backgroundBrush->RealizeResource();
return (WXHBRUSH)backgroundBrush->GetResourceHandle();
}
long wxButton::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) long wxButton::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{ {
// make sure that we won't have BS_DEFPUSHBUTTON style any more if the // make sure that we won't have BS_DEFPUSHBUTTON style any more if the

View File

@@ -179,34 +179,6 @@ bool wxCheckBox::GetValue() const
#endif #endif
} }
WXHBRUSH wxCheckBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
#if wxUSE_CTL3D
if ( m_useCtl3D )
{
HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
return (WXHBRUSH) hbrush;
}
#endif
if (GetParent()->GetTransparentBackground())
SetBkMode((HDC) pDC, TRANSPARENT);
else
SetBkMode((HDC) pDC, OPAQUE);
::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
// Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
// has a zero usage count.
// backgroundBrush->RealizeResource();
return (WXHBRUSH) backgroundBrush->GetResourceHandle();
}
void wxCheckBox::Command (wxCommandEvent & event) void wxCheckBox::Command (wxCommandEvent & event)
{ {
SetValue ((event.GetInt() != 0)); SetValue ((event.GetInt() != 0));

View File

@@ -208,6 +208,34 @@ void wxControl::OnEraseBackground(wxEraseEvent& event)
::SetMapMode(hdc, mode); ::SetMapMode(hdc, mode);
} }
WXHBRUSH wxControl::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message,
WXWPARAM wParam,
WXLPARAM lParam)
{
#if wxUSE_CTL3D
if ( m_useCtl3D )
{
HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
return (WXHBRUSH) hbrush;
}
#endif // wxUSE_CTL3D
HDC hdc = (HDC)pDC;
if (GetParent()->GetTransparentBackground())
SetBkMode(hdc, TRANSPARENT);
else
SetBkMode(hdc, OPAQUE);
const wxColour& colBack = GetBackgroundColour();
::SetBkColor(hdc, wxColourToRGB(colBack));
::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBack, wxSOLID);
return (WXHBRUSH)brush->GetResourceHandle();
}
WXDWORD wxControl::GetExStyle(WXDWORD& style, bool *want3D) const WXDWORD wxControl::GetExStyle(WXDWORD& style, bool *want3D) const
{ {
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, want3D); WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, want3D);

View File

@@ -696,33 +696,6 @@ bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
return FALSE; return FALSE;
} }
WXHBRUSH wxListBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
#if wxUSE_CTL3D
if ( m_useCtl3D )
{
HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
return (WXHBRUSH) hbrush;
}
#endif
if (GetParent()->GetTransparentBackground())
SetBkMode((HDC) pDC, TRANSPARENT);
else
SetBkMode((HDC) pDC, OPAQUE);
::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
// Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
// has a zero usage count.
backgroundBrush->RealizeResource();
return (WXHBRUSH) backgroundBrush->GetResourceHandle();
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxCheckListBox support // wxCheckListBox support
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -213,6 +213,9 @@ wxMDIParentFrame::~wxMDIParentFrame()
{ {
DestroyChildren(); DestroyChildren();
// already delete by DestroyChildren()
m_frameToolBar = NULL;
::DestroyMenu((HMENU)m_windowMenu); ::DestroyMenu((HMENU)m_windowMenu);
m_windowMenu = 0; m_windowMenu = 0;

View File

@@ -29,8 +29,6 @@
#endif #endif
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/setup.h"
#include "wx/bitmap.h" #include "wx/bitmap.h"
#include "wx/brush.h" #include "wx/brush.h"
#include "wx/radiobox.h" #include "wx/radiobox.h"
@@ -38,10 +36,25 @@
#include "wx/msw/private.h" #include "wx/msw/private.h"
#if wxUSE_TOOLTIPS
#include <commctrl.h>
#include "wx/tooltip.h"
#endif // wxUSE_TOOLTIPS
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
#endif #endif
// VZ: the new behaviour is to create the radio buttons as children of the
// radiobox instead of creating them as children of the radiobox' parent.
//
// This seems more logical, more consistent with what other frameworks do
// and allows tooltips to work with radioboxes, so there should be no
// reason to revert to the backward compatible behaviour - but I still
// leave this possibility just in case.
#define RADIOBTN_PARENT_IS_RADIOBOX 1
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// private functions // private functions
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -154,116 +167,101 @@ wxRadioBox::wxRadioBox()
m_radioHeight = NULL; m_radioHeight = NULL;
} }
bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, bool wxRadioBox::Create(wxWindow *parent,
const wxPoint& pos, const wxSize& size, wxWindowID id,
int n, const wxString choices[], const wxString& title,
int majorDim, long style, const wxPoint& pos,
const wxValidator& val, const wxString& name) const wxSize& size,
int n,
const wxString choices[],
int majorDim,
long style,
const wxValidator& val,
const wxString& name)
{ {
// initialize members
m_selectedButton = -1; m_selectedButton = -1;
m_noItems = n; m_noItems = n;
SetName(name); m_majorDim = majorDim == 0 ? n : majorDim;
SetValidator(val);
parent->AddChild(this);
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
m_windowStyle = (long&)style;
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
if (id == -1)
m_windowId = NewControlId();
else
m_windowId = id;
if ( majorDim == 0 )
m_majorDim = n;
else
m_majorDim = majorDim;
m_noRowsOrCols = majorDim; m_noRowsOrCols = majorDim;
long msStyle = GROUP_FLAGS; // common initialization
if ( !CreateControl(parent, id, pos, size, style, val, name) )
return FALSE;
bool want3D; // create the static box
WXDWORD exStyle = Determine3DEffects(0, &want3D); if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX, pos, size, title, 0) )
return FALSE;
HWND hwndParent = (HWND)parent->GetHWND(); // and now create the buttons
#if RADIOBTN_PARENT_IS_RADIOBOX
m_hWnd = (WXHWND)::CreateWindowEx HWND hwndParent = GetHwnd();
( #else
(DWORD)exStyle, HWND hwndParent = GetHwndOf(parent);
GROUP_CLASS, #endif
title,
msStyle,
0, 0, 0, 0,
hwndParent,
(HMENU)m_windowId,
wxGetInstance(),
NULL
);
#if wxUSE_CTL3D
if (want3D)
{
Ctl3dSubclassCtl((HWND)m_hWnd);
m_useCtl3D = TRUE;
}
#endif // wxUSE_CTL3D
SetFont(parent->GetFont());
SubclassWin(m_hWnd);
// Some radio boxes test consecutive id. // Some radio boxes test consecutive id.
(void)NewControlId(); (void)NewControlId();
m_radioButtons = new WXHWND[n]; m_radioButtons = new WXHWND[n];
m_radioWidth = new int[n]; m_radioWidth = new int[n];
m_radioHeight = new int[n]; m_radioHeight = new int[n];
int i;
for (i = 0; i < n; i++)
{
m_radioWidth[i] = m_radioHeight[i] = -1;
long groupStyle = 0;
if ( i == 0 && style == 0 )
groupStyle = WS_GROUP;
long newId = NewControlId();
long msStyle = groupStyle | RADIO_FLAGS;
HWND hwndBtn = CreateWindowEx(exStyle, RADIO_CLASS, WXHFONT hfont = 0;
choices[i], msStyle, wxFont& font = GetFont();
0,0,0,0, if ( font.Ok() )
{
hfont = font.GetResourceHandle();
}
for ( int i = 0; i < n; i++ )
{
m_radioWidth[i] =
m_radioHeight[i] = -1;
long styleBtn = BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE;
if ( i == 0 && style == 0 )
styleBtn |= WS_GROUP;
long newId = NewControlId();
HWND hwndBtn = ::CreateWindow(_T("BUTTON"),
choices[i],
styleBtn,
0, 0, 0, 0, // will be set in SetSize()
hwndParent, hwndParent,
(HMENU)newId, wxGetInstance(), (HMENU)newId,
wxGetInstance(),
NULL); NULL);
if ( !hwndBtn )
{
wxLogLastError("CreateWindow(radio btn)");
return FALSE;
}
m_radioButtons[i] = (WXHWND)hwndBtn; m_radioButtons[i] = (WXHWND)hwndBtn;
SubclassRadioButton((WXHWND)hwndBtn); SubclassRadioButton((WXHWND)hwndBtn);
wxFont& font = GetFont(); if ( hfont )
if ( font.Ok() )
{ {
SendMessage(hwndBtn, WM_SETFONT, ::SendMessage(hwndBtn, WM_SETFONT, (WPARAM)hfont, 0L);
(WPARAM)font.GetResourceHandle(), 0L);
} }
m_subControls.Append((wxObject *)(WXDWORD)(WXWORD)newId); m_subControls.Add(newId);
} }
// Create a dummy radio control to end the group. // Create a dummy radio control to end the group.
(void)CreateWindowEx(0, RADIO_CLASS, wxT(""), WS_GROUP | RADIO_FLAGS, (void)::CreateWindow(_T("BUTTON"),
_T(""),
WS_GROUP | BS_AUTORADIOBUTTON | WS_CHILD,
0, 0, 0, 0, hwndParent, 0, 0, 0, 0, hwndParent,
(HMENU)NewControlId(), wxGetInstance(), NULL); (HMENU)NewControlId(), wxGetInstance(), NULL);
SetSelection(0); SetSelection(0);
SetSize(x, y, width, height); SetSize(pos.x, pos.y, size.x, size.y);
return TRUE; return TRUE;
} }
@@ -364,10 +362,14 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
yy = currentY; yy = currentY;
wxString buf; #if RADIOBTN_PARENT_IS_RADIOBOX
int y_offset = 0;
int x_offset = 0;
#else
int y_offset = yy; int y_offset = yy;
int x_offset = xx; int x_offset = xx;
#endif
int current_width, cyf; int current_width, cyf;
int cx1,cy1; int cx1,cy1;
@@ -386,8 +388,8 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
if (m_radioWidth[i]<0) if (m_radioWidth[i]<0)
{ {
// It's a labelled toggle // It's a labelled toggle
buf = wxGetWindowText(m_radioButtons[i]); GetTextExtent(wxGetWindowText(m_radioButtons[i]),
GetTextExtent(buf, &current_width, &cyf); &current_width, &cyf);
eachWidth = (int)(current_width + RADIO_SIZE); eachWidth = (int)(current_width + RADIO_SIZE);
eachHeight = (int)((3*cyf)/2); eachHeight = (int)((3*cyf)/2);
} }
@@ -409,7 +411,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
int totHeight; int totHeight;
int nbHor = GetNumHor(), int nbHor = GetNumHor(),
nbVer = GetNumVer(); nbVer = GetNumVer();
// this formula works, but I don't know why. // this formula works, but I don't know why.
// Please, be sure what you do if you modify it!! // Please, be sure what you do if you modify it!!
@@ -444,7 +446,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
height = heightOld; height = heightOld;
} }
MoveWindow(GetHwnd(), x_offset, y_offset, width, height, TRUE); ::MoveWindow(GetHwnd(), xx, yy, width, height, TRUE);
x_offset += cx1; x_offset += cx1;
y_offset += cy1; y_offset += cy1;
@@ -480,8 +482,8 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
if (m_radioWidth[i]<0) if (m_radioWidth[i]<0)
{ {
// It's a labeled item // It's a labeled item
buf = wxGetWindowText(m_radioButtons[i]); GetTextExtent(wxGetWindowText(m_radioButtons[i]),
GetTextExtent(buf, &current_width, &cyf); &current_width, &cyf);
// How do we find out radio button bitmap size!! // How do we find out radio button bitmap size!!
// By adjusting them carefully, manually :-) // By adjusting them carefully, manually :-)
@@ -494,9 +496,13 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
eachHeight = m_radioHeight[i]; eachHeight = m_radioHeight[i];
} }
MoveWindow((HWND)m_radioButtons[i], x_offset, y_offset, // VZ: make all buttons of the same, maximal size - like this they
eachWidth, eachHeight, // cover the radiobox entirely and the radiobox tooltips are always
TRUE); // shown (otherwise they are not when the mouse pointer is in the
// radiobox part not belonging to any radiobutton)
::MoveWindow((HWND)m_radioButtons[i],
x_offset, y_offset, maxWidth, maxHeight,
TRUE);
if (m_windowStyle & wxRA_SPECIFY_ROWS) if (m_windowStyle & wxRA_SPECIFY_ROWS)
{ {
@@ -528,8 +534,7 @@ void wxRadioBox::GetSize(int *width, int *height) const
void wxRadioBox::GetPosition(int *x, int *y) const void wxRadioBox::GetPosition(int *x, int *y) const
{ {
wxWindow *parent = GetParent(); wxWindow *parent = GetParent();
RECT rect; RECT rect = { -1, -1, -1, -1 };
rect.left = -1; rect.right = -1; rect.top = -1; rect.bottom = -1;
int i; int i;
for (i = 0; i < m_noItems; i++) for (i = 0; i < m_noItems; i++)
@@ -538,8 +543,8 @@ void wxRadioBox::GetPosition(int *x, int *y) const
if (m_hWnd) if (m_hWnd)
wxFindMaxSize(m_hWnd, &rect); wxFindMaxSize(m_hWnd, &rect);
// Since we now have the absolute screen coords, // Since we now have the absolute screen coords, if there's a parent we
// if there's a parent we must subtract its top left corner // must subtract its top left corner
POINT point; POINT point;
point.x = rect.left; point.x = rect.left;
point.y = rect.top; point.y = rect.top;
@@ -547,9 +552,9 @@ void wxRadioBox::GetPosition(int *x, int *y) const
{ {
::ScreenToClient((HWND) parent->GetHWND(), &point); ::ScreenToClient((HWND) parent->GetHWND(), &point);
} }
// We may be faking the client origin.
// So a window that's really at (0, 30) may appear // We may be faking the client origin. So a window that's really at (0, 30)
// (to wxWin apps) to be at (0, 0). // may appear (to wxWin apps) to be at (0, 0).
if (GetParent()) if (GetParent())
{ {
wxPoint pt(GetParent()->GetClientAreaOrigin()); wxPoint pt(GetParent()->GetClientAreaOrigin());
@@ -617,30 +622,6 @@ void wxRadioBox::Show(int item, bool show)
::ShowWindow((HWND)m_radioButtons[item], show ? SW_SHOW : SW_HIDE); ::ShowWindow((HWND)m_radioButtons[item], show ? SW_SHOW : SW_HIDE);
} }
WXHBRUSH wxRadioBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
#if wxUSE_CTL3D
if ( m_useCtl3D )
{
HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
return (WXHBRUSH) hbrush;
}
#endif
if (GetParent()->GetTransparentBackground())
SetBkMode((HDC) pDC, TRANSPARENT);
else
SetBkMode((HDC) pDC, OPAQUE);
::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
return (WXHBRUSH) backgroundBrush->GetResourceHandle();
}
// For single selection items only // For single selection items only
wxString wxRadioBox::GetStringSelection() const wxString wxRadioBox::GetStringSelection() const
{ {
@@ -716,68 +697,91 @@ LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
bool processed = TRUE; bool processed = FALSE;
if ( msg != WM_KEYDOWN ) if ( msg == WM_KEYDOWN
processed = FALSE; #if wxUSE_TOOLTIPS
|| msg == WM_NOTIFY
if ( processed ) #endif // wxUSE_TOOLTIPS
)
{ {
wxRadioBox *radiobox = (wxRadioBox *)::GetWindowLong(hwnd, GWL_USERDATA); wxRadioBox *radiobox = (wxRadioBox *)::GetWindowLong(hwnd, GWL_USERDATA);
wxCHECK_MSG( radiobox, 0, wxT("radio button without radio box?") ); wxCHECK_MSG( radiobox, 0, wxT("radio button without radio box?") );
int sel = radiobox->GetSelection(); #if wxUSE_TOOLTIPS
if ( msg == WM_NOTIFY )
switch ( wParam )
{ {
case VK_UP: NMHDR* hdr = (NMHDR *)lParam;
sel--; if ( (int)hdr->code == TTN_NEEDTEXT )
break;
case VK_LEFT:
sel -= radiobox->GetNumVer();
break;
case VK_DOWN:
sel++;
break;
case VK_RIGHT:
sel += radiobox->GetNumVer();
break;
case VK_TAB:
{
wxNavigationKeyEvent event;
event.SetDirection(!(::GetKeyState(VK_SHIFT) & 0x100));
event.SetWindowChange(FALSE);
event.SetEventObject(radiobox);
if ( radiobox->GetEventHandler()->ProcessEvent(event) )
return 0;
}
// fall through
default:
processed = FALSE;
}
if ( processed )
{
if ( sel >= 0 && sel < radiobox->Number() )
{ {
radiobox->SetSelection(sel); wxToolTip *tt = radiobox->GetToolTip();
if ( tt )
{
TOOLTIPTEXT *ttt = (TOOLTIPTEXT *)lParam;
ttt->lpszText = (wxChar *)tt->GetTip().c_str();
// emulate the button click processed = TRUE;
radiobox->SendNotificationEvent(); }
}
}
else // msg == WM_KEYDOWN
#endif // wxUSE_TOOLTIPS
{
processed = TRUE;
int sel = radiobox->GetSelection();
switch ( wParam )
{
case VK_UP:
sel--;
break;
case VK_LEFT:
sel -= radiobox->GetNumVer();
break;
case VK_DOWN:
sel++;
break;
case VK_RIGHT:
sel += radiobox->GetNumVer();
break;
case VK_TAB:
{
wxNavigationKeyEvent event;
event.SetDirection(!(::GetKeyState(VK_SHIFT) & 0x100));
event.SetWindowChange(FALSE);
event.SetEventObject(radiobox);
if ( radiobox->GetEventHandler()->ProcessEvent(event) )
return 0;
}
// fall through
default:
processed = FALSE;
}
if ( processed )
{
if ( sel >= 0 && sel < radiobox->Number() )
{
radiobox->SetSelection(sel);
// emulate the button click
radiobox->SendNotificationEvent();
}
} }
} }
} }
if ( !processed ) if ( processed )
return ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn, hwnd, msg, wParam, lParam);
else
return 0; return 0;
return ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn, hwnd, msg, wParam, lParam);
} }
#endif // __WIN32__ #endif // __WIN32__

View File

@@ -157,33 +157,6 @@ bool wxRadioButton::GetValue(void) const
return (SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0L) != 0); return (SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0L) != 0);
} }
WXHBRUSH wxRadioButton::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
#if wxUSE_CTL3D
if ( m_useCtl3D )
{
HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
return (WXHBRUSH) hbrush;
}
#endif
if (GetParent()->GetTransparentBackground())
SetBkMode((HDC) pDC, TRANSPARENT);
else
SetBkMode((HDC) pDC, OPAQUE);
::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
// Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
// has a zero usage count.
// backgroundBrush->RealizeResource();
return (WXHBRUSH) backgroundBrush->GetResourceHandle();
}
void wxRadioButton::Command (wxCommandEvent & event) void wxRadioButton::Command (wxCommandEvent & event)
{ {
SetValue ( (event.m_commandInt != 0) ); SetValue ( (event.m_commandInt != 0) );

View File

@@ -531,16 +531,7 @@ WXHBRUSH wxSlider95::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
return 0; return 0;
// Otherwise, it's a static // Otherwise, it's a static
if (GetParent()->GetTransparentBackground()) return wxControl::OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
SetBkMode((HDC) pDC, TRANSPARENT);
else
SetBkMode((HDC) pDC, OPAQUE);
::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
return (WXHBRUSH) backgroundBrush->GetResourceHandle();
} }
// For trackbars only // For trackbars only

View File

@@ -481,17 +481,7 @@ WXHBRUSH wxSliderMSW::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
return 0; return 0;
// Otherwise, it's a static // Otherwise, it's a static
if (GetParent()->GetTransparentBackground()) return wxControl::OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam);
SetBkMode((HDC) pDC, TRANSPARENT);
else
SetBkMode((HDC) pDC, OPAQUE);
::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
return (WXHBRUSH) backgroundBrush->GetResourceHandle();
} }
// For trackbars only // For trackbars only

View File

@@ -61,7 +61,7 @@ bool wxStaticBox::Create(wxWindow *parent,
long style, long style,
const wxString& name) const wxString& name)
{ {
if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) ) if ( !CreateControl(parent, id, pos, size, style, name) )
return FALSE; return FALSE;
if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX, pos, size, label, 0) ) if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX, pos, size, label, 0) )
@@ -84,34 +84,6 @@ wxSize wxStaticBox::DoGetBestSize() const
return wxSize(wBox, hBox); return wxSize(wBox, hBox);
} }
WXHBRUSH wxStaticBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message,
WXWPARAM wParam,
WXLPARAM lParam)
{
#if wxUSE_CTL3D
if ( m_useCtl3D )
{
HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
return (WXHBRUSH) hbrush;
}
#endif // wxUSE_CTL3D
HDC hdc = (HDC)pDC;
if (GetParent()->GetTransparentBackground())
SetBkMode(hdc, TRANSPARENT);
else
SetBkMode(hdc, OPAQUE);
const wxColour& colBack = GetBackgroundColour();
::SetBkColor(hdc, wxColourToRGB(colBack));
::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
wxBrush *brush = wxTheBrushList->FindOrCreateBrush(colBack, wxSOLID);
return (WXHBRUSH)brush->GetResourceHandle();
}
long wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) long wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{ {
switch ( nMsg ) switch ( nMsg )

View File

@@ -150,39 +150,6 @@ void wxStaticText::SetLabel(const wxString& label)
} }
} }
WXHBRUSH wxStaticText::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
/*
#if wxUSE_CTL3D
if ( m_useCtl3D )
{
HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
if (hbrush != (HBRUSH) 0)
return hbrush;
else
return (HBRUSH)MSWDefWindowProc(message, wParam, lParam);
}
#endif
*/
if (GetParent()->GetTransparentBackground())
SetBkMode((HDC) pDC, TRANSPARENT);
else
SetBkMode((HDC) pDC, OPAQUE);
::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
// Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
// has a zero usage count.
// backgroundBrush->RealizeResource();
return (WXHBRUSH) backgroundBrush->GetResourceHandle();
}
long wxStaticText::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) long wxStaticText::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{ {
// Ensure that static items get messages. Some controls don't like this // Ensure that static items get messages. Some controls don't like this

View File

@@ -764,30 +764,6 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
} }
} }
WXHBRUSH wxTextCtrl::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam,
WXLPARAM lParam)
{
#if wxUSE_CTL3D
if ( m_useCtl3D )
{
HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
return (WXHBRUSH) hbrush;
}
#endif
HDC hdc = (HDC)pDC;
SetBkMode(hdc, GetParent()->GetTransparentBackground() ? TRANSPARENT
: OPAQUE);
::SetBkColor(hdc, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
::SetTextColor(hdc, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
return (WXHBRUSH) backgroundBrush->GetResourceHandle();
}
void wxTextCtrl::OnChar(wxKeyEvent& event) void wxTextCtrl::OnChar(wxKeyEvent& event)
{ {
switch ( event.KeyCode() ) switch ( event.KeyCode() )

View File

@@ -32,16 +32,32 @@
#include "wx/tooltip.h" #include "wx/tooltip.h"
#include "wx/msw/private.h" #include "wx/msw/private.h"
#if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__) || defined(wxUSE_NORLANDER_HEADERS) #if defined(__WIN95__) && !defined(__GNUWIN32_OLD__)
#include <commctrl.h> #include <commctrl.h>
#endif #endif
// VZ: normally, the trick with subclassing the tooltip control and processing
// TTM_WINDOWFROMPOINT should work but, somehow, it doesn't. I leave the
// code here for now (but it's not compiled) in case we need it later.
//
// For now, instead of this, we just add all radiobox buttons to the
// tooltip control as well (see SetWindow) - this is probably less
// efficient, but it works.
#define wxUSE_TTM_WINDOWFROMPOINT 0
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// global variables // global variables
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// the tooltip parent window // the tooltip parent window
WXHWND wxToolTip::hwndTT = (WXHWND)NULL; WXHWND wxToolTip::ms_hwndTT = (WXHWND)NULL;
#if wxUSE_TTM_WINDOWFROMPOINT
// the tooltip window proc
static WNDPROC gs_wndprocToolTip = (WNDPROC)NULL;
#endif // wxUSE_TTM_WINDOWFROMPOINT
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// private classes // private classes
@@ -54,14 +70,14 @@ WXHWND wxToolTip::hwndTT = (WXHWND)NULL;
class wxToolInfo : public TOOLINFO class wxToolInfo : public TOOLINFO
{ {
public: public:
wxToolInfo(wxWindow *win) wxToolInfo(HWND hwnd)
{ {
// initialize all members // initialize all members
::ZeroMemory(this, sizeof(TOOLINFO)); ::ZeroMemory(this, sizeof(TOOLINFO));
cbSize = sizeof(TOOLINFO); cbSize = sizeof(TOOLINFO);
uFlags = TTF_IDISHWND; uFlags = TTF_IDISHWND;
uId = (UINT)win->GetHWND(); uId = (UINT)hwnd;
} }
}; };
#ifdef __VISUALC__ #ifdef __VISUALC__
@@ -88,28 +104,68 @@ static void SendTooltipMessageToAll(WXHWND hwnd,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
if ( hwnd ) (void)SendTooltipMessage((WXHWND)hwnd, msg, wParam, (void *)lParam);
(void)SendTooltipMessage((WXHWND)hwnd, msg, wParam, (void *)lParam);
} }
// ============================================================================ // ============================================================================
// implementation // implementation
// ============================================================================ // ============================================================================
#if wxUSE_TTM_WINDOWFROMPOINT
// ----------------------------------------------------------------------------
// window proc for our tooltip control
// ----------------------------------------------------------------------------
LRESULT APIENTRY wxToolTipWndProc(HWND hwndTT,
UINT msg,
WPARAM wParam,
LPARAM lParam)
{
if ( msg == TTM_WINDOWFROMPOINT )
{
LPPOINT ppt = (LPPOINT)lParam;
// is the window under control a wxWindow?
HWND hwnd = ::WindowFromPoint(*ppt);
// return a HWND correspondign to wxWindow because only wxWindows are
// associated with tooltips using TTM_ADDTOOL
while ( hwnd && !wxFindWinFromHandle((WXHWND)hwnd) )
{
hwnd = ::GetParent(hwnd);
}
if ( hwnd )
{
// modify the point too!
RECT rect;
GetWindowRect(hwnd, &rect);
ppt->x = rect.left;
ppt->y = rect.top;
return (LRESULT)hwnd;
}
}
return ::CallWindowProc(gs_wndprocToolTip, hwndTT, msg, wParam, lParam);
}
#endif // wxUSE_TTM_WINDOWFROMPOINT
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// static functions // static functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxToolTip::Enable(bool flag) void wxToolTip::Enable(bool flag)
{ {
SendTooltipMessageToAll((WXHWND)hwndTT,TTM_ACTIVATE, flag, 0); SendTooltipMessageToAll(ms_hwndTT, TTM_ACTIVATE, flag, 0);
} }
void wxToolTip::SetDelay(long milliseconds) void wxToolTip::SetDelay(long milliseconds)
{ {
SendTooltipMessageToAll((WXHWND)hwndTT,TTM_SETDELAYTIME, TTDT_INITIAL, milliseconds); SendTooltipMessageToAll(ms_hwndTT, TTM_SETDELAYTIME,
TTDT_INITIAL, milliseconds);
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -119,25 +175,31 @@ void wxToolTip::SetDelay(long milliseconds)
// create the tooltip ctrl for our parent frame if it doesn't exist yet // create the tooltip ctrl for our parent frame if it doesn't exist yet
WXHWND wxToolTip::GetToolTipCtrl() WXHWND wxToolTip::GetToolTipCtrl()
{ {
if ( !hwndTT ) if ( !ms_hwndTT )
{ {
hwndTT = (WXHWND)::CreateWindow(TOOLTIPS_CLASS, ms_hwndTT = (WXHWND)::CreateWindow(TOOLTIPS_CLASS,
(LPSTR)NULL, (LPSTR)NULL,
TTS_ALWAYSTIP, TTS_ALWAYSTIP,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, (HMENU)NULL, NULL, (HMENU)NULL,
wxGetInstance(), wxGetInstance(),
NULL); NULL);
if ( hwndTT ) if ( ms_hwndTT )
{ {
SetWindowPos((HWND)hwndTT, HWND_TOPMOST, 0, 0, 0, 0, HWND hwnd = (HWND)ms_hwndTT;
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
}
#if wxUSE_TTM_WINDOWFROMPOINT
// subclass the newly created control
gs_wndprocToolTip = (WNDPROC)::GetWindowLong(hwnd, GWL_WNDPROC);
::SetWindowLong(hwnd, GWL_WNDPROC, (long)wxToolTipWndProc);
#endif // wxUSE_TTM_WINDOWFROMPOINT
}
} }
return (WXHWND)hwndTT; return ms_hwndTT;
} }
void wxToolTip::RelayEvent(WXMSG *msg) void wxToolTip::RelayEvent(WXMSG *msg)
@@ -170,32 +232,57 @@ void wxToolTip::Remove()
// remove this tool from the tooltip control // remove this tool from the tooltip control
if ( m_window ) if ( m_window )
{ {
wxToolInfo ti(m_window); wxToolInfo ti(GetHwndOf(m_window));
(void)SendTooltipMessage(GetToolTipCtrl(), TTM_DELTOOL, 0, &ti); (void)SendTooltipMessage(GetToolTipCtrl(), TTM_DELTOOL, 0, &ti);
} }
} }
void wxToolTip::Add(WXHWND hWnd)
{
HWND hwnd = (HWND)hWnd;
wxToolInfo ti(hwnd);
// as we store our text anyhow, it seems useless to waste system memory
// by asking the tooltip ctrl to remember it too - instead it will send
// us TTN_NEEDTEXT (via WM_NOTIFY) when it is about to be shown
ti.hwnd = hwnd;
ti.lpszText = LPSTR_TEXTCALLBACK;
// instead of: ti.lpszText = (char *)m_text.c_str();
if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, 0, &ti) )
{
wxLogSysError(_("Failed to create the tooltip '%s'"),
m_text.c_str());
}
}
void wxToolTip::SetWindow(wxWindow *win) void wxToolTip::SetWindow(wxWindow *win)
{ {
Remove(); Remove();
m_window = win; m_window = win;
// add the window itself
if ( m_window ) if ( m_window )
{ {
wxToolInfo ti(m_window); Add(m_window->GetHWND());
}
// as we store our text anyhow, it seems useless to waste system memory // and all of its subcontrols (e.g. radiobuttons in a radiobox) as well
// by asking the tooltip ctrl to remember it too - instead it will send wxControl *control = wxDynamicCast(m_window, wxControl);
// us TTN_NEEDTEXT (via WM_NOTIFY) when it is about to be shown if ( control )
ti.hwnd = (HWND)m_window->GetHWND(); {
ti.lpszText = LPSTR_TEXTCALLBACK; size_t count = control->GetSubcontrols().GetCount();
// instead of: ti.lpszText = (char *)m_text.c_str(); for ( size_t n = 0; n < count; n++ )
if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, 0, &ti) )
{ {
wxLogSysError(_("Failed to create the tooltip '%s'"), wxWindowID id = control->GetSubcontrols()[n];
m_text.c_str()); HWND hwnd = GetDlgItem(GetHwndOf(m_window), id);
if ( hwnd )
{
Add((WXHWND)hwnd);
}
} }
} }
} }
@@ -207,7 +294,7 @@ void wxToolTip::SetTip(const wxString& tip)
if ( m_window ) if ( m_window )
{ {
// update it immediately // update it immediately
wxToolInfo ti(m_window); wxToolInfo ti(GetHwndOf(m_window));
ti.lpszText = (wxChar *)m_text.c_str(); ti.lpszText = (wxChar *)m_text.c_str();
(void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, 0, &ti); (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, 0, &ti);

View File

@@ -163,6 +163,17 @@ END_EVENT_TABLE()
// Find an item given the MS Windows id // Find an item given the MS Windows id
wxWindow *wxWindow::FindItem(long id) const wxWindow *wxWindow::FindItem(long id) const
{ {
wxControl *item = wxDynamicCast(this, wxControl);
if ( item )
{
// i it we or one of our "internal" children?
if ( item->GetId() == id ||
(item->GetSubcontrols().Index(id) != wxNOT_FOUND) )
{
return item;
}
}
wxWindowList::Node *current = GetChildren().GetFirst(); wxWindowList::Node *current = GetChildren().GetFirst();
while (current) while (current)
{ {
@@ -172,19 +183,6 @@ wxWindow *wxWindow::FindItem(long id) const
if ( wnd ) if ( wnd )
return wnd; return wnd;
if ( childWin->IsKindOf(CLASSINFO(wxControl)) )
{
wxControl *item = (wxControl *)childWin;
if ( item->GetId() == id )
return item;
else
{
// In case it's a 'virtual' control (e.g. radiobox)
if ( item->GetSubcontrols().Member((wxObject *)id) )
return item;
}
}
current = current->GetNext(); current = current->GetNext();
} }
@@ -2946,7 +2944,8 @@ bool wxWindow::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control)
return popupMenu->MSWCommand(cmd, id); return popupMenu->MSWCommand(cmd, id);
} }
wxWindow *win = FindItem(id); // must cast to a signed type before comparing with other ids!
wxWindow *win = FindItem((signed short)id);
if ( !win ) if ( !win )
{ {
win = wxFindWinFromHandle(control); win = wxFindWinFromHandle(control);