c28746f4887f10e6f9f10eeafae0fb22ecdbf9c7.patch 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966
  1. From c28746f4887f10e6f9f10eeafae0fb22ecdbf9c7 Mon Sep 17 00:00:00 2001
  2. From: wh11204 <wh11204@2a5c6006-c6dd-42ca-98ab-0921f2732cef>
  3. Date: Wed, 15 Dec 2021 08:28:41 +0000
  4. Subject: [PATCH] - Remove code for wxWidgets < 3.0.0 (part III and last).
  5. Includes: src/plugins/compilergcc/compileroptionsdlg.cpp
  6. src/sdk/templatemanager.cpp src/src/associations.cpp src/src/dlgabout.cpp
  7. src/src/main.cpp src/src/notebookstyles.cpp src/src/notebookstyles.h
  8. src/src/projectmanagerui.cpp
  9. git-svn-id: https://svn.code.sf.net/p/codeblocks/code/trunk@12580 2a5c6006-c6dd-42ca-98ab-0921f2732cef
  10. ---
  11. .../compilergcc/compileroptionsdlg.cpp | 12 +-
  12. src/sdk/templatemanager.cpp | 12 -
  13. src/src/associations.cpp | 4 -
  14. src/src/dlgabout.cpp | 10 +-
  15. src/src/main.cpp | 13 -
  16. src/src/notebookstyles.cpp | 592 +-----------------
  17. src/src/notebookstyles.h | 39 --
  18. src/src/projectmanagerui.cpp | 4 -
  19. 8 files changed, 5 insertions(+), 681 deletions(-)
  20. diff --git a/src/plugins/compilergcc/compileroptionsdlg.cpp b/src/plugins/compilergcc/compileroptionsdlg.cpp
  21. index 476bbc795..ade5fcf93 100644
  22. --- a/src/plugins/compilergcc/compileroptionsdlg.cpp
  23. +++ b/src/plugins/compilergcc/compileroptionsdlg.cpp
  24. @@ -677,13 +677,9 @@ void CompilerOptionsDlg::DoFillOptions()
  25. wxPGProperty *root = m_FlagsPG->GetRoot();
  26. if (root)
  27. {
  28. - unsigned count = root->GetChildCount();
  29. + const unsigned count = root->GetChildCount();
  30. for (unsigned ii = 0; ii < count; ++ii)
  31. -#if wxCHECK_VERSION(3, 0, 0)
  32. m_FlagsPG->SortChildren(root->Item(ii), wxPG_RECURSE);
  33. -#else
  34. - m_FlagsPG->Sort(root->Item(ii));
  35. -#endif
  36. }
  37. m_FlagsPG->Thaw();
  38. } // DoFillOptions
  39. @@ -2118,11 +2114,7 @@ void CompilerOptionsDlg::OnSetDefaultCompilerClick(cb_unused wxCommandEvent& eve
  40. CompilerFactory::SetDefaultCompiler(idx);
  41. wxString msg;
  42. Compiler* compiler = CompilerFactory::GetDefaultCompiler();
  43. - #if wxCHECK_VERSION(3, 0, 0)
  44. - msg.Printf(_("%s is now selected as the default compiler for new projects"), compiler ? compiler->GetName().wx_str() : _("[invalid]").wx_str());
  45. - #else
  46. - msg.Printf(_("%s is now selected as the default compiler for new projects"), compiler ? compiler->GetName().c_str() : _("[invalid]"));
  47. - #endif
  48. + msg.Printf(_("%s is now selected as the default compiler for new projects"), compiler ? compiler->GetName() : _("[invalid]"));
  49. cbMessageBox(msg);
  50. } // OnSetDefaultCompilerClick
  51. diff --git a/src/sdk/templatemanager.cpp b/src/sdk/templatemanager.cpp
  52. index 5b5b91dff..0161badf0 100644
  53. --- a/src/sdk/templatemanager.cpp
  54. +++ b/src/sdk/templatemanager.cpp
  55. @@ -186,11 +186,7 @@ cbProject* TemplateManager::NewProjectFromUserTemplate(NewFromTemplateDlg& dlg,
  56. ++count;
  57. }
  58. else
  59. - #if wxCHECK_VERSION(3, 0, 0)
  60. Manager::Get()->GetLogManager()->DebugLog(F(_T("Failed copying %s to %s"), src.wx_str(), dst.wx_str()));
  61. - #else
  62. - Manager::Get()->GetLogManager()->DebugLog(F(_T("Failed copying %s to %s"), src.c_str(), dst.c_str()));
  63. - #endif
  64. }
  65. if (count != total_count)
  66. cbMessageBox(_("Some files could not be loaded with the template..."), _("Error"), wxICON_ERROR);
  67. @@ -303,21 +299,13 @@ void TemplateManager::SaveUserTemplate(cbProject* prj)
  68. {
  69. wxString src = (*it)->file.GetFullPath();
  70. wxString dst = templ + (*it)->relativeToCommonTopLevelPath;
  71. - #if wxCHECK_VERSION(3, 0, 0)
  72. Manager::Get()->GetLogManager()->DebugLog(F(_T("Copying %s to %s"), src.wx_str(), dst.wx_str()));
  73. - #else
  74. - Manager::Get()->GetLogManager()->DebugLog(F(_T("Copying %s to %s"), src.c_str(), dst.c_str()));
  75. - #endif
  76. if (!CreateDirRecursively(dst))
  77. Manager::Get()->GetLogManager()->DebugLog(_T("Failed creating directory for ") + dst);
  78. if (wxCopyFile(src, dst, true))
  79. ++count;
  80. else
  81. - #if wxCHECK_VERSION(3, 0, 0)
  82. Manager::Get()->GetLogManager()->DebugLog(F(_T("Failed copying %s to %s"), src.wx_str(), dst.wx_str()));
  83. - #else
  84. - Manager::Get()->GetLogManager()->DebugLog(F(_T("Failed copying %s to %s"), src.c_str(), dst.c_str()));
  85. - #endif
  86. }
  87. // cbProject doesn't have a GetRelativeToCommonTopLevelPath() function, so we simulate it here
  88. diff --git a/src/src/associations.cpp b/src/src/associations.cpp
  89. index f6cebd5c0..f981c3f27 100644
  90. --- a/src/src/associations.cpp
  91. +++ b/src/src/associations.cpp
  92. @@ -201,11 +201,7 @@ void Associations::DoClearAssociation(const wxString& ext)
  93. if (key.Exists())
  94. {
  95. wxString s;
  96. - #if wxCHECK_VERSION(3, 0, 0)
  97. if (key.QueryValue(wxEmptyString, s) && s.StartsWith(_T("CodeBlocks")))
  98. - #else
  99. - if (key.QueryValue(NULL, s) && s.StartsWith(_T("CodeBlocks")))
  100. - #endif
  101. key.DeleteSelf();
  102. }
  103. diff --git a/src/src/dlgabout.cpp b/src/src/dlgabout.cpp
  104. index 294350696..545f7d13a 100644
  105. --- a/src/src/dlgabout.cpp
  106. +++ b/src/src/dlgabout.cpp
  107. @@ -20,9 +20,7 @@
  108. #include <wx/string.h>
  109. #include <wx/textctrl.h>
  110. #include <wx/xrc/xmlres.h>
  111. - #if wxCHECK_VERSION(3, 0, 0)
  112. - #include <wx/versioninfo.h>
  113. - #endif // wxCHECK_VERSION
  114. + #include <wx/versioninfo.h>
  115. #include "licenses.h"
  116. #include "configmanager.h"
  117. @@ -146,15 +144,11 @@ dlgAbout::dlgAbout(wxWindow* parent)
  118. wxTextCtrl *txtLicense = XRCCTRL(*this, "txtLicense", wxTextCtrl);
  119. txtLicense->SetValue(LICENSE_GPL);
  120. -#if wxCHECK_VERSION(3, 0, 0)
  121. const wxVersionInfo scintillaVersion = wxScintilla::GetLibraryVersionInfo();
  122. const wxString scintillaStr = wxString::Format(wxT("%d.%d.%d"),
  123. scintillaVersion.GetMajor(),
  124. scintillaVersion.GetMinor(),
  125. scintillaVersion.GetMicro());
  126. -#else
  127. - const wxString scintillaStr = wxSCINTILLA_VERSION;
  128. -#endif // wxCHECK_VERSION
  129. struct Item
  130. {
  131. @@ -218,9 +212,7 @@ dlgAbout::dlgAbout(wxWindow* parent)
  132. information += wxT(": ") + item.value + wxT("\n");
  133. }
  134. -#if wxCHECK_VERSION(3, 0, 0)
  135. information += wxT("\n") + wxGetLibraryVersionInfo().GetDescription();
  136. -#endif // wxCHECK_VERSION(3, 0, 0)
  137. wxTextCtrl *txtInformation = XRCCTRL(*this, "txtInformation", wxTextCtrl);
  138. txtInformation->SetValue(information);
  139. diff --git a/src/src/main.cpp b/src/src/main.cpp
  140. index d730a9294..8de2a4206 100644
  141. --- a/src/src/main.cpp
  142. +++ b/src/src/main.cpp
  143. @@ -2075,11 +2075,7 @@ void MainFrame::DoSelectLayout(const wxString& name)
  144. {
  145. if (!items[i]->IsCheckable())
  146. continue;
  147. -#if wxCHECK_VERSION(3, 0, 0)
  148. items[i]->Check(items[i]->GetItemLabel().IsSameAs(name));
  149. -#else
  150. - items[i]->Check(items[i]->GetText().IsSameAs(name));
  151. -#endif
  152. }
  153. if (!m_LastLayoutIsTemp)
  154. @@ -2401,12 +2397,7 @@ void MainFrame::DoUpdateEditorStyle(cbAuiNotebook* target, const wxString& prefi
  155. break;
  156. default: // default style
  157. - #if defined(__WXGTK__) && (USE_GTK_NOTEBOOK) && !wxCHECK_VERSION(3, 0, 0)
  158. - target->SetArtProvider(new NbStyleGTK());
  159. - #else
  160. target->SetArtProvider(new wxAuiDefaultTabArt());
  161. - #endif
  162. - break;
  163. }
  164. target->SetTabCtrlHeight(-1);
  165. @@ -4801,13 +4792,9 @@ void MainFrame::OnEditorUpdateUI(CodeBlocksEvent& event)
  166. if (Manager::Get()->GetEditorManager() && event.GetEditor() == Manager::Get()->GetEditorManager()->GetActiveEditor())
  167. {
  168. -#if wxCHECK_VERSION(3, 0, 0)
  169. // Execute the code to update the status bar outside of the paint event for scintilla.
  170. // Executing this function directly in the event handler causes redraw problems on Windows.
  171. CallAfter(&MainFrame::DoUpdateStatusBar);
  172. -#else
  173. - DoUpdateStatusBar();
  174. -#endif // defined(__wxMSW__) && wxCHECK_VERSION(3, 0, 0)
  175. }
  176. event.Skip();
  177. diff --git a/src/src/notebookstyles.cpp b/src/src/notebookstyles.cpp
  178. index 81362d498..d53edcaed 100644
  179. --- a/src/src/notebookstyles.cpp
  180. +++ b/src/src/notebookstyles.cpp
  181. @@ -13,14 +13,6 @@
  182. #include "prep.h"
  183. #include "notebookstyles.h"
  184. -#if defined(__WXGTK__) && (USE_GTK_NOTEBOOK) && !wxCHECK_VERSION(3, 0, 0)
  185. - #define GSocket GLibSocket
  186. - #include <gtk/gtk.h>
  187. - #undef GSocket
  188. - #include <wx/artprov.h>
  189. - #include <wx/renderer.h>
  190. -#endif
  191. -
  192. #include <wx/dc.h>
  193. #include <wx/dcclient.h>
  194. @@ -42,15 +34,9 @@ wxAuiTabArt* NbStyleVC71::Clone()
  195. {
  196. NbStyleVC71* clone = new NbStyleVC71();
  197. -#if wxCHECK_VERSION(3, 0, 0)
  198. clone->SetNormalFont(m_normalFont);
  199. clone->SetSelectedFont(m_selectedFont);
  200. clone->SetMeasuringFont(m_measuringFont);
  201. -#else
  202. - clone->SetNormalFont(m_normal_font);
  203. - clone->SetSelectedFont(m_selected_font);
  204. - clone->SetMeasuringFont(m_measuring_font);
  205. -#endif
  206. return clone;
  207. }
  208. @@ -75,11 +61,7 @@ void NbStyleVC71::DrawTab(wxDC& dc, wxWindow* wnd,
  209. close_button_state,
  210. x_extent);
  211. -#if wxCHECK_VERSION(3, 0, 0)
  212. wxCoord tab_height = m_tabCtrlHeight - 3;
  213. -#else
  214. - wxCoord tab_height = m_tab_ctrl_height - 3;
  215. -#endif
  216. wxCoord tab_width = tab_size.x;
  217. wxCoord tab_x = in_rect.x;
  218. wxCoord tab_y = in_rect.y + in_rect.height - tab_height;
  219. @@ -166,17 +148,10 @@ void NbStyleVC71::DrawTab(wxDC& dc, wxWindow* wnd,
  220. wxCoord textx;
  221. wxCoord texty;
  222. if (page.active)
  223. -#if wxCHECK_VERSION(3, 0, 0)
  224. dc.SetFont(m_selectedFont);
  225. -#else
  226. - dc.SetFont(m_selected_font);
  227. -#endif
  228. else
  229. -#if wxCHECK_VERSION(3, 0, 0)
  230. dc.SetFont(m_normalFont);
  231. -#else
  232. - dc.SetFont(m_normal_font);
  233. -#endif
  234. +
  235. dc.GetTextExtent(caption, &textx, &texty);
  236. // draw tab text
  237. dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
  238. @@ -186,21 +161,12 @@ void NbStyleVC71::DrawTab(wxDC& dc, wxWindow* wnd,
  239. // draw 'x' on tab (if enabled)
  240. if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
  241. {
  242. -#if wxCHECK_VERSION(3, 0, 0)
  243. int close_button_width = m_activeCloseBmp.GetWidth();
  244. wxBitmap bmp = m_disabledCloseBmp;
  245. -#else
  246. - int close_button_width = m_active_close_bmp.GetWidth();
  247. - wxBitmap bmp = m_disabled_close_bmp;
  248. -#endif
  249. if ((close_button_state == wxAUI_BUTTON_STATE_HOVER) ||
  250. (close_button_state == wxAUI_BUTTON_STATE_PRESSED))
  251. -#if wxCHECK_VERSION(3, 0, 0)
  252. bmp = m_activeCloseBmp;
  253. -#else
  254. - bmp = m_active_close_bmp;
  255. -#endif
  256. wxRect rect(tab_x + tab_width - close_button_width - 3,
  257. drawn_tab_yoff + (drawn_tab_height / 2) - (bmp.GetHeight() / 2),
  258. @@ -227,11 +193,7 @@ int NbStyleVC71::GetBestTabCtrlSize(wxWindow* wnd,
  259. // m_requested_tabctrl_height = -1;
  260. // m_tab_ctrl_height = -1;
  261. wxClientDC dc(wnd);
  262. -#if wxCHECK_VERSION(3, 0, 0)
  263. dc.SetFont(m_measuringFont);
  264. -#else
  265. - dc.SetFont(m_measuring_font);
  266. -#endif
  267. int x_ext = 0;
  268. wxSize s = GetTabSize(dc, wnd, wxT("ABCDEFGHIj"), wxNullBitmap, true,
  269. wxAUI_BUTTON_STATE_HIDDEN, &x_ext);
  270. @@ -246,15 +208,9 @@ wxAuiTabArt* NbStyleFF2::Clone()
  271. {
  272. NbStyleFF2* clone = new NbStyleFF2();
  273. -#if wxCHECK_VERSION(3, 0, 0)
  274. clone->SetNormalFont(m_normalFont);
  275. clone->SetSelectedFont(m_selectedFont);
  276. clone->SetMeasuringFont(m_measuringFont);
  277. -#else
  278. - clone->SetNormalFont(m_normal_font);
  279. - clone->SetSelectedFont(m_selected_font);
  280. - clone->SetMeasuringFont(m_measuring_font);
  281. -#endif
  282. return clone;
  283. }
  284. @@ -272,11 +228,7 @@ void NbStyleFF2::DrawTab(wxDC& dc, wxWindow* wnd,
  285. wxSize tab_size = GetTabSize(dc, wnd, page.caption, page.bitmap,
  286. page.active, close_button_state, x_extent);
  287. -#if wxCHECK_VERSION(3, 0, 0)
  288. wxCoord tab_height = m_tabCtrlHeight - 2;
  289. -#else
  290. - wxCoord tab_height = m_tab_ctrl_height - 2;
  291. -#endif
  292. wxCoord tab_width = tab_size.x;
  293. wxCoord tab_x = in_rect.x;
  294. wxCoord tab_y = in_rect.y + in_rect.height - tab_height;
  295. @@ -360,17 +312,10 @@ void NbStyleFF2::DrawTab(wxDC& dc, wxWindow* wnd,
  296. wxCoord textx;
  297. wxCoord texty;
  298. if (page.active)
  299. -#if wxCHECK_VERSION(3, 0, 0)
  300. dc.SetFont(m_selectedFont);
  301. -#else
  302. - dc.SetFont(m_selected_font);
  303. -#endif
  304. else
  305. -#if wxCHECK_VERSION(3, 0, 0)
  306. dc.SetFont(m_normalFont);
  307. -#else
  308. - dc.SetFont(m_normal_font);
  309. -#endif
  310. +
  311. dc.GetTextExtent(caption, &textx, &texty);
  312. // draw tab text
  313. dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
  314. @@ -380,21 +325,12 @@ void NbStyleFF2::DrawTab(wxDC& dc, wxWindow* wnd,
  315. // draw 'x' on tab (if enabled)
  316. if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
  317. {
  318. -#if wxCHECK_VERSION(3, 0, 0)
  319. int close_button_width = m_activeCloseBmp.GetWidth();
  320. wxBitmap bmp = m_disabledCloseBmp;
  321. -#else
  322. - int close_button_width = m_active_close_bmp.GetWidth();
  323. - wxBitmap bmp = m_disabled_close_bmp;
  324. -#endif
  325. if ((close_button_state == wxAUI_BUTTON_STATE_HOVER) ||
  326. (close_button_state == wxAUI_BUTTON_STATE_PRESSED))
  327. -#if wxCHECK_VERSION(3, 0, 0)
  328. bmp = m_activeCloseBmp;
  329. -#else
  330. - bmp = m_active_close_bmp;
  331. -#endif
  332. wxRect rect(tab_x + tab_width - close_button_width - 3,
  333. drawn_tab_yoff + (drawn_tab_height / 2) - (bmp.GetHeight() / 2),
  334. @@ -421,533 +357,9 @@ int NbStyleFF2::GetBestTabCtrlSize(wxWindow* wnd,
  335. // m_requested_tabctrl_height = -1;
  336. // m_tab_ctrl_height = -1;
  337. wxClientDC dc(wnd);
  338. -#if wxCHECK_VERSION(3, 0, 0)
  339. dc.SetFont(m_measuringFont);
  340. -#else
  341. - dc.SetFont(m_measuring_font);
  342. -#endif
  343. int x_ext = 0;
  344. wxSize s = GetTabSize(dc, wnd, wxT("ABCDEFGHIj"), wxNullBitmap, true,
  345. wxAUI_BUTTON_STATE_HIDDEN, &x_ext);
  346. return s.y + 6;
  347. }
  348. -
  349. -#if defined(__WXGTK__) && (USE_GTK_NOTEBOOK) && !wxCHECK_VERSION(3, 0, 0)
  350. -
  351. -namespace
  352. -{
  353. -
  354. -static GtkWidget *g_window = nullptr;
  355. -static GtkWidget *g_container = nullptr;
  356. -static GtkWidget *g_notebook = nullptr;
  357. -static GtkWidget *g_button = nullptr;
  358. -static int s_CloseIconSize = 16; // default size
  359. -
  360. -static void setup_widget_prototype(GtkWidget* widget)
  361. -{
  362. - if (!g_window)
  363. - {
  364. - g_window = gtk_window_new(GTK_WINDOW_POPUP);
  365. - gtk_widget_realize(g_window);
  366. - }
  367. - if (!g_container)
  368. - {
  369. - g_container = gtk_fixed_new();
  370. - gtk_container_add(GTK_CONTAINER(g_window), g_container);
  371. - }
  372. -
  373. - gtk_container_add(GTK_CONTAINER(g_container), widget);
  374. - gtk_widget_realize(widget);
  375. -}
  376. -
  377. -static GtkStyle * get_style_button()
  378. -{
  379. - if (!g_button)
  380. - {
  381. - g_button = gtk_button_new();
  382. - setup_widget_prototype(g_button);
  383. - }
  384. - return gtk_widget_get_style(g_button);
  385. -}
  386. -
  387. -static GtkStyle * get_style_notebook()
  388. -{
  389. - if (!g_notebook)
  390. - {
  391. - g_notebook = gtk_notebook_new();
  392. - setup_widget_prototype(g_notebook);
  393. - }
  394. - return gtk_widget_get_style(g_notebook);
  395. -}
  396. -
  397. -}
  398. -
  399. -NbStyleGTK::NbStyleGTK():
  400. - m_Xthickness(0),
  401. - m_Ythickness(0),
  402. - m_TabHBorder(0),
  403. - m_TabVBorder(0)
  404. -
  405. -{
  406. -}
  407. -
  408. -wxAuiTabArt* NbStyleGTK::Clone()
  409. -{
  410. - NbStyleGTK* clone = new NbStyleGTK();
  411. -
  412. -#if wxCHECK_VERSION(3, 0, 0)
  413. - clone->SetNormalFont(m_normalFont);
  414. - clone->SetSelectedFont(m_normalFont);
  415. - clone->SetMeasuringFont(m_normalFont);
  416. -#else
  417. - clone->SetNormalFont(m_normal_font);
  418. - clone->SetSelectedFont(m_normal_font);
  419. - clone->SetMeasuringFont(m_normal_font);
  420. -#endif
  421. -
  422. - return clone;
  423. -}
  424. -
  425. -void NbStyleGTK::DrawBackground(wxDC& dc, wxWindow* wnd, const wxRect& rect)
  426. -{
  427. - GtkStyle* style_notebook = get_style_notebook();
  428. - GtkNotebook* notebook = GTK_NOTEBOOK (g_notebook);
  429. -
  430. - // if one of the parameters have changed, the height needs to be recalculated, so we force it,
  431. - if(m_Xthickness != style_notebook->xthickness ||
  432. - m_Ythickness != style_notebook->ythickness ||
  433. - m_TabVBorder != notebook->tab_vborder ||
  434. - m_TabHBorder != notebook->tab_hborder)
  435. - {
  436. - m_Xthickness = style_notebook->xthickness;
  437. - m_Ythickness = style_notebook->ythickness;
  438. - m_TabVBorder = notebook->tab_vborder;
  439. - m_TabHBorder = notebook->tab_hborder;
  440. - wxAuiNotebook* nb = nullptr;
  441. - if(wnd)
  442. - nb = (cbAuiNotebook*)wnd->GetParent();
  443. - if(nb)
  444. - nb->SetTabCtrlHeight(-1);
  445. - }
  446. -#if wxCHECK_VERSION(3, 0, 0)
  447. - wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
  448. - GdkWindow* pWin = impldc->GetGDKWindow();
  449. -#else
  450. - GdkWindow* pWin = dc.GetGDKWindow();
  451. -#endif
  452. - gtk_style_apply_default_background(style_notebook, pWin, 1, GTK_STATE_NORMAL, nullptr,
  453. - rect.x, rect.y, rect.width, rect.height);
  454. -}
  455. -
  456. -void ButtonStateAndShadow(int button_state, GtkStateType &state, GtkShadowType &shadow)
  457. -{
  458. -
  459. - if (button_state & wxAUI_BUTTON_STATE_DISABLED)
  460. - {
  461. - state = GTK_STATE_INSENSITIVE;
  462. - shadow = GTK_SHADOW_ETCHED_IN;
  463. - }
  464. - else if (button_state & wxAUI_BUTTON_STATE_HOVER)
  465. - {
  466. - state = GTK_STATE_PRELIGHT;
  467. - shadow = GTK_SHADOW_OUT;
  468. - }
  469. - else if (button_state & wxAUI_BUTTON_STATE_PRESSED)
  470. - {
  471. - state = GTK_STATE_ACTIVE;
  472. - shadow = GTK_SHADOW_IN;
  473. - }
  474. - else
  475. - {
  476. - state = GTK_STATE_NORMAL;
  477. - shadow = GTK_SHADOW_OUT;
  478. - }
  479. -}
  480. -
  481. -wxRect DrawCloseButton(wxDC& dc,
  482. - GtkWidget *widget,
  483. - int button_state,
  484. - wxRect const &in_rect,
  485. - int orientation,
  486. - GdkRectangle* clipRect)
  487. -{
  488. - GtkStyle *style_button = get_style_button();
  489. - int xthickness = style_button->xthickness;
  490. - int ythickness = style_button->ythickness;
  491. -
  492. - wxBitmap bmp;
  493. - bmp.SetPixbuf(gtk_widget_render_icon(widget, GTK_STOCK_CLOSE, GTK_ICON_SIZE_SMALL_TOOLBAR, "tab"));
  494. -
  495. - if(bmp.GetWidth() != s_CloseIconSize || bmp.GetHeight() != s_CloseIconSize)
  496. - {
  497. - wxImage img = bmp.ConvertToImage();
  498. - img.Rescale(s_CloseIconSize, s_CloseIconSize);
  499. - bmp = img;
  500. - }
  501. -
  502. - int button_size = s_CloseIconSize + 2 * xthickness;
  503. -
  504. - wxRect out_rect;
  505. -
  506. - if (orientation == wxLEFT)
  507. - out_rect.x = in_rect.x - ythickness;
  508. - else
  509. - out_rect.x = in_rect.x + in_rect.width - button_size - ythickness;
  510. -
  511. - out_rect.y = in_rect.y + (in_rect.height - button_size) / 2;
  512. - out_rect.width = button_size;
  513. - out_rect.height = button_size;
  514. -
  515. -#if wxCHECK_VERSION(3, 0, 0)
  516. - wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
  517. - GdkWindow* pWin = impldc->GetGDKWindow();
  518. -#else
  519. - GdkWindow* pWin = dc.GetGDKWindow();
  520. -#endif
  521. -
  522. - if (button_state == wxAUI_BUTTON_STATE_HOVER)
  523. - {
  524. - gtk_paint_box(style_button, pWin,
  525. - GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, clipRect, widget, "button",
  526. - out_rect.x, out_rect.y, out_rect.width, out_rect.height);
  527. - }
  528. - else if (button_state == wxAUI_BUTTON_STATE_PRESSED)
  529. - {
  530. - gtk_paint_box(style_button, pWin,
  531. - GTK_STATE_ACTIVE, GTK_SHADOW_IN, clipRect, widget, "button",
  532. - out_rect.x, out_rect.y, out_rect.width, out_rect.height);
  533. - }
  534. -
  535. -
  536. - dc.DrawBitmap(bmp, out_rect.x + xthickness, out_rect.y + ythickness, true);
  537. -
  538. - return out_rect;
  539. -}
  540. -
  541. -void NbStyleGTK::DrawTab(wxDC& dc, wxWindow* wnd, const wxAuiNotebookPage& page,
  542. - const wxRect& in_rect, int close_button_state, wxRect* out_tab_rect,
  543. - wxRect* out_button_rect, int* x_extent)
  544. -{
  545. - GtkWidget *widget = wnd->GetHandle();
  546. - GtkStyle *style_notebook = get_style_notebook();
  547. -
  548. - wxRect const &window_rect = wnd->GetRect();
  549. -
  550. - int focus_width = 0;
  551. -
  552. - gtk_widget_style_get(g_notebook,
  553. - "focus-line-width", &focus_width,
  554. - NULL);
  555. -
  556. - int tab_pos;
  557. - if (m_flags &wxAUI_NB_BOTTOM)
  558. - tab_pos = wxAUI_NB_BOTTOM;
  559. - else //if (m_flags & wxAUI_NB_TOP) {}
  560. - tab_pos = wxAUI_NB_TOP;
  561. -
  562. - // TODO: else if (m_flags &wxAUI_NB_LEFT) {}
  563. - // TODO: else if (m_flags &wxAUI_NB_RIGHT) {}
  564. -
  565. - // figure out the size of the tab
  566. - wxSize tab_size = GetTabSize(dc, wnd, page.caption, page.bitmap,
  567. - page.active, close_button_state, x_extent);
  568. -
  569. - wxRect tab_rect = in_rect;
  570. - tab_rect.width = tab_size.x;
  571. - tab_rect.height = tab_size.y;
  572. - tab_rect.y += 2 * m_TabHBorder;
  573. -
  574. - if (page.active)
  575. - tab_rect.height += 2 * m_TabHBorder;
  576. -#if wxCHECK_VERSION(3, 0, 0)
  577. - // if no bitmap is set, we need a tiny correction
  578. - if (! page.bitmap.IsOk())
  579. - tab_rect.height += 1;
  580. -#endif
  581. -
  582. - int gap_rect_height = 6 * m_TabHBorder;
  583. - int gap_rect_x = 1, gap_start = 0, gap_width = 0;
  584. - int gap_rect_y = tab_rect.y - gap_rect_height;
  585. - int gap_rect_width = window_rect.width;
  586. -
  587. - switch (tab_pos)
  588. - {
  589. - case wxAUI_NB_TOP:
  590. - tab_rect.y -= 2 * m_TabHBorder;
  591. - if (!page.active)
  592. - tab_rect.y += 2 * m_TabHBorder;
  593. - gap_rect_y = tab_rect.y + tab_rect.height - m_TabHBorder / 2;
  594. - // fall through
  595. - case wxAUI_NB_BOTTOM:
  596. - gap_start = tab_rect.x - m_TabVBorder / 2;
  597. - gap_width = tab_rect.width;
  598. - break;
  599. - default:
  600. - break;
  601. - }
  602. - tab_rect.y += m_TabHBorder / 2;
  603. - gap_rect_y += m_TabHBorder / 2;
  604. -
  605. - int padding = focus_width + m_TabHBorder;
  606. -
  607. - int clip_width = tab_rect.width;
  608. - if (tab_rect.x + tab_rect.width > in_rect.x + in_rect.width)
  609. - clip_width = (in_rect.x + in_rect.width) - tab_rect.x;
  610. -
  611. - dc.SetClippingRegion(tab_rect.x, tab_rect.y - m_TabVBorder, clip_width, tab_rect.height + m_TabVBorder);
  612. -
  613. - GdkRectangle area;
  614. - area.x = tab_rect.x - m_TabVBorder;
  615. - area.y = tab_rect.y - 2 * m_TabHBorder;
  616. - area.width = clip_width + m_TabVBorder;
  617. - area.height = tab_rect.height + 2 * m_TabHBorder;
  618. -
  619. -#if wxCHECK_VERSION(3, 0, 0)
  620. - wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
  621. - GdkWindow* pWin = impldc->GetGDKWindow();
  622. -#else
  623. - GdkWindow* pWin = dc.GetGDKWindow();
  624. -#endif
  625. -
  626. - if (tab_pos == wxAUI_NB_BOTTOM)
  627. - {
  628. - if (page.active)
  629. - {
  630. - gtk_paint_box_gap(style_notebook, pWin, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
  631. - NULL, widget, "notebook",
  632. - gap_rect_x, gap_rect_y,
  633. - gap_rect_width, gap_rect_height,
  634. - GTK_POS_BOTTOM, gap_start , gap_width);
  635. - }
  636. - gtk_paint_extension(style_notebook, pWin,
  637. - page.active ? GTK_STATE_NORMAL : GTK_STATE_ACTIVE, GTK_SHADOW_OUT,
  638. - &area, widget, "tab",
  639. - tab_rect.x, tab_rect.y,
  640. - tab_rect.width, tab_rect.height,
  641. - GTK_POS_TOP);
  642. - }
  643. - else
  644. - {
  645. - if (page.active)
  646. - {
  647. - gtk_paint_box_gap(style_notebook, pWin, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
  648. - NULL, widget, "notebook",
  649. - gap_rect_x, gap_rect_y,
  650. - gap_rect_width, gap_rect_height,
  651. - GTK_POS_TOP, gap_start , gap_width);
  652. - }
  653. - gtk_paint_extension(style_notebook, pWin,
  654. - page.active ? GTK_STATE_NORMAL : GTK_STATE_ACTIVE, GTK_SHADOW_OUT,
  655. - &area, widget, "tab",
  656. - tab_rect.x, tab_rect.y,
  657. - tab_rect.width, tab_rect.height,
  658. - GTK_POS_BOTTOM);
  659. - }
  660. -
  661. - wxCoord textX = tab_rect.x + padding + m_Xthickness;
  662. -
  663. - int bitmap_offset = 0;
  664. - if (page.bitmap.IsOk())
  665. - {
  666. - bitmap_offset = textX;
  667. -
  668. - // draw bitmap
  669. - int bitmapY = tab_rect.y +(tab_rect.height - page.bitmap.GetHeight()) / 2;
  670. - if(!page.active)
  671. - {
  672. - if (tab_pos == wxAUI_NB_TOP)
  673. - bitmapY += m_Ythickness / 2;
  674. - else
  675. - bitmapY -= m_Ythickness / 2;
  676. - }
  677. - dc.DrawBitmap(page.bitmap,
  678. - bitmap_offset,
  679. - bitmapY,
  680. - true);
  681. -
  682. - textX += page.bitmap.GetWidth() + padding;
  683. - }
  684. -
  685. - wxCoord textW, textH, textY;
  686. -
  687. -#if wxCHECK_VERSION(3, 0, 0)
  688. - dc.SetFont(m_normalFont);
  689. -#else
  690. - dc.SetFont(m_normal_font);
  691. -#endif
  692. - dc.GetTextExtent(page.caption, &textW, &textH);
  693. - textY = tab_rect.y + (tab_rect.height - textH) / 2;
  694. - if(!page.active)
  695. - {
  696. - if (tab_pos == wxAUI_NB_TOP)
  697. - textY += m_Ythickness / 2;
  698. - else
  699. - textY -= m_Ythickness / 2;
  700. - }
  701. -
  702. - // draw tab text
  703. - GdkColor text_colour = page.active ? style_notebook->fg[GTK_STATE_NORMAL] : style_notebook->fg[GTK_STATE_ACTIVE];
  704. - dc.SetTextForeground(wxColor(text_colour));
  705. - GdkRectangle focus_area;
  706. -
  707. - int padding_focus = padding - focus_width;
  708. - focus_area.x = tab_rect.x + padding_focus;
  709. - focus_area.y = textY - focus_width;
  710. - focus_area.width = tab_rect.width - 2 * padding_focus;
  711. - focus_area.height = textH + 2 * focus_width;
  712. -
  713. - if(page.active && (wnd->FindFocus() == wnd) && focus_area.x <= (area.x + area.width))
  714. - {
  715. - // clipping seems not to work here, so we we have to recalc the focus-area manually
  716. - if((focus_area.x + focus_area.width) > (area.x + area.width))
  717. - focus_area.width = area.x + area.width - focus_area.x + focus_width - m_TabVBorder;
  718. - gtk_paint_focus (style_notebook, pWin,
  719. - GTK_STATE_ACTIVE, NULL, widget, "tab",
  720. - focus_area.x, focus_area.y, focus_area.width, focus_area.height);
  721. - }
  722. -
  723. - dc.DrawText(page.caption, textX, textY);
  724. -
  725. - // draw close-button on tab (if enabled)
  726. - if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN)
  727. - {
  728. - wxRect rect(tab_rect.x, tab_rect.y, tab_rect.width - m_Xthickness, tab_rect.height);
  729. - if(!page.active)
  730. - {
  731. - if (tab_pos == wxAUI_NB_TOP)
  732. - rect.y += m_Ythickness / 2;
  733. - else
  734. - rect.y -= m_Ythickness / 2;
  735. - }
  736. - *out_button_rect = DrawCloseButton(dc, widget, close_button_state, rect, wxRIGHT, &area);
  737. - }
  738. -
  739. - tab_rect.width = std::min(tab_rect.width, clip_width);
  740. - *out_tab_rect = tab_rect;
  741. -
  742. - dc.DestroyClippingRegion();
  743. -}
  744. -
  745. -wxRect DrawSimpleArrow(wxDC& dc,
  746. - GtkWidget *widget,
  747. - int button_state,
  748. - wxRect const &in_rect,
  749. - int orientation,
  750. - GtkArrowType arrow_type)
  751. -{
  752. - int scroll_arrow_hlength, scroll_arrow_vlength;
  753. - gtk_widget_style_get(widget,
  754. - "scroll-arrow-hlength", &scroll_arrow_hlength,
  755. - "scroll-arrow-vlength", &scroll_arrow_vlength,
  756. - NULL);
  757. -
  758. - GtkStateType state;
  759. - GtkShadowType shadow;
  760. - ButtonStateAndShadow(button_state, state, shadow);
  761. -
  762. - wxRect out_rect;
  763. -
  764. - if (orientation == wxLEFT)
  765. - out_rect.x = in_rect.x;
  766. - else
  767. - out_rect.x = in_rect.x + in_rect.width - scroll_arrow_hlength;
  768. - out_rect.y = (in_rect.y + in_rect.height - 3 * get_style_notebook()->ythickness - scroll_arrow_vlength) / 2;
  769. - out_rect.width = scroll_arrow_hlength;
  770. - out_rect.height = scroll_arrow_vlength;
  771. -
  772. -#if wxCHECK_VERSION(3, 0, 0)
  773. - wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
  774. - GdkWindow* pWin = impldc->GetGDKWindow();
  775. -#else
  776. - GdkWindow* pWin = dc.GetGDKWindow();
  777. -#endif
  778. - gtk_paint_arrow (get_style_button(), pWin, state, shadow, nullptr, widget, "notebook",
  779. - arrow_type, TRUE, out_rect.x, out_rect.y, out_rect.width, out_rect.height);
  780. -
  781. - return out_rect;
  782. -}
  783. -
  784. -void NbStyleGTK::DrawButton(wxDC& dc, wxWindow* wnd,
  785. - const wxRect& in_rect,
  786. - int bitmap_id,
  787. - int button_state,
  788. - int orientation,
  789. - wxRect* out_rect)
  790. -{
  791. - GtkWidget *widget = wnd->GetHandle();
  792. - wxRect rect = in_rect;
  793. - if (m_flags &wxAUI_NB_BOTTOM)
  794. - rect.y += 2 * get_style_button()->ythickness;
  795. -
  796. - switch (bitmap_id)
  797. - {
  798. - case wxAUI_BUTTON_CLOSE:
  799. - rect.y -= 2 * get_style_button()->ythickness;
  800. - rect = DrawCloseButton(dc, widget, button_state, rect, orientation, NULL);
  801. - break;
  802. -
  803. - case wxAUI_BUTTON_LEFT:
  804. - rect = DrawSimpleArrow(dc, widget, button_state, rect, orientation, GTK_ARROW_LEFT);
  805. - break;
  806. -
  807. - case wxAUI_BUTTON_RIGHT:
  808. - rect = DrawSimpleArrow(dc, widget, button_state, rect, orientation, GTK_ARROW_RIGHT);
  809. - break;
  810. -
  811. - case wxAUI_BUTTON_WINDOWLIST:
  812. - {
  813. - rect.height -= 4 * get_style_button()->ythickness;
  814. - rect.width = rect.height;
  815. - rect.x = in_rect.x + in_rect.width - rect.width;
  816. -
  817. - if (button_state == wxAUI_BUTTON_STATE_HOVER)
  818. - wxRendererNative::Get().DrawComboBoxDropButton(wnd, dc, rect, wxCONTROL_CURRENT);
  819. - else if (button_state == wxAUI_BUTTON_STATE_PRESSED)
  820. - wxRendererNative::Get().DrawComboBoxDropButton(wnd, dc, rect, wxCONTROL_PRESSED);
  821. - else
  822. - wxRendererNative::Get().DrawDropArrow(wnd, dc, rect);
  823. - }
  824. - break;
  825. -
  826. - default:
  827. - break;
  828. - }
  829. -
  830. - *out_rect = rect;
  831. -}
  832. -
  833. -
  834. -int NbStyleGTK::GetBestTabCtrlSize(wxWindow* wnd,
  835. - const wxAuiNotebookPageArray& pages,
  836. - const wxSize& required_bmp_size)
  837. -{
  838. -#if wxCHECK_VERSION(3, 0, 0)
  839. - SetMeasuringFont(m_normalFont);
  840. - SetSelectedFont(m_normalFont);
  841. -#else
  842. - SetMeasuringFont(m_normal_font);
  843. - SetSelectedFont(m_normal_font);
  844. -#endif
  845. - int tab_height = 3 * get_style_notebook()->ythickness + wxAuiDefaultTabArt::GetBestTabCtrlSize(wnd, pages, required_bmp_size);
  846. - return tab_height;
  847. -}
  848. -
  849. -wxSize NbStyleGTK::GetTabSize(wxDC& dc,
  850. - wxWindow* wnd,
  851. - const wxString& caption,
  852. - const wxBitmap& bitmap,
  853. - bool active,
  854. - int close_button_state,
  855. - int* x_extent)
  856. -{
  857. - wxSize s = wxAuiDefaultTabArt::GetTabSize(dc, wnd, caption, bitmap, active, close_button_state, x_extent);
  858. -
  859. - int overlap = 0;
  860. - gtk_widget_style_get (wnd->GetHandle(),
  861. - "focus-line-width", &overlap,
  862. - NULL);
  863. - *x_extent -= overlap;
  864. - return s;
  865. -}
  866. -
  867. -#endif // #if defined(__WXGTK__) && (USE_GTK_NOTEBOOK) && !wxCHECK_VERSION(3, 0, 0)
  868. diff --git a/src/src/notebookstyles.h b/src/src/notebookstyles.h
  869. index 1a4942847..36f84139a 100644
  870. --- a/src/src/notebookstyles.h
  871. +++ b/src/src/notebookstyles.h
  872. @@ -8,14 +8,6 @@
  873. #include "cbauibook.h"
  874. -#if defined(__WXGTK__) && (USE_GTK_NOTEBOOK) && !wxCHECK_VERSION(3, 0, 0)
  875. - #define GSocket GLibSocket
  876. - #include <gtk/gtk.h>
  877. - #undef GSocket
  878. - #include <wx/artprov.h>
  879. -#endif
  880. -
  881. -
  882. class wxDC;
  883. class wxWindow;
  884. class wxRect;
  885. @@ -53,35 +45,4 @@ class NbStyleFF2 : public wxAuiDefaultTabArt
  886. const wxSize& required_bmp_size) override;
  887. };
  888. -#if defined(__WXGTK__) && (USE_GTK_NOTEBOOK) && !wxCHECK_VERSION(3, 0, 0)
  889. -class NbStyleGTK : public wxAuiDefaultTabArt
  890. -{
  891. -public:
  892. - NbStyleGTK();
  893. -
  894. - virtual wxAuiTabArt* Clone();
  895. - virtual void DrawBackground(wxDC& dc, wxWindow* wnd, const wxRect& rect);
  896. - virtual void DrawTab(wxDC& dc,
  897. - wxWindow* wnd,
  898. - const wxAuiNotebookPage& page,
  899. - const wxRect& in_rect,
  900. - int close_button_state,
  901. - wxRect* out_tab_rect,
  902. - wxRect* out_button_rect,
  903. - int* x_extent);
  904. - void DrawButton(wxDC& dc, wxWindow* wnd, const wxRect& in_rect, int bitmap_id,
  905. - int button_state, int orientation, wxRect* out_rect);
  906. - int GetBestTabCtrlSize(wxWindow* wnd, const wxAuiNotebookPageArray& pages,
  907. - const wxSize& required_bmp_size);
  908. - virtual wxSize GetTabSize(wxDC& dc, wxWindow* wnd, const wxString& caption, const wxBitmap& bitmap, bool active,
  909. - int close_button_state, int* x_extent);
  910. -private:
  911. - int m_Xthickness;
  912. - int m_Ythickness;
  913. - int m_TabHBorder;
  914. - int m_TabVBorder;
  915. - wxBitmap m_ActiveCloseButton;
  916. -};
  917. -#endif // #if defined(__WXGTK__) && (USE_GTK_NOTEBOOK) && !wxCHECK_VERSION(3, 0, 0)
  918. -
  919. #endif // NOTEBOOKSTYLES_H
  920. diff --git a/src/src/projectmanagerui.cpp b/src/src/projectmanagerui.cpp
  921. index 05718ef60..18b2dcecf 100644
  922. --- a/src/src/projectmanagerui.cpp
  923. +++ b/src/src/projectmanagerui.cpp
  924. @@ -1875,11 +1875,7 @@ struct cbStringHash
  925. {
  926. size_t operator()(const wxString& s) const
  927. {
  928. -#if wxCHECK_VERSION(3, 0, 0)
  929. return std::hash<std::wstring>()(s.ToStdWstring());
  930. -#else
  931. - return std::hash<std::wstring>()(s.wc_str());
  932. -#endif // wxCHECK_VERSION
  933. }
  934. };