Commit Graph

21 Commits

Author SHA1 Message Date
utelle
1c65e88221 Replace references to wxLocale by wxUILocale
Use newer wxUILocale class directly instead of using wxLocale functions
that forward to it anyhow.

No real changes.

Closes #22375.
2022-05-01 03:02:26 +02:00
Vadim Zeitlin
552c9dd4ff Fix wxMSW wxDateTimePickerCtrl build with wxUSE_UNICODE_UTF8
Don't use the ternary operator as t_str() doesn't return a pointer in
this build configuration.

Also remove outdated (and maybe even wrong) comment about MinGW headers,
as it's better to use a temporary variable just to avoid writing the
cast explicitly anyhow.

Closes #19338.
2021-12-03 15:49:30 +01:00
Vadim Zeitlin
a244059934 Avoid using DTM_GETIDEALSIZE with DTS_SHOWNONE
This message is completely broken when DTS_SHOWNONE is used, it returns
wrong result (less than the size without DTS_SHOWNONE) initially and
completely wrong results after a DPI change.

Create a temporary date time picker control without DTS_SHOWNONE and
call DTM_GETIDEALSIZE for it instead. This is wasteful, but at least
returns correct results.

This commit is best viewed ignoring whitespace-only changes.
2021-03-28 03:22:17 +02:00
Vadim Zeitlin
aa50c6d829 Further improve best size of wxDatePickerCtrl with wxDP_ALLOWNONE
Compute the best size more precisely to be exactly compatible with the
control appearance when not using wxDP_ALLOWNONE. This unfortunately
requires hardcoding an arbitrary constant in DoGetBestSize().

Patch used for testing this code for future reference:

diff --git a/samples/minimal/minimal.cpp b/samples/minimal/minimal.cpp
index 470e765423..a1d5fb9938 100644
--- a/samples/minimal/minimal.cpp
+++ b/samples/minimal/minimal.cpp
@@ -26,6 +26,8 @@
     #include "wx/wx.h"
 #endif

+#include "wx/datectrl.h"
+
 // ----------------------------------------------------------------------------
 // resources
 // ----------------------------------------------------------------------------
@@ -175,6 +177,28 @@ bool MyApp::OnInit()
     CreateStatusBar(2);
     SetStatusText("Welcome to wxWidgets!");
 #endif // wxUSE_STATUSBAR
+
+    auto sz = new wxBoxSizer(wxVERTICAL);
+    auto addDPC = [this, sz](int style)
+    {
+        sz->Add(new wxDatePickerCtrl(this, wxID_ANY, wxDefaultDateTime,
+                                     wxDefaultPosition, wxDefaultSize, style),
+                wxSizerFlags().Right());
+    };
+
+    addDPC(wxDP_DROPDOWN | wxDP_ALLOWNONE | wxDP_SHOWCENTURY);
+    addDPC(wxDP_DROPDOWN | wxDP_SHOWCENTURY);
+    addDPC(wxDP_DROPDOWN | wxDP_ALLOWNONE);
+    addDPC(wxDP_DROPDOWN);
+
+    sz->AddSpacer(10);
+
+    addDPC(wxDP_SPIN | wxDP_ALLOWNONE | wxDP_SHOWCENTURY);
+    addDPC(wxDP_SPIN | wxDP_SHOWCENTURY);
+    addDPC(wxDP_SPIN | wxDP_ALLOWNONE);
+    addDPC(wxDP_SPIN);
+
+    SetSizerAndFit(sz);
 }
2021-03-27 21:55:13 +01:00
Vadim Zeitlin
8ceca69064 Always handle wxDP_ALLOWNONE ourselves in best size computation
DTM_GETIDEALSIZE doesn't seem to account for it, so we need to do it
ourselves even when using it.

Closes #19120.
2021-03-27 21:52:04 +01:00
Vadim Zeitlin
4f6cf6da5b Don't call GetTextExtent() if we don't use its result
It's unnecessary to call GetTextExtent() just to discard/overwrite its
result immediately with the value returned from DTM_GETIDEALSIZE, so
don't do it.

This reverts another part of a98d8448fa (Fix size of
wxDateTimePickerCtrl after DPI change, 2019-01-13) which wasn't done in
7de85d7470 (Restore correct best width of wxDatePickerCtrl in MSW,
2020-05-24).included

This commit is best viewed ignoring whitespace-only changes.
2021-03-25 14:49:54 +01:00
Vadim Zeitlin
67e9829b55 Remove unneeded wxClientDC wxDateTimePickerCtrl::DoGetBestSize()
Just call GetTextExtent() on the window itself, it does the same thing
anyhow.

No real changes, just a tiny simplification.
2021-03-25 14:46:37 +01:00
Vadim Zeitlin
02f1ee3987 Add wxDateTimePickerCtrl::SetNullText()
This allows to customize the string shown when there is no valid date
under MSW (only, for now) and can be notably used to suppress the
unused date completely, which can be useful to lighten up the display
when there are many controls.

