[Git][wxwidgets/wxwidgets][master] 19 commits: Improve wxToolbar ToolPacking at high DPI

2 views
Skip to first unread message

Vadim Zeitlin (@_VZ_)

unread,
Feb 11, 2026, 8:33:38 AM (6 days ago) Feb 11
to wx-commi...@googlegroups.com

Vadim Zeitlin pushed to branch master at wxWidgets / wxWidgets

Commits:

  • b72a48b8
    by Maarten Bent at 2026-01-27T20:02:13+01:00
    Improve wxToolbar ToolPacking at high DPI
    
    Treat m_toolPacking as DPI independent, and scale it to the active DPI.
    Also scale other hard-coded sizes to the active DPI.
    
    Fixes #26038
    
  • 9f0235f2
    by Maarten Bent at 2026-01-29T22:31:18+01:00
    Store wxMSW wxToolBar packing in logical pixels
    
    Keep the public API consistent and the same as wxAuiToolBar::SetToolPacking().
    
  • a54a4392
    by Vadim Zeitlin at 2026-02-09T23:53:15+01:00
    Fix format specifiers used for size_t in text sample
    
    Using "%lu" for size_t resulted in an assertion failure under Win64.
    
    Also remove casts of size_t to "unsigned int", even if this worked, it
    is ugly and using "%zu" is simpler.
    
    And remove even more useless casts of int to long too.
    
  • 72447342
    by Vadim Zeitlin at 2026-02-09T23:59:23+01:00
    Show text state in text sample with a single wxLogMessage() call
    
    This is easier to read than 3 different log messages.
    
    Also group pieces of related information together.
    
    No real changes.
    
  • 14687e2b
    by Vadim Zeitlin at 2026-02-10T00:50:20+01:00
    Remove hard coded controls positions and sizes from text sample
    
    This was not only useless, because the controls were repositioned by the
    sizers later anyhow, but also actively harmful in at least one case,
    when creating a control with wxTE_MULTILINE and wxTE_NO_VSCROLL styles
    with too small height prevented the text from being appended to it.
    
    Closes #26177.
    
  • b2701138
    by Vadim Zeitlin at 2026-02-10T13:36:16+01:00
    Fix GetValue() returning hint for wxMSW controls with wxTE_RICH
    
    Override DoGetValue() in wxMSW wxTextCtrl and not GetValue() itself as
    the base class version correctly takes the manually managed hints into
    account, unlike the overridden version which only did this for plain
    edit controls but not the rich edit ones.
    
    Add a unit test to ensure that this bug remains fixed.
    
    See #26176.
    
  • 3b01ebf5
    by Vadim Zeitlin at 2026-02-10T14:08:58+01:00
    Add forgotten support for %T to our own wxDateTime::Format() code
    
    "%T" was only handled when strftime() could be used but not by our own
    implementation, resulting in failing to handle it for format string
    including both "%T" and one of the specifiers not supported by the
    standard function, such as "%l" or several others when using MinGW.
    
    Closes #26179.
    
  • 6fa122c0
    by AliKet at 2026-02-10T14:26:01+01:00
    wxQt: Add missing wxEVT_COLOUR_CHANGED event generation
    
  • 54180dd7
    by AliKet at 2026-02-10T15:33:45+01:00
    wxQt: Override wxWindow::ClearBackground()
    
    The base class version uses wxClientDC which doesn't work well when
    used simultaneously with a wxPaintDC.
    
  • a5b101f7
    by AliKet at 2026-02-10T15:33:48+01:00
    Remove unnecessary cast to wxScrolledWindow pointer
    
    wxPreviewCanvas (the pointer type of m_previewCanvas) is in fact
    a wxScrolledWindow anyhow.
    
  • 21bf245f
    by AliKet at 2026-02-10T15:33:48+01:00
    Remove unnecessary call to ClearBackground()
    
    Calling ClearBackground() followed by a Refresh() doesn't make any sense
    because ClearBackground() either a no-op (e.g. wxGTK) or just redundant
    under (wxOSX and wxQt) or will be overwritten in wxMSW.
    
  • ceab6b93
    by AliKet at 2026-02-10T21:00:59+01:00
    Add documentation for wxFrame::SetWindowModality()
    
  • 4117a8e2
    by AliKet at 2026-02-10T22:57:38+01:00
    wxQt: Fix dynamic ellipsizing of wxStaticText
    
    Without this, the label is not correctly updated when resizing the control
    as can be seen in the dialogs sample with wxInfoBar displayed. i.e.:
    
    	- Press Ctrl+I to display the wxInfoBar control.
    	- Press Ctrl+I again to show an ellipsized wxStaticText in the wxInfoBar.
    	- Try resizing the window.
    	- The wxStaticText is not updated correctly, unlike the other ports.
    
  • 62b4432d
    by Vadim Zeitlin at 2026-02-11T13:43:12+01:00
    Merge branch 'msw-toolbar-packing-dpi' of github.com:MaartenBent/wxWidgets
    
    Improve wxToolbar tool packing at high DPI.
    
    See #26115.
    
  • 5748d281
    by Vadim Zeitlin at 2026-02-11T13:43:58+01:00
    Merge branch 'qt-some-fixes' of github.com:AliKet/wxWidgets
    
    Miscellaneous wxQt fixes.
    
    See #26166.
    
  • 0e3a3b8c
    by Vadim Zeitlin at 2026-02-11T13:45:09+01:00
    Merge branch 'text-fixes'
    
    Fixes for wxMSW wxTextCtrl and text sample.
    
    See #26178.
    
  • d7fd467f
    by Lauri Nurmi at 2026-02-11T13:46:22+01:00
    Add wxTextEntryDialog::SetHint()
    
    Sets the hint text for the underlying wxTextCtrl.
    
    Closes #26176.
    
  • 9aa2abcd
    by Vadim Zeitlin at 2026-02-11T13:50:08+01:00
    Improve documentation of POSIX extensions to strftime()
    
    Mention that wxWidgets internal implementation may be used in this case
    and replace the mention of MSVC (whose CRT now supports these
    extensions) with MinGW.
    
  • 15850a5d
    by Vadim Zeitlin at 2026-02-11T13:51:26+01:00
    Merge branch 'dt-format-t'
    
    Add forgotten support for %T to our own wxDateTime::Format() code.
    
    See #26180.
    

