From e421922f90186d0619a806d277a0a2182e61b5fb Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 27 Jun 2001 00:27:24 +0000 Subject: [PATCH] MSW compilation fixes - widgets sample runs! git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10677 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- distrib/msw/tmake/filelist.txt | 1 + include/wx/chkconf.h | 20 ++++- include/wx/datetime.h | 4 + include/wx/generic/msgdlgg.h | 9 --- include/wx/msgdlg.h | 14 ++++ include/wx/msw/msgdlg.h | 4 - include/wx/msw/setup0.h | 50 ++++++++---- include/wx/scrolwin.h | 6 ++ samples/menu/menu.cpp | 132 +++++++++++++++++++++---------- src/common/radiocmn.cpp | 138 +++++++++++++++++++++++++++++++++ src/generic/scrolwin.cpp | 75 ++++++++++-------- src/html/htmlcell.cpp | 4 +- src/html/htmlwin.cpp | 48 ++++++------ src/msw/font.cpp | 112 +------------------------- src/msw/listctrl.cpp | 3 +- src/msw/notebook.cpp | 3 +- src/msw/ole/automtn.cpp | 2 + src/msw/radiobox.cpp | 82 ++++++++------------ src/msw/window.cpp | 2 - 19 files changed, 420 insertions(+), 289 deletions(-) create mode 100644 src/common/radiocmn.cpp diff --git a/distrib/msw/tmake/filelist.txt b/distrib/msw/tmake/filelist.txt index 96ee59195e..88425e87cc 100644 --- a/distrib/msw/tmake/filelist.txt +++ b/distrib/msw/tmake/filelist.txt @@ -192,6 +192,7 @@ prntbase.cpp C process.cpp C 32,B protocol.cpp C S,B quantize.cpp C +radiocmn.cpp C resource.cpp C sckaddr.cpp C S,B sckfile.cpp C S,B diff --git a/include/wx/chkconf.h b/include/wx/chkconf.h index 25497ebb13..834520a36b 100644 --- a/include/wx/chkconf.h +++ b/include/wx/chkconf.h @@ -181,6 +181,14 @@ # endif #endif /* !defined(wxUSE_LISTCTRL) */ +#ifndef wxUSE_MSGDLG +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxUSE_MSGDLG must be defined." +# else +# define wxUSE_MSGDLG 0 +# endif +#endif /* !defined(wxUSE_MSGDLG) */ + #ifndef wxUSE_MDI_ARCHITECTURE # ifdef wxABORT_ON_CONFIG_ERROR # error "wxUSE_MDI_ARCHITECTURE must be defined." @@ -457,7 +465,7 @@ # define wxUSE_FILEDLG 1 # endif # endif -#endif /* !wxUSE_FILEDLG */ +#endif /* wxUSE_FILEDLG */ #if !wxUSE_FONTDLG # if defined(wxUSE_FONTMAP) @@ -481,6 +489,16 @@ # endif #endif /* !wxUSE_IMAGLIST */ +#if !wxUSE_MSGDLG +# ifdef wxABORT_ON_CONFIG_ERROR + /* FIXME: should compile without it, of course, but doesn't */ +# error "wxMessageBox is always needed" +# else +# undef wxUSE_MSGDLG +# define wxUSE_MSGDLG 1 +# endif +#endif + #if wxUSE_RADIOBTN # if defined(__WXUNIVERSAL__) && !wxUSE_CHECKBOX # ifdef wxABORT_ON_CONFIG_ERROR diff --git a/include/wx/datetime.h b/include/wx/datetime.h index 14c36c2d25..1dc31ef6d5 100644 --- a/include/wx/datetime.h +++ b/include/wx/datetime.h @@ -17,6 +17,8 @@ #pragma interface "datetime.h" #endif +#if wxUSE_DATETIME + #include #include // for INT_MIN @@ -1570,4 +1572,6 @@ inline WXDLLEXPORT void wxPrevWDay(wxDateTime::WeekDay& wd) : (wxDateTime::WeekDay)(wd - 1); } +#endif // wxUSE_DATETIME + #endif // _WX_DATETIME_H diff --git a/include/wx/generic/msgdlgg.h b/include/wx/generic/msgdlgg.h index 80e9d48827..df43bc5293 100644 --- a/include/wx/generic/msgdlgg.h +++ b/include/wx/generic/msgdlgg.h @@ -45,15 +45,6 @@ private: #if !defined( __WXMSW__ ) && !defined( __WXMAC__) && !defined(__WXPM__) #define wxMessageDialog wxGenericMessageDialog - -int wxMessageBox( const wxString& message - ,const wxString& caption = wxMessageBoxCaptionStr - ,long style = wxOK|wxCENTRE - ,wxWindow *parent = (wxWindow *) NULL - ,int x = -1 - ,int y = -1 - ); - #endif #endif diff --git a/include/wx/msgdlg.h b/include/wx/msgdlg.h index 573907b3c6..48d1a3c214 100644 --- a/include/wx/msgdlg.h +++ b/include/wx/msgdlg.h @@ -1,6 +1,8 @@ #ifndef _WX_MSGDLG_H_BASE_ #define _WX_MSGDLG_H_BASE_ +#if wxUSE_MSGDLG + #if defined(__WXMSW__) #include "wx/msw/msgdlg.h" #elif defined(__WXMOTIF__) @@ -17,5 +19,17 @@ #include "wx/generic/msgdlgg.h" #endif +// ---------------------------------------------------------------------------- +// wxMessageBox: the simplest way to use wxMessageDialog +// ---------------------------------------------------------------------------- + +int WXDLLEXPORT wxMessageBox(const wxString& message, + const wxString& caption = wxMessageBoxCaptionStr, + long style = wxOK | wxCENTRE, + wxWindow *parent = NULL, + int x = -1, int y = -1); + +#endif // wxUSE_MSGDLG + #endif // _WX_MSGDLG_H_BASE_ diff --git a/include/wx/msw/msgdlg.h b/include/wx/msw/msgdlg.h index 43093a234f..eeccdf6c91 100644 --- a/include/wx/msw/msgdlg.h +++ b/include/wx/msw/msgdlg.h @@ -41,9 +41,5 @@ public: }; -int WXDLLEXPORT wxMessageBox(const wxString& message, const wxString& caption = wxMessageBoxCaptionStr, - long style = wxOK|wxCENTRE, - wxWindow *parent = NULL, int x = -1, int y = -1); - #endif // _WX_MSGBOXDLG_H_ diff --git a/include/wx/msw/setup0.h b/include/wx/msw/setup0.h index 31fd6c1cf6..7a7ef8146a 100644 --- a/include/wx/msw/setup0.h +++ b/include/wx/msw/setup0.h @@ -232,7 +232,7 @@ // i18n support: _() macro, wxLocale class. Requires wxTextFile. #define wxUSE_INTL 1 -// Set wxUSE_TIMEDATE to 1 to compile the wxDateTime and related classes which +// Set wxUSE_DATETIME to 1 to compile the wxDateTime and related classes which // allow to manipulate dates, times and time intervals. wxDateTime replaces the // old wxTime and wxDate classes which are still provided for backwards // compatibility (and implemented in terms of wxDateTime). @@ -244,8 +244,19 @@ // // Requires: wxUSE_LONGLONG // +// Default is 1 +// // Recommended setting: 1 -#define wxUSE_TIMEDATE 1 +#define wxUSE_DATETIME 1 + +// wxUSE_TIMEDATE enables compilation of the old wxDate and wxTime classes (not +// the same as wxDateTime!). These classes are obsolete and shouldn't be used +// in new code +// +// Default is 0 +// +// Recommended setting: 0 unless you have legacy code which uses these classes +#define wxUSE_TIMEDATE 0 // Set wxUSE_TIMER to 1 to compile wxTimer class // @@ -539,6 +550,22 @@ // Recommended setting: 1 (unless it really doesn't work) #define wxUSE_COMMON_DIALOGS 1 +// wxBusyInfo displays window with message when app is busy. Works in same way +// as wxBusyCursor +#define wxUSE_BUSYINFO 1 + +// Use single/multiple choice dialogs. +// +// Default is 1 +// +// Recommended setting: 1 (used in the library itself) +#define wxUSE_CHOICEDLG 1 + +// wxDirDlg class for getting a directory name from user +#define wxUSE_DIRDLG 1 + +// TODO: setting to choose the generic or native one + // Use file open/save dialogs. // // Default is 1 @@ -553,29 +580,22 @@ // Recommended setting: 1 (used in the library itself) #define wxUSE_FONTDLG 1 -// Use single/multiple choice dialogs. +// Use wxMessageDialog and wxMessageBox. // // Default is 1 // // Recommended setting: 1 (used in the library itself) -#define wxUSE_CHOICEDLG 1 - -// text entry dialog and wxGetTextFromUser function -#define wxUSE_TEXTDLG 1 +#define wxUSE_MSGDLG 1 // progress dialog class for lengthy operations #define wxUSE_PROGRESSDLG 1 -// wxBusyInfo displays window with message when app is busy. Works in same way -// as wxBusyCursor -#define wxUSE_BUSYINFO 1 - -// wxDirDlg class for getting a directory name from user -#define wxUSE_DIRDLG 1 - // support for startup tips (wxShowTip &c) #define wxUSE_STARTUP_TIPS 1 +// text entry dialog and wxGetTextFromUser function +#define wxUSE_TEXTDLG 1 + // ---------------------------------------------------------------------------- // Metafiles support // ---------------------------------------------------------------------------- @@ -1073,7 +1093,7 @@ // you need to modify setup.h and rebuild everything // ---------------------------------------------------------------------------- -#if wxUSE_TIMEDATE && !wxUSE_LONGLONG +#if wxUSE_DATETIME && !wxUSE_LONGLONG #error wxDateTime requires wxLongLong #endif diff --git a/include/wx/scrolwin.h b/include/wx/scrolwin.h index 154e7286c0..9464b6973d 100644 --- a/include/wx/scrolwin.h +++ b/include/wx/scrolwin.h @@ -112,7 +112,9 @@ public: void HandleOnChar(wxKeyEvent& event); void HandleOnMouseEnter(wxMouseEvent& event); void HandleOnMouseLeave(wxMouseEvent& event); +#if wxUSE_MOUSEWHEEL void HandleOnMouseWheel(wxMouseEvent& event); +#endif // wxUSE_MOUSEWHEEL protected: // get pointer to our scroll rect if we use it or NULL @@ -158,6 +160,10 @@ protected: double m_scaleX; double m_scaleY; + +#if wxUSE_MOUSEWHEEL + int m_wheelRotation; +#endif // wxUSE_MOUSEWHEEL }; // ---------------------------------------------------------------------------- diff --git a/samples/menu/menu.cpp b/samples/menu/menu.cpp index 365e990140..58abd848dd 100644 --- a/samples/menu/menu.cpp +++ b/samples/menu/menu.cpp @@ -25,8 +25,11 @@ #endif #ifndef WX_PRECOMP - #include + #include + #include + #include #include + #include #endif #if !wxUSE_MENUS @@ -41,9 +44,6 @@ WX_USE_THEME(win32); WX_USE_THEME(gtk); - - // not implemented yet - #define wxMessageBox #endif // __WXUNIVERSAL__ // ---------------------------------------------------------------------------- @@ -67,7 +67,10 @@ public: void LogMenuEvent(const wxCommandEvent& event); +protected: void OnQuit(wxCommandEvent& event); + void OnClearLog(wxCommandEvent& event); + void OnAbout(wxCommandEvent& event); void OnDummy(wxCommandEvent& event); @@ -90,19 +93,29 @@ public: void OnGetLabelMenu(wxCommandEvent& event); void OnSetLabelMenu(wxCommandEvent& event); - void OnRightDown(wxMouseEvent& event); + void OnRightUp(wxMouseEvent& event); void OnUpdateCheckMenuItemUI(wxUpdateUIEvent& event); + void OnSize(wxSizeEvent& event); + private: wxMenu *CreateDummyMenu(wxString *title); wxMenuItem *GetLastMenuItem() const; - wxMenu *m_menu; + // the menu previously detached from the menubar (may be NULL) + wxMenu *m_menu; + // the count of dummy menus already created size_t m_countDummy; + // the control used for logging + wxTextCtrl *m_textctrl; + + // the previous log target + wxLog *m_logOld; + DECLARE_EVENT_TABLE() }; @@ -132,6 +145,7 @@ private: enum { Menu_File_Quit = 100, + Menu_File_ClearLog, Menu_MenuBar_Toggle = 200, Menu_MenuBar_Append, @@ -172,7 +186,8 @@ enum // ---------------------------------------------------------------------------- BEGIN_EVENT_TABLE(MyFrame, wxFrame) - EVT_MENU(Menu_File_Quit, MyFrame::OnQuit) + EVT_MENU(Menu_File_Quit, MyFrame::OnQuit) + EVT_MENU(Menu_File_ClearLog, MyFrame::OnClearLog) EVT_MENU(Menu_Help_About, MyFrame::OnAbout) @@ -198,7 +213,9 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_UPDATE_UI(Menu_Menu_Check, MyFrame::OnUpdateCheckMenuItemUI) - EVT_RIGHT_DOWN(MyFrame::OnRightDown) + EVT_RIGHT_UP(MyFrame::OnRightUp) + + EVT_SIZE(MyFrame::OnSize) END_EVENT_TABLE() BEGIN_EVENT_TABLE(MyEvtHandler, wxEvtHandler) @@ -225,7 +242,7 @@ bool MyApp::OnInit() frame->Show(TRUE); #if wxUSE_STATUSBAR - frame->SetStatusText("Hello, wxWindows"); + frame->SetStatusText("Welcome to wxWindows menu sample"); #endif // wxUSE_STATUSBAR SetTopWindow(frame); @@ -244,19 +261,21 @@ MyFrame::MyFrame() { m_menu = NULL; m_countDummy = 0; + m_logOld = NULL; #if wxUSE_STATUSBAR - CreateStatusBar(2); + CreateStatusBar(); #endif // wxUSE_STATUSBAR // create the menubar wxMenu *fileMenu = new wxMenu; - fileMenu->Append(Menu_File_Quit, "E&xit\tAlt-X", "Quit toolbar sample"); - wxMenuItem *itemBitmap = new wxMenuItem(fileMenu, Menu_File_Quit, - "Quit with &bitmap\tAlt-Q"); - itemBitmap->SetBitmap(wxBitmap(copy_xpm)); - fileMenu->Append(itemBitmap); + wxMenuItem *item = new wxMenuItem(fileMenu, Menu_File_ClearLog, + "Clear &log\tCtrl-L"); + item->SetBitmap(copy_xpm); + fileMenu->Append(item); + fileMenu->AppendSeparator(); + fileMenu->Append(Menu_File_Quit, "E&xit\tAlt-X", "Quit menu sample"); wxMenu *menubarMenu = new wxMenu; menubarMenu->Append(Menu_MenuBar_Append, "&Append menu\tCtrl-A", @@ -320,6 +339,19 @@ MyFrame::MyFrame() // intercept all menu events and log them in this custom event handler PushEventHandler(new MyEvtHandler(this)); + + // create the log text window + m_textctrl = new wxTextCtrl(this, -1, _T(""), + wxDefaultPosition, wxDefaultSize, + wxTE_MULTILINE); + m_textctrl->SetEditable(FALSE); + m_logOld = wxLog::SetActiveTarget(new wxLogTextCtrl(m_textctrl)); + + wxLogMessage(_T("Brief explanations: the commands or the \"Menu\" menu\n") + _T("append/insert/delete items to/from the last menu.\n") + _T("The commands from \"Menubar\" menu work with the\n") + _T("menubar itself.\n") + _T("Right click the band below to test popup menus.\n")); } MyFrame::~MyFrame() @@ -328,14 +360,17 @@ MyFrame::~MyFrame() // delete the event handler installed in ctor PopEventHandler(TRUE); + + // restore old logger + delete wxLog::SetActiveTarget(m_logOld); } wxMenu *MyFrame::CreateDummyMenu(wxString *title) { wxMenu *menu = new wxMenu; - menu->Append(Menu_Dummy_First, "First item\tCtrl-F1"); + menu->Append(Menu_Dummy_First, "&First item\tCtrl-F1"); menu->AppendSeparator(); - menu->Append(Menu_Dummy_Second, "Second item\tCtrl-F2", "", TRUE); + menu->Append(Menu_Dummy_Second, "&Second item\tCtrl-F2", "", TRUE); if ( title ) { @@ -366,8 +401,9 @@ wxMenuItem *MyFrame::GetLastMenuItem() const void MyFrame::LogMenuEvent(const wxCommandEvent& event) { int id = event.GetId(); - if (!GetMenuBar()->FindItem(id)) + if ( !GetMenuBar()->FindItem(id) ) return; + wxString msg = wxString::Format("Menu command %d", id); if ( GetMenuBar()->FindItem(id)->IsCheckable() ) { @@ -375,9 +411,7 @@ void MyFrame::LogMenuEvent(const wxCommandEvent& event) event.IsChecked() ? "" : "not "); } -#if wxUSE_STATUSBAR - SetStatusText(msg, 1); -#endif // wxUSE_STATUSBAR + wxLogMessage(msg); } // ---------------------------------------------------------------------------- @@ -389,11 +423,21 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) Close(TRUE); } +void MyFrame::OnClearLog(wxCommandEvent& WXUNUSED(event)) +{ + m_textctrl->Clear(); +} + void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { - (void)wxMessageBox("wxWindows toolbar sample", +#ifdef __WXUNIVERSAL__ + // wxMessageBox not implemented yet + wxLogMessage("wxWindows menu sample\n© 1999-2001 Vadim Zeitlin"); +#else + (void)wxMessageBox("wxWindows menu sample\n© 1999-2001 Vadim Zeitlin", "About wxWindows menu sample", wxICON_INFORMATION); +#endif } void MyFrame::OnDeleteMenu(wxCommandEvent& WXUNUSED(event)) @@ -442,15 +486,12 @@ void MyFrame::OnToggleMenu(wxCommandEvent& WXUNUSED(event)) } } -void MyFrame::OnEnableMenu(wxCommandEvent& WXUNUSED(event)) +void MyFrame::OnEnableMenu(wxCommandEvent& event) { wxMenuBar *mbar = GetMenuBar(); size_t count = mbar->GetMenuCount(); - static bool s_enabled = TRUE; - - s_enabled = !s_enabled; - mbar->EnableTop(count - 1, s_enabled); + mbar->EnableTop(count - 1, event.IsChecked()); } void MyFrame::OnGetLabelMenu(wxCommandEvent& WXUNUSED(event)) @@ -472,9 +513,7 @@ void MyFrame::OnSetLabelMenu(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnDummy(wxCommandEvent& event) { - wxString s; - s.Printf("Dummy item #%d", event.GetId() - Menu_Dummy_First + 1); - wxMessageBox(s, "Menu sample", wxICON_INFORMATION); + wxLogMessage("Dummy item #%d", event.GetId() - Menu_Dummy_First + 1); } void MyFrame::OnAppendMenuItem(wxCommandEvent& WXUNUSED(event)) @@ -483,7 +522,7 @@ void MyFrame::OnAppendMenuItem(wxCommandEvent& WXUNUSED(event)) wxMenu *menu = menubar->GetMenu(menubar->GetMenuCount() - 1); menu->AppendSeparator(); - menu->Append(Menu_Dummy_Third, "Third dummy item\tCtrl-F3", + menu->Append(Menu_Dummy_Third, "&Third dummy item\tCtrl-F3", "Checkable item", TRUE); } @@ -493,7 +532,7 @@ void MyFrame::OnAppendSubMenu(wxCommandEvent& WXUNUSED(event)) wxMenu *menu = menubar->GetMenu(menubar->GetMenuCount() - 1); - menu->Append(Menu_Dummy_Last, "Dummy sub menu", + menu->Append(Menu_Dummy_Last, "&Dummy sub menu", CreateDummyMenu(NULL), "Dummy sub menu help"); } @@ -645,15 +684,15 @@ void MyFrame::OnGetMenuItemInfo(wxCommandEvent& WXUNUSED(event)) } } -void MyFrame::OnRightDown(wxMouseEvent &event ) +void MyFrame::OnRightUp(wxMouseEvent &event) { wxMenu menu("Test popup"); menu.Append(Menu_Help_About, "&About"); - menu.Append(Menu_Popup_Submenu, "Submenu", CreateDummyMenu(NULL)); - menu.Append(Menu_Popup_ToBeDeleted, "To be deleted"); - menu.Append(Menu_Popup_ToBeChecked, "To be checked", "", TRUE); - menu.Append(Menu_Popup_ToBeGreyed, "To be greyed"); + menu.Append(Menu_Popup_Submenu, "&Submenu", CreateDummyMenu(NULL)); + menu.Append(Menu_Popup_ToBeDeleted, "To be &deleted"); + menu.Append(Menu_Popup_ToBeChecked, "To be &checked", "", TRUE); + menu.Append(Menu_Popup_ToBeGreyed, "To be &greyed"); menu.AppendSeparator(); menu.Append(Menu_File_Quit, "E&xit"); @@ -661,12 +700,27 @@ void MyFrame::OnRightDown(wxMouseEvent &event ) menu.Check(Menu_Popup_ToBeChecked, TRUE); menu.Enable(Menu_Popup_ToBeGreyed, FALSE); - PopupMenu( &menu, event.GetX(), event.GetY() ); + PopupMenu(&menu, event.GetX(), event.GetY()); // test for destroying items in popup menus -#if 0 +#if 0 // doesn't work in wxGTK! menu.Destroy(Menu_Popup_Submenu); PopupMenu( &menu, event.GetX(), event.GetY() ); #endif // 0 } + +void MyFrame::OnSize(wxSizeEvent& event) +{ + // leave a band below for popup menu testing + wxSize size = GetClientSize(); + m_textctrl->SetSize(0, 0, size.x, (3*size.y)/4); + + // this is really ugly but we have to do it as we can't just call + // event.Skip() because wxFrameBase would make the text control fill the + // entire frame then +#ifdef __WXUNIVERSAL__ + PositionMenuBar(); +#endif // __WXUNIVERSAL__ +} + diff --git a/src/common/radiocmn.cpp b/src/common/radiocmn.cpp new file mode 100644 index 0000000000..2c91443928 --- /dev/null +++ b/src/common/radiocmn.cpp @@ -0,0 +1,138 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: src/common/radiocmn.cpp +// Purpose: wxRadioBox methods common to all ports +// Author: Vadim Zeitlin +// Modified by: +// Created: 03.06.01 +// RCS-ID: $Id$ +// Copyright: (c) 2001 Vadim Zeitlin +// License: wxWindows license +/////////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#ifdef __GNUG__ + #pragma implementation "radioboxbase.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#if wxUSE_RADIOBOX + +#ifndef WX_PRECOMP + #include "wx/radiobox.h" +#endif //WX_PRECOMP + +// ============================================================================ +// implementation +// ============================================================================ + +int wxRadioBoxBase::GetNextItem(int item, wxDirection dir, long style) const +{ + int count = GetCount(), + numCols = GetColumnCount(), + numRows = GetRowCount(); + + bool horz = (style & wxRA_SPECIFY_COLS) != 0; + + switch ( dir ) + { + case wxUP: + if ( horz ) + { + item -= numCols; + } + else // vertical layout + { + if ( !item-- ) + item = count - 1; + } + break; + + case wxLEFT: + if ( horz ) + { + if ( !item-- ) + item = count - 1; + } + else // vertical layout + { + item -= numRows; + } + break; + + case wxDOWN: + if ( horz ) + { + item += numCols; + } + else // vertical layout + { + if ( ++item == count ) + item = 0; + } + break; + + case wxRIGHT: + if ( horz ) + { + if ( ++item == count ) + item = 0; + } + else // vertical layout + { + item += numRows; + } + break; + + default: + wxFAIL_MSG( _T("unexpected wxDirection value") ); + return -1; + } + + // ensure that the item is in range [0..count) + if ( item < 0 ) + { + // first map the item to the one in the same column but in the last row + item += count; + + // now there are 2 cases: either it is the first item of the last row + // in which case we need to wrap again and get to the last item or we + // can just go to the previous item + if ( item % (horz ? numCols : numRows) ) + item--; + else + item = count - 1; + } + else if ( item >= count ) + { + // same logic as above + item -= count; + + // ... except that we need to check if this is not the last item, not + // the first one + if ( (item + 1) % (horz ? numCols : numRows) ) + item++; + else + item = 0; + } + + wxASSERT_MSG( item < count && item >= 0, + _T("logic error in wxRadioBox::GetNextItem()") ); + + return item; +} + +#endif // wxUSE_RADIOBOX + diff --git a/src/generic/scrolwin.cpp b/src/generic/scrolwin.cpp index 3a07c7886e..991029613d 100644 --- a/src/generic/scrolwin.cpp +++ b/src/generic/scrolwin.cpp @@ -174,42 +174,49 @@ bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event) // ProcessEvent() above event.Skip(FALSE); - switch ( event.GetEventType() ) - { - case wxEVT_SCROLLWIN_TOP: - case wxEVT_SCROLLWIN_BOTTOM: - case wxEVT_SCROLLWIN_LINEUP: - case wxEVT_SCROLLWIN_LINEDOWN: - case wxEVT_SCROLLWIN_PAGEUP: - case wxEVT_SCROLLWIN_PAGEDOWN: - case wxEVT_SCROLLWIN_THUMBTRACK: - case wxEVT_SCROLLWIN_THUMBRELEASE: - m_scrollHelper->HandleOnScroll((wxScrollWinEvent &)event); - return !event.GetSkipped(); + wxEventType evType = event.GetEventType(); - case wxEVT_PAINT: - m_scrollHelper->HandleOnPaint((wxPaintEvent &)event); - return TRUE; - - case wxEVT_SIZE: - m_scrollHelper->HandleOnSize((wxSizeEvent &)event); - return FALSE; + if ( evType == wxEVT_PAINT ) + { + m_scrollHelper->HandleOnPaint((wxPaintEvent &)event); + return TRUE; + } - case wxEVT_CHAR: - m_scrollHelper->HandleOnChar((wxKeyEvent &)event); + if ( evType == wxEVT_SCROLLWIN_TOP || + evType == wxEVT_SCROLLWIN_BOTTOM || + evType == wxEVT_SCROLLWIN_LINEUP || + evType == wxEVT_SCROLLWIN_LINEDOWN || + evType == wxEVT_SCROLLWIN_PAGEUP || + evType == wxEVT_SCROLLWIN_PAGEDOWN || + evType == wxEVT_SCROLLWIN_THUMBTRACK || + evType == wxEVT_SCROLLWIN_THUMBRELEASE ) + { + m_scrollHelper->HandleOnScroll((wxScrollWinEvent &)event); return !event.GetSkipped(); + } - case wxEVT_ENTER_WINDOW: - m_scrollHelper->HandleOnMouseEnter((wxMouseEvent &)event); - break; - - case wxEVT_LEAVE_WINDOW: - m_scrollHelper->HandleOnMouseLeave((wxMouseEvent &)event); - break; - - case wxEVT_MOUSEWHEEL: - m_scrollHelper->HandleOnMouseWheel((wxMouseEvent &)event); - break; + if ( evType == wxEVT_ENTER_WINDOW ) + { + m_scrollHelper->HandleOnMouseEnter((wxMouseEvent &)event); + } + else if ( evType == wxEVT_LEAVE_WINDOW ) + { + m_scrollHelper->HandleOnMouseLeave((wxMouseEvent &)event); + } +#if wxUSE_MOUSEWHEEL + else if ( evType == wxEVT_MOUSEWHEEL ) + { + m_scrollHelper->HandleOnMouseWheel((wxMouseEvent &)event); + } +#endif // wxUSE_MOUSEWHEEL + else if ( evType == wxEVT_SIZE ) + { + m_scrollHelper->HandleOnSize((wxSizeEvent &)event); + } + else if ( evType == wxEVT_CHAR ) + { + m_scrollHelper->HandleOnChar((wxKeyEvent &)event); + return !event.GetSkipped(); } return FALSE; @@ -937,6 +944,8 @@ void wxScrollHelper::HandleOnMouseLeave(wxMouseEvent& event) } } +#if wxUSE_MOUSEWHEEL + void wxScrollHelper::HandleOnMouseWheel(wxMouseEvent& event) { m_wheelRotation += event.GetWheelRotation(); @@ -953,6 +962,8 @@ void wxScrollHelper::HandleOnMouseWheel(wxMouseEvent& event) } } +#endif // wxUSE_MOUSEWHEEL + // ---------------------------------------------------------------------------- // wxGenericScrolledWindow implementation // ---------------------------------------------------------------------------- diff --git a/src/html/htmlcell.cpp b/src/html/htmlcell.cpp index daab625a4c..c907af3fe7 100644 --- a/src/html/htmlcell.cpp +++ b/src/html/htmlcell.cpp @@ -784,7 +784,7 @@ void wxHtmlWidgetCell::Draw(wxDC& dc, int x, int y, int view_y1, int view_y2) c = c->GetParent(); } - ((wxScrolledWindow*)(m_Wnd->GetParent()))->ViewStart(&stx, &sty); + ((wxScrolledWindow*)(m_Wnd->GetParent()))->GetViewStart(&stx, &sty); m_Wnd->SetSize(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty, m_Width, m_Height); wxHtmlCell::Draw(dc, x, y, view_y1, view_y2); @@ -804,7 +804,7 @@ void wxHtmlWidgetCell::DrawInvisible(wxDC& dc, int x, int y) c = c->GetParent(); } - ((wxScrolledWindow*)(m_Wnd->GetParent()))->ViewStart(&stx, &sty); + ((wxScrolledWindow*)(m_Wnd->GetParent()))->GetViewStart(&stx, &sty); m_Wnd->SetSize(absx - wxHTML_SCROLL_STEP * stx, absy - wxHTML_SCROLL_STEP * sty, m_Width, m_Height); wxHtmlCell::DrawInvisible(dc, x, y); diff --git a/src/html/htmlwin.cpp b/src/html/htmlwin.cpp index d6b79d5cbd..9db304ff22 100644 --- a/src/html/htmlwin.cpp +++ b/src/html/htmlwin.cpp @@ -150,7 +150,7 @@ bool wxHtmlWindow::SetPage(const wxString& source) nodeG = (m_GlobalProcessors) ? m_GlobalProcessors->GetFirst() : NULL; // VS: there are two lists, global and local, both of them sorted by - // priority. Since we have to go through _both_ lists with + // priority. Since we have to go through _both_ lists with // decreasing priority, we "merge-sort" the lists on-line by // processing that one of the two heads that has higher priority // in every iteration @@ -205,15 +205,15 @@ bool wxHtmlWindow::LoadPage(const wxString& location) wxYield(); Refresh(FALSE); m_tmpCanDrawLocks++; - if (m_HistoryOn && (m_HistoryPos != -1)) + if (m_HistoryOn && (m_HistoryPos != -1)) { // store scroll position into history item: int x, y; - ViewStart(&x, &y); + GetViewStart(&x, &y); (*m_History)[m_HistoryPos].SetPos(y); } - if (location[0] == wxT('#')) + if (location[0] == wxT('#')) { // local anchor: wxString anch = location.Mid(1) /*1 to end*/; @@ -230,7 +230,7 @@ bool wxHtmlWindow::LoadPage(const wxString& location) } else if (location.Find(wxT('#')) != wxNOT_FOUND && (m_FS->GetPath() + location.BeforeFirst(wxT('#'))) == m_OpenedPage) - { + { wxString anch = location.AfterFirst(wxT('#')); m_tmpCanDrawLocks--; rt_val = ScrollToAnchor(anch); @@ -242,7 +242,7 @@ bool wxHtmlWindow::LoadPage(const wxString& location) needs_refresh = TRUE; // load&display it: if (m_RelatedStatusBar != -1) - { + { m_RelatedFrame->SetStatusText(_("Connecting..."), m_RelatedStatusBar); Refresh(FALSE); } @@ -250,9 +250,7 @@ bool wxHtmlWindow::LoadPage(const wxString& location) f = m_FS->OpenFile(location); if (f == NULL) - { - wxString err; - + { wxLogError(_("Unable to open requested HTML document: %s"), location.c_str()); m_tmpCanDrawLocks--; @@ -261,12 +259,12 @@ bool wxHtmlWindow::LoadPage(const wxString& location) } else - { + { wxNode *node; wxString src = wxEmptyString; if (m_RelatedStatusBar != -1) - { + { wxString msg = _("Loading : ") + location; m_RelatedFrame->SetStatusText(msg, m_RelatedStatusBar); Refresh(FALSE); @@ -274,17 +272,17 @@ bool wxHtmlWindow::LoadPage(const wxString& location) node = m_Filters.GetFirst(); while (node) - { + { wxHtmlFilter *h = (wxHtmlFilter*) node->GetData(); if (h->CanRead(*f)) - { + { src = h->ReadFile(*f); break; } node = node->GetNext(); } if (src == wxEmptyString) - { + { if (m_DefaultFilter == NULL) m_DefaultFilter = GetDefaultFilter(); src = m_DefaultFilter->ReadFile(*f); } @@ -293,7 +291,7 @@ bool wxHtmlWindow::LoadPage(const wxString& location) rt_val = SetPage(src); m_OpenedPage = f->GetLocation(); if (f->GetAnchor() != wxEmptyString) - { + { wxYield(); ScrollToAnchor(f->GetAnchor()); } @@ -384,7 +382,7 @@ void wxHtmlWindow::CreateLayout() GetClientSize(&ClientWidth, &ClientHeight); m_Cell->Layout(ClientWidth); if (ClientHeight < m_Cell->GetHeight() + GetCharHeight()) - { + { SetScrollbars( wxHTML_SCROLL_STEP, wxHTML_SCROLL_STEP, m_Cell->GetWidth() / wxHTML_SCROLL_STEP, @@ -392,7 +390,7 @@ void wxHtmlWindow::CreateLayout() /*cheat: top-level frag is always container*/); } else /* we fit into window, no need for scrollbars */ - { + { SetScrollbars(wxHTML_SCROLL_STEP, 1, m_Cell->GetWidth() / wxHTML_SCROLL_STEP, 0); // disable... GetClientSize(&ClientWidth, &ClientHeight); m_Cell->Layout(ClientWidth); // ...and relayout @@ -465,7 +463,7 @@ bool wxHtmlWindow::HistoryBack() // store scroll position into history item: int x, y; - ViewStart(&x, &y); + GetViewStart(&x, &y); (*m_History)[m_HistoryPos].SetPos(y); // go to previous position: @@ -558,7 +556,7 @@ void wxHtmlWindow::AddProcessor(wxHtmlProcessor *processor) m_GlobalProcessors->DeleteContents(TRUE); } wxHtmlProcessorList::Node *node; - + for (node = m_GlobalProcessors->GetFirst(); node; node = node->GetNext()) { if (processor->GetPriority() > node->GetData()->GetPriority()) @@ -624,7 +622,7 @@ void wxHtmlWindow::OnDraw(wxDC& dc) #endif #endif dc.SetBackgroundMode(wxTRANSPARENT); - ViewStart(&x, &y); + GetViewStart(&x, &y); while (upd) { @@ -656,7 +654,7 @@ void wxHtmlWindow::OnMouseEvent(wxMouseEvent& event) wxPoint pos; wxString lnk; - ViewStart(&sx, &sy); sx *= wxHTML_SCROLL_STEP; sy *= wxHTML_SCROLL_STEP; + GetViewStart(&sx, &sy); sx *= wxHTML_SCROLL_STEP; sy *= wxHTML_SCROLL_STEP; pos = event.GetPosition(); if (m_Cell) @@ -680,20 +678,20 @@ void wxHtmlWindow::OnIdle(wxIdleEvent& WXUNUSED(event)) int x, y; wxHtmlLinkInfo *lnk; - ViewStart(&sx, &sy); sx *= wxHTML_SCROLL_STEP; sy *= wxHTML_SCROLL_STEP; + GetViewStart(&sx, &sy); sx *= wxHTML_SCROLL_STEP; sy *= wxHTML_SCROLL_STEP; wxGetMousePosition(&x, &y); ScreenToClient(&x, &y); lnk = m_Cell->GetLink(sx + x, sy + y); if (lnk != m_tmpLastLink) - { + { if (lnk == NULL) - { + { SetCursor(*s_cur_arrow); if (m_RelatedStatusBar != -1) m_RelatedFrame->SetStatusText(wxEmptyString, m_RelatedStatusBar); } else - { + { SetCursor(*s_cur_hand); if (m_RelatedStatusBar != -1) m_RelatedFrame->SetStatusText(lnk->GetHref(), m_RelatedStatusBar); diff --git a/src/msw/font.cpp b/src/msw/font.cpp index a2a73706ed..87ab343794 100644 --- a/src/msw/font.cpp +++ b/src/msw/font.cpp @@ -645,115 +645,11 @@ wxFontEncoding wxFont::GetEncoding() const return M_FONTDATA->m_encoding; } -// ---------------------------------------------------------------------------- -// wxNativeFontInfo -// ---------------------------------------------------------------------------- - -bool wxNativeFontInfo::FromString(const wxString& s) -{ - long l; - - wxStringTokenizer tokenizer(s, _T(";")); - - wxString token = tokenizer.GetNextToken(); - // - // Ignore the version for now - // - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfHeight = l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfWidth = l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfEscapement = l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfOrientation = l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfWeight = l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfItalic = (BYTE)l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfUnderline = (BYTE)l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfStrikeOut = (BYTE)l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfCharSet = (BYTE)l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfOutPrecision = (BYTE)l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfClipPrecision = (BYTE)l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfQuality = (BYTE)l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfPitchAndFamily = (BYTE)l; - - token = tokenizer.GetNextToken(); - if(!token) - return FALSE; - wxStrcpy(lf.lfFaceName, token.c_str()); - - return TRUE; -} - -wxString wxNativeFontInfo::ToString() const +wxNativeFontInfo *wxFont::GetNativeFontInfo() const { - wxString s; + if( M_FONTDATA->m_nativeFontInfoOk ) + return new wxNativeFontInfo(M_FONTDATA->m_nativeFontInfo); - s.Printf(_T("%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%s"), - 0, // version, in case we want to change the format later - lf.lfHeight, - lf.lfWidth, - lf.lfEscapement, - lf.lfOrientation, - lf.lfWeight, - lf.lfItalic, - lf.lfUnderline, - lf.lfStrikeOut, - lf.lfCharSet, - lf.lfOutPrecision, - lf.lfClipPrecision, - lf.lfQuality, - lf.lfPitchAndFamily, - lf.lfFaceName); - - return s; + return 0; } diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 1d73b061d6..3bd2d2cfa8 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1992,7 +1992,8 @@ static void wxConvertToMSWListItem(const wxListCtrl *ctrl, wxListItem& info, LV_ } else { - lvItem.pszText = info.m_text; + // pszText is not const, hence the cast + lvItem.pszText = (wxChar *)info.m_text.c_str(); if ( lvItem.pszText ) lvItem.cchTextMax = info.m_text.Length(); else diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index 3ff4dd87ce..dc4f4d5d4c 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -196,7 +196,8 @@ bool wxNotebook::Create(wxWindow *parent, // dtor wxNotebook::~wxNotebook() { - if (m_bOwnsImageList) delete m_pImageList; + if (m_bOwnsImageList) + delete m_imageList; } // ---------------------------------------------------------------------------- diff --git a/src/msw/ole/automtn.cpp b/src/msw/ole/automtn.cpp index e08b49196d..7586cd9aae 100644 --- a/src/msw/ole/automtn.cpp +++ b/src/msw/ole/automtn.cpp @@ -85,9 +85,11 @@ static wxString ConvertStringFromOle(BSTR bStr); static int rgMonthDays[13] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}; +#if wxUSE_TIMEDATE static BOOL OleDateFromTm(WORD wYear, WORD wMonth, WORD wDay, WORD wHour, WORD wMinute, WORD wSecond, DATE& dtDest); static BOOL TmFromOleDate(DATE dtSrc, struct tm& tmDest); +#endif // wxUSE_TIMEDATE static void ClearVariant(VARIANTARG *pvarg) ; static void ReleaseVariant(VARIANTARG *pvarg) ; diff --git a/src/msw/radiobox.cpp b/src/msw/radiobox.cpp index 7d41132ef3..026f8a2830 100644 --- a/src/msw/radiobox.cpp +++ b/src/msw/radiobox.cpp @@ -905,14 +905,7 @@ LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd, bool processed = TRUE; - bool horz = (radiobox->GetWindowStyle() & wxRA_SPECIFY_COLS) != 0; - int num = radiobox->Number(), - rows = radiobox->GetNumVer(), - cols = radiobox->GetNumHor(); - - int selOld = radiobox->GetSelection(); - int selNew = selOld; - + wxDirection dir; switch ( wParam ) { case VK_UP: @@ -948,17 +941,6 @@ LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd, radiobox->GetWindowStyle() ); - int dim = horz ? cols : rows; - if ( selNew % dim == 0 ) - { - selNew -= dim - 1; - } - else - { - selNew++; - } - } - if ( selNew != selOld ) { radiobox->SetSelection(selNew); @@ -974,45 +956,45 @@ LRESULT APIENTRY _EXPORT wxRadioBtnWndProc(HWND hwnd, #ifdef __WIN32__ case WM_HELP: - { - 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?") ); - bool processed = TRUE; + bool processed = TRUE; - HELPINFO* info = (HELPINFO*) lParam; - // Don't yet process menu help events, just windows - if (info->iContextType == HELPINFO_WINDOW) - { - wxWindow* subjectOfHelp = radiobox; - bool eventProcessed = FALSE; - while (subjectOfHelp && !eventProcessed) + HELPINFO* info = (HELPINFO*) lParam; + // Don't yet process menu help events, just windows + if (info->iContextType == HELPINFO_WINDOW) { - wxHelpEvent helpEvent(wxEVT_HELP, subjectOfHelp->GetId(), wxPoint(info->MousePos.x, info->MousePos.y) ) ; // info->iCtrlId); - helpEvent.SetEventObject(radiobox); - eventProcessed = radiobox->GetEventHandler()->ProcessEvent(helpEvent); + wxWindow* subjectOfHelp = radiobox; + bool eventProcessed = FALSE; + while (subjectOfHelp && !eventProcessed) + { + wxHelpEvent helpEvent(wxEVT_HELP, subjectOfHelp->GetId(), wxPoint(info->MousePos.x, info->MousePos.y) ) ; // info->iCtrlId); + helpEvent.SetEventObject(radiobox); + eventProcessed = radiobox->GetEventHandler()->ProcessEvent(helpEvent); - // Go up the window hierarchy until the event is handled (or not) - subjectOfHelp = subjectOfHelp->GetParent(); + // Go up the window hierarchy until the event is handled (or not) + subjectOfHelp = subjectOfHelp->GetParent(); + } + processed = eventProcessed; } - processed = eventProcessed; - } - else if (info->iContextType == HELPINFO_MENUITEM) - { - wxHelpEvent helpEvent(wxEVT_HELP, info->iCtrlId) ; - helpEvent.SetEventObject(radiobox); - processed = radiobox->GetEventHandler()->ProcessEvent(helpEvent); - } - else processed = FALSE; + else if (info->iContextType == HELPINFO_MENUITEM) + { + wxHelpEvent helpEvent(wxEVT_HELP, info->iCtrlId) ; + helpEvent.SetEventObject(radiobox); + processed = radiobox->GetEventHandler()->ProcessEvent(helpEvent); + } + else processed = FALSE; - if (processed) - return 0; + if (processed) + return 0; - break; - } -#endif + break; + } +#endif // __WIN32__ } return ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn, hwnd, message, wParam, lParam); diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 31ef0ea340..814fb2bf6e 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -166,8 +166,6 @@ static bool IsMouseInWindow(HWND hwnd); // event tables // --------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) - // in wxUniv/MSW this class is abstract because it doesn't have DoPopupMenu() // method #ifdef __WXUNIVERSAL__ -- 2.45.2