Add UI elements to the widgets sample allowing to test the new function.
2020-11-05 14:22:05 +01:00
PB
f57f214122 Remove BCC-specific hdrstop pragma from everywhere 2020-10-12 21:58:37 +02:00
Vadim Zeitlin
7de85d7470 Restore correct best width of wxDatePickerCtrl in MSW
This partially reverts the changes of a98d8448fa (Fix size of
wxDateTimePickerCtrl after DPI change, 2019-01-13) to still use
DTM_GETIDEALSIZE, even if it returns wrong height value after a DPI
change, because it still computes the best width more precisely than we
do and using our code could result in the date being partially truncated
when using some date formats.
2020-05-24 22:47:28 +02:00
Maarten Bent
a98d8448fa Fix size of wxDateTimePickerCtrl after DPI change
Do not use DateTime_GetIdealSize or DTM_GETIDEALSIZE. They return
incorrect sizes after the DPI of the window has changed. For every DPI
change, the returned size is 4 pixels higher, even if the DPI is
lowered.

Improve the existing method to also take the minimum height of the
scroll-arrows into account.
2019-09-28 23:37:01 +02:00
Maarten Bent
f74d756ca5 Use DPI Aware wxGetSystemMetrics
If no wxWindow is known, use wxTheApp->GetTopWindow().
Also use a wxWindow for all wxSystemSettings::GetMetric calls.
2019-07-15 00:00:18 +02:00
Vadim Zeitlin
66fdf49ed8 Work around a Wine bug in wxDateTimePickerCtrl sizing
Don't assume that all Vista and later systems support DTM_GETIDEALSIZE,
this is not the case under Wine even when it's emulating a Vista+
Windows version and trusting DTM_GETIDEALSIZE to always return the right
value resulted in these controls having 0 size and not being shown at
all when running wxWidgets programs under Wine.

See https://bugs.winehq.org/show_bug.cgi?id=44680
2018-03-07 15:12:21 +01:00
Vadim Zeitlin
a3747ac959 Don't leave too much blank space in wxDatePickerCtrl under XP.
In our efforts to account for the longest possible string we made the control
too wide by default which didn't look very good, so reduce the amount of space
added to it, this still seems to be (just) enough for all the reasonable date
formats (tested under Windows XP SP3 with default DPI).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78417 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2015-01-26 15:10:45 +00:00
Vadim Zeitlin
340d7f67b6 Use DTM_GETIDEALSIZE to implement wxDateTimePickerCtrl::DoGetBestSize().
If possible, i.e. when running under Vista or later, just ask the control for
its best size instead of trying to approximate it ourselves.

Notice that we still use our own height, to ensure that it's the same as for
the text controls, but it's the width that really counts.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78221 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-12-05 22:17:17 +00:00
Vadim Zeitlin
9fc78c8167 Add wxLocale::GetOSInfo() and use it in MSW wxDateTimePickerCtrl.
This fixes the size of wxDateTimePickerCtrl in programs that don't set any
specific locale: previously, the standard "%m/%d/%y" format was used for
computing the best size of the control in this case, but this could have been
significantly shorter than the format actually used (compare with the default
"%d %b, %Y"), resulting in the control contents being truncated by default.

GetOSInfo() is currently different from GetInfo() only under MSW, but we might
need to make the same distinction under OS X too, so do make this function
public instead of keeping it MSW-specific.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78220 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-12-05 22:17:13 +00:00
Vadim Zeitlin
8a00553fda Remove unneeded CacheBestSize() from wxMSW wxDateTimePickerCtrl.
The best size is already cached by the base class GetBestSize(), no need to do
it here as well.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78219 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2014-12-05 22:17:08 +00:00
Vadim Zeitlin
8f7c658ef1 Fix wxMSW build when wxUSE_INTL==0.
Don't use wxLocaleInfo in this case as it's not defined.

Closes #15599.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75059 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-10-25 12:17:28 +00:00
Vadim Zeitlin
3f66f6a5b3 Remove all lines containing cvs/svn "$Id$" keyword.
This keyword is not expanded by Git which means it's not replaced with the
correct revision value in the releases made using git-based scripts and it's
confusing to have lines with unexpanded "$Id$" in the released files. As
expanding them with Git is not that simple (it could be done with git archive
and export-subst attribute) and there are not many benefits in having them in
the first place, just remove all these lines.

If nothing else, this will make an eventual transition to Git simpler.

Closes #14487.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2013-07-26 16:02:46 +00:00
Vadim Zeitlin
ae97a3bdab Fix wxDateTimePickerCtrl compilation without PCH.
Include the MSW private headers usually included from the PCH file.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69293 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-10-02 17:39:21 +00:00
Vadim Zeitlin
8957e55ed3 Refactor wxDatePickerCtrl to derive from wxDateTimePickerCtrl.
No real changes, just refactor wxMSW wxDatePickerCtrl to allow sharing code
with the upcoming wxTimePickerCtrl class. Even less changes for the other
platforms where wxDateTimePickerCtrl is trivial.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69222 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2011-09-29 13:43:02 +00:00