19 changed files:

Changes:

  • include/wx/generic/textdlgg.h
    ... ... @@ -63,6 +63,8 @@ public:
    63 63
         void SetValue(const wxString& val);
    
    64 64
         wxString GetValue() const { return m_value; }
    
    65 65
     
    
    66
    +    void SetHint(const wxString &hint);
    
    67
    +
    
    66 68
         void SetMaxLength(unsigned long len);
    
    67 69
     
    
    68 70
         void ForceUpper();
    

  • include/wx/msw/textctrl.h
    ... ... @@ -37,7 +37,6 @@ public:
    37 37
         // overridden wxTextEntry methods
    
    38 38
         // ------------------------------
    
    39 39
     
    
    40
    -    virtual wxString GetValue() const override;
    
    41 40
         virtual wxString GetRange(long from, long to) const override;
    
    42 41
     
    
    43 42
     #if wxUSE_RICHEDIT
    
    ... ... @@ -246,6 +245,8 @@ protected:
    246 245
     
    
    247 246
         virtual void DoMoveWindow(int x, int y, int width, int height) override;
    
    248 247
     
    
    248
    +    virtual wxString DoGetValue() const override;
    
    249
    +
    
    249 250
     #if wxUSE_RICHEDIT
    
    250 251
         virtual void MSWUpdateFontOnDPIChange(const wxSize& newDPI) override;
    
    251 252
     
    

  • include/wx/qt/window.h
    ... ... @@ -89,6 +89,7 @@ public:
    89 89
         virtual void Update() override;
    
    90 90
         virtual void Refresh( bool eraseBackground = true,
    
    91 91
                               const wxRect *rect = nullptr ) override;
    
    92
    +    virtual void ClearBackground() override;
    
    92 93
     
    
    93 94
         virtual bool SetCursor( const wxCursor &cursor ) override;
    
    94 95
         virtual bool SetFont(const wxFont& font) override;
    

  • interface/wx/datetime.h
    ... ... @@ -925,7 +925,9 @@ public:
    925 925
     
    
    926 926
             Notice that POSIX @c "%g", @c "%G", @c "%V" and @c "%z" format
    
    927 927
             specifiers are supported even if the standard library doesn't support
    
    928
    -        them (e.g. MSVC).
    
    928
    +        them (as is the case when using MinGW, for example), but wxWidgets own
    
    929
    +        implementation is used if any of them are used instead of calling
    
    930
    +        `strftime()`.
    
    929 931
     
    
    930 932
             It also accepts a few wxWidgets-specific extensions: you can optionally
    
    931 933
             specify the width of the field to follow using @c printf(3)-like syntax
    

  • interface/wx/frame.h
    ... ... @@ -315,6 +315,31 @@ public:
    315 315
         */
    
    316 316
         virtual wxPoint GetClientAreaOrigin() const;
    
    317 317
     
    
    318
    +    /**
    
    319
    +        Possible parameters for SetWindowModality().
    
    320
    +
    
    321
    +        @since 3.3.2
    
    322
    +    */
    
    323
    +    enum class Modality
    
    324
    +    {
    
    325
    +        App,    ///< Disable all the other TLWs while the frame is shown.
    
    326
    +        Window, ///< Disable only the parent window while the frame is shown.
    
    327
    +        None    ///< Show the frame non-modally, and this is the default.
    
    328
    +    };
    
    329
    +
    
    330
    +    /**
    
    331
    +        Set the frame modality.
    
    332
    +
    
    333
    +        Call this function before showing the frame to make it modal to the
    
    334
    +        application (Modality::App) or just to the parent window (Modality::Window).
    
    335
    +
    
    336
    +        @note Changing the frame modality after it has been shown has no effect
    
    337
    +
    
    338
    +        @since 3.3.2
    
    339
    +    */
    
    340
    +    virtual void SetWindowModality(Modality modality);
    
    341
    +
    
    342
    +
    
    318 343
         /**
    
    319 344
             Returns a pointer to the menubar currently associated with the frame (if any).
    
    320 345
     
    

  • interface/wx/print.h
    ... ... @@ -153,6 +153,8 @@ public:
    153 153
         The elements of this enum can be used with wxPreviewFrame::Initialize() to
    
    154 154
         indicate how should the preview frame be shown.
    
    155 155
     
    
    156
    +    @note Since version 3.3.2, this is just an alias for wxFrame::Modality.
    
    157
    +
    
    156 158
         @since 2.9.2
    
    157 159
     */
    
    158 160
     enum wxPreviewFrameModalityKind
    
    ... ... @@ -160,17 +162,23 @@ enum wxPreviewFrameModalityKind
    160 162
         /**
    
    161 163
             Disable all the other top level windows while the preview frame is shown.
    
    162 164
     
    
    165
    +        Same as wxFrame::Modality::App
    
    166
    +
    
    163 167
             This is the default behaviour.
    
    164 168
          */
    
    165 169
         wxPreviewFrame_AppModal,
    
    166 170
     
    
    167 171
         /**
    
    168 172
             Disable only the parent window while the preview frame is shown.
    
    173
    +
    
    174
    +        Same as wxFrame::Modality::Window
    
    169 175
          */
    
    170 176
         wxPreviewFrame_WindowModal,
    
    171 177
     
    
    172 178
         /**
    
    173 179
             Show the preview frame non-modally and don't disable any other windows.
    
    180
    +
    
    181
    +        Same as wxFrame::Modality::None
    
    174 182
          */
    
    175 183
         wxPreviewFrame_NonModal
    
    176 184
     };
    

  • interface/wx/textdlg.h
    ... ... @@ -178,6 +178,15 @@ public:
    178 178
         */
    
    179 179
         void SetValue(const wxString& value);
    
    180 180
     
    
    181
    +    /**
    
    182
    +        Sets the hint shown in the empty text control.
    
    183
    +
    
    184
    +        @see wxTextEntry::SetHint()
    
    185
    +
    
    186
    +        @since 3.3.2
    
    187
    +    */
    
    188
    +    void SetHint(const wxString &hint);
    
    189
    +
    
    181 190
         /**
    
    182 191
             Convert all text entered into the text control used by the dialog to upper case.
    
    183 192
     
    

  • samples/dialogs/dialogs.cpp
    ... ... @@ -794,7 +794,6 @@ void MyFrame::DoApplyColour(const wxColour& colour)
    794 794
             return;
    
    795 795
     
    
    796 796
         m_canvas->SetBackgroundColour(colour);
    
    797
    -    m_canvas->ClearBackground();
    
    798 797
         m_canvas->Refresh();
    
    799 798
     }
    
    800 799
     
    
    ... ... @@ -858,7 +857,6 @@ void MyFrame::ChooseColourGeneric(wxCommandEvent& event)
    858 857
         {
    
    859 858
             m_clrData = dialog->GetColourData();
    
    860 859
             m_canvas->SetBackgroundColour(m_clrData.GetColour());
    
    861
    -        m_canvas->ClearBackground();
    
    862 860
             m_canvas->Refresh();
    
    863 861
         }
    
    864 862
         dialog->Destroy();
    
    ... ... @@ -1180,6 +1178,7 @@ void MyFrame::LineEntry(wxCommandEvent& WXUNUSED(event))
    1180 1178
                                  "Please enter a string",
    
    1181 1179
                                  "Default value",
    
    1182 1180
                                  wxOK | wxCANCEL);
    
    1181
    +    dialog.SetHint("Enter your text here");
    
    1183 1182
     
    
    1184 1183
         if (dialog.ShowModal() == wxID_OK)
    
    1185 1184
         {
    
    ... ... @@ -1193,6 +1192,7 @@ void MyFrame::TextEntry(wxCommandEvent& WXUNUSED(event))
    1193 1192
                                  "Please enter some text",
    
    1194 1193
                                  "First line\nSecond one\nAnd another one too",
    
    1195 1194
                                  wxOK | wxCANCEL | wxTE_MULTILINE);
    
    1195
    +    dialog.SetHint("Enter your text here");
    
    1196 1196
     
    
    1197 1197
         if (dialog.ShowModal() == wxID_OK)
    
    1198 1198
         {
    

  • samples/text/text.cpp
    ... ... @@ -59,9 +59,8 @@ public:
    59 59
     class MyTextCtrl : public wxTextCtrl
    
    60 60
     {
    
    61 61
     public:
    
    62
    -    MyTextCtrl(wxWindow *parent, wxWindowID id, const wxString &value,
    
    63
    -               const wxPoint &pos, const wxSize &size, int style = 0)
    
    64
    -        : wxTextCtrl(parent, id, value, pos, size, style)
    
    62
    +    MyTextCtrl(wxWindow *parent, wxWindowID id, const wxString &value, int style = 0)
    
    63
    +        : wxTextCtrl(parent, id, value, wxDefaultPosition, wxDefaultSize, style)
    
    65 64
         {
    
    66 65
             m_hasCapture = false;
    
    67 66
         }
    
    ... ... @@ -1044,27 +1043,29 @@ void MyTextCtrl::OnKeyDown(wxKeyEvent& event)
    1044 1043
                     long line, column, pos = GetInsertionPoint();
    
    1045 1044
                     PositionToXY(pos, &column, &line);
    
    1046 1045
     
    
    1047
    -                wxLogMessage("Current position: %ld\nCurrent line, column: (%ld, %ld)\nNumber of lines: %ld\nCurrent line length: %ld\nTotal text length: %u (%ld)",
    
    1048
    -                        pos,
    
    1049
    -                        line, column,
    
    1050
    -                        (long) GetNumberOfLines(),
    
    1051
    -                        (long) GetLineLength(line),
    
    1052
    -                        (unsigned int) GetValue().length(),
    
    1053
    -                        GetLastPosition());
    
    1054
    -
    
    1055 1046
                     long from, to;
    
    1056 1047
                     GetSelection(&from, &to);
    
    1057 1048
     
    
    1058
    -                wxString sel = GetStringSelection();
    
    1059
    -
    
    1060
    -                wxLogMessage("Selection: from %ld to %ld.", from, to);
    
    1061
    -                wxLogMessage("Selection = '%s' (len = %u)",
    
    1062
    -                             sel,
    
    1063
    -                             (unsigned int) sel.length());
    
    1064
    -
    
    1049
    +                const wxString sel = GetStringSelection();
    
    1065 1050
                     const wxString text = GetLineText(line);
    
    1066
    -                wxLogMessage("Current line: \"%s\"; length = %lu",
    
    1067
    -                             text, text.length());
    
    1051
    +
    
    1052
    +                wxLogMessage(R"(Control state:
    
    1053
    +Current position: %ld
    
    1054
    +Current line, column: (%ld, %ld)
    
    1055
    +Number of lines: %d
    
    1056
    +Current line: "%s" (length from control %d, actual %zu)
    
    1057
    +Total text length: %zu (last position %ld)
    
    1058
    +Selection: "%s" (length %zu, from %ld to %ld))",
    
    1059
    +                        pos,
    
    1060
    +                        line, column,
    
    1061
    +                        GetNumberOfLines(),
    
    1062
    +                        text,
    
    1063
    +                        GetLineLength(line),
    
    1064
    +                        text.length(),
    
    1065
    +                        GetValue().length(),
    
    1066
    +                        GetLastPosition(),
    
    1067
    +                        sel, sel.length(),
    
    1068
    +                        from, to);
    
    1068 1069
                 }
    
    1069 1070
                 break;
    
    1070 1071
     
    
    ... ... @@ -1140,7 +1141,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
    1140 1141
     {
    
    1141 1142
     #if wxUSE_LOG
    
    1142 1143
         m_log = new wxTextCtrl( this, wxID_ANY, "This is the log window.\n",
    
    1143
    -                            wxPoint(5,260), wxSize(630,100),
    
    1144
    +                            wxDefaultPosition, wxDefaultSize,
    
    1144 1145
                                 wxTE_MULTILINE | wxTE_READONLY);
    
    1145 1146
     
    
    1146 1147
         m_logOld = wxLog::SetActiveTarget( new wxLogTextCtrl( m_log ) );
    
    ... ... @@ -1149,7 +1150,6 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
    1149 1150
         // single line text controls
    
    1150 1151
     
    
    1151 1152
         m_text = new MyTextCtrl( this, wxID_ANY, "Single line.",
    
    1152
    -                             wxDefaultPosition, wxDefaultSize,
    
    1153 1153
                                  wxTE_PROCESS_ENTER | wxTE_RICH2);
    
    1154 1154
         m_text->SetForegroundColour(*wxBLUE);
    
    1155 1155
         m_text->SetBackgroundColour(*wxLIGHT_GREY);
    
    ... ... @@ -1167,36 +1167,33 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
    1167 1167
         }
    
    1168 1168
     #endif
    
    1169 1169
     
    
    1170
    -    m_password = new MyTextCtrl( this, wxID_ANY, "",
    
    1171
    -      wxPoint(10,50), wxSize(140,wxDefaultCoord), wxTE_PASSWORD );
    
    1170
    +    m_password = new MyTextCtrl( this, wxID_ANY, "", wxTE_PASSWORD );
    
    1172 1171
         m_password->SetHint("Don't use 12345 here");
    
    1173 1172
     
    
    1174
    -    m_limited = new MyTextCtrl(this, wxID_ANY, "",
    
    1175
    -                              wxPoint(10, 90), wxDefaultSize);
    
    1173
    +    m_limited = new MyTextCtrl(this, wxID_ANY, "");
    
    1176 1174
         m_limited->SetHint("Max 8 ch");
    
    1177 1175
         m_limited->SetMaxLength(8);
    
    1178 1176
         wxSize size2 = m_limited->GetSizeFromTextSize(m_limited->GetTextExtent("WWWWWWWW"));
    
    1179 1177
         m_limited->SetSizeHints(size2, size2);
    
    1180
    -    m_limitedMultiline = new MyTextCtrl( this, wxID_ANY, "", wxPoint( 10, 110 ), wxDefaultSize, wxTE_MULTILINE );
    
    1178
    +    m_limitedMultiline = new MyTextCtrl( this, wxID_ANY, "", wxTE_MULTILINE );
    
    1181 1179
         m_limitedMultiline->SetHint( "Max 20 characters" );
    
    1182 1180
         m_limitedMultiline->SetMinSize( wxSize(size2.x, wxDefaultCoord) );
    
    1183 1181
         m_limitedMultiline->SetMaxLength( 20 );
    
    1184 1182
     
    
    1185
    -    wxTextCtrl* upperOnly = new MyTextCtrl(this, wxID_ANY, "Only upper case",
    
    1186
    -                                           wxDefaultPosition, wxDefaultSize);
    
    1183
    +    wxTextCtrl* upperOnly = new MyTextCtrl(this, wxID_ANY, "Only upper case");
    
    1187 1184
         upperOnly->ForceUpper();
    
    1188 1185
     
    
    1189 1186
         // multi line text controls
    
    1190 1187
     
    
    1191 1188
         wxString string3L("Read only\nMultiline\nFitted size");
    
    1192 1189
         m_readonly = new MyTextCtrl( this, wxID_ANY, string3L,
    
    1193
    -               wxPoint(10, 120), wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY );
    
    1190
    +               wxTE_MULTILINE | wxTE_READONLY );
    
    1194 1191
         wxWindowDC dc(m_readonly);
    
    1195 1192
         size2 = m_readonly->GetSizeFromTextSize(dc.GetMultiLineTextExtent(string3L));
    
    1196 1193
         m_readonly->SetMinSize(size2);
    
    1197 1194
     
    
    1198 1195
         m_horizontal = new MyTextCtrl( this, wxID_ANY, "Multiline text control with a horizontal scrollbar.\n",
    
    1199
    -      wxPoint(10,170), wxSize(140,70), wxTE_MULTILINE | wxHSCROLL);
    
    1196
    +      wxTE_MULTILINE | wxHSCROLL);
    
    1200 1197
         m_horizontal->SetHint("Enter multiline text here");
    
    1201 1198
     
    
    1202 1199
         // a little hack to use the command line argument for encoding testing
    
    ... ... @@ -1232,7 +1229,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
    1232 1229
     
    
    1233 1230
         m_multitext = new MyTextCtrl( this, wxID_ANY,
    
    1234 1231
                                       "Multi line without vertical scrollbar.",
    
    1235
    -      wxPoint(180,10), wxSize(200,70), wxTE_MULTILINE | wxTE_NO_VSCROLL );
    
    1232
    +                                  wxTE_MULTILINE | wxTE_NO_VSCROLL );
    
    1236 1233
         m_multitext->SetFont(*wxITALIC_FONT);
    
    1237 1234
         (*m_multitext) << " Appended.";
    
    1238 1235
         m_multitext->SetInsertionPoint(0);
    
    ... ... @@ -1245,11 +1242,11 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
    1245 1242
     #endif
    
    1246 1243
     
    
    1247 1244
         m_tab = new MyTextCtrl( this, 100, "Multiline, allow <TAB> processing.",
    
    1248
    -      wxPoint(180,90), wxSize(200,70), wxTE_MULTILINE |  wxTE_PROCESS_TAB );
    
    1245
    +      wxTE_MULTILINE |  wxTE_PROCESS_TAB );
    
    1249 1246
         m_tab->SetClientData(const_cast<void*>(static_cast<const void*>(wxS("tab"))));
    
    1250 1247
     
    
    1251 1248
         m_enter = new MyTextCtrl( this, 100, "Multiline, allow <ENTER> processing.",
    
    1252
    -      wxPoint(180,170), wxSize(200,70), wxTE_MULTILINE | wxTE_PROCESS_ENTER | wxTE_RICH2 );
    
    1249
    +      wxTE_MULTILINE | wxTE_PROCESS_ENTER | wxTE_RICH2 );
    
    1253 1250
         m_enter->SetClientData(const_cast<void*>(static_cast<const void*>(wxS("enter"))));
    
    1254 1251
     
    
    1255 1252
     #if wxUSE_SPELLCHECK
    
    ... ... @@ -1278,7 +1275,6 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
    1278 1275
                                     "wxHSCROLL style\n"
    
    1279 1276
                                     "\nAnd here is a link in quotation marks to "
    
    1280 1277
                                     "test wxTE_AUTO_URL: \"http://www.wxwidgets.org\"",
    
    1281
    -                                wxPoint(450, 10), wxSize(200, 230),
    
    1282 1278
                                     wxTE_RICH | wxTE_MULTILINE | wxTE_AUTO_URL);
    
    1283 1279
         m_textrich->SetStyle(0, 10, *wxRED);
    
    1284 1280
         m_textrich->SetStyle(10, 20, *wxBLUE);
    
    ... ... @@ -1327,10 +1323,11 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
    1327 1323
         column2->Add( m_tab, 0, wxALL | wxEXPAND, 10 );
    
    1328 1324
         column2->Add( m_enter, 1, wxALL | wxEXPAND, 10 );
    
    1329 1325
     
    
    1330
    -    wxBoxSizer *row1 = new wxBoxSizer(wxHORIZONTAL);
    
    1326
    +    auto* const row1 = new wxGridSizer(3, FromDIP(wxSize(10, 10)));
    
    1331 1327
         row1->Add( column1, 0, wxALL | wxEXPAND, 10 );
    
    1332 1328
         row1->Add( column2, 1, wxALL | wxEXPAND, 10 );
    
    1333 1329
         row1->Add( m_textrich, 1, wxALL | wxEXPAND, 10 );
    
    1330
    +    row1->SetItemMinSize( m_textrich, FromDIP(wxSize(300, 200)) );
    
    1334 1331
     
    
    1335 1332
         wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
    
    1336 1333
         topSizer->Add( row1, 2, wxALL | wxEXPAND, 10 );
    

  • src/common/datetimefmt.cpp
    ... ... @@ -634,6 +634,10 @@ wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
    634 634
                         res += wxString::Format(fmt, tm.sec);
    
    635 635
                         break;
    
    636 636
     
    
    637
    +                case wxT('T'):       // time as %H:%M:%S
    
    638
    +                    res += wxString::Format(wxT("%02d:%02d:%02d"), tm.hour, tm.min, tm.sec);
    
    639
    +                    break;
    
    640
    +
    
    637 641
                     case wxT('U'):       // week number in the year (Sunday 1st week day)
    
    638 642
                         res += wxString::Format(fmt, GetWeekOfYear(Sunday_First, tz));
    
    639 643
                         break;
    

  • src/common/prntbase.cpp
    ... ... @@ -2144,8 +2144,7 @@ void wxPrintPreviewBase::SetZoom(int percent)
    2144 2144
         if (m_previewCanvas)
    
    2145 2145
         {
    
    2146 2146
             AdjustScrollbars(m_previewCanvas);
    
    2147
    -        ((wxScrolledWindow *) m_previewCanvas)->Scroll(0, 0);
    
    2148
    -        m_previewCanvas->ClearBackground();
    
    2147
    +        m_previewCanvas->Scroll(0, 0);
    
    2149 2148
             m_previewCanvas->Refresh();
    
    2150 2149
             m_previewCanvas->SetFocus();
    
    2151 2150
         }
    

  • src/generic/textdlgg.cpp
    ... ... @@ -170,6 +170,14 @@ void wxTextEntryDialog::SetValue(const wxString& val)
    170 170
         }
    
    171 171
     }
    
    172 172
     
    
    173
    +void wxTextEntryDialog::SetHint(const wxString& hint)
    
    174
    +{
    
    175
    +    if ( m_textctrl )
    
    176
    +    {
    
    177
    +        m_textctrl->SetHint(hint);
    
    178
    +    }
    
    179
    +}
    
    180
    +
    
    173 181
     void wxTextEntryDialog::ForceUpper()
    
    174 182
     {
    
    175 183
         if ( m_textctrl )
    

  • src/msw/textctrl.cpp
    ... ... @@ -1036,7 +1036,7 @@ bool wxTextCtrl::IsEmpty() const
    1036 1036
         return wxTextCtrlBase::IsEmpty();
    
    1037 1037
     }
    
    1038 1038
     
    
    1039
    -wxString wxTextCtrl::GetValue() const
    
    1039
    +wxString wxTextCtrl::DoGetValue() const
    
    1040 1040
     {
    
    1041 1041
         // range 0..-1 is special for GetRange() and means to retrieve all text
    
    1042 1042
         return GetRange(0, -1);
    
    ... ... @@ -1096,9 +1096,7 @@ wxString wxTextCtrl::GetRange(long from, long to) const
    1096 1096
         else
    
    1097 1097
     #endif // wxUSE_RICHEDIT
    
    1098 1098
         {
    
    1099
    -        // retrieve all text: wxTextEntry method works even for multiline
    
    1100
    -        // controls and must be used for single line ones to account for hints
    
    1101
    -        str = wxTextEntry::GetValue();
    
    1099
    +        str = wxTextEntry::DoGetValue();
    
    1102 1100
     
    
    1103 1101
             // need only a range?
    
    1104 1102
             if ( from < to )
    

  • src/msw/toolbar.cpp
    ... ... @@ -443,18 +443,19 @@ bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size)
    443 443
     #endif
    
    444 444
     
    
    445 445
         // Retrieve or apply/restore tool packing value.
    
    446
    +    DWORD padding = ::SendMessage(GetHwnd(), TB_GETPADDING, 0, 0);
    
    446 447
         if ( m_toolPacking <= 0 )
    
    447 448
         {
    
    448 449
             // Retrieve packing value if it hasn't been yet set with SetToolPacking.
    
    449
    -        DWORD padding = ::SendMessage(GetHwnd(), TB_GETPADDING, 0, 0);
    
    450
    -        m_toolPacking = IsVertical() ? HIWORD(padding) : LOWORD(padding);
    
    451
    -    }
    
    452
    -    else
    
    453
    -    {
    
    454
    -        // Apply packing value if it has been already set with SetToolPacking.
    
    455
    -        MSWSetPadding(m_toolPacking);
    
    450
    +        m_toolPacking = FromDIP(IsVertical() ? HIWORD(padding) : LOWORD(padding));
    
    456 451
         }
    
    457 452
     
    
    453
    +    // Scale the tool packing to the active DPI
    
    454
    +    DWORD orthoPadding = FromDIP(IsVertical() ? LOWORD(padding) : HIWORD(padding));
    
    455
    +    DWORD scaledPadding = IsVertical() ? MAKELPARAM(orthoPadding, m_toolPacking)
    
    456
    +                                       : MAKELPARAM(m_toolPacking, orthoPadding);
    
    457
    +    ::SendMessage(GetHwnd(), TB_SETPADDING, 0, scaledPadding);
    
    458
    +
    
    458 459
     #if wxUSE_TOOLTIPS
    
    459 460
         // MSW "helpfully" handles ampersands as mnemonics in the tooltips
    
    460 461
         // (officially in order to allow using the same string as the menu item and
    
    ... ... @@ -590,7 +591,7 @@ wxSize wxToolBar::MSWGetFittingtSizeForControl(wxToolBarTool* tool) const
    590 591
     
    
    591 592
         // This is arbitrary, but we want to leave at least 1px around the control
    
    592 593
         // vertically, otherwise it really looks too cramped.
    
    593
    -    size.y += 2*1;
    
    594
    +    size.y += FromDIP(2*1);
    
    594 595
     
    
    595 596
         // Account for the label, if any.
    
    596 597
         if ( wxStaticText * const staticText = tool->GetStaticText() )
    
    ... ... @@ -603,7 +604,7 @@ wxSize wxToolBar::MSWGetFittingtSizeForControl(wxToolBarTool* tool) const
    603 604
                     size.x = sizeLabel.x;
    
    604 605
     
    
    605 606
                 size.y += sizeLabel.y;
    
    606
    -            size.y += MARGIN_CONTROL_LABEL;
    
    607
    +            size.y += FromDIP(MARGIN_CONTROL_LABEL);
    
    607 608
             }
    
    608 609
         }
    
    609 610
     
    
    ... ... @@ -1396,12 +1397,13 @@ bool wxToolBar::Realize()
    1396 1397
     
    
    1397 1398
                     // Center the static text horizontally for consistency with the
    
    1398 1399
                     // button labels and position it below the control vertically.
    
    1400
    +                const int labelMargin = FromDIP(MARGIN_CONTROL_LABEL);
    
    1399 1401
                     staticText->Move(x + (totalWidth - staticTextSize.x)/2,
    
    1400 1402
                                      r.top + (height + controlSize.y
    
    1401 1403
                                                      - staticTextSize.y
    
    1402
    -                                                 + MARGIN_CONTROL_LABEL)/2);
    
    1404
    +                                                 + labelMargin)/2);
    
    1403 1405
     
    
    1404
    -                totalHeight += staticTextSize.y + MARGIN_CONTROL_LABEL;
    
    1406
    +                totalHeight += staticTextSize.y + labelMargin;
    
    1405 1407
                 }
    
    1406 1408
             }
    
    1407 1409
     
    
    ... ... @@ -2121,6 +2123,13 @@ void wxToolBar::RealizeHelper()
    2121 2123
     
    
    2122 2124
     void wxToolBar::OnDPIChanged(wxDPIChangedEvent& event)
    
    2123 2125
     {
    
    2126
    +    // Scale the tool packing to the new DPI
    
    2127
    +    DWORD curPadding = ::SendMessage(GetHwnd(), TB_GETPADDING, 0, 0);
    
    2128
    +    DWORD newPadding = MAKELPARAM(event.ScaleX(LOWORD(curPadding)),
    
    2129
    +                                  event.ScaleY(HIWORD(curPadding)));
    
    2130
    +    m_toolPacking = IsVertical() ? HIWORD(newPadding) : LOWORD(newPadding);
    
    2131
    +    ::SendMessage(GetHwnd(), TB_SETPADDING, 0, newPadding);
    
    2132
    +
    
    2124 2133
         // Manually scale the size of the controls. Even though the font has been
    
    2125 2134
         // updated, the internal size of the controls does not.
    
    2126 2135
         wxToolBarToolsList::compatibility_iterator node;
    

  • src/qt/colordlg.cpp
    ... ... @@ -20,7 +20,20 @@ class wxQtColorDialog : public wxQtEventSignalHandler< QColorDialog, wxDialog >
    20 20
     public:
    
    21 21
         wxQtColorDialog( wxWindow *parent, wxDialog *handler)
    
    22 22
             : wxQtEventSignalHandler<QColorDialog,wxDialog>(parent, handler)
    
    23
    -        { }
    
    23
    +    {
    
    24
    +        connect(this, &QColorDialog::currentColorChanged,
    
    25
    +                this, &wxQtColorDialog::currentColorChanged);
    
    26
    +    }
    
    27
    +
    
    28
    +private:
    
    29
    +    void currentColorChanged(const QColor& color)
    
    30
    +    {
    
    31
    +        wxColourDialogEvent event(wxEVT_COLOUR_CHANGED,
    
    32
    +                                  static_cast<wxColourDialog*>(GetHandler()),
    
    33
    +                                  wxQtConvertColour(color));
    
    34
    +
    
    35
    +        EmitEvent( event );
    
    36
    +    }
    
    24 37
     };
    
    25 38
     
    
    26 39
     wxIMPLEMENT_DYNAMIC_CLASS(wxColourDialog,wxDialog)
    

  • src/qt/stattext.cpp
    ... ... @@ -33,6 +33,14 @@ wxStaticText::wxStaticText(wxWindow *parent,
    33 33
                  const wxString &name)
    
    34 34
     {
    
    35 35
         Create( parent, id, label, pos, size, style, name );
    
    36
    +
    
    37
    +    // to allow dynamic ellipsizing of the label.
    
    38
    +    Bind(wxEVT_SIZE, [this](wxSizeEvent& event)
    
    39
    +        {
    
    40
    +            event.Skip();
    
    41
    +
    
    42
    +            UpdateLabel();
    
    43
    +        });
    
    36 44
     }
    
    37 45
     
    
    38 46
     wxStaticText::~wxStaticText()
    

  • src/qt/window.cpp
    ... ... @@ -653,6 +653,18 @@ void wxWindowQt::Refresh( bool WXUNUSED( eraseBackground ), const wxRect *rect )
    653 653
         }
    
    654 654
     }
    
    655 655
     
    
    656
    +void wxWindowQt::ClearBackground()
    
    657
    +{
    
    658
    +    if ( !GetHandle()->autoFillBackground() )
    
    659
    +    {
    
    660
    +        // Rely on Qt to do the right thing with clearing the background.
    
    661
    +        GetHandle()->setAutoFillBackground(true);
    
    662
    +        GetHandle()->setAutoFillBackground(false);
    
    663
    +    }
    
    664
    +    // else: No need to do anything because Qt will fill the background
    
    665
    +    //       of the widget before invoking the paint event anyhow.
    
    666
    +}
    
    667
    +
    
    656 668
     bool wxWindowQt::SetCursor( const wxCursor &cursor )
    
    657 669
     {
    
    658 670
         if (!wxWindowBase::SetCursor(cursor))
    

  • tests/controls/textctrltest.cpp
    ... ... @@ -35,6 +35,7 @@
    35 35
     #endif
    
    36 36
     
    
    37 37
     #include "wx/private/localeset.h"
    
    38
    +#include "wx/private/make_unique.h"
    
    38 39
     
    
    39 40
     #include "textentrytest.h"
    
    40 41
     #include "testableframe.h"
    
    ... ... @@ -1775,4 +1776,34 @@ TEST_CASE("wxTextCtrl::EmptyUndoBuffer", "[wxTextCtrl][undo]")
    1775 1776
     
    
    1776 1777
     #endif // __MINGW32_TOOLCHAIN__
    
    1777 1778
     
    
    1779
    +#if wxUSE_RICHEDIT
    
    1780
    +
    
    1781
    +TEST_CASE("wxTextCtrl::RichWithHint", "[wxTextCtrl][hint][rich]")
    
    1782
    +{
    
    1783
    +    long richStyle = 0;
    
    1784
    +
    
    1785
    +    SECTION("Rich")
    
    1786
    +    {
    
    1787
    +        richStyle = wxTE_RICH;
    
    1788
    +    }
    
    1789
    +
    
    1790
    +    SECTION("Rich2")
    
    1791
    +    {
    
    1792
    +        richStyle = wxTE_RICH2;
    
    1793
    +    }
    
    1794
    +
    
    1795
    +    auto text = std::make_unique<wxTextCtrl>
    
    1796
    +                (
    
    1797
    +                    wxTheApp->GetTopWindow(), wxID_ANY, "",
    
    1798
    +                    wxDefaultPosition, wxSize(400, 200),
    
    1799
    +                    wxTE_MULTILINE | richStyle
    
    1800
    +                );
    
    1801
    +    text->SetHint("This is a hint");
    
    1802
    +
    
    1803
    +    CHECK( text->GetHint() == "This is a hint" );
    
    1804
    +    CHECK( text->GetValue() == "" );
    
    1805
    +}
    
    1806
    +
    
    1807
    +#endif // wxUSE_RICHEDIT
    
    1808
    +
    
    1778 1809
     #endif //wxUSE_TEXTCTRL

  • tests/datetime/datetimetest.cpp
    ... ... @@ -796,6 +796,10 @@ TEST_CASE("wxDateTime::Format", "[datetime]")
    796 796
         }
    
    797 797
     
    
    798 798
         CHECK(wxDateTime::Now().Format("%%") == "%");
    
    799
    +
    
    800
    +
    
    801
    +    wxDateTime dt(29, wxDateTime::May, 1976, 18, 30, 15, 678);
    
    802
    +    CHECK( dt.Format("%F %T.%l") == "1976-05-29 18:30:15.678" );
    
    799 803
     }
    
    800 804
     
    
    801 805
     TEST_CASE("wxDateTime::ParseFormat", "[datetime]")
    

Reply all
Reply to author
Forward
0 new messages