Fix building non-GTK ports under Windows with Cairo >= 1.18 Cairo 1.18 broke using cairo_public redefinition hack used before to avoid declaring Cairo functions as being dll-imported. Use the new way to prevent this from happening but still define cairo_public when using older versions. Note that, unfortunately, we can't do it unconditionally because this results in a macro redefinition warning with newer versions which is impossible to disable using gcc. As the new hack is even worse than the existing one, move it into its own header to avoid duplicating it in both between src/common/cairo.cpp and src/generic/graphicc.cpp. Closes #26224.
Avoid asserts if wxAuiTabFrame::GetLayoutDirection() is called This may happen when using sizer debugging code which uses wxClientDC which calls this function on all windows in the hierarchy.
Make wxSizerItem::GetRect() const There is really no reason for it not to be. There also doesn't seem to be any reason for it to be virtual, but keep this just to warn any people who override it in their code so that they could add "const".
Add wxDumpSizer() function This is helpful to call from the debugger to see the information about the given sizer and its contents.
Make it easier to enable sizer debugging code Add wxHAS_SIZER_DEBUG to allow enabling sizer debugging by predefining this symbol and without necessarily recompiling everything with wxDEBUG_LEVEL > 1.
Use range for loop in sizer debugging code No real changes.
Improve debug output from sizer debugging code Make it more readable by indenting it according to the nesting level and also showing virtual size only if it's different from the actual size, as otherwise it is just redundant. Also don't show maximum size at at all, it's never set anyhow.
Merge branch 'improve-sizer-debugging' Miscellaneous small changes to help with debugging sizer layout. See #26234.
Scale wxAuiToolBar packing, padding and margins by DPI factor Store these values in DIPs internally and apply FromDIP() when using them. This is simpler and possibly more precise than rescaling them when getting wxEVT_DPI_CHANGED event and the only awkward part is that we need to use ToDIP() in the setter functions, but this is arguably not very important as these functions are hardly ever used anyhow. See #26235. Closes #26076.
Fix handling of "%s" in vararg functions in some UTF-8 builds When wxUSE_UNICODE_UTF8 is set to 1, strings use UTF-8 and are still char strings and not wchar_t ones, but when using wx own implementation of vsnprintf(), "%s" expected a wide string and not a normal one. Fix this at wxPrintfFormatConverterUtf8 level. Closes #26236.
Allow passing null config to wxHtmlHelpWindow::UseConfig() Null argument is allowed in wxHtmlHelpController::ReadCustomization() and is potentially useful here to prevent the use of a dangling pointer. Also explicitly document that this parameter can be null. Closes #26238.
| ... | ... | @@ -132,7 +132,8 @@ public: |
| 132 | 132 | {
|
| 133 | 133 | m_Config = config;
|
| 134 | 134 | m_ConfigRoot = rootpath;
|
| 135 | - ReadCustomization(config, rootpath);
|
|
| 135 | + if ( config )
|
|
| 136 | + ReadCustomization(config, rootpath);
|
|
| 136 | 137 | }
|
| 137 | 138 | |
| 138 | 139 | // Saves custom settings into cfg config. it will use the path 'path'
|
| 1 | +///////////////////////////////////////////////////////////////////////////////
|
|
| 2 | +// Name: wx/private/cairo.h
|
|
| 3 | +// Purpose: Wrapper for including cairo.h from wx code
|
|
| 4 | +// Author: Vadim Zeitlin
|
|
| 5 | +// Created: 2026-02-23
|
|
| 6 | +// Copyright: (c) 2026 Vadim Zeitlin <va...@wxwidgets.org>
|
|
| 7 | +// Licence: wxWindows licence
|
|
| 8 | +///////////////////////////////////////////////////////////////////////////////
|
|
| 9 | + |
|
| 10 | +#ifndef _WX_PRIVATE_CAIRO_H_
|
|
| 11 | +#define _WX_PRIVATE_CAIRO_H_
|
|
| 12 | + |
|
| 13 | +// We want to prevent cairo.h from using dllimport attribute for the functions
|
|
| 14 | +// it declares as we're loading them dynamically, but this is trickier than it
|
|
| 15 | +// should be because older versions of cairo.h respected cairo_public being
|
|
| 16 | +// defined before including it, but this was broken in 1.18, so we need to
|
|
| 17 | +// define an alternative symbol and avoid defining cairo_public as this would
|
|
| 18 | +// result in a warning about its redefinition.
|
|
| 19 | +#include <cairo-version.h>
|
|
| 20 | + |
|
| 21 | +#if CAIRO_VERSION_MAJOR > 1 || CAIRO_VERSION_MINOR >= 18
|
|
| 22 | +#define CAIRO_WIN32_STATIC_BUILD
|
|
| 23 | +#else
|
|
| 24 | +#define cairo_public
|
|
| 25 | +#endif
|
|
| 26 | + |
|
| 27 | +#include <cairo.h>
|
|
| 28 | + |
|
| 29 | +#endif // _WX_PRIVATE_CAIRO_H_ |
| ... | ... | @@ -374,7 +374,7 @@ public: |
| 374 | 374 | float GetRatio() const
|
| 375 | 375 | { return m_ratio; }
|
| 376 | 376 | |
| 377 | - virtual wxRect GetRect() { return m_rect; }
|
|
| 377 | + virtual wxRect GetRect() const { return m_rect; }
|
|
| 378 | 378 | |
| 379 | 379 | // set a sizer item id (different from a window id, all sizer items,
|
| 380 | 380 | // including spacers, can have an associated id)
|
| ... | ... | @@ -144,8 +144,13 @@ public: |
| 144 | 144 | const wxString& path = wxEmptyString);
|
| 145 | 145 | |
| 146 | 146 | /**
|
| 147 | - Associates a wxConfig object with the help window. It is recommended that you
|
|
| 148 | - use wxHtmlHelpController::UseConfig instead.
|
|
| 147 | + Associates a wxConfig object with the help window.
|
|
| 148 | + |
|
| 149 | + It is recommended that you use wxHtmlHelpController::UseConfig instead.
|
|
| 150 | + |
|
| 151 | + @param config The object to use or @NULL to disable the use of wxConfig.
|
|
| 152 | + @param rootpath The path in the wxConfig object to use as the root for
|
|
| 153 | + this window's settings. If empty, the current path will be used.
|
|
| 149 | 154 | */
|
| 150 | 155 | void UseConfig(wxConfigBase* config,
|
| 151 | 156 | const wxString& rootpath = wxEmptyString);
|
| ... | ... | @@ -1306,7 +1306,7 @@ public: |
| 1306 | 1306 | /**
|
| 1307 | 1307 | Get the rectangle of the item on the parent window, excluding borders.
|
| 1308 | 1308 | */
|
| 1309 | - virtual wxRect GetRect();
|
|
| 1309 | + virtual wxRect GetRect() const;
|
|
| 1310 | 1310 | |
| 1311 | 1311 | /**
|
| 1312 | 1312 | Get the current size of the item, as set in the last Layout.
|
| ... | ... | @@ -951,8 +951,9 @@ bool wxAuiToolBar::Create(wxWindow* parent, |
| 951 | 951 | |
| 952 | 952 | m_windowStyle = style;
|
| 953 | 953 | |
| 954 | - m_toolPacking = FromDIP(2);
|
|
| 955 | - m_toolBorderPadding = FromDIP(3);
|
|
| 954 | + // Tool packing and padding are in DIPs, i.e. do not use FromDIP() here.
|
|
| 955 | + m_toolPacking = 2;
|
|
| 956 | + m_toolBorderPadding = 3;
|
|
| 956 | 957 | |
| 957 | 958 | m_gripperVisible = (style & wxAUI_TB_GRIPPER) ? true : false;
|
| 958 | 959 | m_overflowVisible = (style & wxAUI_TB_OVERFLOW) ? true : false;
|
| ... | ... | @@ -963,9 +964,12 @@ bool wxAuiToolBar::Create(wxWindow* parent, |
| 963 | 964 | m_orientation = wxHORIZONTAL;
|
| 964 | 965 | }
|
| 965 | 966 | |
| 966 | - wxSize margin_lt = FromDIP(wxSize(5, 5));
|
|
| 967 | - wxSize margin_rb = FromDIP(wxSize(2, 2));
|
|
| 968 | - SetMargins(margin_lt.x, margin_lt.y, margin_rb.x, margin_rb.y);
|
|
| 967 | + // Margins are in DIPs, i.e. do not use FromDIP() here.
|
|
| 968 | + m_leftPadding =
|
|
| 969 | + m_rightPadding = 5;
|
|
| 970 | + m_topPadding =
|
|
| 971 | + m_bottomPadding = 2;
|
|
| 972 | + |
|
| 969 | 973 | SetFont(*wxNORMAL_FONT);
|
| 970 | 974 | SetArtFlags();
|
| 971 | 975 | SetExtraStyle(wxWS_EX_PROCESS_IDLE);
|
| ... | ... | @@ -1298,7 +1302,7 @@ wxAuiToolBarItem* wxAuiToolBar::FindToolByPositionWithPacking(wxCoord x, wxCoord |
| 1298 | 1302 | |
| 1299 | 1303 | // apply tool packing
|
| 1300 | 1304 | if (i+1 < count)
|
| 1301 | - rect.width += m_toolPacking;
|
|
| 1305 | + rect.width += FromDIP(m_toolPacking);
|
|
| 1302 | 1306 | |
| 1303 | 1307 | if (rect.Contains(x,y))
|
| 1304 | 1308 | {
|
| ... | ... | @@ -1437,7 +1441,7 @@ bool wxAuiToolBar::GetToolSticky(int tool_id) const |
| 1437 | 1441 | |
| 1438 | 1442 | void wxAuiToolBar::SetToolBorderPadding(int padding)
|
| 1439 | 1443 | {
|
| 1440 | - m_toolBorderPadding = padding;
|
|
| 1444 | + m_toolBorderPadding = ToDIP(padding);
|
|
| 1441 | 1445 | }
|
| 1442 | 1446 | |
| 1443 | 1447 | int wxAuiToolBar::GetToolBorderPadding() const
|
| ... | ... | @@ -1490,7 +1494,7 @@ bool wxAuiToolBar::IsToolTextVertical() const |
| 1490 | 1494 | |
| 1491 | 1495 | void wxAuiToolBar::SetToolPacking(int packing)
|
| 1492 | 1496 | {
|
| 1493 | - m_toolPacking = packing;
|
|
| 1497 | + m_toolPacking = ToDIP(packing);
|
|
| 1494 | 1498 | }
|
| 1495 | 1499 | |
| 1496 | 1500 | int wxAuiToolBar::GetToolPacking() const
|
| ... | ... | @@ -1516,13 +1520,13 @@ void wxAuiToolBar::SetOrientation(int orientation) |
| 1516 | 1520 | void wxAuiToolBar::SetMargins(int left, int right, int top, int bottom)
|
| 1517 | 1521 | {
|
| 1518 | 1522 | if (left != -1)
|
| 1519 | - m_leftPadding = left;
|
|
| 1523 | + m_leftPadding = ToDIP(left);
|
|
| 1520 | 1524 | if (right != -1)
|
| 1521 | - m_rightPadding = right;
|
|
| 1525 | + m_rightPadding = ToDIP(right);
|
|
| 1522 | 1526 | if (top != -1)
|
| 1523 | - m_topPadding = top;
|
|
| 1527 | + m_topPadding = ToDIP(top);
|
|
| 1524 | 1528 | if (bottom != -1)
|
| 1525 | - m_bottomPadding = bottom;
|
|
| 1529 | + m_bottomPadding = ToDIP(bottom);
|
|
| 1526 | 1530 | }
|
| 1527 | 1531 | |
| 1528 | 1532 | bool wxAuiToolBar::GetGripperVisible() const
|
| ... | ... | @@ -2049,7 +2053,7 @@ wxSize wxAuiToolBar::RealizeHelper(wxReadOnlyDC& dc, wxOrientation orientation) |
| 2049 | 2053 | // add "left" padding
|
| 2050 | 2054 | if (m_leftPadding > 0)
|
| 2051 | 2055 | {
|
| 2052 | - sizer->AddSpacer(m_leftPadding);
|
|
| 2056 | + sizer->AddSpacer(FromDIP(m_leftPadding));
|
|
| 2053 | 2057 | }
|
| 2054 | 2058 | |
| 2055 | 2059 | size_t i, count;
|
| ... | ... | @@ -2063,13 +2067,13 @@ wxSize wxAuiToolBar::RealizeHelper(wxReadOnlyDC& dc, wxOrientation orientation) |
| 2063 | 2067 | case wxITEM_LABEL:
|
| 2064 | 2068 | {
|
| 2065 | 2069 | wxSize size = m_art->GetLabelSize(dc, this, item);
|
| 2066 | - sizerItem = sizer->Add(size.x + (m_toolBorderPadding*2),
|
|
| 2067 | - size.y + (m_toolBorderPadding*2),
|
|
| 2070 | + sizerItem = sizer->Add(size.x + (FromDIP(m_toolBorderPadding*2)),
|
|
| 2071 | + size.y + (FromDIP(m_toolBorderPadding*2)),
|
|
| 2068 | 2072 | item.m_proportion,
|
| 2069 | 2073 | item.m_alignment);
|
| 2070 | 2074 | if (i+1 < count)
|
| 2071 | 2075 | {
|
| 2072 | - sizer->AddSpacer(m_toolPacking);
|
|
| 2076 | + sizer->AddSpacer(FromDIP(m_toolPacking));
|
|
| 2073 | 2077 | }
|
| 2074 | 2078 | |
| 2075 | 2079 | break;
|
| ... | ... | @@ -2080,14 +2084,14 @@ wxSize wxAuiToolBar::RealizeHelper(wxReadOnlyDC& dc, wxOrientation orientation) |
| 2080 | 2084 | case wxITEM_RADIO:
|
| 2081 | 2085 | {
|
| 2082 | 2086 | wxSize size = m_art->GetToolSize(dc, this, item);
|
| 2083 | - sizerItem = sizer->Add(size.x + (m_toolBorderPadding*2),
|
|
| 2084 | - size.y + (m_toolBorderPadding*2),
|
|
| 2087 | + sizerItem = sizer->Add(size.x + (FromDIP(m_toolBorderPadding*2)),
|
|
| 2088 | + size.y + (FromDIP(m_toolBorderPadding*2)),
|
|
| 2085 | 2089 | 0,
|
| 2086 | 2090 | item.m_alignment);
|
| 2087 | 2091 | // add tool packing
|
| 2088 | 2092 | if (i+1 < count)
|
| 2089 | 2093 | {
|
| 2090 | - sizer->AddSpacer(m_toolPacking);
|
|
| 2094 | + sizer->AddSpacer(FromDIP(m_toolPacking));
|
|
| 2091 | 2095 | }
|
| 2092 | 2096 | |
| 2093 | 2097 | break;
|
| ... | ... | @@ -2101,7 +2105,7 @@ wxSize wxAuiToolBar::RealizeHelper(wxReadOnlyDC& dc, wxOrientation orientation) |
| 2101 | 2105 | // add tool packing
|
| 2102 | 2106 | if (i+1 < count)
|
| 2103 | 2107 | {
|
| 2104 | - sizer->AddSpacer(m_toolPacking);
|
|
| 2108 | + sizer->AddSpacer(FromDIP(m_toolPacking));
|
|
| 2105 | 2109 | }
|
| 2106 | 2110 | |
| 2107 | 2111 | break;
|
| ... | ... | @@ -2152,7 +2156,7 @@ wxSize wxAuiToolBar::RealizeHelper(wxReadOnlyDC& dc, wxOrientation orientation) |
| 2152 | 2156 | // add tool packing
|
| 2153 | 2157 | if (i+1 < count)
|
| 2154 | 2158 | {
|
| 2155 | - sizer->AddSpacer(m_toolPacking);
|
|
| 2159 | + sizer->AddSpacer(FromDIP(m_toolPacking));
|
|
| 2156 | 2160 | }
|
| 2157 | 2161 | }
|
| 2158 | 2162 | }
|
| ... | ... | @@ -2163,7 +2167,7 @@ wxSize wxAuiToolBar::RealizeHelper(wxReadOnlyDC& dc, wxOrientation orientation) |
| 2163 | 2167 | // add "right" padding
|
| 2164 | 2168 | if (m_rightPadding > 0)
|
| 2165 | 2169 | {
|
| 2166 | - sizer->AddSpacer(m_rightPadding);
|
|
| 2170 | + sizer->AddSpacer(FromDIP(m_rightPadding));
|
|
| 2167 | 2171 | }
|
| 2168 | 2172 | |
| 2169 | 2173 | // add drop down area
|
| ... | ... | @@ -2191,7 +2195,7 @@ wxSize wxAuiToolBar::RealizeHelper(wxReadOnlyDC& dc, wxOrientation orientation) |
| 2191 | 2195 | // add "top" padding
|
| 2192 | 2196 | if (m_topPadding > 0)
|
| 2193 | 2197 | {
|
| 2194 | - outside_sizer->AddSpacer(m_topPadding);
|
|
| 2198 | + outside_sizer->AddSpacer(FromDIP(m_topPadding));
|
|
| 2195 | 2199 | }
|
| 2196 | 2200 | |
| 2197 | 2201 | // add the sizer that contains all of the toolbar elements
|
| ... | ... | @@ -2200,7 +2204,7 @@ wxSize wxAuiToolBar::RealizeHelper(wxReadOnlyDC& dc, wxOrientation orientation) |
| 2200 | 2204 | // add "bottom" padding
|
| 2201 | 2205 | if (m_bottomPadding > 0)
|
| 2202 | 2206 | {
|
| 2203 | - outside_sizer->AddSpacer(m_bottomPadding);
|
|
| 2207 | + outside_sizer->AddSpacer(FromDIP(m_bottomPadding));
|
|
| 2204 | 2208 | }
|
| 2205 | 2209 | |
| 2206 | 2210 | m_sizer = outside_sizer;
|
| ... | ... | @@ -1909,13 +1909,19 @@ public: |
| 1909 | 1909 | m_tabCtrlHeight = h;
|
| 1910 | 1910 | }
|
| 1911 | 1911 | |
| 1912 | - // As we don't have a valid HWND, the base class version doesn't work for
|
|
| 1913 | - // this window, so override it to return the appropriate DPI.
|
|
| 1912 | + // As we don't have a valid HWND, base class implementations of these
|
|
| 1913 | + // functions don't work for this window, so override them to forward to the
|
|
| 1914 | + // real window.
|
|
| 1914 | 1915 | wxSize GetDPI() const override
|
| 1915 | 1916 | {
|
| 1916 | 1917 | return m_tabs->GetDPI();
|
| 1917 | 1918 | }
|
| 1918 | 1919 | |
| 1920 | + wxLayoutDirection GetLayoutDirection() const override
|
|
| 1921 | + {
|
|
| 1922 | + return m_tabs->GetLayoutDirection();
|
|
| 1923 | + }
|
|
| 1924 | + |
|
| 1919 | 1925 | protected:
|
| 1920 | 1926 | void DoSetSize(int x, int y,
|
| 1921 | 1927 | int width, int height,
|
| ... | ... | @@ -14,11 +14,8 @@ |
| 14 | 14 | |
| 15 | 15 | #if wxUSE_CAIRO && !defined(__WXGTK__)
|
| 16 | 16 | |
| 17 | -// keep cairo.h from defining dllimport as we're defining the symbols inside
|
|
| 18 | -// the wx dll in order to load them dynamically.
|
|
| 19 | -#define cairo_public
|
|
| 17 | +#include "wx/private/cairo.h"
|
|
| 20 | 18 | |
| 21 | -#include <cairo.h>
|
|
| 22 | 19 | #include "wx/dynlib.h"
|
| 23 | 20 | |
| 24 | 21 | #ifdef __WXMSW__
|
| ... | ... | @@ -84,6 +84,84 @@ WX_DEFINE_EXPORTED_LIST( wxSizerItemList ) |
| 84 | 84 | minsize
|
| 85 | 85 | */
|
| 86 | 86 | |
| 87 | +// ----------------------------------------------------------------------------
|
|
| 88 | +// global functions
|
|
| 89 | +// ----------------------------------------------------------------------------
|
|
| 90 | + |
|
| 91 | +namespace
|
|
| 92 | +{
|
|
| 93 | + |
|
| 94 | +// Helper formatting wxSize as string.
|
|
| 95 | +wxString ToString(const wxSize& size)
|
|
| 96 | +{
|
|
| 97 | + return wxString::Format("%dx%d", size.x, size.y);
|
|
| 98 | +}
|
|
| 99 | + |
|
| 100 | +// wxDumpSizer() helper calling itself recursively to dump the whole sizer tree.
|
|
| 101 | +wxString DoDumpSizer(const wxSizer* sizer, const wxSize& minSize, int level)
|
|
| 102 | +{
|
|
| 103 | + wxString str = sizer->GetClassInfo()->GetClassName();
|
|
| 104 | + if ( auto* const boxSizer = wxDynamicCast(sizer, wxBoxSizer) )
|
|
| 105 | + {
|
|
| 106 | + str += boxSizer->IsVertical() ? "[V]" : "[H]";
|
|
| 107 | + }
|
|
| 108 | + |
|
| 109 | + switch ( sizer->GetItemCount() )
|
|
| 110 | + {
|
|
| 111 | + case 0:
|
|
| 112 | + str += " (empty)";
|
|
| 113 | + break;
|
|
| 114 | + |
|
| 115 | + case 1:
|
|
| 116 | + break;
|
|
| 117 | + |
|
| 118 | + default:
|
|
| 119 | + str += wxString::Format(" (%zu items)", sizer->GetItemCount());
|
|
| 120 | + }
|
|
| 121 | + |
|
| 122 | + if ( minSize != wxDefaultSize )
|
|
| 123 | + {
|
|
| 124 | + str += wxString::Format(" min size %s", ToString(minSize));
|
|
| 125 | + }
|
|
| 126 | + |
|
| 127 | + for ( const wxSizerItem* item : sizer->GetChildren() )
|
|
| 128 | + {
|
|
| 129 | + str += "\n";
|
|
| 130 | + str += wxString(' ', level + 1);
|
|
| 131 | + |
|
| 132 | + if ( wxSizer* child = item->GetSizer() )
|
|
| 133 | + {
|
|
| 134 | + str += DoDumpSizer(child, item->GetMinSize(), level + 1);
|
|
| 135 | + }
|
|
| 136 | + else if ( wxWindow* win = item->GetWindow() )
|
|
| 137 | + {
|
|
| 138 | + str += wxString::Format("%s min size %s",
|
|
| 139 | + wxDumpWindow(win),
|
|
| 140 | + ToString(item->GetMinSize()));
|
|
| 141 | + }
|
|
| 142 | + else
|
|
| 143 | + {
|
|
| 144 | + wxASSERT_MSG( item->IsSpacer(), "unknown wxSizerItem kind" );
|
|
| 145 | + |
|
| 146 | + str += wxString::Format("space %s", ToString(item->GetSpacer()));
|
|
| 147 | + }
|
|
| 148 | + }
|
|
| 149 | + |
|
| 150 | + return str;
|
|
| 151 | +}
|
|
| 152 | + |
|
| 153 | +} // anonymous namespace
|
|
| 154 | + |
|
| 155 | +// debugger helper: this function can be called from a debugger to show what
|
|
| 156 | +// the sizer contains
|
|
| 157 | +extern wxString wxDumpSizer(const wxSizer* sizer)
|
|
| 158 | +{
|
|
| 159 | + if ( !sizer )
|
|
| 160 | + return "<null sizer>";
|
|
| 161 | + |
|
| 162 | + return DoDumpSizer(sizer, wxDefaultSize, 0);
|
|
| 163 | +}
|
|
| 164 | + |
|
| 87 | 165 | // ----------------------------------------------------------------------------
|
| 88 | 166 | // wxSizerFlags
|
| 89 | 167 | // ----------------------------------------------------------------------------
|
| ... | ... | @@ -478,7 +478,14 @@ class wxPrintfFormatConverterUtf8 : public wxFormatConverterBase<char> |
| 478 | 478 | CharType& outConv, SizeModifier& outSize) override
|
| 479 | 479 | {
|
| 480 | 480 | outConv = 's';
|
| 481 | +#if wxUSE_WXVSNPRINTFA
|
|
| 482 | + // When using wx's own vsnprintf implementation, plain %s is
|
|
| 483 | + // interpreted as wchar_t*. We need %hs to indicate char* args,
|
|
| 484 | + // which is what we actually pass in UTF-8 builds.
|
|
| 485 | + outSize = Size_Short;
|
|
| 486 | +#else
|
|
| 481 | 487 | outSize = Size_Default;
|
| 488 | +#endif
|
|
| 482 | 489 | }
|
| 483 | 490 | |
| 484 | 491 | virtual void HandleChar(CharType WXUNUSED(conv),
|
| ... | ... | @@ -3122,8 +3122,11 @@ bool wxWindowBase::WXSendContextMenuEvent(const wxPoint& posInScreenCoords) |
| 3122 | 3122 | // that well and also because we don't want to leave it enabled in default
|
| 3123 | 3123 | // builds used for production
|
| 3124 | 3124 | #if wxDEBUG_LEVEL > 1
|
| 3125 | + #define wxHAS_SIZER_DEBUG
|
|
| 3126 | +#endif
|
|
| 3125 | 3127 | |
| 3126 | -static void DrawSizers(wxWindowBase *win);
|
|
| 3128 | +#ifdef wxHAS_SIZER_DEBUG
|
|
| 3129 | +static void DrawSizers(wxWindowBase *win, int level = 0);
|
|
| 3127 | 3130 | |
| 3128 | 3131 | static void DrawBorder(wxWindowBase *win, const wxRect& rect, bool fill, const wxPen* pen)
|
| 3129 | 3132 | {
|
| ... | ... | @@ -3134,19 +3137,14 @@ static void DrawBorder(wxWindowBase *win, const wxRect& rect, bool fill, const w |
| 3134 | 3137 | dc.DrawRectangle(rect.Deflate(1, 1));
|
| 3135 | 3138 | }
|
| 3136 | 3139 | |
| 3137 | -static void DrawSizer(wxWindowBase *win, wxSizer *sizer)
|
|
| 3140 | +static void DrawSizer(wxWindowBase *win, const wxSizer *sizer, int level)
|
|
| 3138 | 3141 | {
|
| 3139 | - const wxSizerItemList& items = sizer->GetChildren();
|
|
| 3140 | - for ( wxSizerItemList::const_iterator i = items.begin(),
|
|
| 3141 | - end = items.end();
|
|
| 3142 | - i != end;
|
|
| 3143 | - ++i )
|
|
| 3142 | + for ( const wxSizerItem* item : sizer->GetChildren() )
|
|
| 3144 | 3143 | {
|
| 3145 | - wxSizerItem *item = *i;
|
|
| 3146 | 3144 | if ( item->IsSizer() )
|
| 3147 | 3145 | {
|
| 3148 | 3146 | DrawBorder(win, item->GetRect().Deflate(2), false, wxRED_PEN);
|
| 3149 | - DrawSizer(win, item->GetSizer());
|
|
| 3147 | + DrawSizer(win, item->GetSizer(), level + 1);
|
|
| 3150 | 3148 | }
|
| 3151 | 3149 | else if ( item->IsSpacer() )
|
| 3152 | 3150 | {
|
| ... | ... | @@ -3154,70 +3152,74 @@ static void DrawSizer(wxWindowBase *win, wxSizer *sizer) |
| 3154 | 3152 | }
|
| 3155 | 3153 | else if ( item->IsWindow() )
|
| 3156 | 3154 | {
|
| 3157 | - DrawSizers(item->GetWindow());
|
|
| 3155 | + DrawSizers(item->GetWindow(), level + 1);
|
|
| 3158 | 3156 | }
|
| 3159 | 3157 | else
|
| 3160 | 3158 | wxFAIL_MSG("inconsistent wxSizerItem status!");
|
| 3161 | 3159 | }
|
| 3162 | 3160 | }
|
| 3163 | 3161 | |
| 3164 | -static void DrawSizers(wxWindowBase *win)
|
|
| 3162 | +static void DrawSizers(wxWindowBase *win, int level)
|
|
| 3165 | 3163 | {
|
| 3164 | + // show all kind of sizes of this window; see the "window sizing" topic
|
|
| 3165 | + // overview for more info about the various differences:
|
|
| 3166 | + const wxSize fullSz = win->GetSize();
|
|
| 3167 | + const wxSize clientSz = win->GetClientSize();
|
|
| 3168 | + const wxSize bestSz = win->GetBestSize();
|
|
| 3169 | + const wxSize minSz = win->GetMinSize();
|
|
| 3170 | + |
|
| 3171 | + // virtual size is only interesting if it's different from the client size
|
|
| 3172 | + wxString virtualStr;
|
|
| 3173 | + const wxSize virtualSz = win->GetVirtualSize();
|
|
| 3174 | + if ( virtualSz != clientSz )
|
|
| 3175 | + {
|
|
| 3176 | + virtualStr.Printf(" virtual=%4dx%-4d", virtualSz.x, virtualSz.y);
|
|
| 3177 | + }
|
|
| 3178 | + |
|
| 3179 | + wxString name = win->GetName();
|
|
| 3180 | + if ( name.empty() )
|
|
| 3181 | + name = "<unnamed>";
|
|
| 3182 | + |
|
| 3183 | + wxMessageOutputDebug dbgout;
|
|
| 3184 | + dbgout.Printf(
|
|
| 3185 | + "%-20s => full=%4dx%-4d client=%4dx%-4d best=%4dx%-4d min=%4dx%-4d %s\n",
|
|
| 3186 | + wxString(level, ' ') + name,
|
|
| 3187 | + fullSz.x, fullSz.y,
|
|
| 3188 | + clientSz.x, clientSz.y,
|
|
| 3189 | + bestSz.x, bestSz.y,
|
|
| 3190 | + minSz.x, minSz.y,
|
|
| 3191 | + virtualStr);
|
|
| 3192 | + |
|
| 3166 | 3193 | DrawBorder(win, win->GetClientSize(), false, wxGREEN_PEN);
|
| 3167 | 3194 | |
| 3168 | - wxSizer *sizer = win->GetSizer();
|
|
| 3169 | - if ( sizer )
|
|
| 3195 | + if ( const wxSizer* const sizer = win->GetSizer() )
|
|
| 3170 | 3196 | {
|
| 3171 | - DrawSizer(win, sizer);
|
|
| 3197 | + DrawSizer(win, sizer, level + 1);
|
|
| 3172 | 3198 | }
|
| 3173 | 3199 | else // no sizer, still recurse into the children
|
| 3174 | 3200 | {
|
| 3175 | - const wxWindowList& children = win->GetChildren();
|
|
| 3176 | - for ( wxWindowList::const_iterator i = children.begin(),
|
|
| 3177 | - end = children.end();
|
|
| 3178 | - i != end;
|
|
| 3179 | - ++i )
|
|
| 3201 | + for ( wxWindowBase* child : win->GetChildren() )
|
|
| 3180 | 3202 | {
|
| 3181 | - DrawSizers(*i);
|
|
| 3203 | + DrawSizers(child, level + 1);
|
|
| 3182 | 3204 | }
|
| 3183 | - |
|
| 3184 | - // show all kind of sizes of this window; see the "window sizing" topic
|
|
| 3185 | - // overview for more info about the various differences:
|
|
| 3186 | - wxSize fullSz = win->GetSize();
|
|
| 3187 | - wxSize clientSz = win->GetClientSize();
|
|
| 3188 | - wxSize bestSz = win->GetBestSize();
|
|
| 3189 | - wxSize minSz = win->GetMinSize();
|
|
| 3190 | - wxSize maxSz = win->GetMaxSize();
|
|
| 3191 | - wxSize virtualSz = win->GetVirtualSize();
|
|
| 3192 | - |
|
| 3193 | - wxMessageOutputDebug dbgout;
|
|
| 3194 | - dbgout.Printf(
|
|
| 3195 | - "%-10s => fullsz=%4d;%-4d clientsz=%4d;%-4d bestsz=%4d;%-4d minsz=%4d;%-4d maxsz=%4d;%-4d virtualsz=%4d;%-4d\n",
|
|
| 3196 | - win->GetName(),
|
|
| 3197 | - fullSz.x, fullSz.y,
|
|
| 3198 | - clientSz.x, clientSz.y,
|
|
| 3199 | - bestSz.x, bestSz.y,
|
|
| 3200 | - minSz.x, minSz.y,
|
|
| 3201 | - maxSz.x, maxSz.y,
|
|
| 3202 | - virtualSz.x, virtualSz.y);
|
|
| 3203 | 3205 | }
|
| 3204 | 3206 | }
|
| 3205 | 3207 | |
| 3206 | -#endif // wxDEBUG_LEVEL
|
|
| 3208 | +#endif // wxHAS_SIZER_DEBUG
|
|
| 3207 | 3209 | |
| 3208 | 3210 | // process special middle clicks
|
| 3209 | 3211 | void wxWindowBase::OnMiddleClick( wxMouseEvent& event )
|
| 3210 | 3212 | {
|
| 3211 | 3213 | if ( event.ControlDown() && event.AltDown() )
|
| 3212 | 3214 | {
|
| 3213 | -#if wxDEBUG_LEVEL > 1
|
|
| 3215 | +#ifdef wxHAS_SIZER_DEBUG
|
|
| 3214 | 3216 | // Ctrl-Alt-Shift-mclick makes the sizers visible in debug builds
|
| 3215 | 3217 | if ( event.ShiftDown() )
|
| 3216 | 3218 | {
|
| 3217 | 3219 | DrawSizers(this);
|
| 3218 | 3220 | }
|
| 3219 | 3221 | else
|
| 3220 | -#endif // __WXDEBUG__
|
|
| 3222 | +#endif // wxHAS_SIZER_DEBUG
|
|
| 3221 | 3223 | {
|
| 3222 | 3224 | #if wxUSE_MSGDLG
|
| 3223 | 3225 | // just Ctrl-Alt-middle click shows information about wx version
|
| ... | ... | @@ -16,13 +16,8 @@ |
| 16 | 16 | |
| 17 | 17 | #if wxUSE_CAIRO
|
| 18 | 18 | |
| 19 | -#ifndef __WXGTK__
|
|
| 20 | -// keep cairo.h from defining dllimport as we're defining the symbols inside
|
|
| 21 | -// the wx dll in order to load them dynamically.
|
|
| 22 | -#define cairo_public
|
|
| 23 | -#endif
|
|
| 19 | +#include "wx/private/cairo.h"
|
|
| 24 | 20 | |
| 25 | -#include <cairo.h>
|
|
| 26 | 21 | #include <float.h>
|
| 27 | 22 | |
| 28 | 23 | bool wxCairoInit();
|
—
View it on GitLab.
You're receiving this email because of your account on gitlab.com. Manage all notifications · Help