From 9d9b77552eeb78e0c7ee903aa265dc187651ff57 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 29 Dec 1999 19:18:01 +0000 Subject: [PATCH] 1. wxCalendarCtrl 2. several wxDateTime bugs corrected, a couple of missing functions added 3. GetBestSize() corrections for several wxGTK controls 4. wxStaticLine doesn't get focus any more under MSW 5. added DoMoveWindow() to wxMotif git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5142 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- Makefile.in | 10 +- distrib/msw/tmake/filelist.txt | 3 + docs/latex/wx/tclipbrd.tex | 2 + include/wx/calctrl.h | 39 ++++ include/wx/datetime.h | 17 +- include/wx/datetime.inl | 11 +- include/wx/event.h | 6 + include/wx/generic/calctrl.h | 34 ++- include/wx/gtk/spinbutt.h | 3 + include/wx/gtk/spinctrl.h | 3 + include/wx/gtk/window.h | 5 +- include/wx/gtk1/spinbutt.h | 3 + include/wx/gtk1/spinctrl.h | 3 + include/wx/gtk1/window.h | 5 +- include/wx/motif/window.h | 1 + include/wx/msw/statline.h | 3 + include/wx/spinctrl.h | 3 +- include/wx/window.h | 6 + samples/console/console.cpp | 242 ++++++++++++++++++---- samples/controls/controls.cpp | 105 +++++++--- src/common/datetime.cpp | 102 +++++---- src/generic/calctrl.cpp | 368 ++++++++++++++++++++++++++++++--- src/gtk/combobox.cpp | 17 +- src/gtk/spinbutt.cpp | 14 +- src/gtk/spinctrl.cpp | 12 +- src/gtk1/combobox.cpp | 17 +- src/gtk1/spinbutt.cpp | 14 +- src/gtk1/spinctrl.cpp | 12 +- src/motif/window.cpp | 96 ++++----- src/msw/makefile.b32 | 7 +- src/msw/makefile.bcc | 5 +- src/msw/makefile.dos | 8 +- src/msw/makefile.g95 | 3 +- src/msw/makefile.sc | 3 +- src/msw/makefile.vc | 103 +-------- src/msw/makefile.wat | 6 +- 36 files changed, 949 insertions(+), 342 deletions(-) create mode 100644 include/wx/calctrl.h diff --git a/Makefile.in b/Makefile.in index dc715e5b5f..c1a87c58e0 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,5 +1,5 @@ # -# This file was automatically generated by tmake at 16:50, 1999/12/21 +# This file was automatically generated by tmake at 20:12, 1999/12/29 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE UNX.T! # @@ -179,6 +179,7 @@ WX_HEADERS = \ buffer.h \ busyinfo.h \ button.h \ + calctrl.h \ caret.h \ checkbox.h \ checklst.h \ @@ -581,6 +582,7 @@ UNIX_HEADERS = \ unix/fontutil.h GENERIC_HEADERS = \ + generic/calctrl.h \ generic/caret.h \ generic/choicdgg.h \ generic/colrdlgg.h \ @@ -635,6 +637,7 @@ HTML_HEADERS = \ GTK_GENERICOBJS = \ busyinfo.o \ + calctrl.o \ caret.o \ choicdgg.o \ colrdlgg.o \ @@ -671,6 +674,7 @@ GTK_GENERICOBJS = \ GTK_GENERICDEPS = \ busyinfo.d \ + calctrl.d \ caret.d \ choicdgg.d \ colrdlgg.d \ @@ -1019,6 +1023,7 @@ GTK_GUIDEPS = \ MOTIF_GENERICOBJS = \ busyinfo.o \ + calctrl.o \ caret.o \ choicdgg.o \ colrdlgg.o \ @@ -1058,6 +1063,7 @@ MOTIF_GENERICOBJS = \ MOTIF_GENERICDEPS = \ busyinfo.d \ + calctrl.d \ caret.d \ choicdgg.d \ colrdlgg.d \ @@ -1399,6 +1405,7 @@ MOTIF_GUIDEPS = \ MSW_GENERICOBJS = \ busyinfo.o \ + calctrl.o \ choicdgg.o \ dirdlgg.o \ grid.o \ @@ -1421,6 +1428,7 @@ MSW_GENERICOBJS = \ MSW_GENERICDEPS = \ busyinfo.d \ + calctrl.d \ choicdgg.d \ dirdlgg.d \ grid.d \ diff --git a/distrib/msw/tmake/filelist.txt b/distrib/msw/tmake/filelist.txt index f39662b862..d92911ca19 100644 --- a/distrib/msw/tmake/filelist.txt +++ b/distrib/msw/tmake/filelist.txt @@ -57,6 +57,7 @@ # File name Type Flags busyinfo.cpp G +calctrl.cpp G caret.cpp G U choicdgg.cpp G colrdlgg.cpp G G @@ -518,6 +519,7 @@ brush.h W buffer.h W busyinfo.h W button.h W +calctrl.h W caret.h W checkbox.h W checklst.h W @@ -1033,6 +1035,7 @@ winpars.h L m_templ.h L htmprint.h L +calctrl.h N caret.h N choicdgg.h N colrdlgg.h N diff --git a/docs/latex/wx/tclipbrd.tex b/docs/latex/wx/tclipbrd.tex index acdf8cac9e..545c46195b 100644 --- a/docs/latex/wx/tclipbrd.tex +++ b/docs/latex/wx/tclipbrd.tex @@ -6,6 +6,8 @@ Classes: \helpref{wxDataObject}{wxdataobject}, \helpref{wxDropSource}{wxdropsource}, \helpref{wxDropTarget}{wxdroptarget} +See also: \helpref{Drag and drop overview}{wxdndoverview} and \helpref{DnD sample}{samplednd} + This overview discusses data transfer through clipboard or drag and drop. In wxWindows, these two ways to transfer data (either between different applications or inside one and the same) are very similar which allows to diff --git a/include/wx/calctrl.h b/include/wx/calctrl.h new file mode 100644 index 0000000000..1017e4e182 --- /dev/null +++ b/include/wx/calctrl.h @@ -0,0 +1,39 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/calctrl.h +// Purpose: date-picker control +// Author: Vadim Zeitlin +// Modified by: +// Created: 29.12.99 +// RCS-ID: $Id$ +// Copyright: (c) 1999 Vadim Zeitlin +// Licence: wxWindows license +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_CALCTRL_H +#define _WX_CALCTRL_H + +// so far we only have a generic version, so keep it simple +#include "wx/generic/calctrl.h" + +// ---------------------------------------------------------------------------- +// wxCalendarCtrl events +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxCalendarEvent : public wxCommandEvent +{ +public: + wxCalendarEvent() { } + wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type); + + const wxDateTime& GetDate() const { return m_date; } + +private: + wxDateTime m_date; +}; + +#define EVT_CALENDAR(id, fn) { wxEVT_CALENDAR_SEL_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, +#define EVT_CALENDAR_DAY(id, fn) { wxEVT_CALENDAR_DAY_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, +#define EVT_CALENDAR_MONTH(id, fn) { wxEVT_CALENDAR_MONTH_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, +#define EVT_CALENDAR_YEAR(id, fn) { wxEVT_CALENDAR_YEAR_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) & fn, (wxObject *) NULL }, + +#endif // _WX_CALCTRL_H diff --git a/include/wx/datetime.h b/include/wx/datetime.h index e19d049dd3..7ca809ea1c 100644 --- a/include/wx/datetime.h +++ b/include/wx/datetime.h @@ -363,6 +363,14 @@ public: Name_Abbr = 0x02 // return abbreviated name }; + // flags for GetWeekOfYear and GetWeekOfMonth + enum WeekFlags + { + Default_First, // Sunday_First for US, Monday_First for the rest + Monday_First, // week starts with a Monday + Sunday_First // week starts with a Sunday + }; + // helper classes // ------------------------------------------------------------------------ @@ -767,10 +775,12 @@ public: wxDateTime_t GetDayOfYear(const TimeZone& tz = Local) const; // get the week number since the year start (1..52 or 53, 0 if date is // invalid) - wxDateTime_t GetWeekOfYear(const TimeZone& tz = Local) const; + wxDateTime_t GetWeekOfYear(WeekFlags flags = Monday_First, + const TimeZone& tz = Local) const; // get the week number since the month start (1..5, 0 if date is // invalid) - wxDateTime_t GetWeekOfMonth(const TimeZone& tz = Local) const; + wxDateTime_t GetWeekOfMonth(WeekFlags flags = Monday_First, + const TimeZone& tz = Local) const; // is this date a work day? This depends on a country, of course, // because the holidays are different in different countries @@ -881,6 +891,9 @@ public: wxString FormatDate() const { return Format(_T("%x")); } // preferred time representation for the current locale wxString FormatTime() const { return Format(_T("%X")); } + // return the string representing the date in ISO 8601 format + // (YYYY-MM-DD) + wxString FormatISODate() const { return Format(_T("%Y-%m-%d")); } // implementation // ------------------------------------------------------------------------ diff --git a/include/wx/datetime.inl b/include/wx/datetime.inl index 3fb5776196..f5d1eeda71 100644 --- a/include/wx/datetime.inl +++ b/include/wx/datetime.inl @@ -35,13 +35,18 @@ bool wxDateTime::IsInStdRange() const /* static */ wxDateTime wxDateTime::Now() { - return wxDateTime(GetTimeNow()); + return wxDateTime(*GetTmNow()); } /* static */ wxDateTime wxDateTime::Today() { - return wxDateTime((time_t)(86400*(GetTimeNow() / 86400))); + struct tm *tm = GetTmNow(); + tm->tm_hour = + tm->tm_min = + tm->tm_sec = 0; + + return wxDateTime(*tm); } wxDateTime& wxDateTime::Set(time_t timet) @@ -55,7 +60,7 @@ wxDateTime& wxDateTime::Set(time_t timet) wxDateTime& wxDateTime::SetToCurrent() { - return Set(GetTimeNow()); + return *this = Now(); } wxDateTime::wxDateTime(time_t timet) diff --git a/include/wx/event.h b/include/wx/event.h index cc865950aa..d125990a06 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -250,6 +250,12 @@ const wxEventType wxEVT_WIZARD_PAGE_CHANGED = wxEVT_FIRST + 900; const wxEventType wxEVT_WIZARD_PAGE_CHANGING = wxEVT_FIRST + 901; const wxEventType wxEVT_WIZARD_CANCEL = wxEVT_FIRST + 902; +/* Calendar events */ +const wxEventType wxEVT_CALENDAR_SEL_CHANGED = wxEVT_FIRST + 950; +const wxEventType wxEVT_CALENDAR_DAY_CHANGED = wxEVT_FIRST + 951; +const wxEventType wxEVT_CALENDAR_MONTH_CHANGED = wxEVT_FIRST + 952; +const wxEventType wxEVT_CALENDAR_YEAR_CHANGED = wxEVT_FIRST + 953; + const wxEventType wxEVT_USER_FIRST = wxEVT_FIRST + 2000; /* Compatibility */ diff --git a/include/wx/generic/calctrl.h b/include/wx/generic/calctrl.h index c781064441..5bde99940d 100644 --- a/include/wx/generic/calctrl.h +++ b/include/wx/generic/calctrl.h @@ -63,12 +63,6 @@ public: // value bool HitTest(const wxPoint& pos, wxDateTime *date); - // implementation only from now on - // ------------------------------- - - void OnPaint(wxPaintEvent& event); - void OnClick(wxMouseEvent& event); - private: // common part of all ctors void Init(); @@ -78,12 +72,37 @@ private: virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags); virtual void DoMoveWindow(int x, int y, int width, int height); + // (re)calc m_widthCol and m_heightRow + void RecalcGeometry(); + + // event handlers + void OnPaint(wxPaintEvent& event); + void OnClick(wxMouseEvent& event); + void OnChar(wxKeyEvent& event); + void OnMonthChange(wxCommandEvent& event); + void OnYearChange(wxSpinEvent& event); + + // set the date and send the notification + void SetDateAndNotify(const wxDateTime& date); + + // get the week (row, in range 1..6) for the given date + size_t GetWeek(const wxDateTime& date) const; + // get the date from which we start drawing days wxDateTime GetStartDate() const; // is this date shown? bool IsDateShown(const wxDateTime& date) const; + // redraw the given date + void RefreshDate(const wxDateTime& date); + + // change the date inside the same month/year + void ChangeDay(const wxDateTime& date); + + // generate a calendar event + void GenerateEvent(wxEventType type); + // the subcontrols wxComboBox *m_comboMonth; wxSpinCtrl *m_spinYear; @@ -94,6 +113,9 @@ private: wxCoord m_widthCol, m_heightRow; + // the week day names + wxString m_weekdays[7]; + DECLARE_DYNAMIC_CLASS(wxCalendarCtrl) DECLARE_EVENT_TABLE() }; diff --git a/include/wx/gtk/spinbutt.h b/include/wx/gtk/spinbutt.h index cdae9dad3b..96e13d0100 100644 --- a/include/wx/gtk/spinbutt.h +++ b/include/wx/gtk/spinbutt.h @@ -55,6 +55,9 @@ public: GtkAdjustment *m_adjust; float m_oldPos; +protected: + virtual wxSize DoGetBestSize() const; + private: DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxSpinButton) diff --git a/include/wx/gtk/spinctrl.h b/include/wx/gtk/spinctrl.h index 1fa6b82982..e51437430c 100644 --- a/include/wx/gtk/spinctrl.h +++ b/include/wx/gtk/spinctrl.h @@ -69,6 +69,9 @@ public: GtkAdjustment *m_adjust; float m_oldPos; +protected: + virtual wxSize DoGetBestSize() const; + private: DECLARE_DYNAMIC_CLASS(wxSpinCtrl) DECLARE_EVENT_TABLE() diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 2895efbb9a..18f6a1abc0 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -104,10 +104,6 @@ public: // implementation // -------------- - // move the window to the specified location and resize it: this is called - // from both DoSetSize() and DoSetClientSize() - virtual void DoMoveWindow(int x, int y, int width, int height); - virtual WXWidget GetHandle() const { return m_widget; } // also sets the global flag @@ -224,6 +220,7 @@ public: int width, int height, int sizeFlags = wxSIZE_AUTO); virtual void DoSetClientSize(int width, int height); + virtual void DoMoveWindow(int x, int y, int width, int height); #if wxUSE_TOOLTIPS virtual void DoSetToolTip( wxToolTip *tip ); diff --git a/include/wx/gtk1/spinbutt.h b/include/wx/gtk1/spinbutt.h index cdae9dad3b..96e13d0100 100644 --- a/include/wx/gtk1/spinbutt.h +++ b/include/wx/gtk1/spinbutt.h @@ -55,6 +55,9 @@ public: GtkAdjustment *m_adjust; float m_oldPos; +protected: + virtual wxSize DoGetBestSize() const; + private: DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxSpinButton) diff --git a/include/wx/gtk1/spinctrl.h b/include/wx/gtk1/spinctrl.h index 1fa6b82982..e51437430c 100644 --- a/include/wx/gtk1/spinctrl.h +++ b/include/wx/gtk1/spinctrl.h @@ -69,6 +69,9 @@ public: GtkAdjustment *m_adjust; float m_oldPos; +protected: + virtual wxSize DoGetBestSize() const; + private: DECLARE_DYNAMIC_CLASS(wxSpinCtrl) DECLARE_EVENT_TABLE() diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index 2895efbb9a..18f6a1abc0 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -104,10 +104,6 @@ public: // implementation // -------------- - // move the window to the specified location and resize it: this is called - // from both DoSetSize() and DoSetClientSize() - virtual void DoMoveWindow(int x, int y, int width, int height); - virtual WXWidget GetHandle() const { return m_widget; } // also sets the global flag @@ -224,6 +220,7 @@ public: int width, int height, int sizeFlags = wxSIZE_AUTO); virtual void DoSetClientSize(int width, int height); + virtual void DoMoveWindow(int x, int y, int width, int height); #if wxUSE_TOOLTIPS virtual void DoSetToolTip( wxToolTip *tip ); diff --git a/include/wx/motif/window.h b/include/wx/motif/window.h index fbb7b729e9..aefcae03a3 100644 --- a/include/wx/motif/window.h +++ b/include/wx/motif/window.h @@ -313,6 +313,7 @@ protected: int width, int height, int sizeFlags = wxSIZE_AUTO); virtual void DoSetClientSize(int width, int height); + virtual void DoMoveWindow(int x, int y, int width, int height); virtual bool DoPopupMenu(wxMenu *menu, int x, int y); #if wxUSE_TOOLTIPS diff --git a/include/wx/msw/statline.h b/include/wx/msw/statline.h index 0b4b2d8341..9fe6273bcb 100644 --- a/include/wx/msw/statline.h +++ b/include/wx/msw/statline.h @@ -43,6 +43,9 @@ public: const wxSize &size = wxDefaultSize, long style = wxLI_HORIZONTAL, const wxString &name = wxStaticTextNameStr ); + + // overriden base class virtuals + virtual bool AcceptsFocus() const { return FALSE; } }; #endif // _WX_MSW_STATLINE_H_ diff --git a/include/wx/spinctrl.h b/include/wx/spinctrl.h index ee3dcb2c53..afa83467f3 100644 --- a/include/wx/spinctrl.h +++ b/include/wx/spinctrl.h @@ -12,8 +12,7 @@ #ifndef _WX_SPINCTRL_H_ #define _WX_SPINCTRL_H_ -#include "wx/control.h" -#include "wx/event.h" +#include "wx/spinbutt.h" // should make wxSpinEvent visible to the app // ---------------------------------------------------------------------------- // a spin ctrl is a text control with a spin button which is usually used to diff --git a/include/wx/window.h b/include/wx/window.h index f78da2dbfc..6c9022850f 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -813,6 +813,12 @@ protected: // same as DoSetSize() for the client size virtual void DoSetClientSize(int width, int height) = 0; + // move the window to the specified location and resize it: this is called + // from both DoSetSize() and DoSetClientSize() and would usually just + // reposition this window except for composite controls which will want to + // arrange themselves inside the given rectangle + virtual void DoMoveWindow(int x, int y, int width, int height) = 0; + #if wxUSE_TOOLTIPS virtual void DoSetToolTip( wxToolTip *tip ); #endif // wxUSE_TOOLTIPS diff --git a/samples/console/console.cpp b/samples/console/console.cpp index 4124632a01..cd100faafb 100644 --- a/samples/console/console.cpp +++ b/samples/console/console.cpp @@ -426,6 +426,13 @@ static void TestTimeZones() printf("Current time in Paris:\t%s\n", now.Format("%c", wxDateTime::CET).c_str()); printf(" Moscow:\t%s\n", now.Format("%c", wxDateTime::MSK).c_str()); printf(" New York:\t%s\n", now.Format("%c", wxDateTime::EST).c_str()); + + wxDateTime::Tm tm = now.GetTm(); + if ( wxDateTime(tm) != now ) + { + printf("ERROR: got %s instead of %s\n", + wxDateTime(tm).Format().c_str(), now.Format().c_str()); + } } // test some minimal support for the dates outside the standard range @@ -666,7 +673,9 @@ static void TestTimeWNumber() struct WeekNumberTestData { Date date; // the date - wxDateTime::wxDateTime_t week; // the week number + wxDateTime::wxDateTime_t week; // the week number in the year + wxDateTime::wxDateTime_t wmon; // the week number in the month + wxDateTime::wxDateTime_t wmon2; // same but week starts with Sun wxDateTime::wxDateTime_t dnum; // day number in the year }; @@ -679,6 +688,18 @@ from string import * monthNames = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ] wdayNames = [ 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun' ] +def GetMonthWeek(dt): + weekNumMonth = dt.iso_week[1] - DateTime(dt.year, dt.month, 1).iso_week[1] + 1 + if weekNumMonth < 0: + weekNumMonth = weekNumMonth + 53 + return weekNumMonth + +def GetLastSundayBefore(dt): + if dt.iso_week[2] == 7: + return dt + else: + return dt - DateTimeDelta(dt.iso_week[2]) + for n in range(20): year = randint(1900, 2100) month = randint(1, 12) @@ -686,34 +707,54 @@ for n in range(20): dt = DateTime(year, month, day) dayNum = dt.day_of_year weekNum = dt.iso_week[1] - - data = { 'day': rjust(`day`, 2), 'month': monthNames[month - 1], 'year': year, 'weekNum': rjust(`weekNum`, 2), 'dayNum': rjust(`dayNum`, 3) } - - print "{ { %(day)s, wxDateTime::%(month)s, %(year)d }, %(weekNum)s, "\ + weekNumMonth = GetMonthWeek(dt) + + weekNumMonth2 = 0 + dtSunday = GetLastSundayBefore(dt) + + while dtSunday >= GetLastSundayBefore(DateTime(dt.year, dt.month, 1)): + weekNumMonth2 = weekNumMonth2 + 1 + dtSunday = dtSunday - DateTimeDelta(7) + + data = { 'day': rjust(`day`, 2), \ + 'month': monthNames[month - 1], \ + 'year': year, \ + 'weekNum': rjust(`weekNum`, 2), \ + 'weekNumMonth': weekNumMonth, \ + 'weekNumMonth2': weekNumMonth2, \ + 'dayNum': rjust(`dayNum`, 3) } + + print " { { %(day)s, "\ + "wxDateTime::%(month)s, "\ + "%(year)d }, "\ + "%(weekNum)s, "\ + "%(weekNumMonth)s, "\ + "%(weekNumMonth2)s, "\ "%(dayNum)s }," % data + */ static const WeekNumberTestData weekNumberTestDates[] = { - { { 2, wxDateTime::Jul, 2093 }, 27, 183 }, - { { 25, wxDateTime::Jun, 1986 }, 26, 176 }, - { { 15, wxDateTime::Jun, 2014 }, 24, 166 }, - { { 20, wxDateTime::Jul, 2018 }, 29, 201 }, - { { 3, wxDateTime::Aug, 2074 }, 31, 215 }, - { { 26, wxDateTime::Jul, 2012 }, 30, 208 }, - { { 4, wxDateTime::Nov, 1915 }, 44, 308 }, - { { 11, wxDateTime::Feb, 2035 }, 6, 42 }, - { { 15, wxDateTime::Feb, 1942 }, 7, 46 }, - { { 5, wxDateTime::Jan, 2087 }, 1, 5 }, - { { 6, wxDateTime::Nov, 2016 }, 44, 311 }, - { { 6, wxDateTime::Jun, 2057 }, 23, 157 }, - { { 25, wxDateTime::Feb, 1976 }, 9, 56 }, - { { 12, wxDateTime::Jan, 2073 }, 2, 12 }, - { { 12, wxDateTime::Sep, 2040 }, 37, 256 }, - { { 15, wxDateTime::Jul, 1931 }, 29, 196 }, - { { 23, wxDateTime::Mar, 2084 }, 12, 83 }, - { { 12, wxDateTime::Dec, 1970 }, 50, 346 }, - { { 6, wxDateTime::Sep, 1996 }, 36, 250 }, - { { 7, wxDateTime::Jan, 2076 }, 2, 7 }, + { { 27, wxDateTime::Dec, 1966 }, 52, 5, 5, 361 }, + { { 22, wxDateTime::Jul, 1926 }, 29, 4, 4, 203 }, + { { 22, wxDateTime::Oct, 2076 }, 43, 4, 4, 296 }, + { { 1, wxDateTime::Jul, 1967 }, 26, 1, 1, 182 }, + { { 8, wxDateTime::Nov, 2004 }, 46, 2, 2, 313 }, + { { 21, wxDateTime::Mar, 1920 }, 12, 3, 4, 81 }, + { { 7, wxDateTime::Jan, 1965 }, 1, 2, 2, 7 }, + { { 19, wxDateTime::Oct, 1999 }, 42, 4, 4, 292 }, + { { 13, wxDateTime::Aug, 1955 }, 32, 2, 2, 225 }, + { { 18, wxDateTime::Jul, 2087 }, 29, 3, 3, 199 }, + { { 2, wxDateTime::Sep, 2028 }, 35, 1, 1, 246 }, + { { 28, wxDateTime::Jul, 1945 }, 30, 5, 4, 209 }, + { { 15, wxDateTime::Jun, 1901 }, 24, 3, 3, 166 }, + { { 10, wxDateTime::Oct, 1939 }, 41, 3, 2, 283 }, + { { 3, wxDateTime::Dec, 1965 }, 48, 1, 1, 337 }, + { { 23, wxDateTime::Feb, 1940 }, 8, 4, 4, 54 }, + { { 2, wxDateTime::Jan, 1987 }, 1, 1, 1, 2 }, + { { 11, wxDateTime::Aug, 2079 }, 32, 2, 2, 223 }, + { { 2, wxDateTime::Feb, 2063 }, 5, 1, 1, 33 }, + { { 16, wxDateTime::Oct, 1942 }, 42, 3, 3, 289 }, }; for ( size_t n = 0; n < WXSIZEOF(weekNumberTestDates); n++ ) @@ -723,8 +764,11 @@ for n in range(20): wxDateTime dt = d.DT(); - wxDateTime::wxDateTime_t week = dt.GetWeekOfYear(), - dnum = dt.GetDayOfYear(); + wxDateTime::wxDateTime_t + week = dt.GetWeekOfYear(wxDateTime::Monday_First), + wmon = dt.GetWeekOfMonth(wxDateTime::Monday_First), + wmon2 = dt.GetWeekOfMonth(wxDateTime::Sunday_First), + dnum = dt.GetDayOfYear(); printf("%s: the day number is %d", d.FormatDate().c_str(), dnum); @@ -737,7 +781,27 @@ for n in range(20): printf(" (ERROR: should be %d)", wn.dnum); } - printf(", week number is %d", week); + printf(", week in month is %d", wmon); + if ( wmon == wn.wmon ) + { + printf(" (ok)"); + } + else + { + printf(" (ERROR: should be %d)", wn.wmon); + } + + printf(" or %d", wmon2); + if ( wmon2 == wn.wmon2 ) + { + printf(" (ok)"); + } + else + { + printf(" (ERROR: should be %d)", wn.wmon2); + } + + printf(", week in year is %d", week); if ( week == wn.week ) { puts(" (ok)"); @@ -991,6 +1055,101 @@ static void TestTimeParse() } } +static void TestInteractive() +{ + puts("\n*** interactive wxDateTime tests ***"); + + char buf[128]; + + for ( ;; ) + { + printf("Enter a date: "); + if ( !fgets(buf, WXSIZEOF(buf), stdin) ) + break; + + wxDateTime dt; + if ( !dt.ParseDate(buf) ) + { + puts("failed to parse the date"); + + continue; + } + + printf("%s: day %u, week of month %u/%u, week of year %u\n", + dt.FormatISODate().c_str(), + dt.GetDayOfYear(), + dt.GetWeekOfMonth(wxDateTime::Monday_First), + dt.GetWeekOfMonth(wxDateTime::Sunday_First), + dt.GetWeekOfYear(wxDateTime::Monday_First)); + } + + puts("\n*** done ***"); +} + +static void TestTimeArithmetics() +{ + puts("\n*** testing arithmetic operations on wxDateTime ***"); + + static const struct + { + wxDateSpan span; + const char *name; + } testArithmData[] = + { + { wxDateSpan::Day(), "day" }, + { wxDateSpan::Week(), "week" }, + { wxDateSpan::Month(), "month" }, + { wxDateSpan::Year(), "year" }, + { wxDateSpan(1, 2, 3, 4), "year, 2 months, 3 weeks, 4 days" }, + }; + + wxDateTime dt(29, wxDateTime::Dec, 1999), dt1, dt2; + + for ( size_t n = 0; n < WXSIZEOF(testArithmData); n++ ) + { + wxDateSpan span = testArithmData[n].span; + dt1 = dt + span; + dt2 = dt - span; + + const char *name = testArithmData[n].name; + printf("%s + %s = %s, %s - %s = %s\n", + dt.FormatISODate().c_str(), name, dt1.FormatISODate().c_str(), + dt.FormatISODate().c_str(), name, dt2.FormatISODate().c_str()); + + printf("Going back: %s", (dt1 - span).FormatISODate().c_str()); + if ( dt1 - span == dt ) + { + puts(" (ok)"); + } + else + { + printf(" (ERROR: should be %s)\n", dt.FormatISODate().c_str()); + } + + printf("Going forward: %s", (dt2 + span).FormatISODate().c_str()); + if ( dt2 + span == dt ) + { + puts(" (ok)"); + } + else + { + printf(" (ERROR: should be %s)\n", dt.FormatISODate().c_str()); + } + + printf("Double increment: %s", (dt2 + 2*span).FormatISODate().c_str()); + if ( dt2 + 2*span == dt1 ) + { + puts(" (ok)"); + } + else + { + printf(" (ERROR: should be %s)\n", dt2.FormatISODate().c_str()); + } + + puts(""); + } +} + #if 0 // test compatibility with the old wxDate/wxTime classes @@ -1479,20 +1638,23 @@ int main(int argc, char **argv) #endif // TEST_MIME #ifdef TEST_TIME - if ( 1 ) + if ( 0 ) { - TestTimeSet(); - TestTimeStatic(); - TestTimeZones(); - TestTimeRange(); - TestTimeTicks(); - TestTimeJDN(); - TestTimeDST(); - TestTimeWDays(); - TestTimeWNumber(); - TestTimeParse(); - TestTimeFormat(); + TestTimeSet(); + TestTimeStatic(); + TestTimeRange(); + TestTimeZones(); + TestTimeTicks(); + TestTimeJDN(); + TestTimeDST(); + TestTimeWDays(); + TestTimeWNumber(); + TestTimeParse(); + TestTimeFormat(); + TestTimeArithmetics(); } + if ( 0 ) + TestInteractive(); #endif // TEST_TIME wxUninitialize(); diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index a29183cd19..aedd9ae761 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -65,7 +65,7 @@ #include "wx/spinctrl.h" #endif // wxUSE_SPINCTRL -#include "wx/generic/calctrl.h" +#include "wx/calctrl.h" //---------------------------------------------------------------------- // class definitions @@ -113,6 +113,8 @@ public: void OnEnableAll(wxCommandEvent& event); void OnChangeColour(wxCommandEvent& event); + void OnCalendarChange(wxCalendarEvent& event); + wxListBox *m_listbox, *m_listboxSorted; wxChoice *m_choice, @@ -141,6 +143,9 @@ public: wxStaticText *m_label; + wxCalendarCtrl *m_calendar; + wxStaticText *m_date; + private: DECLARE_EVENT_TABLE() }; @@ -260,7 +265,7 @@ bool MyApp::OnInit() frame->Show(TRUE); frame->SetCursor(wxCursor(wxCURSOR_HAND)); - frame->GetPanel()->m_notebook->SetSelection(5); + frame->GetPanel()->m_notebook->SetSelection(6); SetTopWindow(frame); @@ -323,6 +328,8 @@ const int ID_SPINCTRL = 185; const int ID_CHANGE_COLOUR = 200; +const int ID_CALENDAR = 210; + BEGIN_EVENT_TABLE(MyPanel, wxPanel) EVT_SIZE ( MyPanel::OnSize) EVT_NOTEBOOK_PAGE_CHANGING(ID_NOTEBOOK, MyPanel::OnPageChanging) @@ -373,12 +380,15 @@ EVT_SPINCTRL (ID_SPINCTRL, MyPanel::OnSpinCtrl) #endif // wxUSE_SPINCTRL EVT_BUTTON (ID_BUTTON_LABEL, MyPanel::OnUpdateLabel) EVT_CHECKBOX (ID_CHANGE_COLOUR, MyPanel::OnChangeColour) +EVT_CALENDAR (ID_CALENDAR, MyPanel::OnCalendarChange) END_EVENT_TABLE() MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) ), m_text(NULL), m_notebook(NULL) { + wxLayoutConstraints *c; + m_text = new wxTextCtrl( this, -1, "This is the log window.\n", wxPoint(0,50), wxSize(100,50), wxTE_MULTILINE ); // m_text->SetBackgroundColour("wheat"); @@ -643,55 +653,74 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) m_notebook->AddPage(panel, "wxBitmapXXX"); + // wxCalendarCtrl + panel = new wxPanel(m_notebook); - (void)new wxCalendarCtrl(panel, -1); - m_notebook->AddPage(panel, "wxCalendar"); + panel->SetAutoLayout( TRUE ); -// --------------- TEST CODE ---------------------- + wxString date; + date.Printf("Selected date: %s", + wxDateTime::Today().FormatISODate().c_str()); + m_date = new wxStaticText(panel, -1, date); + m_calendar = new wxCalendarCtrl(panel, ID_CALENDAR); - // layout constraints + c = new wxLayoutConstraints; + c->left.SameAs( panel, wxLeft, 10 ); + c->centreY.SameAs( m_calendar, wxCentreY ); + c->height.AsIs(); + c->width.AsIs(); - panel = new wxPanel(m_notebook); - panel->SetAutoLayout( TRUE ); + m_date->SetConstraints(c); - wxLayoutConstraints *c; - c = new wxLayoutConstraints; - c->top.SameAs( panel, wxTop, 10 ); - c->height.AsIs( ); - c->left.SameAs( panel, wxLeft, 10 ); - c->width.PercentOf( panel, wxWidth, 40 ); + c = new wxLayoutConstraints; + c->left.SameAs( m_date, wxRight, 10 ); + c->top.SameAs( panel, wxTop, 10 ); + c->height.AsIs(); + c->width.AsIs(); - wxButton *pMyButton = new wxButton(panel, -1, "Test Button" ); - pMyButton->SetConstraints( c ); + m_calendar->SetConstraints(c); - c = new wxLayoutConstraints; - c->top.SameAs( panel, wxTop, 10 ); - c->bottom.SameAs( panel, wxBottom, 10 ); - c->right.SameAs( panel, wxRight, 10 ); - c->width.PercentOf( panel, wxWidth, 40 ); + m_notebook->AddPage(panel, "wxCalendar"); - wxButton *pMyButton2 = new wxButton(panel, -1, "Test Button 2" ); - pMyButton2->SetConstraints( c ); + // layout constraints - m_notebook->AddPage(panel, "wxLayoutConstraint"); + panel = new wxPanel(m_notebook); + panel->SetAutoLayout( TRUE ); - // sizer + c = new wxLayoutConstraints; + c->top.SameAs( panel, wxTop, 10 ); + c->height.AsIs( ); + c->left.SameAs( panel, wxLeft, 10 ); + c->width.PercentOf( panel, wxWidth, 40 ); - panel = new wxPanel(m_notebook); - panel->SetAutoLayout( TRUE ); + wxButton *pMyButton = new wxButton(panel, -1, "Test Button" ); + pMyButton->SetConstraints( c ); - wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL ); + c = new wxLayoutConstraints; + c->top.SameAs( panel, wxTop, 10 ); + c->bottom.SameAs( panel, wxBottom, 10 ); + c->right.SameAs( panel, wxRight, 10 ); + c->width.PercentOf( panel, wxWidth, 40 ); - sizer->Add( new wxButton(panel, -1, "Test Button" ), 3, wxALL, 10 ); - sizer->Add( 20,20, 1 ); - sizer->Add( new wxButton(panel, -1, "Test Button 2" ), 3, wxGROW|wxALL, 10 ); + wxButton *pMyButton2 = new wxButton(panel, -1, "Test Button 2" ); + pMyButton2->SetConstraints( c ); - panel->SetSizer( sizer ); + m_notebook->AddPage(panel, "wxLayoutConstraint"); - m_notebook->AddPage(panel, "wxSizer"); + // sizer -// --------------- TEST CODE ---------------------- + panel = new wxPanel(m_notebook); + panel->SetAutoLayout( TRUE ); + wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL ); + + sizer->Add( new wxButton(panel, -1, "Test Button" ), 3, wxALL, 10 ); + sizer->Add( 20,20, 1 ); + sizer->Add( new wxButton(panel, -1, "Test Button 2" ), 3, wxGROW|wxALL, 10 ); + + panel->SetSizer( sizer ); + + m_notebook->AddPage(panel, "wxSizer"); } void MyPanel::OnSize( wxSizeEvent& WXUNUSED(event) ) @@ -729,6 +758,14 @@ void MyPanel::OnPageChanged( wxNotebookEvent &event ) *m_text << "Notebook selection is " << event.GetSelection() << "\n"; } +void MyPanel::OnCalendarChange(wxCalendarEvent& event) +{ + wxString s; + s.Printf("Selected date: %s", event.GetDate().FormatISODate().c_str()); + + m_date->SetLabel(s); +} + void MyPanel::OnChangeColour(wxCommandEvent& WXUNUSED(event)) { static wxColour s_colOld; diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index 5e6df3b2d1..53e4d8be68 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -442,14 +442,14 @@ void wxDateTime::Tm::AddMonths(int monDiff) void wxDateTime::Tm::AddDays(int dayDiff) { // normalize the days field - mday += dayDiff; - while ( mday < 1 ) + while ( dayDiff + mday < 1 ) { AddMonths(-1); - mday += GetNumOfDaysInMonth(year, mon); + dayDiff += GetNumOfDaysInMonth(year, mon); } + mday += dayDiff; while ( mday > GetNumOfDaysInMonth(year, mon) ) { mday -= GetNumOfDaysInMonth(year, mon); @@ -1035,8 +1035,7 @@ wxDateTime& wxDateTime::Set(wxDateTime_t hour, _T("Invalid time in wxDateTime::Set()") ); // get the current date from system - time_t timet = GetTimeNow(); - struct tm *tm = localtime(&timet); + struct tm *tm = GetTmNow(); wxCHECK_MSG( tm, wxInvalidDateTime, _T("localtime() failed") ); @@ -1125,6 +1124,23 @@ wxDateTime& wxDateTime::Set(double jdn) return *this; } +wxDateTime& wxDateTime::ResetTime() +{ + Tm tm = GetTm(); + + if ( tm.hour || tm.min || tm.sec || tm.msec ) + { + tm.msec = + tm.sec = + tm.min = + tm.hour = 0; + + Set(tm); + } + + return *this; +} + // ---------------------------------------------------------------------------- // time_t <-> broken down time conversions // ---------------------------------------------------------------------------- @@ -1152,11 +1168,11 @@ wxDateTime::Tm wxDateTime::GetTm(const TimeZone& tz) const else { time += tz.GetOffset(); -#ifdef __VMS__ /* time is unsigned so VMS gives a warning on the original */ - time2 = (int) time; - if ( time2 >= 0 ) +#ifdef __VMS__ // time is unsigned so avoid warning + time2 = (int) time; + if ( time2 >= 0 ) #else - if ( time >= 0 ) + if ( time >= 0 ) #endif { tm = gmtime(&time); @@ -1349,6 +1365,9 @@ wxDateTime& wxDateTime::Add(const wxDateSpan& diff) Set(tm); + wxASSERT_MSG( IsSameTime(tm), + _T("Add(wxDateSpan) shouldn't modify time") ); + return *this; } @@ -1508,48 +1527,50 @@ wxDateTime::wxDateTime_t wxDateTime::GetDayOfYear(const TimeZone& tz) const return gs_cumulatedDays[IsLeapYear(tm.year)][tm.mon] + tm.mday; } -wxDateTime::wxDateTime_t wxDateTime::GetWeekOfYear(const TimeZone& tz) const +wxDateTime::wxDateTime_t wxDateTime::GetWeekOfYear(wxDateTime::WeekFlags flags, + const TimeZone& tz) const { -#if 1 - // the first week of the year is the one which contains Jan, 4 (according - // to ISO standard rule), so the year day N0 = 4 + 7*W always lies in the - // week W+1. As any day N = 7*W + 4 + (N - 4)%7, it lies in the same week - // as N0 or in the next one. - - // TODO this surely may be optimized - I got confused while writing it + if ( flags == Default_First ) + { + flags = GetCountry() == USA ? Sunday_First : Monday_First; + } wxDateTime_t nDayInYear = GetDayOfYear(tz); + wxDateTime_t week; - // the week day of the day lying in the first week - WeekDay wdayStart = wxDateTime(4, Jan, GetYear()).GetWeekDay(); - - wxDateTime_t week = (nDayInYear - 4) / 7 + 1; + WeekDay wd = GetWeekDay(tz); + if ( flags == Sunday_First ) + { + week = (nDayInYear - wd + 7) / 7; + } + else + { + // have to shift the week days values + week = (nDayInYear - (wd - 1 + 7) % 7 + 7) / 7; + } - // notice that Sunday shoould be counted as 7, not 0 here! - if ( ((nDayInYear - 4) % 7) + (!wdayStart ? 7 : wdayStart) > 7 ) + // FIXME some more elegant way?? + WeekDay wdYearStart = wxDateTime(1, Jan, GetYear()).GetWeekDay(); + if ( wdYearStart == Wed || wdYearStart == Thu ) { week++; } return week; -#else // 0 - // an attempt at doing it simpler - but this doesn't quite work... - return (WeekDay)((GetDayOfYear(tz) - (GetWeekDay(tz) - 1 + 7) % 7 + 7) / 7); -#endif // 0/1 } -wxDateTime::wxDateTime_t wxDateTime::GetWeekOfMonth(const TimeZone& tz) const +wxDateTime::wxDateTime_t wxDateTime::GetWeekOfMonth(wxDateTime::WeekFlags flags, + const TimeZone& tz) const { - size_t nWeek = 0; - - wxDateTime dt(*this); - do + Tm tm = GetTm(tz); + wxDateTime dtMonthStart = wxDateTime(1, tm.mon, tm.year); + size_t nWeek = GetWeekOfYear(flags) - dtMonthStart.GetWeekOfYear(flags) + 1; + if ( nWeek < 0 ) { - nWeek++; - - dt -= wxTimeSpan::Week(); + // this may happen for January when Jan, 1 is the last week of the + // previous year + nWeek += IsLeapYear(tm.year - 1) ? 53 : 52; } - while ( dt.GetMonth(tz) == GetMonth(tz) ); return nWeek; } @@ -1936,14 +1957,11 @@ restart: break; case _T('U'): // week number in the year (Sunday 1st week day) - { - int week = (GetDayOfYear(tz) - tm.GetWeekDay() + 7) / 7; - res += wxString::Format(fmt, week); - } + res += wxString::Format(fmt, GetWeekOfYear(Sunday_First, tz)); break; case _T('W'): // week number in the year (Monday 1st week day) - res += wxString::Format(fmt, GetWeekOfYear(tz)); + res += wxString::Format(fmt, GetWeekOfYear(Monday_First, tz)); break; case _T('w'): // weekday as a number (0-6), Sunday = 0 @@ -2896,7 +2914,7 @@ const wxChar *wxDateTime::ParseDate(const wxChar *date) int year = 0; // tokenize the string - wxStringTokenizer tok(p, _T(",/-\t ")); + wxStringTokenizer tok(p, _T(",/-\t\n ")); while ( tok.HasMoreTokens() ) { wxString token = tok.GetNextToken(); diff --git a/src/generic/calctrl.cpp b/src/generic/calctrl.cpp index 5417b7d49b..b1a43f47e1 100644 --- a/src/generic/calctrl.cpp +++ b/src/generic/calctrl.cpp @@ -29,9 +29,12 @@ #endif #ifndef WX_PRECOMP + #include "wx/dcclient.h" + #include "wx/settings.h" + #include "wx/brush.h" #endif //WX_PRECOMP -#include "wx/generic/calctrl.h" +#include "wx/calctrl.h" // ---------------------------------------------------------------------------- // wxWin macros @@ -40,7 +43,12 @@ BEGIN_EVENT_TABLE(wxCalendarCtrl, wxControl) EVT_PAINT(wxCalendarCtrl::OnPaint) + EVT_CHAR(wxCalendarCtrl::OnChar) + EVT_LEFT_DOWN(wxCalendarCtrl::OnClick) + + EVT_COMBOBOX(-1, wxCalendarCtrl::OnMonthChange) + EVT_SPINCTRL(-1, wxCalendarCtrl::OnYearChange) END_EVENT_TABLE() IMPLEMENT_DYNAMIC_CLASS(wxCalendarCtrl, wxControl) @@ -60,6 +68,12 @@ void wxCalendarCtrl::Init() m_widthCol = m_heightRow = 0; + + wxDateTime::WeekDay wd; + for ( wd = wxDateTime::Sun; wd < wxDateTime::Inv_WeekDay; wxNextWDay(wd) ) + { + m_weekdays[wd] = wxDateTime::GetWeekDayName(wd, wxDateTime::Name_Abbr); + } } bool wxCalendarCtrl::Create(wxWindow *parent, @@ -72,6 +86,31 @@ bool wxCalendarCtrl::Create(wxWindow *parent, { m_date = date.IsValid() ? date : wxDateTime::Today(); + wxString monthNames[12]; + wxDateTime::Month m; + for ( m = wxDateTime::Jan; m < wxDateTime::Inv_Month; wxNextMonth(m) ) + { + monthNames[m] = wxDateTime::GetMonthName(m); + } + + m_comboMonth = new wxComboBox(parent, -1, + monthNames[m_date.GetMonth()], + wxDefaultPosition, + wxDefaultSize, + WXSIZEOF(monthNames), monthNames, + wxCB_READONLY); + + m_spinYear = new wxSpinCtrl(parent, -1, + m_date.Format(_T("%Y")), + wxDefaultPosition, + wxDefaultSize, + wxSP_ARROW_KEYS, + -4300, 10000, m_date.GetYear()); + + // we want to process the events from these controls + m_comboMonth->PushEventHandler(this); + m_spinYear->PushEventHandler(this); + wxSize sizeReal; if ( size.x == -1 || size.y == -1 ) { @@ -89,10 +128,76 @@ bool wxCalendarCtrl::Create(wxWindow *parent, SetSize(sizeReal); SetBackgroundColour(*wxWHITE); + SetFont(*wxSWISS_FONT); return TRUE; } +// ---------------------------------------------------------------------------- +// changing date +// ---------------------------------------------------------------------------- + +void wxCalendarCtrl::SetDate(const wxDateTime& date) +{ + if ( m_date.GetMonth() == date.GetMonth() && + m_date.GetYear() == date.GetYear() ) + { + // just change the day + ChangeDay(date); + } + else + { + // change everything + m_date = date; + + // update the controls + m_comboMonth->SetSelection(m_date.GetMonth()); + m_spinYear->SetValue(m_date.Format(_T("%Y"))); + + // update the calendar + Refresh(); + } +} + +void wxCalendarCtrl::ChangeDay(const wxDateTime& date) +{ + if ( m_date != date ) + { + // we need to refresh the row containing the old date and the one + // containing the new one + wxDateTime dateOld = m_date; + m_date = date; + + RefreshDate(dateOld); + + // if the date is in the same row, it was already drawn correctly + if ( GetWeek(m_date) != GetWeek(dateOld) ) + { + RefreshDate(m_date); + } + } +} + +void wxCalendarCtrl::SetDateAndNotify(const wxDateTime& date) +{ + wxDateTime::Tm tm1 = m_date.GetTm(), + tm2 = date.GetTm(); + + wxEventType type; + if ( tm1.year != tm2.year ) + type = wxEVT_CALENDAR_YEAR_CHANGED; + else if ( tm1.mon != tm2.mon ) + type = wxEVT_CALENDAR_MONTH_CHANGED; + else if ( tm1.mday != tm2.mday ) + type = wxEVT_CALENDAR_DAY_CHANGED; + else + return; + + SetDate(date); + + GenerateEvent(type); +} + // ---------------------------------------------------------------------------- // date helpers // ---------------------------------------------------------------------------- @@ -102,7 +207,14 @@ wxDateTime wxCalendarCtrl::GetStartDate() const wxDateTime::Tm tm = m_date.GetTm(); wxDateTime date = wxDateTime(1, tm.mon, tm.year); - date.SetToPrevWeekDay(wxDateTime::Sun); + if ( date.GetWeekDay() != wxDateTime::Sun ) + { + date.SetToPrevWeekDay(wxDateTime::Sun); + + // be sure to do it or it might gain 1 hour if DST changed in between + date.ResetTime(); + } + //else: we already have it return date; } @@ -112,13 +224,37 @@ bool wxCalendarCtrl::IsDateShown(const wxDateTime& date) const return date.GetMonth() == m_date.GetMonth(); } +size_t wxCalendarCtrl::GetWeek(const wxDateTime& date) const +{ + return date.GetWeekOfMonth(wxDateTime::Sunday_First); +} + // ---------------------------------------------------------------------------- // size management // ---------------------------------------------------------------------------- +// this is a composite control and it must arrange its parts each time its +// size or position changes: the combobox and spinctrl are along the top of +// the available area and the calendar takes up therest of the space + +// the constants used for the layout +#define VERT_MARGIN 5 // distance between combo and calendar +#define HORZ_MARGIN 15 // spin + wxSize wxCalendarCtrl::DoGetBestSize() const { - return wxSize(230, 200); + // calc the size of the calendar + ((wxCalendarCtrl *)this)->RecalcGeometry(); // const_cast + + wxCoord width = 7*m_widthCol, + height = 7*m_heightRow; + + wxSize sizeCombo = m_comboMonth->GetBestSize(), + sizeSpin = m_spinYear->GetBestSize(); + + height += VERT_MARGIN + wxMax(sizeCombo.y, sizeSpin.y); + + return wxSize(width, height); } void wxCalendarCtrl::DoSetSize(int x, int y, @@ -130,31 +266,35 @@ void wxCalendarCtrl::DoSetSize(int x, int y, void wxCalendarCtrl::DoMoveWindow(int x, int y, int width, int height) { - wxControl::DoMoveWindow(x, y, width, height); -} + wxSize sizeCombo = m_comboMonth->GetSize(); + m_comboMonth->Move(x, y); -// ---------------------------------------------------------------------------- -// drawing -// ---------------------------------------------------------------------------- + int xDiff = sizeCombo.x + HORZ_MARGIN; + m_spinYear->SetSize(x + xDiff, y, width - xDiff, -1); -void wxCalendarCtrl::OnPaint(wxPaintEvent& event) + wxSize sizeSpin = m_spinYear->GetSize(); + int yDiff = wxMax(sizeSpin.y, sizeCombo.y) + VERT_MARGIN; + + wxControl::DoMoveWindow(x, y + yDiff, width, height - yDiff); +} + +void wxCalendarCtrl::RecalcGeometry() { - wxPaintDC dc(this); + if ( m_widthCol != 0 ) + return; - wxDateTime::WeekDay wd; - wxString weekdays[7]; + wxClientDC dc(this); - dc.SetFont(*wxSWISS_FONT); + dc.SetFont(m_font); // determine the column width (we assume that the weekday names are always // wider (in any language) than the numbers) m_widthCol = 0; + wxDateTime::WeekDay wd; for ( wd = wxDateTime::Sun; wd < wxDateTime::Inv_WeekDay; wxNextWDay(wd) ) { - weekdays[wd] = wxDateTime::GetWeekDayName(wd, wxDateTime::Name_Abbr); - wxCoord width; - dc.GetTextExtent(weekdays[wd], &width, &m_heightRow); + dc.GetTextExtent(m_weekdays[wd], &width, &m_heightRow); if ( width > m_widthCol ) { m_widthCol = width; @@ -164,16 +304,40 @@ void wxCalendarCtrl::OnPaint(wxPaintEvent& event) // leave some margins m_widthCol += 2; m_heightRow += 2; +} + +// ---------------------------------------------------------------------------- +// drawing +// ---------------------------------------------------------------------------- + +void wxCalendarCtrl::OnPaint(wxPaintEvent& event) +{ + wxPaintDC dc(this); + + wxDateTime::WeekDay wd; + + dc.SetFont(m_font); + + RecalcGeometry(); + + printf("--- starting to paint, selection: %s, week %u\n", + m_date.Format("%a %d-%m-%Y %H:%M:%S").c_str(), + GetWeek(m_date)); // first draw the week days - dc.SetTextForeground(*wxBLUE); - dc.SetBrush(wxBrush(*wxLIGHT_GREY, wxSOLID)); - dc.SetBackgroundMode(wxTRANSPARENT); - dc.SetPen(*wxWHITE_PEN); - dc.DrawRectangle(0, 0, 7*m_widthCol - 1, m_heightRow); - for ( wd = wxDateTime::Sun; wd < wxDateTime::Inv_WeekDay; wxNextWDay(wd) ) + if ( IsExposed(0, 0, 7*m_widthCol, m_heightRow) ) { - dc.DrawText(weekdays[wd], wd*m_widthCol + 1, 0); + puts("painting the header"); + + dc.SetTextForeground(*wxBLUE); + dc.SetBrush(wxBrush(*wxLIGHT_GREY, wxSOLID)); + dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetPen(*wxLIGHT_GREY_PEN); + dc.DrawRectangle(0, 0, 7*m_widthCol, m_heightRow); + for ( wd = wxDateTime::Sun; wd < wxDateTime::Inv_WeekDay; wxNextWDay(wd) ) + { + dc.DrawText(m_weekdays[wd], wd*m_widthCol + 1, 0); + } } // then the calendar itself @@ -183,9 +347,22 @@ void wxCalendarCtrl::OnPaint(wxPaintEvent& event) wxCoord y = m_heightRow; wxDateTime date = GetStartDate(); + printf("starting calendar from %s\n", + date.Format("%a %d-%m-%Y %H:%M:%S").c_str()); + dc.SetBackgroundMode(wxSOLID); - for ( size_t nWeek = 0; nWeek < 6; nWeek++ ) + for ( size_t nWeek = 1; nWeek <= 6; nWeek++, y += m_heightRow ) { + // if the update region doesn't intersect this row, don't paint it + if ( !IsExposed(0, y, 7*m_widthCol, y + m_heightRow - 1) ) + { + date += wxDateSpan::Week(); + + continue; + } + + printf("painting week %d at y = %d\n", nWeek, y); + for ( wd = wxDateTime::Sun; wd < wxDateTime::Inv_WeekDay; wxNextWDay(wd) ) { if ( IsDateShown(date) ) @@ -205,7 +382,7 @@ void wxCalendarCtrl::OnPaint(wxPaintEvent& event) if ( isSel ) { - dc.SetTextForeground(*wxBLACK); + dc.SetTextForeground(m_foregroundColour); dc.SetTextBackground(m_backgroundColour); } } @@ -213,9 +390,31 @@ void wxCalendarCtrl::OnPaint(wxPaintEvent& event) date += wxDateSpan::Day(); } - - y += m_heightRow; } + + puts("+++ finished painting"); +} + +void wxCalendarCtrl::RefreshDate(const wxDateTime& date) +{ + RecalcGeometry(); + + wxRect rect; + + // always refresh the whole row at once because our OnPaint() will draw + // the whole row anyhow - and this allows the small optimisation in + // OnClick() below to work + rect.x = 0; + rect.y = m_heightRow * GetWeek(date); + rect.width = 7*m_widthCol; + rect.height = m_heightRow; + + printf("*** refreshing week %d at (%d, %d)-(%d, %d)\n", + GetWeek(date), + rect.x, rect.y, + rect.x + rect.width, rect.y + rect.height); + + Refresh(TRUE, &rect); } // ---------------------------------------------------------------------------- @@ -224,6 +423,8 @@ void wxCalendarCtrl::OnPaint(wxPaintEvent& event) void wxCalendarCtrl::OnClick(wxMouseEvent& event) { + RecalcGeometry(); + wxDateTime date; if ( !HitTest(event.GetPosition(), &date) ) { @@ -231,14 +432,16 @@ void wxCalendarCtrl::OnClick(wxMouseEvent& event) } else { - m_date = date; + ChangeDay(date); - Refresh(); + GenerateEvent(wxEVT_CALENDAR_DAY_CHANGED); } } bool wxCalendarCtrl::HitTest(const wxPoint& pos, wxDateTime *date) { + RecalcGeometry(); + wxCoord y = pos.y; if ( y < m_heightRow ) return FALSE; @@ -254,5 +457,112 @@ bool wxCalendarCtrl::HitTest(const wxPoint& pos, wxDateTime *date) *date = GetStartDate(); *date += wxDateSpan::Days(7*week + wday); + return IsDateShown(*date); } + +// ---------------------------------------------------------------------------- +// subcontrols events handling +// ---------------------------------------------------------------------------- + +void wxCalendarCtrl::OnMonthChange(wxCommandEvent& event) +{ + wxDateTime::Tm tm = m_date.GetTm(); + + wxDateTime::Month mon = (wxDateTime::Month)event.GetInt(); + if ( tm.mday > wxDateTime::GetNumberOfDays(mon, tm.year) ) + { + tm.mday = wxDateTime::GetNumberOfDays(mon, tm.year); + } + + SetDate(wxDateTime(tm.mday, mon, tm.year)); + + GenerateEvent(wxEVT_CALENDAR_MONTH_CHANGED); +} + +void wxCalendarCtrl::OnYearChange(wxSpinEvent& event) +{ + wxDateTime::Tm tm = m_date.GetTm(); + + int year = event.GetInt(); + if ( tm.mday > wxDateTime::GetNumberOfDays(tm.mon, year) ) + { + tm.mday = wxDateTime::GetNumberOfDays(tm.mon, year); + } + + SetDate(wxDateTime(tm.mday, tm.mon, year)); + + GenerateEvent(wxEVT_CALENDAR_YEAR_CHANGED); +} + +// ---------------------------------------------------------------------------- +// keyboard interface +// ---------------------------------------------------------------------------- + +void wxCalendarCtrl::OnChar(wxKeyEvent& event) +{ + switch ( event.KeyCode() ) + { + case _T('+'): + case WXK_ADD: + SetDateAndNotify(m_date + wxDateSpan::Year()); + break; + + case _T('-'): + case WXK_SUBTRACT: + SetDateAndNotify(m_date - wxDateSpan::Year()); + break; + + case WXK_PAGEDOWN: + SetDateAndNotify(m_date + wxDateSpan::Year()); + break; + + case WXK_PAGEUP: + SetDateAndNotify(m_date - wxDateSpan::Year()); + break; + + case WXK_RIGHT: + SetDateAndNotify(m_date + wxDateSpan::Day()); + break; + + case WXK_LEFT: + SetDateAndNotify(m_date - wxDateSpan::Day()); + break; + + case WXK_UP: + SetDateAndNotify(m_date - wxDateSpan::Week()); + break; + + case WXK_DOWN: + SetDateAndNotify(m_date + wxDateSpan::Week()); + break; + + case WXK_HOME: + SetDateAndNotify(wxDateTime::Today()); + break; + + default: + event.Skip(); + } +} + +// ---------------------------------------------------------------------------- +// wxCalendarEvent +// ---------------------------------------------------------------------------- + +void wxCalendarCtrl::GenerateEvent(wxEventType type) +{ + // we're called for a change in some particular date field but we always + // also generate a generic "changed" event + wxCalendarEvent event(this, type); + wxCalendarEvent event2(this, wxEVT_CALENDAR_SEL_CHANGED); + + (void)GetEventHandler()->ProcessEvent(event); + (void)GetEventHandler()->ProcessEvent(event2); +} + +wxCalendarEvent::wxCalendarEvent(wxCalendarCtrl *cal, wxEventType type) + : wxCommandEvent(type, cal->GetId()) +{ + m_date = cal->GetDate(); +} diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 3f8b535c07..a52c0d6124 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -101,19 +101,21 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, m_needParent = TRUE; m_acceptsFocus = TRUE; - wxSize newSize( size ); + wxSize newSize = size, + bestSize = DoGetBestSize(); + if (newSize.x == -1) - newSize.x = 80; + newSize.x = bestSize.x; if (newSize.y == -1) - newSize.y = 26; + newSize.y = bestSize.y; if (newSize.y > 30) - newSize.y = 30; - + newSize.y = 30; + if (!PreCreation( parent, pos, newSize ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxComboBox creation failed") ); - return FALSE; + return FALSE; } m_widget = gtk_combo_new(); @@ -126,7 +128,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, for (int i = 0; i < n; i++) { /* don't send first event, which GTK sends aways when - inserting the first item */ + inserting the first item */ m_alreadySent = TRUE; GtkWidget *list_item = gtk_list_item_new_with_label( choices[i].mbc_str() ); @@ -663,6 +665,7 @@ bool wxComboBox::IsOwnGtkWindow( GdkWindow *window ) wxSize wxComboBox::DoGetBestSize() const { + // totally bogus - should measure the strings in the combo! return wxSize(100, 26); } diff --git a/src/gtk/spinbutt.cpp b/src/gtk/spinbutt.cpp index f95ee16dc8..2ecf6885e4 100644 --- a/src/gtk/spinbutt.cpp +++ b/src/gtk/spinbutt.cpp @@ -99,10 +99,11 @@ bool wxSpinButton::Create(wxWindow *parent, { m_needParent = TRUE; - wxSize new_size = size; - new_size.x = 15; + wxSize new_size = size, + sizeBest = DoGetBestSize(); + new_size.x = sizeBest.x; // override width always if (new_size.y == -1) - new_size.y = 26; + new_size.y = sizeBest.y; if (!PreCreation( parent, pos, new_size ) || !CreateBase( parent, id, pos, new_size, style, wxDefaultValidator, name )) @@ -197,7 +198,7 @@ void wxSpinButton::OnSize( wxSizeEvent &WXUNUSED(event) ) { wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") ); - m_width = 15; + m_width = DoGetBestSize().x; gtk_widget_set_usize( m_widget, m_width, m_height ); } @@ -212,4 +213,9 @@ void wxSpinButton::ApplyWidgetStyle() gtk_widget_set_style( m_widget, m_widgetStyle ); } +wxSize wxSpinButton::DoGetBestSize() const +{ + return wxSize(15, 26); +} + #endif diff --git a/src/gtk/spinctrl.cpp b/src/gtk/spinctrl.cpp index 10651bf765..439794f545 100644 --- a/src/gtk/spinctrl.cpp +++ b/src/gtk/spinctrl.cpp @@ -75,9 +75,12 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id, m_needParent = TRUE; m_acceptsFocus = TRUE; - wxSize new_size = size; + wxSize new_size = size, + sizeBest = DoGetBestSize(); + if (new_size.x == -1) + new_size.x = sizeBest.x; if (new_size.y == -1) - new_size.y = 26; + new_size.y = sizeBest.y; if (!PreCreation( parent, pos, new_size ) || !CreateBase( parent, id, pos, new_size, style, wxDefaultValidator, name )) @@ -219,5 +222,10 @@ void wxSpinCtrl::ApplyWidgetStyle() gtk_widget_set_style( m_widget, m_widgetStyle ); } +wxSize wxSpinCtrl::DoGetBestSize() const +{ + return wxSize(95, 26); +} + #endif // wxUSE_SPINCTRL diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index 3f8b535c07..a52c0d6124 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -101,19 +101,21 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, m_needParent = TRUE; m_acceptsFocus = TRUE; - wxSize newSize( size ); + wxSize newSize = size, + bestSize = DoGetBestSize(); + if (newSize.x == -1) - newSize.x = 80; + newSize.x = bestSize.x; if (newSize.y == -1) - newSize.y = 26; + newSize.y = bestSize.y; if (newSize.y > 30) - newSize.y = 30; - + newSize.y = 30; + if (!PreCreation( parent, pos, newSize ) || !CreateBase( parent, id, pos, size, style, validator, name )) { wxFAIL_MSG( wxT("wxComboBox creation failed") ); - return FALSE; + return FALSE; } m_widget = gtk_combo_new(); @@ -126,7 +128,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, for (int i = 0; i < n; i++) { /* don't send first event, which GTK sends aways when - inserting the first item */ + inserting the first item */ m_alreadySent = TRUE; GtkWidget *list_item = gtk_list_item_new_with_label( choices[i].mbc_str() ); @@ -663,6 +665,7 @@ bool wxComboBox::IsOwnGtkWindow( GdkWindow *window ) wxSize wxComboBox::DoGetBestSize() const { + // totally bogus - should measure the strings in the combo! return wxSize(100, 26); } diff --git a/src/gtk1/spinbutt.cpp b/src/gtk1/spinbutt.cpp index f95ee16dc8..2ecf6885e4 100644 --- a/src/gtk1/spinbutt.cpp +++ b/src/gtk1/spinbutt.cpp @@ -99,10 +99,11 @@ bool wxSpinButton::Create(wxWindow *parent, { m_needParent = TRUE; - wxSize new_size = size; - new_size.x = 15; + wxSize new_size = size, + sizeBest = DoGetBestSize(); + new_size.x = sizeBest.x; // override width always if (new_size.y == -1) - new_size.y = 26; + new_size.y = sizeBest.y; if (!PreCreation( parent, pos, new_size ) || !CreateBase( parent, id, pos, new_size, style, wxDefaultValidator, name )) @@ -197,7 +198,7 @@ void wxSpinButton::OnSize( wxSizeEvent &WXUNUSED(event) ) { wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") ); - m_width = 15; + m_width = DoGetBestSize().x; gtk_widget_set_usize( m_widget, m_width, m_height ); } @@ -212,4 +213,9 @@ void wxSpinButton::ApplyWidgetStyle() gtk_widget_set_style( m_widget, m_widgetStyle ); } +wxSize wxSpinButton::DoGetBestSize() const +{ + return wxSize(15, 26); +} + #endif diff --git a/src/gtk1/spinctrl.cpp b/src/gtk1/spinctrl.cpp index 10651bf765..439794f545 100644 --- a/src/gtk1/spinctrl.cpp +++ b/src/gtk1/spinctrl.cpp @@ -75,9 +75,12 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id, m_needParent = TRUE; m_acceptsFocus = TRUE; - wxSize new_size = size; + wxSize new_size = size, + sizeBest = DoGetBestSize(); + if (new_size.x == -1) + new_size.x = sizeBest.x; if (new_size.y == -1) - new_size.y = 26; + new_size.y = sizeBest.y; if (!PreCreation( parent, pos, new_size ) || !CreateBase( parent, id, pos, new_size, style, wxDefaultValidator, name )) @@ -219,5 +222,10 @@ void wxSpinCtrl::ApplyWidgetStyle() gtk_widget_set_style( m_widget, m_widgetStyle ); } +wxSize wxSpinCtrl::DoGetBestSize() const +{ + return wxSize(95, 26); +} + #endif // wxUSE_SPINCTRL diff --git a/src/motif/window.cpp b/src/motif/window.cpp index 627a7afd8a..8595126325 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -1250,69 +1250,61 @@ void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags) GetSize(& oldW, & oldH); GetPosition(& oldX, & oldY); - bool useOldPos = FALSE; - bool useOldSize = FALSE; + if ( !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) + { + if ( x == -1 ) + x = oldX; + if ( y == -1 ) + y = oldY; + } - if ((x == -1) && (x == -1) && ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)) - useOldPos = TRUE; - else if (x == oldX && y == oldY) - useOldPos = TRUE; + if ( width == -1 ) + width = oldW; + if ( height == -1 ) + height = oldH; - if ((width == -1) && (height == -1)) - useOldSize = TRUE; - else if (width == oldW && height == oldH) - useOldSize = TRUE; + bool nothingChanged = (x == oldX) && (y == oldY) && + (width == oldW) && (height == oldH); if (!wxNoOptimize::CanOptimize()) { - useOldSize = FALSE; useOldPos = FALSE; + nothingChanged = FALSE; } - if (useOldPos && useOldSize) - return; - - if (m_drawingArea) + if ( !nothingChanged ) { - CanvasSetSize(x, y, width, height, sizeFlags); - return; - } - Widget widget = (Widget) GetTopWidget(); - if (!widget) - return; + if (m_drawingArea) + { + CanvasSetSize(x, y, width, height, sizeFlags); + return; + } - bool managed = XtIsManaged( widget ); - if (managed) - XtUnmanageChild(widget); + Widget widget = (Widget) GetTopWidget(); + if (!widget) + return; - int xx = x; int yy = y; - AdjustForParentClientOrigin(xx, yy, sizeFlags); + bool managed = XtIsManaged( widget ); + if (managed) + XtUnmanageChild(widget); - if (!useOldPos) - { - if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) - XtVaSetValues(widget, XmNx, xx, NULL); - if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) - XtVaSetValues(widget, XmNy, yy, NULL); - } - if (!useOldSize) - { - if (width > -1) - XtVaSetValues(widget, XmNwidth, width, NULL); - if (height > -1) - XtVaSetValues(widget, XmNheight, height, NULL); - } + int xx = x; + int yy = y; + AdjustForParentClientOrigin(xx, yy, sizeFlags); - if (managed) - XtManageChild(widget); + DoMoveWindow(xx, yy, width, height); - // How about this bit. Maybe we don't need to generate size events - // all the time -- they'll be generated when the window is sized anyway. + if (managed) + XtManageChild(widget); + + // How about this bit. Maybe we don't need to generate size events + // all the time -- they'll be generated when the window is sized anyway. #if 0 - wxSizeEvent sizeEvent(wxSize(width, height), GetId()); - sizeEvent.SetEventObject(this); + wxSizeEvent sizeEvent(wxSize(width, height), GetId()); + sizeEvent.SetEventObject(this); - GetEventHandler()->ProcessEvent(sizeEvent); + GetEventHandler()->ProcessEvent(sizeEvent); #endif // 0 + } } void wxWindow::DoSetClientSize(int width, int height) @@ -1384,6 +1376,16 @@ void wxWindow::SetSizeHints(int minW, int minH, int maxW, int maxH, int incW, in XtVaSetValues(widget, XmNheightInc, incH, NULL); } +void wxWindow::DoMoveWindow(int x, int y, int width, int height) +{ + XtVaSetValues(GetWidget(), + XmNx, xx, + XmNy, yy, + XmNwidth, width, + XmNheight, height, + NULL); +} + // --------------------------------------------------------------------------- // text metrics // --------------------------------------------------------------------------- diff --git a/src/msw/makefile.b32 b/src/msw/makefile.b32 index f453da3397..79f51a782e 100644 --- a/src/msw/makefile.b32 +++ b/src/msw/makefile.b32 @@ -1,6 +1,6 @@ -# This file was automatically generated by tmake at 02:45, 1999/12/21 +# This file was automatically generated by tmake at 20:12, 1999/12/29 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE B32.T! # @@ -79,6 +79,7 @@ MSWDIR=. DOCDIR = $(WXDIR)\docs GENERICOBJS= $(MSWDIR)\busyinfo.obj \ + $(MSWDIR)\calctrl.obj \ $(MSWDIR)\choicdgg.obj \ $(MSWDIR)\grid.obj \ $(MSWDIR)\laywin.obj \ @@ -762,6 +763,8 @@ $(MSWDIR)\zstream.obj: $(COMMDIR)\zstream.$(SRCSUFF) $(MSWDIR)\busyinfo.obj: $(GENDIR)\busyinfo.$(SRCSUFF) +$(MSWDIR)\calctrl.obj: $(GENDIR)\calctrl.$(SRCSUFF) + $(MSWDIR)\choicdgg.obj: $(GENDIR)\choicdgg.$(SRCSUFF) $(MSWDIR)\grid.obj: $(GENDIR)\grid.$(SRCSUFF) @@ -912,7 +915,7 @@ $(CFG): makefile.b32 -WE -tWM --I$(WXINC);$(BCCDIR)\include;$(WXDIR)/src/generic;$(WXDIR)/src/png;$(WXDIR)/src/jpeg;$(WXDIR)/src/zlib;$(WXDIR)/src/xpm +-I$(WXINC);$(BCCDIR)\include;$(WXDIR)/src/generic;$(WXDIR)/src/png;$(WXDIR)/src/jpeg;$(WXDIR)/src/zlib;$(WXDIR)/src/xpm;$(WXDIR)/src/tiff -I$(WXDIR)\include\wx\msw\gnuwin32 -L$(BCCDIR)\lib diff --git a/src/msw/makefile.bcc b/src/msw/makefile.bcc index 411ac38603..a3bd617a3e 100644 --- a/src/msw/makefile.bcc +++ b/src/msw/makefile.bcc @@ -1,6 +1,6 @@ -# This file was automatically generated by tmake at 02:45, 1999/12/21 +# This file was automatically generated by tmake at 20:12, 1999/12/29 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BCC.T! # @@ -74,6 +74,7 @@ MSWDIR=. DOCDIR = $(WXDIR)\docs GENERICOBJS= $(MSWDIR)\busyinfo.obj \ + $(MSWDIR)\calctrl.obj \ $(MSWDIR)\choicdgg.obj \ $(MSWDIR)\dirdlgg.obj \ $(MSWDIR)\grid.obj \ @@ -616,6 +617,8 @@ ${MSWDIR}\resourc2.obj: ${COMMDIR}\resourc2.$(SRCSUFF) $(MSWDIR)\busyinfo.obj: $(GENDIR)\busyinfo.$(SRCSUFF) +$(MSWDIR)\calctrl.obj: $(GENDIR)\calctrl.$(SRCSUFF) + $(MSWDIR)\choicdgg.obj: $(GENDIR)\choicdgg.$(SRCSUFF) $(MSWDIR)\dirdlgg.obj: $(GENDIR)\dirdlgg.$(SRCSUFF) diff --git a/src/msw/makefile.dos b/src/msw/makefile.dos index 2a0818210c..7847cd8b64 100644 --- a/src/msw/makefile.dos +++ b/src/msw/makefile.dos @@ -1,4 +1,4 @@ -# This file was automatically generated by tmake at 02:45, 1999/12/21 +# This file was automatically generated by tmake at 20:12, 1999/12/29 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE DOS.T! # @@ -58,6 +58,7 @@ OLEDIR=.\ole MSWDIR=. GENERICOBJS= $(GENDIR)\busyinfo.obj \ + $(GENDIR)\calctrl.obj \ $(GENDIR)\choicdgg.obj \ $(GENDIR)\dirdlgg.obj \ $(GENDIR)\grid.obj \ @@ -1109,6 +1110,11 @@ $(GENDIR)/busyinfo.obj: $*.$(SRCSUFF) $(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF) << +$(GENDIR)/calctrl.obj: $*.$(SRCSUFF) + cl @<< +$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF) +<< + $(GENDIR)/choicdgg.obj: $*.$(SRCSUFF) cl @<< $(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF) diff --git a/src/msw/makefile.g95 b/src/msw/makefile.g95 index 74d2837f3d..eb89b5a2f6 100644 --- a/src/msw/makefile.g95 +++ b/src/msw/makefile.g95 @@ -1,4 +1,4 @@ -# This file was automatically generated by tmake at 02:45, 1999/12/21 +# This file was automatically generated by tmake at 20:12, 1999/12/29 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE G95.T! # @@ -53,6 +53,7 @@ endif GENERICOBJS = \ $(GENDIR)/busyinfo.$(OBJSUFF) \ + $(GENDIR)/calctrl.$(OBJSUFF) \ $(GENDIR)/choicdgg.$(OBJSUFF) \ $(GENDIR)/grid.$(OBJSUFF) \ $(GENDIR)/laywin.$(OBJSUFF) \ diff --git a/src/msw/makefile.sc b/src/msw/makefile.sc index 652f2e71e7..137a861f37 100644 --- a/src/msw/makefile.sc +++ b/src/msw/makefile.sc @@ -1,6 +1,6 @@ -# This file was automatically generated by tmake at 02:45, 1999/12/21 +# This file was automatically generated by tmake at 20:12, 1999/12/29 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE SC.T! # Symantec C++ makefile for the msw objects @@ -27,6 +27,7 @@ OLEDIR=ole MSWDIR=$(WXDIR)\src\msw GENERICOBJS= $(GENDIR)\busyinfo.obj \ + $(GENDIR)\calctrl.obj \ $(GENDIR)\choicdgg.obj \ $(GENDIR)\grid.obj \ $(GENDIR)\laywin.obj \ diff --git a/src/msw/makefile.vc b/src/msw/makefile.vc index fafb791651..ff3f40387f 100644 --- a/src/msw/makefile.vc +++ b/src/msw/makefile.vc @@ -1,4 +1,4 @@ -# This file was automatically generated by tmake at 02:45, 1999/12/21 +# This file was automatically generated by tmake at 20:12, 1999/12/29 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE VC.T! # File: makefile.vc @@ -84,6 +84,7 @@ $(CPPFLAGS) /Fo$@ /c /Tp $< << GENERICOBJS= ..\generic\$D\busyinfo.obj \ + ..\generic\$D\calctrl.obj \ ..\generic\$D\choicdgg.obj \ ..\generic\$D\grid.obj \ ..\generic\$D\laywin.obj \ @@ -572,31 +573,20 @@ cleanall: clean # Making documents docs: allhlp allhtml allpdfrtf alldocs: docs -hlp: wxhlp portinghlp +hlp: wxhlp wxhlp: $(DOCDIR)/winhelp/wx.hlp -prophlp: $(DOCDIR)/winhelp/prop.hlp refhlp: $(DOCDIR)/winhelp/techref.hlp rtf: $(DOCDIR)/winhelp/wx.rtf -proprtf: $(DOCDIR)/winhelp/prop.rtf pdfrtf: $(DOCDIR)/pdf/wx.rtf -proppdfrtf: $(DOCDIR)/pdf/prop.rtf refpdfrtf: $(DOCDIR)/pdf/techref.rtf -html: wxhtml portinghtml +html: wxhtml wxhtml: $(DOCDIR)\html\wx\wx.htm htmlhelp: $(DOCDIR)\html\wx\wx.chm -prophtml: $(DOCDIR)\html\proplist\prop.htm ps: wxps referencps wxps: $(WXDIR)\docs\ps\wx.ps -propps: $(WXDIR)\docs\ps\prop.ps referencps: $(WXDIR)\docs\ps\referenc.ps -portinghtml: $(DOCDIR)\html\porting\port.htm -portingrtf: $(DOCDIR)/winhelp/porting.rtf -portinghlp: $(DOCDIR)/winhelp/porting.hlp -portingpdfrtf: $(DOCDIR)/pdf/porting.rtf -portingps: $(WXDIR)\docs\ps\porting.ps - -allhlp: wxhlp portinghlp prophlp +allhlp: wxhlp cd $(WXDIR)\utils\dialoged\src nmake -f makefile.vc hlp cd $(THISDIR) @@ -616,7 +606,7 @@ allhlp: wxhlp portinghlp prophlp # cd $(WXDIR)\utils\wxgrid\src # nmake -f makefile.vc hlp -allhtml: wxhtml portinghtml prophtml +allhtml: wxhtml cd $(WXDIR)\utils\dialoged\src nmake -f makefile.vc html cd $(THISDIR) @@ -637,12 +627,12 @@ allhtml: wxhtml portinghtml prophtml # cd $(WXDIR)\utils\wxtree\src # nmake -f makefile.vc html -allps: wxps referencps portingps propps +allps: wxps referencps cd $(WXDIR)\utils\dialoged\src nmake -f makefile.vc ps cd $(THISDIR) -allpdfrtf: pdfrtf portingpdfrtf proppdfrtf +allpdfrtf: pdfrtf cd $(WXDIR)\utils\dialoged\src nmake -f makefile.vc pdfrtf cd $(THISDIR) @@ -667,22 +657,6 @@ $(DOCDIR)/winhelp/wx.hlp: $(DOCDIR)/latex/wx/wx.rtf $(DOCDIR)/latex/wx/w move wx.cnt $(DOCDIR)\winhelp\wx.cnt cd $(THISDIR) -$(DOCDIR)/winhelp/porting.hlp: $(DOCDIR)/latex/porting/porting.rtf $(DOCDIR)/latex/porting/porting.hpj - cd $(DOCDIR)/latex/porting - -erase porting.ph - hc porting - move porting.hlp $(DOCDIR)\winhelp\porting.hlp - move porting.cnt $(DOCDIR)\winhelp\porting.cnt - cd $(THISDIR) - -$(DOCDIR)/winhelp/prop.hlp: $(DOCDIR)/latex/proplist/prop.rtf $(DOCDIR)/latex/proplist/prop.hpj - cd $(DOCDIR)/latex/proplist - -erase prop.ph - hc prop - move prop.hlp $(DOCDIR)\winhelp\prop.hlp - move prop.cnt $(DOCDIR)\winhelp\prop.cnt - cd $(THISDIR) - $(DOCDIR)/winhelp/techref.hlp: $(DOCDIR)/latex/techref/techref.rtf $(DOCDIR)/latex/techref/techref.hpj cd $(DOCDIR)/latex/techref -erase techref.ph @@ -696,16 +670,6 @@ $(DOCDIR)/latex/wx/wx.rtf: $(DOCDIR)/latex/wx/classes.tex $(DOCDIR)/late -start $(WAITFLAG) tex2rtf $(DOCDIR)/latex/wx/manual.tex $(DOCDIR)/latex/wx/wx.rtf -twice -winhelp cd $(THISDIR) -$(DOCDIR)/latex/porting/porting.rtf: $(DOCDIR)/latex/porting/porting.tex - cd $(DOCDIR)\latex\porting - -start $(WAITFLAG) tex2rtf $(DOCDIR)/latex/porting/porting.tex $(DOCDIR)/latex/porting/porting.rtf -twice -winhelp - cd $(THISDIR) - -$(DOCDIR)/latex/proplist/prop.rtf: $(DOCDIR)/latex/proplist/prop.tex $(DOCDIR)/latex/proplist/body.tex $(DOCDIR)/latex/proplist/classes.tex $(DOCDIR)/latex/proplist/changes.tex - cd $(DOCDIR)\latex\proplist - -start $(WAITFLAG) tex2rtf $(DOCDIR)/latex/proplist/prop.tex $(DOCDIR)/latex/proplist/prop.rtf -twice -winhelp - cd $(THISDIR) - $(DOCDIR)/latex/techref/techref.rtf: $(DOCDIR)/latex/techref/techref.tex cd $(DOCDIR)\latex\techref -start $(WAITFLAG) tex2rtf $(DOCDIR)/latex/techref/techref.tex $(DOCDIR)/latex/techref/techref.rtf -twice -winhelp @@ -718,20 +682,6 @@ $(DOCDIR)/pdf/wx.rtf: $(DOCDIR)/latex/wx/classes.tex $(DOCDIR)/latex/wx/ -start $(WAITFLAG) tex2rtf $(DOCDIR)/latex/wx/manual.tex $(DOCDIR)/pdf/wx.rtf -twice -rtf cd $(THISDIR) -$(DOCDIR)/pdf/porting.rtf: $(DOCDIR)/latex/porting/porting.tex - cd $(DOCDIR)\latex\porting - -copy *.wmf $(DOCDIR)\pdf - -copy *.bmp $(DOCDIR)\pdf - -start $(WAITFLAG) tex2rtf $(DOCDIR)/latex/porting/porting.tex $(DOCDIR)/pdf/porting.rtf -twice -rtf - cd $(THISDIR) - -$(DOCDIR)/pdf/prop.rtf: $(DOCDIR)/latex/proplist/prop.tex $(DOCDIR)/latex/proplist/body.tex $(DOCDIR)/latex/proplist/classes.tex $(DOCDIR)/latex/proplist/changes.tex - cd $(DOCDIR)\latex\proplist - -copy *.wmf $(DOCDIR)\pdf - -copy *.bmp $(DOCDIR)\pdf - -start $(WAITFLAG) tex2rtf $(DOCDIR)/latex/proplist/prop.tex $(DOCDIR)/pdf/prop.rtf -twice -rtf - cd $(THISDIR) - $(DOCDIR)/pdf/techref.rtf: $(DOCDIR)/latex/techref/techref.tex cd $(DOCDIR)\latex\techref -copy *.wmf $(DOCDIR)\pdf @@ -754,27 +704,6 @@ $(DOCDIR)\html\wx\wx.chm : $(DOCDIR)\html\wx\wx.htm $(DOCDIR)\html\wx\wx.hhp -hhc wx.hhp cd $(THISDIR) - -$(DOCDIR)\html\porting\port.htm: $(DOCDIR)\latex\porting\porting.tex - cd $(DOCDIR)\latex\porting - -mkdir $(DOCDIR)\html\porting - -start $(WAITFLAG) tex2rtf $(DOCDIR)\latex\porting\porting.tex $(DOCDIR)\html\porting\port.htm -twice -html - -erase $(DOCDIR)\html\porting\*.con - -erase $(DOCDIR)\html\porting\*.ref - -erase $(DOCDIR)\latex\porting\*.con - -erase $(DOCDIR)\latex\porting\*.ref - cd $(THISDIR) - -$(DOCDIR)\html\proplist\prop.htm: $(DOCDIR)\latex\proplist\prop.tex $(DOCDIR)\latex\proplist\body.tex $(DOCDIR)\latex\proplist\classes.tex $(DOCDIR)\latex\proplist\changes.tex - cd $(DOCDIR)\latex\proplist - -mkdir $(DOCDIR)\html\proplist - -start $(WAITFLAG) tex2rtf $(DOCDIR)\latex\proplist\prop.tex $(DOCDIR)\html\proplist\prop.htm -twice -html - -erase $(DOCDIR)\html\proplist\*.con - -erase $(DOCDIR)\html\proplist\*.ref - -erase $(DOCDIR)\latex\proplist\*.con - -erase $(DOCDIR)\latex\proplist\*.ref - cd $(THISDIR) - $(WXDIR)\docs\latex\wx\manual.dvi: $(DOCDIR)/latex/wx/body.tex $(DOCDIR)/latex/wx/manual.tex cd $(WXDIR)\docs\latex\wx -latex manual @@ -785,28 +714,12 @@ $(WXDIR)\docs\latex\wx\manual.dvi: $(DOCDIR)/latex/wx/body.tex $(DOCDIR)/latex/w -latex manual cd $(THISDIR) -$(WXDIR)\docs\latex\porting\porting.dvi: $(DOCDIR)/latex/porting/porting.tex - cd $(WXDIR)\docs\latex\porting - -latex porting - -latex porting - -makeindx porting - -bibtex porting - -latex porting - -latex porting - cd $(THISDIR) - $(WXDIR)\docs\ps\wx.ps: $(WXDIR)\docs\latex\wx\manual.dvi cd $(WXDIR)\docs\latex\wx -dvips32 -o wx.ps manual move wx.ps $(WXDIR)\docs\ps\wx.ps cd $(THISDIR) -$(WXDIR)\docs\ps\porting.ps: $(WXDIR)\docs\latex\porting\porting.dvi - cd $(WXDIR)\docs\latex\porting - -dvips32 -o porting.ps porting - move porting.ps $(WXDIR)\docs\ps\porting.ps - cd $(THISDIR) - $(WXDIR)\docs\latex\wx\referenc.dvi: $(DOCDIR)/latex/wx/classes.tex $(DOCDIR)/latex/wx/topics.tex $(DOCDIR)/latex/wx/referenc.tex cd $(WXDIR)\docs\latex\wx -latex referenc diff --git a/src/msw/makefile.wat b/src/msw/makefile.wat index 21d2e49c6c..882bb7fdb6 100644 --- a/src/msw/makefile.wat +++ b/src/msw/makefile.wat @@ -1,6 +1,6 @@ #!/binb/wmake.exe -# This file was automatically generated by tmake at 02:45, 1999/12/21 +# This file was automatically generated by tmake at 20:12, 1999/12/29 # DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE WAT.T! # @@ -40,6 +40,7 @@ OLEDIR=$(MSWDIR)\ole DOCDIR = $(WXDIR)\docs GENERICOBJS= busyinfo.obj & + calctrl.obj & choicdgg.obj & grid.obj & laywin.obj & @@ -907,6 +908,9 @@ $(COMMDIR)\lex_yy.c: $(COMMDIR)\doslex.c busyinfo.obj: $(GENDIR)\busyinfo.cpp *$(CCC) $(CPPFLAGS) $(IFLAGS) $< +calctrl.obj: $(GENDIR)\calctrl.cpp + *$(CCC) $(CPPFLAGS) $(IFLAGS) $< + choicdgg.obj: $(GENDIR)\choicdgg.cpp *$(CCC) $(CPPFLAGS) $(IFLAGS) $< -- 2.45.2