0001-wxWidget-fix.patch 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. diff --git a/include/wx/fontutil.h b/include/wx/fontutil.h
  2. index 09ad8c8ef3..3c0c2d8f7e 100644
  3. --- a/include/wx/fontutil.h
  4. +++ b/include/wx/fontutil.h
  5. @@ -294,7 +294,11 @@ public:
  6. wxFontEncoding GetEncoding() const;
  7. void SetPointSize(int pointsize);
  8. - void SetFractionalPointSize(double pointsize);
  9. + void SetFractionalPointSize(double pointsize
  10. +#if defined(__WXMSW__)
  11. + , const wxWindow *window = nullptr
  12. +#endif
  13. + );
  14. void SetPixelSize(const wxSize& pixelSize);
  15. void SetStyle(wxFontStyle style);
  16. void SetNumericWeight(int weight);
  17. @@ -307,12 +311,19 @@ public:
  18. // Helper used in many ports: use the normal font size if the input is
  19. // negative, as we handle -1 as meaning this for compatibility.
  20. - void SetSizeOrDefault(double size)
  21. + void SetSizeOrDefault(double size
  22. +#if defined(__WXMSW__)
  23. + , const wxWindow *window = nullptr
  24. +#endif
  25. + )
  26. {
  27. SetFractionalPointSize
  28. (
  29. size < 0 ? wxNORMAL_FONT->GetFractionalPointSize()
  30. : size
  31. +#if defined(__WXMSW__)
  32. + ,window
  33. +#endif
  34. );
  35. }
  36. diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h
  37. index e29a77627c..dc48cf9451 100644
  38. --- a/include/wx/gdicmn.h
  39. +++ b/include/wx/gdicmn.h
  40. @@ -38,6 +38,7 @@ class WXDLLIMPEXP_FWD_CORE wxRegion;
  41. class WXDLLIMPEXP_FWD_BASE wxString;
  42. class WXDLLIMPEXP_FWD_CORE wxIconBundle;
  43. class WXDLLIMPEXP_FWD_CORE wxPoint;
  44. +class WXDLLIMPEXP_FWD_CORE wxWindow;
  45. // ---------------------------------------------------------------------------
  46. // constants
  47. @@ -1092,7 +1093,9 @@ extern int WXDLLIMPEXP_CORE wxDisplayDepth();
  48. // get the display size
  49. extern void WXDLLIMPEXP_CORE wxDisplaySize(int *width, int *height);
  50. +extern void WXDLLIMPEXP_CORE wxDisplaySize(const wxWindow *window, int *width, int *height);
  51. extern wxSize WXDLLIMPEXP_CORE wxGetDisplaySize();
  52. +extern wxSize WXDLLIMPEXP_CORE wxGetDisplaySize(const wxWindow *window);
  53. extern void WXDLLIMPEXP_CORE wxDisplaySizeMM(int *width, int *height);
  54. extern wxSize WXDLLIMPEXP_CORE wxGetDisplaySizeMM();
  55. extern wxSize WXDLLIMPEXP_CORE wxGetDisplayPPI();
  56. diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h
  57. index d7a3890764..e4dee51d5a 100644
  58. --- a/include/wx/generic/grid.h
  59. +++ b/include/wx/generic/grid.h
  60. @@ -2951,9 +2951,11 @@ private:
  61. wxGridWindow* gridWindow);
  62. // Update the width/height of the column/row being drag-resized.
  63. + //BBS: add cursor mode for DoGridDragResize's paremeters
  64. void DoGridDragResize(const wxPoint& position,
  65. const wxGridOperations& oper,
  66. - wxGridWindow* gridWindow);
  67. + wxGridWindow* gridWindow,
  68. + CursorMode mode);
  69. // process different clicks on grid cells
  70. void DoGridCellLeftDown(wxMouseEvent& event,
  71. diff --git a/include/wx/msw/font.h b/include/wx/msw/font.h
  72. index 0f9768b44e..094d774918 100644
  73. --- a/include/wx/msw/font.h
  74. +++ b/include/wx/msw/font.h
  75. @@ -23,7 +23,7 @@ public:
  76. // ctors and such
  77. wxFont() { }
  78. - wxFont(const wxFontInfo& info);
  79. + wxFont(const wxFontInfo& info, const wxWindow *window = nullptr);
  80. wxFont(int size,
  81. wxFontFamily family,
  82. diff --git a/include/wx/msw/tooltip.h b/include/wx/msw/tooltip.h
  83. index 4c3be08cec..96fb378d01 100644
  84. --- a/include/wx/msw/tooltip.h
  85. +++ b/include/wx/msw/tooltip.h
  86. @@ -91,10 +91,10 @@ private:
  87. // the one and only one tooltip control we use - never access it directly
  88. // but use GetToolTipCtrl() which will create it when needed
  89. static WXHWND ms_hwndTT;
  90. -
  91. +public:
  92. // create the tooltip ctrl if it doesn't exist yet and return its HWND
  93. static WXHWND GetToolTipCtrl();
  94. -
  95. +private:
  96. // to be used in wxModule for deleting tooltip ctrl window when exiting mainloop
  97. static void DeleteToolTipCtrl();
  98. diff --git a/include/wx/osx/app.h b/include/wx/osx/app.h
  99. index 317a0ca96f..58014ec1d4 100644
  100. --- a/include/wx/osx/app.h
  101. +++ b/include/wx/osx/app.h
  102. @@ -161,7 +161,7 @@ private:
  103. public:
  104. bool OSXInitWasCalled() { return m_inited; }
  105. - void OSXStoreOpenFiles(const wxArrayString &files ) { m_openFiles = files ; }
  106. + virtual void OSXStoreOpenFiles(const wxArrayString &files ) { m_openFiles = files ; }
  107. void OSXStorePrintFiles(const wxArrayString &files ) { m_printFiles = files ; }
  108. void OSXStoreOpenURL(const wxString &url ) { m_getURL = url ; }
  109. #endif
  110. diff --git a/src/common/combocmn.cpp b/src/common/combocmn.cpp
  111. index b61aac35bf..d12b745e8c 100644
  112. --- a/src/common/combocmn.cpp
  113. +++ b/src/common/combocmn.cpp
  114. @@ -2141,7 +2141,7 @@ void wxComboCtrlBase::CreatePopup()
  115. #if !USES_GENERICTLW
  116. m_winPopup = new wxComboPopupWindowBase2( this, wxNO_BORDER );
  117. #else
  118. - int tlwFlags = wxNO_BORDER;
  119. + int tlwFlags = wxNO_BORDER | wxSTAY_ON_TOP;
  120. #ifdef wxCC_GENERIC_TLW_IS_FRAME
  121. tlwFlags |= wxFRAME_NO_TASKBAR;
  122. #endif
  123. @@ -2285,6 +2285,9 @@ void wxComboCtrlBase::ShowPopup()
  124. SetFocus();
  125. + //int displayIdx = wxDisplay::GetFromWindow(this);
  126. + //wxRect displayRect = wxDisplay(displayIdx != wxNOT_FOUND ? displayIdx : 0u).GetGeometry();
  127. +
  128. // Space above and below
  129. int screenHeight;
  130. wxPoint scrPos;
  131. @@ -2407,9 +2410,13 @@ void wxComboCtrlBase::ShowPopup()
  132. int showFlags = CanDeferShow;
  133. - if ( spaceBelow < szp.y )
  134. + int anchorSideVertical = m_anchorSide & (wxUP | wxDOWN);
  135. + if (// Pop up as asked for by the library user.
  136. + (anchorSideVertical & wxUP) ||
  137. + // Automatic: Pop up if it does not fit down.
  138. + (anchorSideVertical == 0 && spaceBelow < szp.y ))
  139. {
  140. - popupY = scrPos.y - szp.y;
  141. + popupY = scrPos.y - szp.y + displayRect.GetTop();
  142. showFlags |= ShowAbove;
  143. }
  144. diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp
  145. index 1f5fd4d66b..14ea2f8ef1 100644
  146. --- a/src/common/datavcmn.cpp
  147. +++ b/src/common/datavcmn.cpp
  148. @@ -1322,7 +1322,11 @@ wxDataViewItem wxDataViewCtrlBase::GetSelection() const
  149. wxDataViewItemArray selections;
  150. GetSelections(selections);
  151. - return selections[0];
  152. + // BBS
  153. + if (!selections.empty())
  154. + return selections[0];
  155. + else
  156. + return wxDataViewItem(0);
  157. }
  158. namespace
  159. diff --git a/src/common/dcbufcmn.cpp b/src/common/dcbufcmn.cpp
  160. index 74958fce10..59844f4526 100644
  161. --- a/src/common/dcbufcmn.cpp
  162. +++ b/src/common/dcbufcmn.cpp
  163. @@ -82,9 +82,15 @@ private:
  164. const double scale = dc ? dc->GetContentScaleFactor() : 1.0;
  165. wxBitmap* const buffer = new wxBitmap;
  166. +#if __WXMSW__
  167. // we must always return a valid bitmap but creating a bitmap of
  168. // size 0 would fail, so create a 1*1 bitmap in this case
  169. - buffer->CreateScaled(wxMax(w, 1), wxMax(h, 1), -1, scale);
  170. + buffer->Create(wxMax(w, 1), wxMax(h, 1), 24);
  171. +#else
  172. + // we must always return a valid bitmap but creating a bitmap of
  173. + // size 0 would fail, so create a 1*1 bitmap in this case
  174. + buffer->CreateScaled(wxMax(w, 1), wxMax(h, 1), -1, scale);
  175. +#endif
  176. return buffer;
  177. }
  178. diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp
  179. index 20442bbc73..9a24951ec7 100644
  180. --- a/src/common/gdicmn.cpp
  181. +++ b/src/common/gdicmn.cpp
  182. @@ -863,11 +863,25 @@ void wxDisplaySize(int *width, int *height)
  183. *height = size.y;
  184. }
  185. +void wxDisplaySize(const wxWindow *window, int *width, int *height)
  186. +{
  187. + const wxSize size = wxGetDisplaySize(window);
  188. + if ( width )
  189. + *width = size.x;
  190. + if ( height )
  191. + *height = size.y;
  192. +}
  193. +
  194. wxSize wxGetDisplaySize()
  195. {
  196. return wxDisplay().GetGeometry().GetSize();
  197. }
  198. +wxSize wxGetDisplaySize(const wxWindow *window)
  199. +{
  200. + return window ? wxDisplay(window).GetGeometry().GetSize() : wxDisplay().GetGeometry().GetSize();
  201. +}
  202. +
  203. void wxClientDisplayRect(int *x, int *y, int *width, int *height)
  204. {
  205. const wxRect rect = wxGetClientDisplayRect();
  206. diff --git a/src/common/intl.cpp b/src/common/intl.cpp
  207. index 0b0d8798f4..7072fab18a 100644
  208. --- a/src/common/intl.cpp
  209. +++ b/src/common/intl.cpp
  210. @@ -1628,6 +1628,12 @@ GetInfoFromLCID(LCID lcid,
  211. {
  212. str = buf;
  213. +//FIXME Vojtech: We forcefully set the locales for a decimal point to "C", but this
  214. +// is not possible for the Win32 locales, therefore there is a discrepancy.
  215. +// It looks like we live with the discrepancy for at least half a year, so we will
  216. +// suppress the assert until we fix Slic3r to properly switch to "C" locales just
  217. +// for file import / export.
  218. +#if 0
  219. // As we get our decimal point separator from Win32 and not the
  220. // CRT there is a possibility of mismatch between them and this
  221. // can easily happen if the user code called setlocale()
  222. @@ -1641,6 +1647,7 @@ GetInfoFromLCID(LCID lcid,
  223. "Decimal separator mismatch -- did you use setlocale()?"
  224. "If so, use wxLocale to change the locale instead."
  225. );
  226. +#endif
  227. }
  228. break;
  229. diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp
  230. index 41fd4524cf..f4a15cb839 100644
  231. --- a/src/generic/grid.cpp
  232. +++ b/src/generic/grid.cpp
  233. @@ -3824,7 +3824,8 @@ void wxGrid::ProcessRowLabelMouseEvent( wxMouseEvent& event, wxGridRowLabelWindo
  234. {
  235. case WXGRID_CURSOR_RESIZE_ROW:
  236. {
  237. - DoGridDragResize(event.GetPosition(), wxGridRowOperations(), gridWindow);
  238. + //BBS: add cursor mode for DoGridDragResize's paremeters
  239. + DoGridDragResize(event.GetPosition(), wxGridRowOperations(), gridWindow, WXGRID_CURSOR_RESIZE_ROW);
  240. }
  241. break;
  242. @@ -4166,7 +4167,8 @@ void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event, wxGridColLabelWindo
  243. switch ( m_cursorMode )
  244. {
  245. case WXGRID_CURSOR_RESIZE_COL:
  246. - DoGridDragResize(event.GetPosition(), wxGridColumnOperations(), gridWindow);
  247. + //BBS: add cursor mode for DoGridDragResize's paremeters
  248. + DoGridDragResize(event.GetPosition(), wxGridColumnOperations(), gridWindow, WXGRID_CURSOR_RESIZE_COL);
  249. break;
  250. case WXGRID_CURSOR_SELECT_COL:
  251. @@ -4708,11 +4710,13 @@ bool wxGrid::DoGridDragEvent(wxMouseEvent& event,
  252. return DoGridCellDrag(event, coords, isFirstDrag);
  253. case WXGRID_CURSOR_RESIZE_ROW:
  254. - DoGridDragResize(event.GetPosition(), wxGridRowOperations(), gridWindow);
  255. + //BBS: add cursor mode for DoGridDragResize's paremeters
  256. + DoGridDragResize(event.GetPosition(), wxGridRowOperations(), gridWindow, WXGRID_CURSOR_RESIZE_ROW);
  257. break;
  258. case WXGRID_CURSOR_RESIZE_COL:
  259. - DoGridDragResize(event.GetPosition(), wxGridColumnOperations(), gridWindow);
  260. + //BBS: add cursor mode for DoGridDragResize's paremeters
  261. + DoGridDragResize(event.GetPosition(), wxGridColumnOperations(), gridWindow, WXGRID_CURSOR_RESIZE_COL);
  262. break;
  263. default:
  264. @@ -4803,6 +4807,8 @@ wxGrid::DoGridCellLeftDown(wxMouseEvent& event,
  265. case wxGridSelectCells:
  266. case wxGridSelectRowsOrColumns:
  267. // nothing to do in these cases
  268. + //BBS: select this cell when first click
  269. + m_selection->SelectBlock(coords.GetRow(), coords.GetCol(), coords.GetRow(), coords.GetCol(), event);
  270. break;
  271. case wxGridSelectRows:
  272. @@ -5044,9 +5050,11 @@ void wxGrid::ProcessGridCellMouseEvent(wxMouseEvent& event, wxGridWindow *eventG
  273. }
  274. }
  275. +//BBS: add cursor mode for DoGridDragResize's paremeters
  276. void wxGrid::DoGridDragResize(const wxPoint& position,
  277. const wxGridOperations& oper,
  278. - wxGridWindow* gridWindow)
  279. + wxGridWindow* gridWindow,
  280. + CursorMode mode)
  281. {
  282. // Get the logical position from the physical one we're passed.
  283. const wxPoint
  284. @@ -5056,10 +5064,28 @@ void wxGrid::DoGridDragResize(const wxPoint& position,
  285. // orthogonal direction.
  286. const int linePos = oper.Dual().Select(logicalPos);
  287. - const int lineStart = oper.GetLineStartPos(this, m_dragRowOrCol);
  288. - oper.SetLineSize(this, m_dragRowOrCol,
  289. + //BBS: add logic for resize multiplexed cols
  290. + if (mode == WXGRID_CURSOR_RESIZE_COL) {
  291. + int col_to_resize = m_dragRowOrCol;
  292. + int num_rows, num_cols;
  293. + this->GetCellSize(0, m_dragRowOrCol, &num_rows, &num_cols);
  294. + if (num_cols < 1)
  295. + col_to_resize = m_dragRowOrCol - 1;
  296. +
  297. + const int lineEnd = oper.GetLineEndPos(this, m_dragRowOrCol);
  298. + const int lineSize = oper.GetLineSize(this, col_to_resize);
  299. + int size = linePos - lineEnd + lineSize;
  300. + oper.SetLineSize(this, col_to_resize,
  301. + wxMax(size,
  302. + oper.GetMinimalLineSize(this, col_to_resize)));
  303. + }
  304. + else {
  305. + const int lineStart = oper.GetLineStartPos(this, m_dragRowOrCol);
  306. +
  307. + oper.SetLineSize(this, m_dragRowOrCol,
  308. wxMax(linePos - lineStart,
  309. oper.GetMinimalLineSize(this, m_dragRowOrCol)));
  310. + }
  311. // TODO: generate RESIZING event, see #10754, if the size has changed.
  312. }
  313. @@ -5082,7 +5108,8 @@ wxPoint wxGrid::GetPositionForResizeEvent(int width) const
  314. void wxGrid::DoEndDragResizeRow(const wxMouseEvent& event, wxGridWindow* gridWindow)
  315. {
  316. - DoGridDragResize(event.GetPosition(), wxGridRowOperations(), gridWindow);
  317. + //BBS: add cursor mode for DoGridDragResize's paremeters
  318. + DoGridDragResize(event.GetPosition(), wxGridRowOperations(), gridWindow, WXGRID_CURSOR_RESIZE_ROW);
  319. SendGridSizeEvent(wxEVT_GRID_ROW_SIZE, m_dragRowOrCol, -1, event);
  320. @@ -5091,7 +5118,8 @@ void wxGrid::DoEndDragResizeRow(const wxMouseEvent& event, wxGridWindow* gridWin
  321. void wxGrid::DoEndDragResizeCol(const wxMouseEvent& event, wxGridWindow* gridWindow)
  322. {
  323. - DoGridDragResize(event.GetPosition(), wxGridColumnOperations(), gridWindow);
  324. + //BBS: add cursor mode for DoGridDragResize's paremeters
  325. + DoGridDragResize(event.GetPosition(), wxGridColumnOperations(), gridWindow, WXGRID_CURSOR_RESIZE_COL);
  326. SendGridSizeEvent(wxEVT_GRID_COL_SIZE, -1, m_dragRowOrCol, event);
  327. @@ -5105,9 +5133,10 @@ void wxGrid::DoHeaderStartDragResizeCol(int col)
  328. void wxGrid::DoHeaderDragResizeCol(int width)
  329. {
  330. + //BBS: add cursor mode for DoGridDragResize's paremeters
  331. DoGridDragResize(GetPositionForResizeEvent(width),
  332. wxGridColumnOperations(),
  333. - m_gridWin);
  334. + m_gridWin, WXGRID_CURSOR_RESIZE_COL);
  335. }
  336. void wxGrid::DoHeaderEndDragResizeCol(int width)
  337. @@ -5891,6 +5920,10 @@ void wxGrid::OnKeyDown( wxKeyEvent& event )
  338. DisableCellEditControl();
  339. MoveCursorDown( event.ShiftDown() );
  340. + //BBS: select this cell when first click
  341. + m_selection->SelectBlock(m_currentCellCoords.GetRow(), m_currentCellCoords.GetCol(),
  342. + m_currentCellCoords.GetRow(), m_currentCellCoords.GetCol(),
  343. + event);
  344. }
  345. break;
  346. diff --git a/src/msw/bmpcbox.cpp b/src/msw/bmpcbox.cpp
  347. index 0a2d167ad7..0aeba45ea9 100644
  348. --- a/src/msw/bmpcbox.cpp
  349. +++ b/src/msw/bmpcbox.cpp
  350. @@ -156,13 +156,20 @@ void wxBitmapComboBox::RecreateControl()
  351. wxComboBox::DoClear();
  352. - HWND hwnd = GetHwnd();
  353. + WNDPROC wndproc_edit = nullptr;
  354. + WinStruct<COMBOBOXINFO> combobox_info;
  355. + HWND hwnd = GetHwnd();
  356. +if (::GetComboBoxInfo(hwnd, &combobox_info))
  357. + wndproc_edit = (WNDPROC)wxGetWindowProc(combobox_info.hwndItem);
  358. DissociateHandle();
  359. ::DestroyWindow(hwnd);
  360. if ( !MSWCreateControl(wxT("COMBOBOX"), wxEmptyString, pos, size) )
  361. return;
  362. +if (::GetComboBoxInfo(GetHwnd(), &combobox_info))
  363. + wxSetWindowProc(combobox_info.hwndItem, wndproc_edit);
  364. +
  365. // initialize the controls contents
  366. for ( i = 0; i < numItems; i++ )
  367. {
  368. diff --git a/src/msw/font.cpp b/src/msw/font.cpp
  369. index 0bd240d79f..d38b1b00f5 100644
  370. --- a/src/msw/font.cpp
  371. +++ b/src/msw/font.cpp
  372. @@ -54,7 +54,7 @@ static const int PITCH_MASK = FIXED_PITCH | VARIABLE_PITCH;
  373. class WXDLLEXPORT wxFontRefData: public wxGDIRefData
  374. {
  375. public:
  376. - wxFontRefData(const wxFontInfo& info = wxFontInfo());
  377. + wxFontRefData(const wxFontInfo& info = wxFontInfo(), const wxWindow* window = nullptr);
  378. wxFontRefData(const wxNativeFontInfo& info, WXHFONT hFont = 0)
  379. {
  380. @@ -324,7 +324,7 @@ protected:
  381. // wxFontRefData
  382. // ----------------------------------------------------------------------------
  383. -wxFontRefData::wxFontRefData(const wxFontInfo& info)
  384. +wxFontRefData::wxFontRefData(const wxFontInfo& info, const wxWindow *window)
  385. {
  386. m_hFont = NULL;
  387. @@ -335,7 +335,7 @@ wxFontRefData::wxFontRefData(const wxFontInfo& info)
  388. }
  389. else
  390. {
  391. - m_nativeFontInfo.SetSizeOrDefault(info.GetFractionalPointSize());
  392. + m_nativeFontInfo.SetSizeOrDefault(info.GetFractionalPointSize(), window);
  393. }
  394. SetStyle(info.GetStyle());
  395. @@ -518,12 +518,12 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const
  396. return wxGetFontEncFromCharSet(lf.lfCharSet);
  397. }
  398. -void wxNativeFontInfo::SetFractionalPointSize(double pointSizeNew)
  399. +void wxNativeFontInfo::SetFractionalPointSize(double pointSizeNew, const wxWindow *window)
  400. {
  401. // We don't have the correct DPI to use here, so use that of the
  402. // primary screen and rely on WXAdjustToPPI() changing it later if
  403. // necessary.
  404. - const int ppi = ::GetDeviceCaps(ScreenHDC(), LOGPIXELSY);
  405. + const int ppi = window ? window->GetDPI().GetY() : ::GetDeviceCaps(ScreenHDC(), LOGPIXELSY);
  406. lf.lfHeight = GetLogFontHeightAtPPI(pointSizeNew, ppi);
  407. pointSize = pointSizeNew;
  408. @@ -812,9 +812,9 @@ wxFont::wxFont(const wxString& fontdesc)
  409. (void)Create(info);
  410. }
  411. -wxFont::wxFont(const wxFontInfo& info)
  412. +wxFont::wxFont(const wxFontInfo& info, const wxWindow *window)
  413. {
  414. - m_refData = new wxFontRefData(info);
  415. + m_refData = new wxFontRefData(info, window);
  416. }
  417. bool wxFont::Create(const wxNativeFontInfo& info, WXHFONT hFont)
  418. diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp
  419. index 9bb397d472..30af7154a7 100644
  420. --- a/src/msw/menuitem.cpp
  421. +++ b/src/msw/menuitem.cpp
  422. @@ -368,6 +368,8 @@ void MenuDrawData::Init(wxWindow const* window)
  423. // native menu uses small top margin for separator
  424. if ( SeparatorMargin.cyTopHeight >= 2 )
  425. SeparatorMargin.cyTopHeight -= 2;
  426. +
  427. + SeparatorSize.cy = 0;
  428. }
  429. else
  430. #endif // wxUSE_UXTHEME
  431. diff --git a/src/msw/window.cpp b/src/msw/window.cpp
  432. index eadc2f5700..f64fea4446 100644
  433. --- a/src/msw/window.cpp
  434. +++ b/src/msw/window.cpp
  435. @@ -4773,33 +4773,49 @@ static wxSize GetWindowDPI(HWND hwnd)
  436. }
  437. /*extern*/
  438. -int wxGetSystemMetrics(int nIndex, const wxWindow* window)
  439. +int wxGetSystemMetrics(int nIndex, const wxWindow* win)
  440. {
  441. #if wxUSE_DYNLIB_CLASS
  442. - if ( !window )
  443. - window = wxApp::GetMainTopWindow();
  444. + const wxWindow* window = (!win && wxTheApp) ? wxTheApp->GetTopWindow() : win;
  445. - if ( window )
  446. + if (window)
  447. {
  448. - typedef int (WINAPI * GetSystemMetricsForDpi_t)(int nIndex, UINT dpi);
  449. - static GetSystemMetricsForDpi_t s_pfnGetSystemMetricsForDpi = NULL;
  450. - static bool s_initDone = false;
  451. -
  452. - if ( !s_initDone )
  453. - {
  454. - wxLoadedDLL dllUser32("user32.dll");
  455. - wxDL_INIT_FUNC(s_pfn, GetSystemMetricsForDpi, dllUser32);
  456. - s_initDone = true;
  457. +#if 1
  458. + if (window->GetHWND() && (nIndex == SM_CXSCREEN || nIndex == SM_CYSCREEN)) {
  459. + HDC hdc = GetDC(window->GetHWND());
  460. +#if 0
  461. + double dim = GetDeviceCaps(hdc, nIndex == SM_CXSCREEN ? HORZRES : VERTRES);
  462. + ReleaseDC(window->GetHWND(), hdc);
  463. + wxSize dpi = window->GetDPI();
  464. + dim *= 96.0 / (nIndex == SM_CXSCREEN ? dpi.x : dpi.y);
  465. + return int(dim + 0.5);
  466. +#else
  467. + return int(GetDeviceCaps(hdc, nIndex == SM_CXSCREEN ? HORZRES : VERTRES));
  468. +#endif
  469. }
  470. -
  471. - if ( s_pfnGetSystemMetricsForDpi )
  472. + else
  473. +#endif
  474. {
  475. - const int dpi = window->GetDPI().y;
  476. - return s_pfnGetSystemMetricsForDpi(nIndex, (UINT)dpi);
  477. + typedef int (WINAPI * GetSystemMetricsForDpi_t)(int nIndex, UINT dpi);
  478. + static GetSystemMetricsForDpi_t s_pfnGetSystemMetricsForDpi = NULL;
  479. + static bool s_initDone = false;
  480. +
  481. + if ( !s_initDone )
  482. + {
  483. + wxLoadedDLL dllUser32("user32.dll");
  484. + wxDL_INIT_FUNC(s_pfn, GetSystemMetricsForDpi, dllUser32);
  485. + s_initDone = true;
  486. + }
  487. +
  488. + if ( s_pfnGetSystemMetricsForDpi )
  489. + {
  490. + const int dpi = window->GetDPI().y;
  491. + return s_pfnGetSystemMetricsForDpi(nIndex, (UINT)dpi);
  492. + }
  493. }
  494. }
  495. #else
  496. - wxUnusedVar(window);
  497. + wxUnusedVar(win);
  498. #endif // wxUSE_DYNLIB_CLASS
  499. return ::GetSystemMetrics(nIndex);
  500. diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm
  501. index 6ff0cc3088..4943f3ea38 100644
  502. --- a/src/osx/cocoa/dataview.mm
  503. +++ b/src/osx/cocoa/dataview.mm
  504. @@ -1734,12 +1734,22 @@ outlineView:(NSOutlineView*)outlineView
  505. if ( !dvc->GetEventHandler()->ProcessEvent(eventDV) )
  506. [super keyDown:event];
  507. }
  508. - else
  509. + //FIXME Vojtech's hack to get the accelerators assigned to the wxDataViewControl working.
  510. + else if (! implementation->DoHandleKeyEvent(event))
  511. {
  512. [super keyDown:event]; // all other keys
  513. }
  514. }
  515. +//FIXME Vojtech: This is a workaround to get at least the "mouse move" events at the wxDataViewControl,
  516. +// so we can show the tooltips. The "mouse move" events are being send only if the wxDataViewControl
  517. +// has focus, which is a limitation of wxWidgets. We may grab focus on "mouse entry" though.
  518. +- (void)mouseMoved:(NSEvent *)event
  519. +{
  520. +if (! implementation->DoHandleMouseEvent(event))
  521. + [super mouseMoved:event];
  522. +}
  523. +
  524. //
  525. // contextual menus
  526. //
  527. @@ -2672,12 +2682,22 @@ void wxCocoaDataViewControl::DoSetIndent(int indent)
  528. void wxCocoaDataViewControl::HitTest(const wxPoint& point, wxDataViewItem& item, wxDataViewColumn*& columnPtr) const
  529. {
  530. - NSPoint const nativePoint = wxToNSPoint((NSScrollView*) GetWXWidget(),point);
  531. + NSTableHeaderView *headerView = [m_OutlineView headerView];
  532. + if (headerView && point.y < headerView.visibleRect.size.height) {
  533. + // The point is inside the header area.
  534. + columnPtr = NULL;
  535. + item = wxDataViewItem();
  536. + return;
  537. + }
  538. + // Convert from the window coordinates to the virtual scrolled view coordinates.
  539. + NSScrollView *scrollView = [m_OutlineView enclosingScrollView];
  540. + const NSRect &visibleRect = scrollView.contentView.visibleRect;
  541. + NSPoint const nativePoint = wxToNSPoint((NSScrollView*) GetWXWidget(),
  542. + wxPoint(point.x + visibleRect.origin.x, point.y + visibleRect.origin.y));
  543. int indexColumn;
  544. int indexRow;
  545. -
  546. indexColumn = [m_OutlineView columnAtPoint:nativePoint];
  547. indexRow = [m_OutlineView rowAtPoint: nativePoint];
  548. if ((indexColumn >= 0) && (indexRow >= 0))
  549. diff --git a/src/osx/cocoa/settings.mm b/src/osx/cocoa/settings.mm
  550. index de5f52860c..a9581174a4 100644
  551. --- a/src/osx/cocoa/settings.mm
  552. +++ b/src/osx/cocoa/settings.mm
  553. @@ -224,7 +224,7 @@ wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
  554. // ----------------------------------------------------------------------------
  555. // Get a system metric, e.g. scrollbar size
  556. -int wxSystemSettingsNative::GetMetric(wxSystemMetric index, const wxWindow* WXUNUSED(win))
  557. +int wxSystemSettingsNative::GetMetric(wxSystemMetric index, const wxWindow* win)
  558. {
  559. int value;
  560. @@ -259,11 +259,11 @@ int wxSystemSettingsNative::GetMetric(wxSystemMetric index, const wxWindow* WXUN
  561. // TODO case wxSYS_WINDOWMIN_Y:
  562. case wxSYS_SCREEN_X:
  563. - wxDisplaySize(&value, NULL);
  564. + wxDisplaySize(win, &value, NULL);
  565. return value;
  566. case wxSYS_SCREEN_Y:
  567. - wxDisplaySize(NULL, &value);
  568. + wxDisplaySize(win, NULL, &value);
  569. return value;
  570. // TODO case wxSYS_FRAMESIZE_X: