Theme engine using TQt for GTK+ 3.x
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tdegtk-draw.cpp 88KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487
  1. /* The TdeGtk Theming Engine for Gtk+.
  2. * Copyright (C) 2012 Timothy Pearson <kb9vqf@pearsoncomputing.net>
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free
  16. * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
  17. * MA 02110-1301, USA.
  18. *
  19. */
  20. #include <cairo.h>
  21. #include <gtk/gtk.h>
  22. #include <math.h>
  23. #include <tqapplication.h>
  24. #include <tqpainter.h>
  25. #include <tqstyle.h>
  26. #include <tqpopupmenu.h>
  27. #include <tqlistview.h>
  28. #include <tqdrawutil.h>
  29. #include <tqslider.h>
  30. #include <kiconloader.h>
  31. #include <kicontheme.h>
  32. #include "tdegtk-cairo-support.h"
  33. #include "tdegtk-draw.h"
  34. #include "tdegtk-support.h"
  35. #include "tdegtk-types.h"
  36. #include "tdegtk-widgetlookup.h"
  37. #include "tdegtk-utils.h"
  38. #include "tdegtk-animations.h"
  39. #include "tqtcairopainter.h"
  40. #define DEBUG_FILL_BACKGROUND_WITH_COLOR(p,x,y,z) TQBrush brush2( TQColor(x,y,z), TQBrush::SolidPattern ); \
  41. p.setBrush( brush2 ); \
  42. p.setPen( TQt::NoPen ); \
  43. p.drawRect( 0,0, width*2,height*2 ); \
  44. p.setBrush(TQt::NoBrush);
  45. #define DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p,x) p.setBrush(x); \
  46. p.setPen(TQt::NoPen); \
  47. p.drawRect(0, 0, width, height); \
  48. p.setBrush(TQt::NoBrush);
  49. #define DRAW_FILLED_RECTANGLE_OVER_SPECIFIC_AREA(p,b,x,y,w,h) p.setBrush(b); \
  50. p.setPen(TQt::NoPen); \
  51. p.drawRect(x, y, w, h); \
  52. p.setBrush(TQt::NoBrush);
  53. extern int m_scrollBarSubLineWidth;
  54. extern bool m_scrollbarBack1;
  55. extern bool m_scrollbarForward1;
  56. extern bool m_scrollbarBack2;
  57. extern bool m_scrollbarForward2;
  58. WidgetLookup m_widgetLookup;
  59. Animations m_animations;
  60. //#define DRAW_SCROLLBAR_PIECES_INSTEAD_OF_ENTIRE_BAR 1
  61. // Keep this in sync with gtkToTQPaletteColorGroup() below
  62. static TQColorGroup gtkToTQtColorGroup(GtkThemingEngine* engine, GtkStateFlags state) {
  63. // GdkRGBA *background_color;
  64. // GdkRGBA *foreground_color;
  65. // gtk_theming_engine_get(engine, state, GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &background_color, NULL);
  66. // gtk_theming_engine_get(engine, state, GTK_STYLE_PROPERTY_COLOR, &foreground_color, NULL);
  67. // GTK_STATE_FLAG_ACTIVE
  68. // GTK_STATE_FLAG_PRELIGHT
  69. // GTK_STATE_FLAG_SELECTED
  70. // GTK_STATE_FLAG_INSENSITIVE
  71. // GTK_STATE_FLAG_INCONSISTENT
  72. // GTK_STATE_FLAG_FOCUSED
  73. TQColorGroup cg;
  74. // if (state & GTK_STATE_FLAG_INCONSISTENT) {
  75. // cg = tqApp->palette().inactive();
  76. // }
  77. /*else*/ if (state & GTK_STATE_FLAG_INSENSITIVE) {
  78. cg = tqApp->palette().disabled();
  79. }
  80. else {
  81. cg = tqApp->palette().active();
  82. }
  83. // cg.setColor(TQColorGroup::Background, TQColor((background_color->red*255.0),(background_color->green*255.0),(background_color->blue*255.0)));
  84. // cg.setColor(TQColorGroup::Foreground, TQColor((foreground_color->red*255.0),(foreground_color->green*255.0),(foreground_color->blue*255.0)));
  85. return cg;
  86. }
  87. // Keep this in sync with gtkToTQtColorGroup() above
  88. static TQPalette::ColorGroup gtkToTQPaletteColorGroup(GtkThemingEngine* engine, GtkStateFlags state) {
  89. TQPalette::ColorGroup cg = TQPalette::Active;
  90. if (state & GTK_STATE_FLAG_INSENSITIVE) {
  91. cg = TQPalette::Disabled;
  92. }
  93. else {
  94. cg = TQPalette::Active;
  95. }
  96. return cg;
  97. }
  98. static TQStyle::SFlags gtkToTQtStyleFlags(GtkThemingEngine* engine, GtkStateFlags state, TQt3WidgetType wt, GtkWidget* widget) {
  99. TQStyle::SFlags sflags = TQStyle::Style_Default;
  100. gboolean active, inconsistent, mousedown, prelight, focused, disabled, in_menu, has_focus;
  101. in_menu = gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUITEM);
  102. prelight = (state & GTK_STATE_FLAG_PRELIGHT) != 0;
  103. focused = (state & GTK_STATE_FLAG_FOCUSED) != 0;
  104. disabled = (state & GTK_STATE_FLAG_INSENSITIVE) != 0;
  105. inconsistent = (state & GTK_STATE_FLAG_INCONSISTENT) != 0;
  106. mousedown = (state & GTK_STATE_FLAG_SELECTED) != 0;
  107. active = (state & GTK_STATE_FLAG_ACTIVE) != 0;
  108. has_focus = gtk_widget_has_visible_focus(widget);
  109. if ((wt == TQT3WT_TQRadioButton) || (wt == TQT3WT_TQCheckBox) || (wt == TQT3WT_TQPushButton)) {
  110. GtkCheckButton* checkButton = (widget)?((GTK_IS_CHECK_BUTTON(widget))?GTK_CHECK_BUTTON(widget):0L):0L;
  111. if ((!inconsistent) && (!mousedown)) {
  112. if (active) {
  113. sflags |= TQStyle::Style_On;
  114. }
  115. else {
  116. sflags |= TQStyle::Style_Off;
  117. }
  118. }
  119. if (mousedown) {
  120. sflags |= TQStyle::Style_Down;
  121. if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkButton))) {
  122. sflags |= TQStyle::Style_On;
  123. }
  124. }
  125. if (prelight) {
  126. sflags |= TQStyle::Style_MouseOver;
  127. }
  128. if (focused) {
  129. sflags |= TQStyle::Style_HasFocus;
  130. }
  131. if (!disabled) {
  132. sflags |= TQStyle::Style_Enabled;
  133. }
  134. if (has_focus) {
  135. sflags |= TQStyle::Style_HasFocus;
  136. }
  137. }
  138. else if (wt == TQT3WT_TQToolButton) {
  139. if (!inconsistent) {
  140. if (active) {
  141. sflags |= TQStyle::Style_On;
  142. }
  143. else {
  144. sflags |= TQStyle::Style_Off;
  145. }
  146. }
  147. if (mousedown) {
  148. sflags |= TQStyle::Style_Down;
  149. }
  150. if (prelight) {
  151. sflags |= TQStyle::Style_MouseOver;
  152. sflags |= TQStyle::Style_Raised;
  153. }
  154. if (focused) {
  155. sflags |= TQStyle::Style_HasFocus;
  156. }
  157. if (!disabled) {
  158. sflags |= TQStyle::Style_Enabled;
  159. }
  160. if (has_focus) {
  161. sflags |= TQStyle::Style_HasFocus;
  162. }
  163. }
  164. else if (wt == TQT3WT_GTKTreeViewCell) {
  165. if (!inconsistent) {
  166. if (active) {
  167. sflags |= TQStyle::Style_On;
  168. }
  169. else {
  170. sflags |= TQStyle::Style_Off;
  171. }
  172. }
  173. if (prelight) {
  174. sflags |= TQStyle::Style_MouseOver;
  175. }
  176. if (focused) {
  177. sflags |= TQStyle::Style_HasFocus;
  178. }
  179. if (!disabled) {
  180. sflags |= TQStyle::Style_Enabled;
  181. }
  182. if (has_focus) {
  183. sflags |= TQStyle::Style_HasFocus;
  184. }
  185. }
  186. else if (wt == TQT3WT_TQGroupBox) {
  187. if (prelight) {
  188. sflags |= TQStyle::Style_MouseOver;
  189. }
  190. if (focused) {
  191. sflags |= TQStyle::Style_HasFocus;
  192. }
  193. if (!disabled) {
  194. sflags |= TQStyle::Style_Enabled;
  195. }
  196. if (has_focus) {
  197. sflags |= TQStyle::Style_HasFocus;
  198. }
  199. }
  200. else if (wt == TQT3WT_TQMenuItem) {
  201. if (prelight) {
  202. sflags |= TQStyle::Style_MouseOver;
  203. }
  204. if (focused) {
  205. sflags |= TQStyle::Style_HasFocus;
  206. }
  207. if (!disabled) {
  208. sflags |= TQStyle::Style_Enabled;
  209. }
  210. if (has_focus) {
  211. sflags |= TQStyle::Style_HasFocus;
  212. }
  213. }
  214. else if (wt == TQT3WT_TQSlider) {
  215. if (active) {
  216. sflags |= TQStyle::Style_Active;
  217. }
  218. if (prelight) {
  219. sflags |= TQStyle::Style_MouseOver;
  220. }
  221. if (focused) {
  222. sflags |= TQStyle::Style_HasFocus;
  223. }
  224. if (!disabled) {
  225. sflags |= TQStyle::Style_Enabled;
  226. }
  227. if (has_focus) {
  228. sflags |= TQStyle::Style_HasFocus;
  229. }
  230. }
  231. else if (wt == TQT3WT_TQScrollBar) {
  232. if (active) {
  233. sflags |= TQStyle::Style_Active;
  234. }
  235. if (prelight) {
  236. sflags |= TQStyle::Style_MouseOver;
  237. }
  238. if (focused) {
  239. sflags |= TQStyle::Style_HasFocus;
  240. }
  241. if (!disabled) {
  242. sflags |= TQStyle::Style_Enabled;
  243. }
  244. if (has_focus) {
  245. sflags |= TQStyle::Style_HasFocus;
  246. }
  247. }
  248. else if (wt == TQT3WT_TQLineEdit) {
  249. if (active) {
  250. sflags |= TQStyle::Style_Down;
  251. }
  252. if (prelight) {
  253. sflags |= TQStyle::Style_MouseOver;
  254. }
  255. if (focused) {
  256. sflags |= TQStyle::Style_HasFocus;
  257. }
  258. if (!disabled) {
  259. sflags |= TQStyle::Style_Enabled;
  260. }
  261. if (has_focus) {
  262. sflags |= TQStyle::Style_HasFocus;
  263. }
  264. sflags |= TQStyle::Style_Sunken;
  265. }
  266. else {
  267. if (active) {
  268. sflags |= TQStyle::Style_Down;
  269. }
  270. if (prelight) {
  271. sflags |= TQStyle::Style_MouseOver;
  272. }
  273. if (focused) {
  274. sflags |= TQStyle::Style_HasFocus;
  275. }
  276. if (!disabled) {
  277. sflags |= TQStyle::Style_Enabled;
  278. }
  279. if (has_focus) {
  280. sflags |= TQStyle::Style_HasFocus;
  281. }
  282. }
  283. return sflags;
  284. }
  285. static TQColorGroup::ColorRole backgroundModeToColorRole(TQt::BackgroundMode mode) {
  286. TQColorGroup::ColorRole ret = TQColorGroup::Background;
  287. if (mode == TQt::PaletteForeground) {
  288. ret = TQColorGroup::Foreground;
  289. }
  290. else if (mode == TQt::PaletteBackground) {
  291. ret = TQColorGroup::Background;
  292. }
  293. else if (mode == TQt::PaletteButton) {
  294. ret = TQColorGroup::Button;
  295. }
  296. else if (mode == TQt::PaletteLight) {
  297. ret = TQColorGroup::Light;
  298. }
  299. else if (mode == TQt::PaletteMidlight) {
  300. ret = TQColorGroup::Midlight;
  301. }
  302. else if (mode == TQt::PaletteDark) {
  303. ret = TQColorGroup::Dark;
  304. }
  305. else if (mode == TQt::PaletteMid) {
  306. ret = TQColorGroup::Mid;
  307. }
  308. else if (mode == TQt::PaletteText) {
  309. ret = TQColorGroup::Text;
  310. }
  311. else if (mode == TQt::PaletteBrightText) {
  312. ret = TQColorGroup::BrightText;
  313. }
  314. else if (mode == TQt::PaletteButtonText) {
  315. ret = TQColorGroup::ButtonText;
  316. }
  317. else if (mode == TQt::PaletteBase) {
  318. ret = TQColorGroup::Base;
  319. }
  320. else if (mode == TQt::PaletteShadow) {
  321. ret = TQColorGroup::Shadow;
  322. }
  323. else if (mode == TQt::PaletteHighlight) {
  324. ret = TQColorGroup::Highlight;
  325. }
  326. else if (mode == TQt::PaletteHighlightedText) {
  327. ret = TQColorGroup::HighlightedText;
  328. }
  329. else if (mode == TQt::PaletteLink) {
  330. ret = TQColorGroup::Link;
  331. }
  332. else if (mode == TQt::PaletteLinkVisited) {
  333. ret = TQColorGroup::LinkVisited;
  334. }
  335. return ret;
  336. }
  337. void gtkRangeToCeData(GtkRange* rangeWidget, TQStyleControlElementData &ceData) {
  338. gint slider_start_pos;
  339. gint slider_end_pos;
  340. GtkAdjustment* adjustment = gtk_range_get_adjustment(rangeWidget);
  341. gtk_range_get_slider_range(rangeWidget, &slider_start_pos, &slider_end_pos);
  342. ceData.minSteps = gtk_adjustment_get_lower(adjustment);
  343. ceData.maxSteps = gtk_adjustment_get_upper(adjustment);
  344. // ceData.tickMarkSetting =
  345. // ceData.tickInterval =
  346. ceData.currentStep = gtk_adjustment_get_value(adjustment);
  347. ceData.startStep = slider_start_pos;
  348. ceData.lineStep = gtk_adjustment_get_step_increment(adjustment);
  349. ceData.pageStep = gtk_adjustment_get_page_increment(adjustment);
  350. }
  351. void gtkScaleToSliderCeData(GtkScale* scaleWidget, TQStyleControlElementData &ceData) {
  352. gtkRangeToCeData(GTK_RANGE(scaleWidget), ceData);
  353. // GtkPositionType valuePosition = gtk_scale_get_value_pos(scaleWidget);
  354. // if (valuePosition == GTK_POS_LEFT) {
  355. // ceData.tickMarkSetting = TQSlider::Left;
  356. // }
  357. // else if (valuePosition == GTK_POS_RIGHT) {
  358. // ceData.tickMarkSetting = TQSlider::Right;
  359. // }
  360. // else if (valuePosition == GTK_POS_TOP) {
  361. // ceData.tickMarkSetting = TQSlider::Above;
  362. // }
  363. // else if (valuePosition == GTK_POS_BOTTOM) {
  364. // ceData.tickMarkSetting = TQSlider::Below;
  365. // }
  366. // else {
  367. ceData.tickMarkSetting = TQSlider::NoMarks;
  368. // }
  369. }
  370. void gtkScrollbarToScrollbarCeData(GtkScrollbar* scrollbarWidget, TQStyleControlElementData &ceData) {
  371. GtkRange* rangeWidget = GTK_RANGE(scrollbarWidget);
  372. gtkRangeToCeData(rangeWidget, ceData);
  373. gint slider_start_pos;
  374. gint slider_end_pos;
  375. GtkAdjustment* adjustment = gtk_range_get_adjustment(rangeWidget);
  376. gtk_range_get_slider_range(rangeWidget, &slider_start_pos, &slider_end_pos);
  377. ceData.minSteps = gtk_adjustment_get_lower(adjustment);
  378. ceData.maxSteps = (gtk_adjustment_get_upper(adjustment)-(gtk_adjustment_get_page_increment(adjustment)+gtk_adjustment_get_step_increment(adjustment)));
  379. ceData.currentStep = gtk_adjustment_get_value(adjustment);
  380. ceData.startStep = slider_start_pos;
  381. ceData.lineStep = gtk_adjustment_get_step_increment(adjustment);
  382. ceData.pageStep = gtk_adjustment_get_page_increment(adjustment);
  383. // Convert the GTK slider length into a correct pagestep that TQt3 can use to obtain the same slider length value
  384. bool threeButtonScrollBar = false;
  385. if (m_scrollbarForward1 | m_scrollbarBack2) threeButtonScrollBar = true;
  386. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  387. int gtkSliderLength = slider_end_pos - slider_start_pos;
  388. uint range = ceData.maxSteps - ceData.minSteps;
  389. // HACK
  390. // GTK3 does not handle odd-sized steppers correctly
  391. if ((m_scrollBarSubLineWidth % 2) != 0) {
  392. gtkSliderLength = gtkSliderLength + 4;
  393. }
  394. int sbextent = tqApp->style().pixelMetric(TQStyle::PM_ScrollBarExtent, ceData, elementFlags, NULL);
  395. int maxlen = ((ceData.orientation == TQt::Horizontal) ? ceData.rect.width() : ceData.rect.height()) - (sbextent * (threeButtonScrollBar ? 3.0 : 2.0));
  396. int gtkPageStep=ceil((-1.0)*(range*gtkSliderLength)/(gtkSliderLength-maxlen));
  397. ceData.pageStep = gtkPageStep;
  398. }
  399. static void
  400. draw_combobox_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, GtkWidget* widget) {
  401. cairo_save(cr);
  402. cairo_matrix_t gtk_matrix;
  403. cairo_get_matrix(cr, &gtk_matrix);
  404. gtk_matrix.x0 = 0;
  405. gtk_matrix.y0 = 0;
  406. cairo_set_matrix(cr, &gtk_matrix);
  407. GtkWidget* parent(widget?gtk_widget_get_parent(widget):0L);
  408. if (GTK_IS_COMBO_BOX(parent)) {
  409. const GtkAllocation allocation = Gtk::gtk_widget_get_allocation(parent);
  410. TQRect boundingRect(0, 0, allocation.width, allocation.height);
  411. TQt3CairoPaintDevice pd2(NULL, allocation.x, allocation.y, allocation.width, allocation.height, cr);
  412. TQPainter p2(&pd2);
  413. TQStringList objectTypes;
  414. objectTypes.append(TQCOMBOBOX_OBJECT_NAME_STRING);
  415. TQPalette objectPalette = tqApp->palette(objectTypes);
  416. TQStyleControlElementData ceData;
  417. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  418. ceData.widgetObjectTypes = objectTypes;
  419. ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal;
  420. if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY)) {
  421. elementFlags = elementFlags | TQStyle::CEF_IsEditable;
  422. }
  423. ceData.rect = boundingRect;
  424. if (gtk_widget_has_visible_focus(widget)) {
  425. elementFlags = elementFlags | TQStyle::CEF_HasFocus;
  426. }
  427. // Draw item
  428. //tqApp->style().drawComplexControl(TQStyle::CC_ComboBox, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget), TQStyle::SC_ComboBoxFrame, TQStyle::SC_None);
  429. tqApp->style().drawComplexControl(TQStyle::CC_ComboBox, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget), TQStyle::SC_All, TQStyle::SC_None);
  430. }
  431. cairo_restore(cr);
  432. }
  433. static void
  434. draw_progressbar_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, GtkWidget* widget) {
  435. cairo_save(cr);
  436. cairo_matrix_t gtk_matrix;
  437. cairo_get_matrix(cr, &gtk_matrix);
  438. gtk_matrix.x0 = 0;
  439. gtk_matrix.y0 = 0;
  440. cairo_set_matrix(cr, &gtk_matrix);
  441. if (GTK_IS_PROGRESS_BAR(widget)) {
  442. const GtkAllocation allocation = Gtk::gtk_widget_get_allocation(widget);
  443. TQRect boundingRect(0, 0, allocation.width, allocation.height);
  444. TQt3CairoPaintDevice pd2(NULL, allocation.x, allocation.y, allocation.width, allocation.height, cr);
  445. TQPainter p2(&pd2);
  446. TQStringList objectTypes;
  447. objectTypes.append(TQPROGRESSBAR_OBJECT_NAME_STRING);
  448. TQPalette objectPalette = tqApp->palette(objectTypes);
  449. TQStyleControlElementData ceData;
  450. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  451. ceData.widgetObjectTypes = objectTypes;
  452. ceData.rect = boundingRect;
  453. ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal;
  454. GtkProgressBar* progressBar = GTK_PROGRESS_BAR(widget);
  455. gdouble gtkProgressBarFraction = gtk_progress_bar_get_fraction(progressBar);
  456. ceData.totalSteps = 8192;
  457. ceData.currentStep = gtkProgressBarFraction*8192;
  458. ceData.percentageVisible = false;
  459. TQStyle::SFlags sflags = gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget);
  460. sflags = sflags | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default);
  461. TQRect progressBarGrooveRect;
  462. TQRect progressBarContentsRect;
  463. if (gtk_widget_has_visible_focus(widget)) {
  464. elementFlags = elementFlags | TQStyle::CEF_HasFocus;
  465. }
  466. // Draw background
  467. TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Base);
  468. DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p2, brush)
  469. // Draw frame
  470. progressBarGrooveRect = TQStyle::visualRect(tqApp->style().subRect(TQStyle::SR_ProgressBarGroove, ceData, elementFlags, NULL), ceData, elementFlags);
  471. progressBarContentsRect = TQStyle::visualRect(tqApp->style().subRect(TQStyle::SR_ProgressBarContents, ceData, elementFlags, NULL), ceData, elementFlags);
  472. tqApp->style().drawControl(TQStyle::CE_ProgressBarGroove, &p2, ceData, elementFlags, progressBarGrooveRect, ((state & GTK_STATE_FLAG_INSENSITIVE)?objectPalette.disabled():objectPalette.active()), sflags);
  473. // Draw contents
  474. if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL)) {
  475. // If vertical, apply a 90 degree rotation matrix to the painter
  476. // This is required to make TQt draw a vertical progress bar
  477. TQWMatrix m;
  478. // // Upside down
  479. // m.rotate(90.0);
  480. // m.translate(0, (allocation.width)*(-1.0));
  481. // Right side up
  482. m.rotate(-90.0);
  483. m.translate((allocation.height)*(-1.0), 0);
  484. p2.setWorldMatrix(m, TRUE);
  485. boundingRect = TQRect(0, 0, allocation.height, allocation.width);
  486. ceData.rect = boundingRect;
  487. }
  488. progressBarGrooveRect = TQStyle::visualRect(tqApp->style().subRect(TQStyle::SR_ProgressBarGroove, ceData, elementFlags, NULL), ceData, elementFlags);
  489. progressBarContentsRect = TQStyle::visualRect(tqApp->style().subRect(TQStyle::SR_ProgressBarContents, ceData, elementFlags, NULL), ceData, elementFlags);
  490. tqApp->style().drawControl(TQStyle::CE_ProgressBarContents, &p2, ceData, elementFlags, progressBarContentsRect, ((state & GTK_STATE_FLAG_INSENSITIVE)?objectPalette.disabled():objectPalette.active()), sflags);
  491. }
  492. cairo_restore(cr);
  493. }
  494. static void
  495. draw_slider_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, GtkWidget* widget) {
  496. cairo_save(cr);
  497. cairo_matrix_t gtk_matrix;
  498. cairo_get_matrix(cr, &gtk_matrix);
  499. gtk_matrix.x0 = 0;
  500. gtk_matrix.y0 = 0;
  501. cairo_set_matrix(cr, &gtk_matrix);
  502. if (GTK_IS_SCALE(widget)) {
  503. const GtkAllocation allocation = Gtk::gtk_widget_get_allocation(widget);
  504. GdkRectangle rangeRect;
  505. gtk_range_get_range_rect(GTK_RANGE(widget), &rangeRect);
  506. TQRect boundingRect(0, 0, rangeRect.width, rangeRect.height);
  507. TQt3CairoPaintDevice pd2(NULL, allocation.x + rangeRect.x, allocation.y + rangeRect.y, rangeRect.width, rangeRect.height, cr);
  508. TQPainter p2(&pd2);
  509. bool mousedown = (state & GTK_STATE_FLAG_ACTIVE) != 0;
  510. bool prelight = (state & GTK_STATE_FLAG_PRELIGHT) != 0;
  511. GtkScale* scaleWidget = GTK_SCALE(widget);
  512. TQStringList objectTypes;
  513. objectTypes.append(TQSLIDER_OBJECT_NAME_STRING);
  514. TQPalette objectPalette = tqApp->palette(objectTypes);
  515. TQStyleControlElementData ceData;
  516. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  517. ceData.widgetObjectTypes = objectTypes;
  518. ceData.rect = boundingRect;
  519. ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal;
  520. gtkScaleToSliderCeData(scaleWidget, ceData);
  521. if (gtk_widget_has_visible_focus(widget)) {
  522. elementFlags = elementFlags | TQStyle::CEF_HasFocus;
  523. }
  524. if (mousedown) {
  525. elementFlags = elementFlags | TQStyle::CEF_IsActive;
  526. }
  527. if (prelight) {
  528. elementFlags = elementFlags | TQStyle::CEF_HasMouse;
  529. }
  530. // Draw item
  531. tqApp->style().drawComplexControl(TQStyle::CC_Slider, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQSlider, widget) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default), TQStyle::SC_All, ((mousedown)?TQStyle::SC_All:TQStyle::SC_None));
  532. }
  533. cairo_restore(cr);
  534. }
  535. TQStyle::SubControl lastSliderActiveSubControl = TQStyle::SC_None;
  536. static void
  537. draw_scrollbar_frame(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, GtkWidget* widget) {
  538. cairo_save(cr);
  539. cairo_matrix_t gtk_matrix;
  540. cairo_get_matrix(cr, &gtk_matrix);
  541. gtk_matrix.x0 = 0;
  542. gtk_matrix.y0 = 0;
  543. cairo_set_matrix(cr, &gtk_matrix);
  544. if (GTK_IS_SCROLLBAR(widget)) {
  545. const GtkAllocation allocation = Gtk::gtk_widget_get_allocation(widget);
  546. GdkRectangle rangeRect;
  547. gtk_range_get_range_rect(GTK_RANGE(widget), &rangeRect);
  548. TQRect boundingRect(0, 0, rangeRect.width, rangeRect.height);
  549. TQt3CairoPaintDevice pd2(NULL, allocation.x + rangeRect.x, allocation.y + rangeRect.y, rangeRect.width, rangeRect.height, cr);
  550. TQPainter p2(&pd2);
  551. GtkStateFlags widgetStateFlags = gtk_widget_get_state_flags(widget);
  552. bool prelight = (state & GTK_STATE_FLAG_PRELIGHT) != 0;
  553. GtkScrollbar* scrollbarWidget = GTK_SCROLLBAR(widget);
  554. TQStringList objectTypes;
  555. objectTypes.append(TQSLIDER_OBJECT_NAME_STRING);
  556. TQPalette objectPalette = tqApp->palette(objectTypes);
  557. TQStyleControlElementData ceData;
  558. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  559. ceData.widgetObjectTypes = objectTypes;
  560. ceData.rect = boundingRect;
  561. ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal;
  562. gtkScrollbarToScrollbarCeData(scrollbarWidget, ceData);
  563. if (gtk_widget_has_visible_focus(widget)) {
  564. elementFlags = elementFlags | TQStyle::CEF_HasFocus;
  565. }
  566. if (prelight) {
  567. elementFlags = elementFlags | TQStyle::CEF_HasMouse;
  568. }
  569. TQStyle::SFlags sflags = gtkToTQtStyleFlags(engine, state, TQT3WT_TQScrollBar, widget);
  570. sflags = sflags | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default);
  571. if (gtk_widget_get_sensitive(widget)) {
  572. sflags |= TQStyle::Style_Enabled;
  573. state = (GtkStateFlags)(state & (~GTK_STATE_FLAG_INSENSITIVE));
  574. }
  575. else {
  576. sflags &= ~TQStyle::Style_Enabled;
  577. state = (GtkStateFlags)(state | GTK_STATE_FLAG_INSENSITIVE);
  578. }
  579. sflags &= ~TQStyle::Style_On;
  580. sflags &= ~TQStyle::Style_Down;
  581. sflags &= ~TQStyle::Style_Active;
  582. // Determine active subcontrols
  583. gint cursor_x = -1;
  584. gint cursor_y = -1;
  585. TQStyle::SubControl activeSubControl = TQStyle::SC_None;
  586. if (gtk_widget_get_realized(widget)) {
  587. GdkDevice *device;
  588. device = gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(gtk_widget_get_display(widget)));
  589. gdk_window_get_device_position(gtk_widget_get_window(widget), device, &cursor_x, &cursor_y, NULL);
  590. cursor_x = cursor_x - allocation.x;
  591. cursor_y = cursor_y - allocation.y;
  592. TQPoint cursor_pos(cursor_x, cursor_y);
  593. TQRect addline, subline, addpage, subpage, slider, first, last;
  594. subline = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, ceData, elementFlags, TQStyle::SC_ScrollBarSubLine);
  595. addline = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, ceData, elementFlags, TQStyle::SC_ScrollBarAddLine);
  596. subpage = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, ceData, elementFlags, TQStyle::SC_ScrollBarSubPage);
  597. addpage = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, ceData, elementFlags, TQStyle::SC_ScrollBarAddPage);
  598. slider = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, ceData, elementFlags, TQStyle::SC_ScrollBarSlider);
  599. first = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, ceData, elementFlags, TQStyle::SC_ScrollBarFirst);
  600. last = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, ceData, elementFlags, TQStyle::SC_ScrollBarLast);
  601. bool threeButtonScrollBar = false;
  602. if (m_scrollbarForward1 | m_scrollbarBack2) threeButtonScrollBar = true;
  603. if (threeButtonScrollBar) {
  604. if (ceData.orientation == TQt::Horizontal) {
  605. addline = TQRect(allocation.width-(subline.width()*2), subline.y(), subline.width()*2, subline.height());
  606. }
  607. else {
  608. addline = TQRect(subline.x(), allocation.height-(subline.height()*2), subline.width(), subline.height()*2);
  609. }
  610. }
  611. // HACK
  612. // This may not be 100% reliable!
  613. GdkModifierType mouseStateFlags;
  614. gdk_device_get_state (device, gtk_widget_get_window(widget), NULL, &mouseStateFlags);
  615. bool mousedown = (mouseStateFlags & GDK_BUTTON1_MASK);
  616. if (mousedown) {
  617. if (lastSliderActiveSubControl != TQStyle::SC_None) {
  618. activeSubControl = (TQStyle::SubControl)(activeSubControl | lastSliderActiveSubControl);
  619. }
  620. else {
  621. if (subline.contains(cursor_pos)) {
  622. activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarSubLine);
  623. lastSliderActiveSubControl = TQStyle::SC_ScrollBarSubLine;
  624. }
  625. else if (addline.contains(cursor_pos)) {
  626. if (threeButtonScrollBar) {
  627. // Not so fast...the addline region may contain a subline control!
  628. TQRect internalSubLine;
  629. if (ceData.orientation == TQt::Horizontal) {
  630. internalSubLine = TQRect(addline.x(), addline.y(), addline.width()/2, addline.height());
  631. }
  632. else {
  633. internalSubLine = TQRect(addline.x(), addline.y(), addline.width(), addline.height()/2);
  634. }
  635. if (internalSubLine.contains(cursor_pos)) {
  636. activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarSubLine);
  637. lastSliderActiveSubControl = TQStyle::SC_ScrollBarSubLine;
  638. }
  639. else {
  640. activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarAddLine);
  641. lastSliderActiveSubControl = TQStyle::SC_ScrollBarAddLine;
  642. }
  643. }
  644. else {
  645. activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarAddLine);
  646. lastSliderActiveSubControl = TQStyle::SC_ScrollBarAddLine;
  647. }
  648. }
  649. else if (subpage.contains(cursor_pos)) {
  650. activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarSubPage);
  651. lastSliderActiveSubControl = TQStyle::SC_ScrollBarSubPage;
  652. }
  653. else if (addpage.contains(cursor_pos)) {
  654. activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarAddPage);
  655. lastSliderActiveSubControl = TQStyle::SC_ScrollBarAddPage;
  656. }
  657. else if (slider.contains(cursor_pos)) {
  658. activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarSlider);
  659. lastSliderActiveSubControl = TQStyle::SC_ScrollBarSlider;
  660. }
  661. else if (first.contains(cursor_pos)) {
  662. activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarFirst);
  663. lastSliderActiveSubControl = TQStyle::SC_ScrollBarFirst;
  664. }
  665. else if (last.contains(cursor_pos)) {
  666. activeSubControl = (TQStyle::SubControl)(activeSubControl | TQStyle::SC_ScrollBarLast);
  667. lastSliderActiveSubControl = TQStyle::SC_ScrollBarLast;
  668. }
  669. }
  670. }
  671. else {
  672. lastSliderActiveSubControl = TQStyle::SC_None;
  673. }
  674. }
  675. // Draw item
  676. tqApp->style().drawComplexControl(TQStyle::CC_ScrollBar, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), sflags, TQStyle::SC_All, activeSubControl);
  677. }
  678. cairo_restore(cr);
  679. }
  680. static void
  681. draw_checkbox(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, GtkWidget* widget, TQt3WidgetType tqt3WidgetType) {
  682. TQStringList objectTypes;
  683. objectTypes.append(TQCHECKBOX_OBJECT_NAME_STRING);
  684. TQPalette objectPalette = tqApp->palette(objectTypes);
  685. TQRect boundingRect(0, 0, width, height);
  686. TQt3CairoPaintDevice pd2(NULL, x, y, width, height, cr);
  687. TQPainter p2(&pd2);
  688. TQStyleControlElementData ceData;
  689. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  690. ceData.widgetObjectTypes = objectTypes;
  691. ceData.rect = boundingRect;
  692. if (gtk_widget_has_visible_focus(widget)) {
  693. elementFlags = elementFlags | TQStyle::CEF_HasFocus;
  694. }
  695. // Draw item
  696. tqApp->style().drawControl(TQStyle::CE_CheckBox, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, tqt3WidgetType, widget));
  697. }
  698. static void
  699. draw_radiobutton(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, GtkWidget* widget, TQt3WidgetType tqt3WidgetType) {
  700. TQStringList objectTypes;
  701. objectTypes.append(TQCHECKBOX_OBJECT_NAME_STRING);
  702. TQPalette objectPalette = tqApp->palette(objectTypes);
  703. TQRect boundingRect(0, 0, width, height);
  704. TQt3CairoPaintDevice pd2(NULL, x, y, width, height, cr);
  705. TQPainter p2(&pd2);
  706. TQStyleControlElementData ceData;
  707. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  708. ceData.widgetObjectTypes = objectTypes;
  709. ceData.rect = boundingRect;
  710. if (gtk_widget_has_visible_focus(widget)) {
  711. elementFlags = elementFlags | TQStyle::CEF_HasFocus;
  712. }
  713. // Draw item
  714. tqApp->style().drawControl(TQStyle::CE_RadioButton, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, tqt3WidgetType, widget));
  715. }
  716. static void
  717. draw_pushbutton(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, GtkWidget* widget, TQt3WidgetType tqt3WidgetType) {
  718. TQStringList objectTypes;
  719. objectTypes.append(TQCHECKBOX_OBJECT_NAME_STRING);
  720. TQPalette objectPalette = tqApp->palette(objectTypes);
  721. TQRect boundingRect(0, 0, width, height);
  722. TQt3CairoPaintDevice pd2(NULL, x, y, width, height, cr);
  723. TQPainter p2(&pd2);
  724. TQStyleControlElementData ceData;
  725. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  726. ceData.widgetObjectTypes = objectTypes;
  727. ceData.rect = boundingRect;
  728. if (gtk_widget_has_default(widget)) {
  729. elementFlags = elementFlags | TQStyle::CEF_IsDefault;
  730. }
  731. if (gtk_widget_has_visible_focus(widget)) {
  732. elementFlags = elementFlags | TQStyle::CEF_HasFocus;
  733. }
  734. // Draw item
  735. tqApp->style().drawControl(TQStyle::CE_PushButton, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, tqt3WidgetType, widget));
  736. }
  737. static void
  738. draw_toolbar_button(DRAW_ARGS, const GtkWidgetPath* path, GtkStateFlags state, GtkWidget* widget, TQt3WidgetType tqt3WidgetType) {
  739. bool mousedown = (state & GTK_STATE_FLAG_ACTIVE) != 0;
  740. TQStringList objectTypes;
  741. objectTypes.append(TQTOOLBUTTON_OBJECT_NAME_STRING);
  742. TQPalette objectPalette = tqApp->palette(objectTypes);
  743. TQStyleControlElementData ceData;
  744. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  745. ceData.widgetObjectTypes = objectTypes;
  746. ceData.colorGroup = ((state & GTK_STATE_FLAG_INSENSITIVE)?objectPalette.disabled():objectPalette.active());
  747. ceData.orientation = TQt::Horizontal;
  748. TQRect boundingRect(0, 0, width, height);
  749. TQt3CairoPaintDevice pd2(NULL, x, y, width, height, cr);
  750. TQPainter p2(&pd2);
  751. ceData.rect = boundingRect;
  752. GtkWidget* parent = (widget)?Gtk::gtk_widget_find_parent(widget, GTK_TYPE_TOOLBAR):0L;
  753. if (parent) {
  754. TQStringList parentObjectTypes;
  755. parentObjectTypes.append(TQTOOLBAR_OBJECT_NAME_STRING);
  756. TQPalette parentObjectPalette = tqApp->palette(parentObjectTypes);
  757. const GtkAllocation allocation = Gtk::gtk_widget_get_allocation(parent);
  758. ceData.parentWidgetData.widgetObjectTypes = parentObjectTypes;
  759. ceData.parentWidgetData.rect = TQRect(0, 0, allocation.width, allocation.height);
  760. ceData.parentWidgetData.colorGroup = ((state & GTK_STATE_FLAG_INSENSITIVE)?parentObjectPalette.disabled():parentObjectPalette.active());
  761. }
  762. // Draw item
  763. tqApp->style().drawComplexControl(TQStyle::CC_ToolButton, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, tqt3WidgetType, widget), TQStyle::SC_ToolButton, ((mousedown)?TQStyle::SC_ToolButton:TQStyle::SC_None));
  764. }
  765. /* draw a texture placed on the centroid */
  766. static gboolean
  767. draw_centroid_texture (GtkThemingEngine *engine,
  768. cairo_t *cr,
  769. gdouble x,
  770. gdouble y,
  771. gdouble width,
  772. gdouble height)
  773. {
  774. GtkStateFlags state;
  775. GValue value = { 0, };
  776. cairo_pattern_t *texture = NULL;
  777. cairo_surface_t *surface = NULL;
  778. gboolean retval = FALSE;
  779. state = gtk_theming_engine_get_state (engine);
  780. gtk_theming_engine_get_property (engine, "-tdegtk-centroid-texture", state, &value);
  781. if (!G_VALUE_HOLDS_BOXED (&value))
  782. return FALSE;
  783. texture = (cairo_pattern_t*)g_value_dup_boxed (&value);
  784. g_value_unset (&value);
  785. if (texture != NULL)
  786. cairo_pattern_get_surface (texture, &surface);
  787. if (surface != NULL)
  788. {
  789. cairo_save (cr);
  790. cairo_set_source_surface (cr, surface, (gint) (x + width / 2 - cairo_image_surface_get_width (surface) / 2),
  791. (gint) (y + height / 2 - cairo_image_surface_get_height (surface) / 2));
  792. cairo_paint (cr);
  793. cairo_restore (cr);
  794. retval = TRUE;
  795. }
  796. if (texture != NULL)
  797. cairo_pattern_destroy (texture);
  798. return retval;
  799. }
  800. static void
  801. tdegtk_draw_activity (DRAW_ARGS)
  802. {
  803. TQRect boundingRect(0, 0, width, height);
  804. TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
  805. TQPainter p(&pd);
  806. const GtkWidgetPath* path;
  807. GtkStateFlags state;
  808. GtkWidget* widget;
  809. path = gtk_theming_engine_get_path(engine);
  810. state = gtk_theming_engine_get_state(engine);
  811. widget = m_widgetLookup.find(cr, path);
  812. if (gtk_widget_path_is_type(path, GTK_TYPE_PROGRESS_BAR)) {
  813. #if 0
  814. TQStringList objectTypes;
  815. objectTypes.append(TQPROGRESSBAR_OBJECT_NAME_STRING);
  816. TQPalette objectPalette = tqApp->palette(objectTypes);
  817. TQStyleControlElementData ceData;
  818. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  819. ceData.widgetObjectTypes = objectTypes;
  820. ceData.rect = boundingRect;
  821. ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal;
  822. TQStyle::SFlags sflags = gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget);
  823. sflags = sflags | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default);
  824. TQRect progressBarRect = TQStyle::visualRect(tqApp->style().subRect(TQStyle::SR_ProgressBarContents, ceData, elementFlags, NULL), ceData, elementFlags);
  825. // Draw item
  826. tqApp->style().drawControl(TQStyle::CE_ProgressBarContents, &p, ceData, elementFlags, progressBarRect, ((state & GTK_STATE_FLAG_INSENSITIVE)?objectPalette.disabled():objectPalette.active()), sflags);
  827. #else
  828. // Do nothing
  829. #endif
  830. }
  831. else {
  832. DEBUG_FILL_BACKGROUND_WITH_COLOR(p,128,0,128);
  833. printf("[WARNING] tdegtk_draw_activity() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout);
  834. }
  835. p.end();
  836. }
  837. static void
  838. tdegtk_draw_arrow (GtkThemingEngine *engine,
  839. cairo_t *cr,
  840. gdouble angle,
  841. gdouble x,
  842. gdouble y,
  843. gdouble size)
  844. {
  845. cairo_save(cr);
  846. cairo_reset_clip(cr);
  847. TQRect boundingRect(0, 0, size, size);
  848. TQt3CairoPaintDevice *pd = NULL;
  849. TQPainter *p = NULL;
  850. const GtkWidgetPath* path;
  851. GtkStateFlags state;
  852. GtkWidget* widget;
  853. path = gtk_theming_engine_get_path(engine);
  854. state = gtk_theming_engine_get_state(engine);
  855. widget = m_widgetLookup.find(cr, path);
  856. GtkWidget* parent(widget?gtk_widget_get_parent(widget):0L);
  857. GtkArrowType arrow_direction;
  858. if ((angle <= ((G_PI/2)-(G_PI/4))) || (angle > ((3*(G_PI/2))+(G_PI/4)))) {
  859. arrow_direction = GTK_ARROW_UP;
  860. }
  861. else if ((angle <= ((G_PI)-(G_PI/4))) && (angle > ((0)+(G_PI/4)))) {
  862. arrow_direction = GTK_ARROW_RIGHT;
  863. }
  864. else if ((angle <= ((3*(G_PI/2))-(G_PI/4))) && (angle > ((G_PI/2)+(G_PI/4)))) {
  865. arrow_direction = GTK_ARROW_DOWN;
  866. }
  867. else {
  868. arrow_direction = GTK_ARROW_LEFT;
  869. }
  870. #if 0
  871. if (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_COMBO_BOX)) {
  872. // Do nothing
  873. }
  874. else
  875. #endif
  876. if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_SCROLLBAR)) {
  877. #ifdef DRAW_SCROLLBAR_PIECES_INSTEAD_OF_ENTIRE_BAR
  878. TQStringList objectTypes;
  879. objectTypes.append(TQSCROLLBAR_OBJECT_NAME_STRING);
  880. TQPalette objectPalette = tqApp->palette(objectTypes);
  881. GtkRange* rangeWidget = GTK_RANGE(widget);
  882. TQStyleControlElementData ceData;
  883. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  884. ceData.widgetObjectTypes = objectTypes;
  885. ceData.orientation = ((arrow_direction == GTK_ARROW_UP) || (arrow_direction == GTK_ARROW_DOWN))?TQt::Vertical:TQt::Horizontal;
  886. bool subline = ((arrow_direction == GTK_ARROW_DOWN) || (arrow_direction == GTK_ARROW_RIGHT))?false:true;
  887. bool combine_addlineregion_drawing_areas = tqApp->style().styleHint(TQStyle::SH_ScrollBar_CombineAddLineRegionDrawingAreas);
  888. const GtkAllocation allocation = Gtk::gtk_widget_get_allocation(widget);
  889. TQStyle::SFlags sflags = gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget);
  890. sflags = sflags | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default);
  891. if (combine_addlineregion_drawing_areas) {
  892. int newx = x;
  893. int newy = y;
  894. int neww = size;
  895. int newh = size;
  896. if (!subline) {
  897. if (ceData.orientation == TQt::Horizontal) {
  898. if ((x+m_scrollBarSubLineWidth) == allocation.width) {
  899. newx = x-m_scrollBarSubLineWidth;
  900. }
  901. boundingRect.setWidth(m_scrollBarSubLineWidth*2);
  902. neww = m_scrollBarSubLineWidth*2;
  903. }
  904. else {
  905. if ((y+m_scrollBarSubLineWidth) == allocation.height) {
  906. newy = y-m_scrollBarSubLineWidth;
  907. }
  908. boundingRect.setHeight(m_scrollBarSubLineWidth*2);
  909. newh = m_scrollBarSubLineWidth*2;
  910. }
  911. }
  912. pd = new TQt3CairoPaintDevice(NULL, newx, newy, neww, newh, cr);
  913. p = new TQPainter(pd);
  914. if (!subline) {
  915. if (ceData.orientation == TQt::Horizontal) {
  916. p->setClipRect(TQRect(0+m_scrollBarSubLineWidth, 0, m_scrollBarSubLineWidth, newh));
  917. }
  918. else {
  919. p->setClipRect(TQRect(0, 0+m_scrollBarSubLineWidth, neww, m_scrollBarSubLineWidth));
  920. }
  921. }
  922. }
  923. else {
  924. pd = new TQt3CairoPaintDevice(NULL, x, y, size, size, cr);
  925. p = new TQPainter(pd);
  926. }
  927. ceData.rect = boundingRect;
  928. gtkRangeToCeData(rangeWidget, ceData);
  929. // Draw slider arrow buttons
  930. TQRect scrollpagerect = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, ceData, elementFlags, (subline)?TQStyle::SC_ScrollBarSubLine:TQStyle::SC_ScrollBarAddLine, sflags);
  931. if (ceData.orientation == TQt::Vertical) {
  932. scrollpagerect.setY(ceData.rect.y());
  933. scrollpagerect.setHeight(ceData.rect.height());
  934. }
  935. else {
  936. scrollpagerect.setX(ceData.rect.x());
  937. scrollpagerect.setWidth(ceData.rect.width());
  938. }
  939. tqApp->style().drawPrimitive((subline)?TQStyle::PE_ScrollBarSubLine:TQStyle::PE_ScrollBarAddLine, p, scrollpagerect, gtkToTQtColorGroup(engine, state), sflags);
  940. #else
  941. // Draw nothing
  942. #endif
  943. }
  944. else if (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_COMBO_BOX) && (!(GTK_IS_MENU_ITEM(widget) || GTK_IS_MENU_ITEM(parent) || (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_MENUITEM))))) {
  945. // Do nothing
  946. }
  947. else {
  948. pd = new TQt3CairoPaintDevice(NULL, x, y, size, size, cr);
  949. p = new TQPainter(pd);
  950. // Draw arrow
  951. TQStyle::PrimitiveElement pe;
  952. if (arrow_direction == GTK_ARROW_UP) {
  953. pe = TQStyle::PE_ArrowUp;
  954. }
  955. else if (arrow_direction == GTK_ARROW_DOWN) {
  956. pe = TQStyle::PE_ArrowDown;
  957. }
  958. else if (arrow_direction == GTK_ARROW_LEFT) {
  959. pe = TQStyle::PE_ArrowLeft;
  960. }
  961. else {
  962. pe = TQStyle::PE_ArrowRight;
  963. }
  964. tqApp->style().drawPrimitive(pe, p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget));
  965. }
  966. if (p) {
  967. p->end();
  968. delete p;
  969. }
  970. if (pd) {
  971. delete pd;
  972. }
  973. cairo_restore(cr);
  974. }
  975. static void
  976. tdegtk_draw_cell_background (DRAW_ARGS,
  977. GtkRegionFlags flags)
  978. {
  979. cairo_save(cr);
  980. cairo_reset_clip(cr);
  981. TQRect boundingRect(0, 0, width, height);
  982. TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
  983. TQPainter p(&pd);
  984. const GtkWidgetPath* path;
  985. GtkStateFlags state;
  986. GtkWidget* widget;
  987. path = gtk_theming_engine_get_path(engine);
  988. state = gtk_theming_engine_get_state(engine);
  989. widget = m_widgetLookup.find(cr, path);
  990. if (gtk_widget_path_is_type(path, GTK_TYPE_TREE_VIEW)) {
  991. TQStringList objectTypes;
  992. objectTypes.append(TQLISTVIEW_OBJECT_NAME_STRING);
  993. TQPalette objectPalette = tqApp->palette(objectTypes);
  994. TQStyleControlElementData ceData;
  995. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  996. ceData.widgetObjectTypes = objectTypes;
  997. ceData.rect = boundingRect;
  998. if ((state & GTK_STATE_FLAG_SELECTED) != 0) {
  999. ceData.viewportData.bgBrush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Highlight);
  1000. }
  1001. else {
  1002. ceData.viewportData.bgBrush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Base);
  1003. }
  1004. TQListViewItem tqt3ListViewItem;
  1005. TQStyleOption listViewItemOpt(&tqt3ListViewItem);
  1006. // Draw item
  1007. tqApp->style().drawComplexControl(TQStyle::CC_ListView, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget), TQStyle::SC_ListView, TQStyle::SC_All, listViewItemOpt);
  1008. }
  1009. // FIXME
  1010. // GtkCellRenderer backgrounds should be drawn here, however GTK3 does not provide any means for a GtkCellRenderer to call style engine methods!
  1011. // See upstream GTK bug #687677
  1012. else {
  1013. DEBUG_FILL_BACKGROUND_WITH_COLOR(p,255,128,64);
  1014. printf("[WARNING] tdegtk_draw_cell_background() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout);
  1015. }
  1016. p.end();
  1017. cairo_restore(cr);
  1018. }
  1019. static void
  1020. tdegtk_draw_cell_frame (DRAW_ARGS,
  1021. GtkRegionFlags flags)
  1022. {
  1023. TQRect boundingRect(0, 0, width, height);
  1024. TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
  1025. TQPainter p(&pd);
  1026. const GtkWidgetPath* path;
  1027. GtkStateFlags state;
  1028. GtkWidget* widget;
  1029. path = gtk_theming_engine_get_path(engine);
  1030. state = gtk_theming_engine_get_state(engine);
  1031. widget = m_widgetLookup.find(cr, path);
  1032. #if 0
  1033. if (gtk_widget_path_is_type(path, GTK_TYPE_TREE_VIEW)) {
  1034. TQStringList objectTypes;
  1035. objectTypes.append(TQLISTVIEW_OBJECT_NAME_STRING);
  1036. TQPalette objectPalette = tqApp->palette(objectTypes);
  1037. TQStyleControlElementData ceData;
  1038. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  1039. ceData.widgetObjectTypes = objectTypes;
  1040. ceData.rect = boundingRect;
  1041. if ((state & GTK_STATE_FLAG_SELECTED) != 0) {
  1042. ceData.viewportData.bgBrush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Highlight);
  1043. }
  1044. else {
  1045. ceData.viewportData.bgBrush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Base);
  1046. }
  1047. TQListViewItem tqt3ListViewItem;
  1048. TQStyleOption listViewItemOpt(&tqt3ListViewItem);
  1049. TQRect paintDeviceRect;
  1050. TQRect backgroundRect;
  1051. // Draw item
  1052. tqApp->style().drawComplexControl(TQStyle::CC_ListView, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget), TQStyle::SC_ListView, TQStyle::SC_All, listViewItemOpt);
  1053. }
  1054. else {
  1055. DEBUG_FILL_BACKGROUND_WITH_COLOR(p,255,64,64);
  1056. printf("[WARNING] tdegtk_draw_cell_background() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout);
  1057. }
  1058. #endif
  1059. p.end();
  1060. }
  1061. static void
  1062. tdegtk_draw_check (DRAW_ARGS)
  1063. {
  1064. TQRect boundingRect(0, 0, width, height);
  1065. TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
  1066. TQPainter p(&pd);
  1067. const GtkWidgetPath* path;
  1068. GtkStateFlags state;
  1069. GtkWidget* widget;
  1070. path = gtk_theming_engine_get_path(engine);
  1071. state = gtk_theming_engine_get_state(engine);
  1072. widget = m_widgetLookup.find(cr, path);
  1073. if (gtk_widget_path_is_type(path, GTK_TYPE_TREE_VIEW)) {
  1074. draw_checkbox(engine, cr, x, y, width, height, path, state, widget, TQT3WT_GTKTreeViewCell);
  1075. }
  1076. else {
  1077. draw_checkbox(engine, cr, x, y, width, height, path, state, widget, TQT3WT_TQCheckBox);
  1078. }
  1079. p.end();
  1080. }
  1081. static void
  1082. tdegtk_draw_common (DRAW_ARGS)
  1083. {
  1084. TQRect boundingRect(0, 0, width, height);
  1085. TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
  1086. TQPainter p(&pd);
  1087. DEBUG_FILL_BACKGROUND_WITH_COLOR(p,0,255,255);
  1088. GtkStateFlags state;
  1089. state = gtk_theming_engine_get_state(engine);
  1090. //tqApp->style().drawPrimitive(TQStyle::PE_Indicator, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget));
  1091. p.end();
  1092. }
  1093. static void
  1094. tdegtk_draw_common_background (DRAW_ARGS)
  1095. {
  1096. cairo_save(cr);
  1097. cairo_reset_clip(cr);
  1098. TQRect boundingRect(0, 0, width, height);
  1099. TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
  1100. TQPainter p(&pd);
  1101. const GtkWidgetPath* path;
  1102. GtkStateFlags state;
  1103. GtkWidget* widget;
  1104. path = gtk_theming_engine_get_path(engine);
  1105. state = gtk_theming_engine_get_state(engine);
  1106. widget = m_widgetLookup.find(cr, path);
  1107. if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_SCROLLBAR)) {
  1108. #ifdef DRAW_SCROLLBAR_PIECES_INSTEAD_OF_ENTIRE_BAR
  1109. TQStringList objectTypes;
  1110. objectTypes.append(TQSCROLLBAR_OBJECT_NAME_STRING);
  1111. TQPalette objectPalette = tqApp->palette(objectTypes);
  1112. GtkRange* rangeWidget = GTK_RANGE(widget);
  1113. TQStyleControlElementData ceData;
  1114. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  1115. ceData.widgetObjectTypes = objectTypes;
  1116. ceData.rect = boundingRect;
  1117. ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal;
  1118. gtkRangeToCeData(rangeWidget, ceData);
  1119. // Draw frame
  1120. tqApp->style().drawPrimitive(TQStyle::PE_PanelLineEdit, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default));
  1121. #else
  1122. draw_scrollbar_frame(engine, cr, x, y, width, height, path, state, widget);
  1123. #endif
  1124. }
  1125. else if ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_FRAME) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_BUTTON)) && (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_COMBO_BOX))) {
  1126. draw_combobox_frame(engine, cr, x, y, width, height, path, state, widget);
  1127. }
  1128. else if ((gtk_widget_path_is_type(path, GTK_TYPE_ENTRY))
  1129. || (gtk_widget_path_is_type(path, GTK_TYPE_TEXT_VIEW))
  1130. || (gtk_widget_path_is_type(path, GTK_TYPE_TEXT_BUFFER))
  1131. || (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY))
  1132. || (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_COMBOBOX_ENTRY))
  1133. ) {
  1134. TQStringList objectTypes;
  1135. objectTypes.append(TQLINEEDIT_OBJECT_NAME_STRING);
  1136. TQPalette objectPalette = tqApp->palette(objectTypes);
  1137. // Draw background
  1138. TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Base);
  1139. DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush)
  1140. }
  1141. #if 0
  1142. else if (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_COMBO_BOX)) {
  1143. bool mousedown = (state & GTK_STATE_FLAG_ACTIVE) != 0;
  1144. TQStringList objectTypes;
  1145. objectTypes.append(TQCOMBOBOX_OBJECT_NAME_STRING);
  1146. TQPalette objectPalette = tqApp->palette(objectTypes);
  1147. TQStyleControlElementData ceData;
  1148. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  1149. ceData.widgetObjectTypes = objectTypes;
  1150. ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal;
  1151. if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY)) {
  1152. elementFlags = elementFlags | TQStyle::CEF_IsEditable;
  1153. }
  1154. ceData.rect = boundingRect;
  1155. // Draw item
  1156. tqApp->style().drawComplexControl(TQStyle::CC_ComboBox, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget), TQStyle::SC_ComboBoxEditField, TQStyle::SC_None);
  1157. }
  1158. #endif
  1159. else if (gtk_widget_path_is_type(path, GTK_TYPE_BUTTON)) {
  1160. #if 0
  1161. TQStringList objectTypes;
  1162. objectTypes.append(TQBUTTON_OBJECT_NAME_STRING);
  1163. TQPalette objectPalette = tqApp->palette(objectTypes);
  1164. if (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_TOOLBAR)) {
  1165. // Draw background
  1166. TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Background);
  1167. DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush)
  1168. }
  1169. else if (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_TREE_VIEW)) {
  1170. // Draw background
  1171. TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Background);
  1172. DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush)
  1173. }
  1174. else {
  1175. draw_pushbutton(engine, cr, x, y, width, height, path, state, widget, TQT3WT_TQPushButton);
  1176. }
  1177. #else
  1178. // Draw nothing!
  1179. #endif
  1180. }
  1181. else if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_TOOLBAR)) {
  1182. TQStringList objectTypes;
  1183. objectTypes.append(TQTOOLBAR_OBJECT_NAME_STRING);
  1184. TQPalette objectPalette = tqApp->palette(objectTypes);
  1185. // Draw background
  1186. TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Background);
  1187. DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush)
  1188. }
  1189. else if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_MENUBAR)) {
  1190. TQStringList objectTypes;
  1191. objectTypes.append(TQMENUBAR_OBJECT_NAME_STRING);
  1192. TQPalette objectPalette = tqApp->palette(objectTypes);
  1193. // Draw background
  1194. TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Background);
  1195. DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush)
  1196. }
  1197. else if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_TOOLTIP)) {
  1198. TQStringList objectTypes;
  1199. objectTypes.append(TQTIPLABEL_OBJECT_NAME_STRING);
  1200. TQPalette objectPalette = tqApp->palette(objectTypes);
  1201. // Draw background
  1202. TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Background);
  1203. DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush)
  1204. }
  1205. else if ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_MENU)) || (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_MENUITEM))) {
  1206. GtkWidget* parent(widget?gtk_widget_get_parent(widget):0L);
  1207. if (!GTK_IS_MENU_BAR(parent)) {
  1208. // FIXME
  1209. // Mouse movements in the popup menu should be tracked similarly to mouse movements in the tab bar
  1210. // Many TQt3 styles highlight inactive menu items on hover; not providing this visual feedback may cause users to briefly think their GTK application has frozen up
  1211. // // Register menu item with animation engine
  1212. // m_animations.menuItemEngine().registerWidget(widget);
  1213. //
  1214. // // Check tab properties
  1215. // int tabIndex = Gtk::gtk_notebook_find_tab(widget, x+width/2, y+height/2);
  1216. // m_animations.tabWidgetEngine().updateTabRect(widget, tabIndex, x, y, width, height);
  1217. // bool prelight = (tabIndex == m_animations.tabWidgetEngine().hoveredTab(widget));
  1218. // GtkMenuItem* menuitem = GTK_MENU_ITEM(widget);
  1219. // const int currentPage = gtk_notebook_get_current_page(notebook);
  1220. // const int numPages = gtk_notebook_get_n_pages(notebook);
  1221. // bool selectedTab = (tabIndex==currentPage);
  1222. TQStringList objectTypes;
  1223. objectTypes.append(TQPOPUPMENU_OBJECT_NAME_STRING);
  1224. TQPalette objectPalette = tqApp->palette(objectTypes);
  1225. bool pressed = false;
  1226. bool prelight = false;
  1227. TQStyleControlElementData ceData;
  1228. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  1229. ceData.widgetObjectTypes = objectTypes;
  1230. ceData.rect = boundingRect;
  1231. TQMenuItem tqt3MenuItem;
  1232. int maxAcceleratorTextWidth = 0;
  1233. int maxIconWidth = IconSize(KIcon::Small) + 4;
  1234. TQStyleOption menuOpt(&tqt3MenuItem, maxIconWidth, maxAcceleratorTextWidth);
  1235. // if (???) elementFlags = elementFlags | TQStyle::TQStyle::CEF_IsCheckable;
  1236. TQRect paintDeviceRect;
  1237. TQRect backgroundRect;
  1238. // Draw item
  1239. tqApp->style().drawControl(TQStyle::CE_PopupMenuItem, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQMenuItem, widget) | ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_MENUITEM))?TQStyle::Style_Active:TQStyle::Style_Default) | ((pressed)?TQStyle::Style_Down:TQStyle::Style_Default) | ((prelight)?TQStyle::Style_MouseOver:TQStyle::Style_Default), menuOpt);
  1240. }
  1241. }
  1242. else if (gtk_widget_path_is_type(path, GTK_TYPE_NOTEBOOK)) {
  1243. TQStringList objectTypes;
  1244. objectTypes.append(TQTABWIDGET_OBJECT_NAME_STRING);
  1245. TQPalette objectPalette = tqApp->palette(objectTypes);
  1246. // Draw background
  1247. TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Background);
  1248. DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush)
  1249. }
  1250. else if (gtk_widget_path_is_type(path, GTK_TYPE_PROGRESS_BAR)) {
  1251. // Do nothing; backround is drawn in frame drawing routine
  1252. }
  1253. else if (gtk_widget_path_is_type(path, GTK_TYPE_HANDLE_BOX)) {
  1254. TQStringList objectTypes;
  1255. objectTypes.append(TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING);
  1256. TQPalette objectPalette = tqApp->palette(objectTypes);
  1257. // Draw background
  1258. TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Background);
  1259. DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush)
  1260. }
  1261. else if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_CELL)) {
  1262. TQStringList objectTypes;
  1263. objectTypes.append(TQLISTVIEW_OBJECT_NAME_STRING);
  1264. TQPalette objectPalette = tqApp->palette(objectTypes);
  1265. TQStyleControlElementData ceData;
  1266. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  1267. ceData.widgetObjectTypes = objectTypes;
  1268. ceData.rect = boundingRect;
  1269. if ((state & GTK_STATE_FLAG_SELECTED) != 0) {
  1270. ceData.viewportData.bgBrush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Highlight);
  1271. }
  1272. else {
  1273. ceData.viewportData.bgBrush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Base);
  1274. }
  1275. TQListViewItem tqt3ListViewItem;
  1276. TQStyleOption listViewItemOpt(&tqt3ListViewItem);
  1277. // Draw item
  1278. tqApp->style().drawComplexControl(TQStyle::CC_ListView, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget), TQStyle::SC_ListView, TQStyle::SC_All, listViewItemOpt);
  1279. }
  1280. else if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_SCALE) /*&& gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_TROUGH)*/) {
  1281. draw_slider_frame(engine, cr, x, y, width, height, path, state, widget);
  1282. }
  1283. else if (gtk_widget_path_is_type(path, GTK_TYPE_IMAGE)) {
  1284. // Do nothing
  1285. }
  1286. else if ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_BACKGROUND))
  1287. || (gtk_widget_path_is_type(path, GTK_TYPE_EXPANDER))
  1288. || (gtk_widget_path_is_type(path, GTK_TYPE_BOX))
  1289. || (gtk_widget_path_is_type(path, GTK_TYPE_VIEWPORT))
  1290. || (gtk_widget_path_is_type(path, GTK_TYPE_SCROLLED_WINDOW))
  1291. || (gtk_widget_path_is_type(path, GTK_TYPE_PANED))
  1292. ) {
  1293. TQStringList objectTypes;
  1294. objectTypes.append(TQWIDGET_OBJECT_NAME_STRING);
  1295. TQPalette objectPalette = tqApp->palette(objectTypes);
  1296. // Draw background
  1297. TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Background);
  1298. DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush)
  1299. }
  1300. else {
  1301. DEBUG_FILL_BACKGROUND_WITH_COLOR(p,0,0,255);
  1302. printf("[WARNING] tdegtk_draw_common_background() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout);
  1303. }
  1304. p.end();
  1305. cairo_restore(cr);
  1306. }
  1307. static void
  1308. tdegtk_draw_common_frame (DRAW_ARGS)
  1309. {
  1310. cairo_save(cr);
  1311. cairo_reset_clip(cr);
  1312. TQRect boundingRect(0, 0, width, height);
  1313. TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
  1314. TQPainter p(&pd);
  1315. const GtkWidgetPath* path;
  1316. GtkStateFlags state;
  1317. GtkWidget* widget;
  1318. path = gtk_theming_engine_get_path(engine);
  1319. state = gtk_theming_engine_get_state(engine);
  1320. widget = m_widgetLookup.find(cr, path);
  1321. TQString widgetPath(Gtk::gtk_widget_path(widget));
  1322. if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_SCROLLBAR)) {
  1323. #ifdef DRAW_SCROLLBAR_PIECES_INSTEAD_OF_ENTIRE_BAR
  1324. if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_BUTTON)) {
  1325. // Scrollbar buttons are drawn in the arrow handler
  1326. }
  1327. else {
  1328. TQStringList objectTypes;
  1329. objectTypes.append(TQSCROLLBAR_OBJECT_NAME_STRING);
  1330. TQPalette objectPalette = tqApp->palette(objectTypes);
  1331. GtkRange* rangeWidget = GTK_RANGE(widget);
  1332. TQStyleControlElementData ceData;
  1333. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  1334. ceData.widgetObjectTypes = objectTypes;
  1335. ceData.rect = boundingRect;
  1336. ceData.orientation = ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal);
  1337. gtkRangeToCeData(rangeWidget, ceData);
  1338. // Draw background
  1339. // HACK
  1340. // PE_ScrollBarAddPage and PE_ScrollBarSubPage are separate in TQt3
  1341. // Apparently there is no such distinction in GTK3!
  1342. TQRect scrollpagerect = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, ceData, elementFlags, TQStyle::SC_ScrollBarAddPage, gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default));
  1343. if (ceData.orientation == TQt::Vertical) {
  1344. scrollpagerect.setY(ceData.rect.y());
  1345. scrollpagerect.setHeight(ceData.rect.height());
  1346. }
  1347. else {
  1348. scrollpagerect.setX(ceData.rect.x());
  1349. scrollpagerect.setWidth(ceData.rect.width());
  1350. }
  1351. tqApp->style().drawPrimitive(TQStyle::PE_ScrollBarAddPage, &p, scrollpagerect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget));
  1352. }
  1353. #else
  1354. // Do nothing...
  1355. #endif
  1356. }
  1357. else if ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_FRAME) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_BUTTON)) && (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_COMBO_BOX))) {
  1358. draw_combobox_frame(engine, cr, x, y, width, height, path, state, widget);
  1359. }
  1360. else {
  1361. if (gtk_widget_path_is_type(path, GTK_TYPE_BUTTON)) {
  1362. if (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_TOOLBAR)) {
  1363. draw_toolbar_button(engine, cr, x, y, width, height, path, state, widget, TQT3WT_TQToolButton);
  1364. }
  1365. else if (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_TREE_VIEW)) {
  1366. // Draw frame
  1367. tqApp->style().drawPrimitive(TQStyle::PE_HeaderSection, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget));
  1368. }
  1369. else {
  1370. draw_pushbutton(engine, cr, x, y, width, height, path, state, widget, TQT3WT_TQPushButton);
  1371. }
  1372. }
  1373. else if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_MENUITEM)) {
  1374. GtkWidget* parent(widget?gtk_widget_get_parent(widget):0L);
  1375. if (GTK_IS_MENU_BAR(parent)) {
  1376. TQStringList objectTypes;
  1377. objectTypes.append(TQPOPUPMENU_OBJECT_NAME_STRING);
  1378. TQPalette objectPalette = tqApp->palette(objectTypes);
  1379. // See FIXME in tdegtk_draw_common_background
  1380. bool pressed = true;
  1381. bool prelight = false;
  1382. TQStyleControlElementData ceData;
  1383. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  1384. ceData.widgetObjectTypes = objectTypes;
  1385. ceData.rect = boundingRect;
  1386. ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal;
  1387. // Draw frame
  1388. tqApp->style().drawPrimitive(TQStyle::PE_ButtonDropDown, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQMenuItem, widget) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default) | ((pressed)?TQStyle::Style_Down:TQStyle::Style_Default) | ((prelight)?TQStyle::Style_MouseOver:TQStyle::Style_Default));
  1389. }
  1390. }
  1391. #if 0
  1392. // FIXME
  1393. // Certain styles (highcolor) paint over the color swatches if this is enabled, rendering the picker useless
  1394. else if (widgetPath.endsWith(".GtkColorSwatch")) {
  1395. TQStringList objectTypes;
  1396. objectTypes.append(TQLINEEDIT_OBJECT_NAME_STRING);
  1397. TQPalette objectPalette = tqApp->palette(objectTypes);
  1398. // Draw frame
  1399. tqApp->style().drawPrimitive(TQStyle::PE_PanelLineEdit, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQLineEdit, widget));
  1400. }
  1401. #endif
  1402. else if (widgetPath.endsWith(".add-color-button")) {
  1403. // Draw frame
  1404. tqApp->style().drawPrimitive(TQStyle::PE_ButtonBevel, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget));
  1405. }
  1406. else if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY)) {
  1407. TQStringList objectTypes;
  1408. objectTypes.append(TQLINEEDIT_OBJECT_NAME_STRING);
  1409. TQPalette objectPalette = tqApp->palette(objectTypes);
  1410. // Draw frame
  1411. tqApp->style().drawPrimitive(TQStyle::PE_PanelLineEdit, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQLineEdit, widget));
  1412. }
  1413. else if (gtk_widget_path_is_type(path, GTK_TYPE_SPIN_BUTTON)) {
  1414. // Draw frame
  1415. tqApp->style().drawPrimitive(TQStyle::PE_ButtonBevel, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQPushButton, widget));
  1416. }
  1417. else if ((gtk_widget_path_is_type(path, GTK_TYPE_HANDLE_BOX))
  1418. || (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_TOOLBAR))
  1419. ) {
  1420. // Draw frame
  1421. tqApp->style().drawPrimitive(TQStyle::PE_PanelDockWindow, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget));
  1422. }
  1423. else if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_MENUBAR)) {
  1424. // Draw frame
  1425. tqApp->style().drawPrimitive(TQStyle::PE_PanelMenuBar, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget));
  1426. }
  1427. else if (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_STATUSBAR)) {
  1428. // Draw frame
  1429. tqApp->style().drawPrimitive(TQStyle::PE_StatusBarSection, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget));
  1430. }
  1431. else if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_MENU)) {
  1432. TQStringList objectTypes;
  1433. objectTypes.append(TQPOPUPMENU_OBJECT_NAME_STRING);
  1434. TQPalette objectPalette = tqApp->palette(objectTypes);
  1435. TQStyleControlElementData ceData;
  1436. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  1437. ceData.widgetObjectTypes = objectTypes;
  1438. ceData.rect = boundingRect;
  1439. ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal;
  1440. // Draw frame
  1441. tqApp->style().drawPrimitive(TQStyle::PE_PanelPopup, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default));
  1442. }
  1443. else if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_TOOLTIP)) {
  1444. TQStringList objectTypes;
  1445. objectTypes.append(TQTOOLTIP_OBJECT_NAME_STRING);
  1446. TQPalette objectPalette = tqApp->palette(objectTypes);
  1447. int groupBoxLineWidth = 1;
  1448. int lineWidth = 0;
  1449. lineWidth = groupBoxLineWidth;
  1450. // Draw tooltip frame
  1451. qDrawPlainRect(&p, boundingRect, ((state & GTK_STATE_FLAG_INSENSITIVE)?objectPalette.disabled():objectPalette.active()).foreground(), lineWidth);
  1452. }
  1453. else if (gtk_widget_path_is_type(path, GTK_TYPE_PROGRESS_BAR)) {
  1454. draw_progressbar_frame(engine, cr, x, y, width, height, path, state, widget);
  1455. }
  1456. else if (gtk_widget_path_is_type(path, GTK_TYPE_IMAGE)) {
  1457. // Do nothing
  1458. }
  1459. else if (gtk_widget_path_is_type(path, GTK_TYPE_NOTEBOOK)) {
  1460. // Draw frame
  1461. tqApp->style().drawPrimitive(TQStyle::PE_PanelTabWidget, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget));
  1462. }
  1463. else if ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_BACKGROUND))
  1464. || (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_BOX))
  1465. || (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_EXPANDER))
  1466. || (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_BOX))
  1467. || (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_VIEWPORT))
  1468. || (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_SCROLLED_WINDOW))
  1469. || (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_PANED))
  1470. ) {
  1471. // Do nothing
  1472. }
  1473. else {
  1474. DEBUG_FILL_BACKGROUND_WITH_COLOR(p,128,64,255);
  1475. printf("[WARNING] tdegtk_draw_common_frame() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout);
  1476. }
  1477. }
  1478. p.end();
  1479. cairo_restore(cr);
  1480. }
  1481. static void
  1482. tdegtk_draw_expander (DRAW_ARGS)
  1483. {
  1484. GtkStateFlags state;
  1485. GdkRGBA color;
  1486. gint size;
  1487. gdouble angle = G_PI_2;
  1488. state = gtk_theming_engine_get_state (engine);
  1489. gtk_theming_engine_get_color (engine, state, &color);
  1490. cairo_save (cr);
  1491. /* use floor function to adjust doubles */
  1492. size = floor (MIN (width, height));
  1493. x += (gint) (width / 2) - size / 2;
  1494. y += (gint) (height / 2) - size / 2;
  1495. if ((state & GTK_STATE_FLAG_ACTIVE) == 0)
  1496. angle = 0;
  1497. cairo_translate (cr, x + size / 2.0 + 0.5, y + size / 2.0 + 0.5);
  1498. cairo_rotate (cr, angle);
  1499. cairo_translate (cr, size / 4.0, 0);
  1500. /* FIXME this + 1/- 1 is done to fix blurred diagonal lines.
  1501. * I know it's not nice at all, but it fix a visual bug */
  1502. cairo_move_to (cr, - size / 2.0, - size / 2.0);
  1503. cairo_rel_line_to (cr, size / 2.0 + 1, size / 2.0);
  1504. cairo_rel_line_to (cr, - size / 2.0 - 1, size / 2.0);
  1505. cairo_close_path (cr);
  1506. cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha * 0.75);
  1507. cairo_fill_preserve (cr);
  1508. gdk_cairo_set_source_rgba (cr, &color);
  1509. cairo_stroke (cr);
  1510. cairo_restore (cr);
  1511. }
  1512. static void
  1513. tdegtk_draw_extension (DRAW_ARGS,
  1514. GtkPositionType gap_side)
  1515. {
  1516. TQRect boundingRect(0, 0, width, height);
  1517. TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
  1518. TQPainter p(&pd);
  1519. const GtkWidgetPath* path;
  1520. GtkStateFlags state;
  1521. GtkWidget* widget;
  1522. path = gtk_theming_engine_get_path(engine);
  1523. state = gtk_theming_engine_get_state(engine);
  1524. widget = m_widgetLookup.find(cr, path);
  1525. if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_NOTEBOOK)) {
  1526. // Register tabbar with animation engine
  1527. m_animations.tabWidgetEngine().registerWidget(widget);
  1528. // Check tab properties
  1529. int tabIndex = Gtk::gtk_notebook_find_tab(widget, x+width/2, y+height/2);
  1530. m_animations.tabWidgetEngine().updateTabRect(widget, tabIndex, x, y, width, height);
  1531. bool prelight = (tabIndex == m_animations.tabWidgetEngine().hoveredTab(widget));
  1532. GtkNotebook* notebook = GTK_NOTEBOOK(widget);
  1533. // bool firstTab = (tabIndex == 0);
  1534. // bool lastTab = (tabIndex == gtk_notebook_get_n_pages(notebook)-1);
  1535. const int currentPage = gtk_notebook_get_current_page(notebook);
  1536. const int numPages = gtk_notebook_get_n_pages(notebook);
  1537. bool selectedTab = (tabIndex==currentPage);
  1538. TQStringList objectTypes;
  1539. objectTypes.append(TQTABBAR_OBJECT_NAME_STRING);
  1540. TQPalette objectPalette = tqApp->palette(objectTypes);
  1541. TQStyleControlElementData ceData;
  1542. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  1543. ceData.widgetObjectTypes = objectTypes;
  1544. ceData.rect = boundingRect;
  1545. TQTab tqt3Tab;
  1546. tqt3Tab.setIdentifier(tabIndex);
  1547. TQStyleOption tabOpt(&tqt3Tab, (prelight)?&tqt3Tab:(TQTab*)NULL);
  1548. elementFlags = elementFlags | TQStyle::CEF_HasParentWidget;
  1549. ceData.parentWidgetData.widgetObjectTypes.append(TQTABBAR_OBJECT_NAME_STRING);
  1550. int tab_overlap = tqApp->style().pixelMetric(TQStyle::PM_TabBarTabOverlap);
  1551. int tab_to_frame_gap_height = 2;
  1552. ceData.tabBarData.tabCount = numPages;
  1553. ceData.tabBarData.identIndexMap[tqt3Tab.identifier()] = tabIndex;
  1554. TQRect paintDeviceRect;
  1555. TQRect backgroundRect;
  1556. switch (gap_side) {
  1557. default:
  1558. case GTK_POS_TOP:
  1559. ceData.tabBarData.shape = TQTabBar::RoundedBelow;
  1560. paintDeviceRect = TQRect(x-tab_overlap, y-tab_to_frame_gap_height, width+(tab_overlap*2), height+tab_to_frame_gap_height);
  1561. boundingRect = TQRect(0, 0, width+tab_overlap, height+tab_to_frame_gap_height);
  1562. backgroundRect = TQRect(tab_overlap, 0, width, height+2);
  1563. break;
  1564. case GTK_POS_LEFT:
  1565. ceData.tabBarData.shape = TQTabBar::RoundedAbove;
  1566. // FIXME
  1567. // TQt3 does not know how to draw these
  1568. // For now, draw a single unconnected tab in this location
  1569. tabIndex = 0;
  1570. ceData.tabBarData.tabCount = 1;
  1571. tqt3Tab.setIdentifier(tabIndex);
  1572. ceData.tabBarData.identIndexMap[tqt3Tab.identifier()] = tabIndex;
  1573. paintDeviceRect = TQRect(x-tab_to_frame_gap_height, y, width+tab_to_frame_gap_height, height);
  1574. boundingRect = TQRect(0, 0, width, height);
  1575. backgroundRect = TQRect(0, 0, width, height);
  1576. break;
  1577. case GTK_POS_BOTTOM:
  1578. ceData.tabBarData.shape = TQTabBar::RoundedAbove;
  1579. paintDeviceRect = TQRect(x-tab_overlap, y, width+(tab_overlap*2), height+tab_to_frame_gap_height);
  1580. boundingRect = TQRect(0, 0, width+tab_overlap, height+tab_to_frame_gap_height);
  1581. backgroundRect = TQRect(tab_overlap, 0, width, height+2);
  1582. break;
  1583. case GTK_POS_RIGHT:
  1584. ceData.tabBarData.shape = TQTabBar::RoundedAbove;
  1585. // FIXME
  1586. // TQt3 does not know how to draw these
  1587. // For now, draw a single unconnected tab in this location
  1588. tabIndex = 0;
  1589. ceData.tabBarData.tabCount = 1;
  1590. tqt3Tab.setIdentifier(tabIndex);
  1591. ceData.tabBarData.identIndexMap[tqt3Tab.identifier()] = tabIndex;
  1592. paintDeviceRect = TQRect(x, y, width+tab_to_frame_gap_height, height);
  1593. boundingRect = TQRect(0, 0, width, height);
  1594. backgroundRect = TQRect(0, 0, width, height);
  1595. break;
  1596. }
  1597. cairo_save(cr);
  1598. cairo_reset_clip(cr);
  1599. TQt3CairoPaintDevice pd2(NULL, paintDeviceRect.x(), paintDeviceRect.y(), paintDeviceRect.width(), paintDeviceRect.height(), cr);
  1600. TQPainter p2(&pd2);
  1601. // Draw background
  1602. TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Background);
  1603. DRAW_FILLED_RECTANGLE_OVER_SPECIFIC_AREA(p2, brush, backgroundRect.x(), backgroundRect.y(), backgroundRect.width(), backgroundRect.height())
  1604. // Draw tab
  1605. tqApp->style().drawControl(TQStyle::CE_TabBarTab, &p2, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget) | ((selectedTab)?TQStyle::Style_Selected:TQStyle::Style_Default) | ((prelight)?TQStyle::Style_MouseOver:TQStyle::Style_Default), tabOpt);
  1606. cairo_restore(cr);
  1607. }
  1608. else {
  1609. DEBUG_FILL_BACKGROUND_WITH_COLOR(p,255,255,0);
  1610. printf("[WARNING] tdegtk_draw_extension() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout);
  1611. }
  1612. p.end();
  1613. }
  1614. static void
  1615. tdegtk_draw_focus (DRAW_ARGS)
  1616. {
  1617. TQRect boundingRect(0, 0, width, height);
  1618. TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
  1619. TQPainter p(&pd);
  1620. const GtkWidgetPath* path;
  1621. GtkStateFlags state;
  1622. GtkWidget* widget;
  1623. path = gtk_theming_engine_get_path(engine);
  1624. state = gtk_theming_engine_get_state(engine);
  1625. widget = m_widgetLookup.find(cr, path);
  1626. if ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_FRAME) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY) || gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_BUTTON)) && (Gtk::gtk_widget_path_has_type(path, GTK_TYPE_COMBO_BOX))) {
  1627. // Draw nothing!
  1628. }
  1629. else if ((gtk_widget_path_is_type(path, GTK_TYPE_ENTRY))
  1630. || (gtk_widget_path_is_type(path, GTK_TYPE_TEXT_VIEW))
  1631. || (gtk_widget_path_is_type(path, GTK_TYPE_TEXT_BUFFER))
  1632. || (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY))
  1633. || (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_COMBOBOX_ENTRY))
  1634. || (gtk_widget_path_is_type(path, GTK_TYPE_TREE_VIEW))
  1635. || (gtk_widget_path_is_type(path, GTK_TYPE_BUTTON))
  1636. || (gtk_widget_path_is_type(path, GTK_TYPE_EXPANDER))
  1637. ) {
  1638. TQStyle::SFlags sflags = TQStyle::Style_Default;
  1639. TQStringList objectTypes;
  1640. if ((gtk_widget_path_is_type(path, GTK_TYPE_ENTRY))
  1641. || (gtk_widget_path_is_type(path, GTK_TYPE_TEXT_VIEW))
  1642. || (gtk_widget_path_is_type(path, GTK_TYPE_TEXT_BUFFER))
  1643. || (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_ENTRY))
  1644. || (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_COMBOBOX_ENTRY))
  1645. ) {
  1646. objectTypes.append(TQLINEEDIT_OBJECT_NAME_STRING);
  1647. }
  1648. else if (gtk_widget_path_is_type(path, GTK_TYPE_TREE_VIEW)) {
  1649. objectTypes.append(TQLISTVIEW_OBJECT_NAME_STRING);
  1650. }
  1651. else if (gtk_widget_path_is_type(path, GTK_TYPE_BUTTON)) {
  1652. objectTypes.append(TQPUSHBUTTON_OBJECT_NAME_STRING);
  1653. }
  1654. else {
  1655. objectTypes.append(TQWIDGET_OBJECT_NAME_STRING);
  1656. }
  1657. TQPalette objectPalette = tqApp->palette(objectTypes);
  1658. TQColor bgColor;
  1659. if (state & GTK_STATE_FLAG_INSENSITIVE) {
  1660. bgColor = objectPalette.color(TQPalette::Disabled, TQColorGroup::Background);
  1661. }
  1662. else {
  1663. bgColor = objectPalette.color(TQPalette::Active, TQColorGroup::Background);
  1664. }
  1665. TQRect focusBoundingRect = boundingRect;
  1666. TQStyleControlElementData ceData;
  1667. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  1668. if (gtk_widget_path_is_type(path, GTK_TYPE_BUTTON)) {
  1669. TQStringList objectTypes;
  1670. objectTypes.append(TQBUTTON_OBJECT_NAME_STRING);
  1671. ceData.widgetObjectTypes = objectTypes;
  1672. ceData.rect = boundingRect;
  1673. focusBoundingRect = TQStyle::visualRect(tqApp->style().subRect(TQStyle::SR_PushButtonFocusRect, ceData, elementFlags, NULL), ceData, elementFlags);
  1674. }
  1675. TQStyleOption opt(bgColor);
  1676. // FIXME
  1677. // There are only a few TQt3 widgets that draw a PE_FocusRect directly
  1678. // Those specific widgets need to be isolated and the draw routine added here
  1679. // All other widget should not trigger any drawing here!
  1680. //tqApp->style().drawPrimitive(TQStyle::PE_FocusRect, &p, focusBoundingRect, gtkToTQtColorGroup(engine, state), sflags, opt);
  1681. }
  1682. else if ((gtk_widget_path_is_type(path, GTK_TYPE_ENTRY))
  1683. || (gtk_widget_path_is_type(path, GTK_TYPE_NOTEBOOK))
  1684. || (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_SCALE))
  1685. ) {
  1686. // Draw nothing
  1687. }
  1688. else {
  1689. DEBUG_FILL_BACKGROUND_WITH_COLOR(p,128,255,64);
  1690. printf("[WARNING] tdegtk_draw_focus() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout);
  1691. }
  1692. p.end();
  1693. }
  1694. static void
  1695. tdegtk_draw_frame_gap (DRAW_ARGS,
  1696. GtkPositionType gap_side,
  1697. gdouble xy0_gap,
  1698. gdouble xy1_gap)
  1699. {
  1700. TQRect boundingRect(0, 0, width, height);
  1701. TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
  1702. TQPainter p(&pd);
  1703. const GtkWidgetPath* path;
  1704. GtkStateFlags state;
  1705. GtkWidget* widget;
  1706. path = gtk_theming_engine_get_path(engine);
  1707. state = gtk_theming_engine_get_state(engine);
  1708. widget = m_widgetLookup.find(cr, path);
  1709. if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_FRAME)) {
  1710. GtkFrame* frame = GTK_FRAME(widget);
  1711. GtkShadowType gtkShadowType = gtk_frame_get_shadow_type(frame);
  1712. TQStringList objectTypes;
  1713. objectTypes.append(TQGROUPBOX_OBJECT_NAME_STRING);
  1714. TQPalette objectPalette = tqApp->palette(objectTypes);
  1715. int groupBoxLineWidth = 1;
  1716. int lineWidth = 0;
  1717. int midLineWidth = 0;
  1718. TQStyle::SFlags sflags = gtkToTQtStyleFlags(engine, state, TQT3WT_TQGroupBox, widget);
  1719. if (gtkShadowType == GTK_SHADOW_NONE) {
  1720. lineWidth = 0;
  1721. midLineWidth = 0;
  1722. }
  1723. else if (gtkShadowType == GTK_SHADOW_IN) {
  1724. lineWidth = groupBoxLineWidth;
  1725. midLineWidth = 0;
  1726. sflags = sflags | TQStyle::Style_Sunken;
  1727. }
  1728. else if (gtkShadowType == GTK_SHADOW_OUT) {
  1729. lineWidth = groupBoxLineWidth;
  1730. midLineWidth = 0;
  1731. sflags = sflags | TQStyle::Style_Raised;
  1732. }
  1733. else if (gtkShadowType == GTK_SHADOW_ETCHED_IN) {
  1734. lineWidth = groupBoxLineWidth;
  1735. midLineWidth = groupBoxLineWidth;
  1736. sflags = sflags | TQStyle::Style_Sunken;
  1737. }
  1738. else if (gtkShadowType == GTK_SHADOW_ETCHED_OUT) {
  1739. lineWidth = groupBoxLineWidth;
  1740. midLineWidth = groupBoxLineWidth;
  1741. sflags = sflags | TQStyle::Style_Raised;
  1742. }
  1743. TQStyleOption opt(lineWidth, midLineWidth);
  1744. // Draw background
  1745. TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Background);
  1746. DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush)
  1747. // Draw group box
  1748. tqApp->style().drawPrimitive(TQStyle::PE_PanelGroupBox, &p, boundingRect, gtkToTQtColorGroup(engine, state), sflags, opt);
  1749. // Draw background behind groupbox label
  1750. DRAW_FILLED_RECTANGLE_OVER_SPECIFIC_AREA(p, brush, xy0_gap, x, (xy1_gap-xy0_gap), (height/2))
  1751. }
  1752. else {
  1753. DEBUG_FILL_BACKGROUND_WITH_COLOR(p,255,128,0);
  1754. printf("[WARNING] tdegtk_draw_frame_gap() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout);
  1755. }
  1756. p.end();
  1757. }
  1758. static void
  1759. tdegtk_draw_grip (DRAW_ARGS)
  1760. {
  1761. TQRect boundingRect(0, 0, width, height);
  1762. TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
  1763. TQPainter p(&pd);
  1764. const GtkWidgetPath* path;
  1765. GtkStateFlags state;
  1766. GtkWidget* widget;
  1767. path = gtk_theming_engine_get_path(engine);
  1768. state = gtk_theming_engine_get_state(engine);
  1769. widget = m_widgetLookup.find(cr, path);
  1770. TQStringList objectTypes;
  1771. objectTypes.append(TQSTATUSBAR_OBJECT_NAME_STRING);
  1772. TQPalette objectPalette = tqApp->palette(objectTypes);
  1773. // Draw background
  1774. TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Background);
  1775. DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush)
  1776. cairo_save(cr);
  1777. cairo_reset_clip(cr);
  1778. // Draw grip
  1779. tqApp->style().drawPrimitive(TQStyle::PE_SizeGrip, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget));
  1780. cairo_restore(cr);
  1781. p.end();
  1782. }
  1783. static void
  1784. tdegtk_draw_handle (DRAW_ARGS)
  1785. {
  1786. TQRect boundingRect(0, 0, width, height);
  1787. TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
  1788. TQPainter p(&pd);
  1789. const GtkWidgetPath* path;
  1790. GtkStateFlags state;
  1791. GtkWidget* widget;
  1792. path = gtk_theming_engine_get_path(engine);
  1793. state = gtk_theming_engine_get_state(engine);
  1794. widget = m_widgetLookup.find(cr, path);
  1795. if (gtk_widget_path_is_type(path, GTK_TYPE_HANDLE_BOX)) {
  1796. TQStringList objectTypes;
  1797. objectTypes.append(TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING);
  1798. TQPalette objectPalette = tqApp->palette(objectTypes);
  1799. // Draw handle
  1800. tqApp->style().drawPrimitive(TQStyle::PE_DockWindowHandle, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget) | ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQStyle::Style_Default:TQStyle::Style_Horizontal));
  1801. }
  1802. else if (gtk_widget_path_is_type(path, GTK_TYPE_PANED)) {
  1803. TQStringList objectTypes;
  1804. objectTypes.append(TQSPLITTER_OBJECT_NAME_STRING);
  1805. TQPalette objectPalette = tqApp->palette(objectTypes);
  1806. // Draw handle
  1807. tqApp->style().drawPrimitive(TQStyle::PE_Splitter, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget) | ((gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQStyle::Style_Default:TQStyle::Style_Horizontal));
  1808. }
  1809. else {
  1810. DEBUG_FILL_BACKGROUND_WITH_COLOR(p,0,128,255);
  1811. printf("[WARNING] tdegtk_draw_handle() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout);
  1812. }
  1813. p.end();
  1814. }
  1815. static void
  1816. tdegtk_draw_line (GtkThemingEngine *engine,
  1817. cairo_t *cr,
  1818. gdouble x0,
  1819. gdouble y0,
  1820. gdouble x1,
  1821. gdouble y1)
  1822. {
  1823. // FIXME
  1824. // This should be using TQt to draw the line with an appropriate line color from the current widget type palette
  1825. // line endings
  1826. if (y0 == y1) {
  1827. y0 += 0.5;
  1828. y1 += 0.5;
  1829. x0 += 0.5;
  1830. x1 -= 0.5;
  1831. }
  1832. else if (x0 == x1) {
  1833. x0 += 0.5;
  1834. x1 += 0.5;
  1835. y0 += 0.5;
  1836. y1 -= 0.5;
  1837. }
  1838. cairo_move_to (cr, x0, y0);
  1839. cairo_line_to (cr, x1, y1);
  1840. tdegtk_cairo_set_source_border (engine, cr, MAX (x1 - x0, 1), MAX (y1 - y0, 1));
  1841. cairo_stroke (cr);
  1842. }
  1843. static void
  1844. tdegtk_draw_notebook (DRAW_ARGS,
  1845. GtkPositionType gap_side,
  1846. gdouble xy0_gap,
  1847. gdouble xy1_gap)
  1848. {
  1849. TQRect boundingRect(0, 0, width, height);
  1850. TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
  1851. TQPainter p(&pd);
  1852. DEBUG_FILL_BACKGROUND_WITH_COLOR(p,0,255,0);
  1853. const GtkWidgetPath* path;
  1854. GtkStateFlags state;
  1855. GtkWidget* widget;
  1856. path = gtk_theming_engine_get_path(engine);
  1857. state = gtk_theming_engine_get_state(engine);
  1858. widget = m_widgetLookup.find(cr, path);
  1859. TQStringList objectTypes;
  1860. objectTypes.append(TQTABWIDGET_OBJECT_NAME_STRING);
  1861. TQPalette objectPalette = tqApp->palette(objectTypes);
  1862. // Draw background
  1863. TQBrush brush = objectPalette.brush(gtkToTQPaletteColorGroup(engine, state), TQColorGroup::Background);
  1864. DRAW_FILLED_RECTANGLE_OVER_ENTIRE_AREA(p, brush)
  1865. // Draw tab frame
  1866. tqApp->style().drawPrimitive(TQStyle::PE_PanelTabWidget, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget));
  1867. p.end();
  1868. }
  1869. static void
  1870. tdegtk_draw_radio (DRAW_ARGS)
  1871. {
  1872. TQRect boundingRect(0, 0, width, height);
  1873. TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
  1874. TQPainter p(&pd);
  1875. const GtkWidgetPath* path;
  1876. GtkStateFlags state;
  1877. GtkWidget* widget;
  1878. path = gtk_theming_engine_get_path(engine);
  1879. state = gtk_theming_engine_get_state(engine);
  1880. widget = m_widgetLookup.find(cr, path);
  1881. if (gtk_widget_path_is_type(path, GTK_TYPE_TREE_VIEW)) {
  1882. draw_radiobutton(engine, cr, x, y, width, height, path, state, widget, TQT3WT_GTKTreeViewCell);
  1883. }
  1884. else if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_MENUITEM)) {
  1885. const GtkAllocation allocation = Gtk::gtk_widget_get_allocation(widget);
  1886. boundingRect = TQRect(0, 0, allocation.width, allocation.height);
  1887. TQt3CairoPaintDevice pd2(NULL, 0, 0, allocation.width, allocation.height, cr);
  1888. TQPainter p2(&pd2);
  1889. bool checked = ((state & GTK_STATE_FLAG_ACTIVE) != 0);
  1890. int maxAcceleratorTextWidth = 0;
  1891. int maxIconWidth = IconSize(KIcon::Small) + 4;
  1892. TQStringList objectTypes;
  1893. objectTypes.append(TQPOPUPMENU_OBJECT_NAME_STRING);
  1894. TQPalette objectPalette = tqApp->palette(objectTypes);
  1895. TQStyleControlElementData ceData;
  1896. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  1897. ceData.widgetObjectTypes = objectTypes;
  1898. ceData.rect = boundingRect;
  1899. TQMenuItem tqt3MenuItem;
  1900. tqt3MenuItem.setChecked(checked);
  1901. TQStyleOption menuOpt(&tqt3MenuItem, maxIconWidth, maxAcceleratorTextWidth);
  1902. elementFlags = elementFlags | TQStyle::TQStyle::CEF_IsCheckable;
  1903. if (checked) {
  1904. tqApp->style().drawPrimitive(TQStyle::PE_MenuItemIndicatorFrame, &p2, ceData, elementFlags, ceData.rect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQRadioButton, widget), menuOpt);
  1905. tqApp->style().drawPrimitive(TQStyle::PE_MenuItemIndicatorCheck, &p2, ceData, elementFlags, ceData.rect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQRadioButton, widget), menuOpt);
  1906. }
  1907. }
  1908. else {
  1909. draw_radiobutton(engine, cr, x, y, width, height, path, state, widget, TQT3WT_TQRadioButton);
  1910. }
  1911. p.end();
  1912. }
  1913. static void
  1914. tdegtk_draw_separator (DRAW_ARGS)
  1915. {
  1916. TQRect boundingRect(0, 0, width, height);
  1917. TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
  1918. TQPainter p(&pd);
  1919. const GtkWidgetPath* path;
  1920. GtkStateFlags state;
  1921. GtkWidget* widget;
  1922. path = gtk_theming_engine_get_path(engine);
  1923. state = gtk_theming_engine_get_state(engine);
  1924. widget = m_widgetLookup.find(cr, path);
  1925. if (gtk_widget_path_is_type(path, GTK_TYPE_SEPARATOR_MENU_ITEM)) {
  1926. TQStringList objectTypes;
  1927. objectTypes.append(TQPOPUPMENU_OBJECT_NAME_STRING);
  1928. TQPalette objectPalette = tqApp->palette(objectTypes);
  1929. bool pressed = false;
  1930. bool prelight = false;
  1931. TQStyleControlElementData ceData;
  1932. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  1933. ceData.widgetObjectTypes = objectTypes;
  1934. ceData.rect = boundingRect;
  1935. TQMenuItem tqt3MenuItem;
  1936. tqt3MenuItem.setSeparator(true);
  1937. int maxAcceleratorTextWidth = 0;
  1938. int maxIconWidth = IconSize(KIcon::Small) + 4;
  1939. TQStyleOption menuOpt(&tqt3MenuItem, maxIconWidth, maxAcceleratorTextWidth);
  1940. // if (???) elementFlags = elementFlags | TQStyle::TQStyle::CEF_IsCheckable;
  1941. TQRect paintDeviceRect;
  1942. TQRect backgroundRect;
  1943. // Draw item
  1944. tqApp->style().drawControl(TQStyle::CE_PopupMenuItem, &p, ceData, elementFlags, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_TQMenuItem, widget), menuOpt);
  1945. }
  1946. else if (gtk_widget_path_is_type(path, GTK_TYPE_SEPARATOR)) {
  1947. TQt::Orientation orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal;
  1948. tqApp->style().drawPrimitive(TQStyle::PE_Separator, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget) | ((orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default));
  1949. }
  1950. else if (gtk_widget_path_is_type(path, GTK_TYPE_SEPARATOR_TOOL_ITEM)) {
  1951. TQt::Orientation orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal;
  1952. tqApp->style().drawPrimitive(TQStyle::PE_Separator, &p, boundingRect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget) | ((orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default));
  1953. }
  1954. else {
  1955. DEBUG_FILL_BACKGROUND_WITH_COLOR(p,128,128,255);
  1956. printf("[WARNING] tdegtk_draw_separator() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout);
  1957. }
  1958. p.end();
  1959. }
  1960. static void
  1961. tdegtk_draw_slider (DRAW_ARGS,
  1962. GtkOrientation orientation)
  1963. {
  1964. cairo_save(cr);
  1965. cairo_reset_clip(cr);
  1966. TQRect boundingRect(0, 0, width, height);
  1967. TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
  1968. TQPainter p(&pd);
  1969. const GtkWidgetPath* path;
  1970. GtkStateFlags state;
  1971. GtkWidget* widget;
  1972. path = gtk_theming_engine_get_path(engine);
  1973. state = gtk_theming_engine_get_state(engine);
  1974. widget = m_widgetLookup.find(cr, path);
  1975. if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_SCROLLBAR)) {
  1976. #ifdef DRAW_SCROLLBAR_PIECES_INSTEAD_OF_ENTIRE_BAR
  1977. TQStringList objectTypes;
  1978. objectTypes.append(TQSCROLLBAR_OBJECT_NAME_STRING);
  1979. TQPalette objectPalette = tqApp->palette(objectTypes);
  1980. GtkRange* rangeWidget = GTK_RANGE(widget);
  1981. TQStyleControlElementData ceData;
  1982. TQStyle::ControlElementFlags elementFlags = TQStyle::CEF_None;
  1983. ceData.widgetObjectTypes = objectTypes;
  1984. ceData.rect = boundingRect;
  1985. ceData.orientation = (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_VERTICAL))?TQt::Vertical:TQt::Horizontal;
  1986. gtkRangeToCeData(rangeWidget, ceData);
  1987. // Draw slider
  1988. TQRect scrollpagerect = tqApp->style().querySubControlMetrics(TQStyle::CC_ScrollBar, ceData, elementFlags, TQStyle::SC_ScrollBarSlider, gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget));
  1989. if (ceData.orientation == TQt::Vertical) {
  1990. scrollpagerect.setY(ceData.rect.y());
  1991. scrollpagerect.setHeight(ceData.rect.height());
  1992. }
  1993. else {
  1994. scrollpagerect.setX(ceData.rect.x());
  1995. scrollpagerect.setWidth(ceData.rect.width());
  1996. }
  1997. tqApp->style().drawPrimitive(TQStyle::PE_ScrollBarSlider, &p, scrollpagerect, gtkToTQtColorGroup(engine, state), gtkToTQtStyleFlags(engine, state, TQT3WT_NONE, widget) | ((ceData.orientation == TQt::Horizontal)?TQStyle::Style_Horizontal:TQStyle::Style_Default));
  1998. #else
  1999. // draw_scrollbar_frame(engine, cr, x, y, width, height, path, state, widget);
  2000. #endif
  2001. }
  2002. else if (gtk_theming_engine_has_class(engine, GTK_STYLE_CLASS_SCALE)) {
  2003. draw_slider_frame(engine, cr, x, y, width, height, path, state, widget);
  2004. }
  2005. else {
  2006. DEBUG_FILL_BACKGROUND_WITH_COLOR(p,255,0,255);
  2007. printf("[WARNING] tdegtk_draw_slider() nonfunctional for widget with path '%s'\n\r", gtk_widget_path_to_string (gtk_theming_engine_get_path(engine))); fflush(stdout);
  2008. }
  2009. p.end();
  2010. cairo_restore(cr);
  2011. }
  2012. static void
  2013. tdegtk_draw_spinbutton_background (DRAW_ARGS)
  2014. {
  2015. TQRect boundingRect(0, 0, width, height);
  2016. TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
  2017. TQPainter p(&pd);
  2018. DEBUG_FILL_BACKGROUND_WITH_COLOR(p,128,255,0);
  2019. p.end();
  2020. }
  2021. static void
  2022. tdegtk_draw_spinbutton_frame (DRAW_ARGS)
  2023. {
  2024. TQRect boundingRect(0, 0, width, height);
  2025. TQt3CairoPaintDevice pd(NULL, x, y, width, height, cr);
  2026. TQPainter p(&pd);
  2027. DEBUG_FILL_BACKGROUND_WITH_COLOR(p,128,255,128);
  2028. p.end();
  2029. }
  2030. void
  2031. tdegtk_register_style_default (TdeGtkStyleFunctions *functions)
  2032. {
  2033. g_assert (functions);
  2034. functions->draw_activity = tdegtk_draw_activity;
  2035. functions->draw_arrow = tdegtk_draw_arrow;
  2036. functions->draw_cell_background = tdegtk_draw_cell_background;
  2037. functions->draw_cell_frame = tdegtk_draw_cell_frame;
  2038. functions->draw_check = tdegtk_draw_check;
  2039. functions->draw_common = tdegtk_draw_common;
  2040. functions->draw_common_background = tdegtk_draw_common_background;
  2041. functions->draw_common_frame = tdegtk_draw_common_frame;
  2042. functions->draw_expander = tdegtk_draw_expander;
  2043. functions->draw_extension = tdegtk_draw_extension;
  2044. functions->draw_focus = tdegtk_draw_focus;
  2045. functions->draw_frame_gap = tdegtk_draw_frame_gap;
  2046. functions->draw_grip = tdegtk_draw_grip;
  2047. functions->draw_handle = tdegtk_draw_handle;
  2048. functions->draw_line = tdegtk_draw_line;
  2049. functions->draw_notebook = tdegtk_draw_notebook;
  2050. functions->draw_radio = tdegtk_draw_radio;
  2051. functions->draw_separator = tdegtk_draw_separator;
  2052. functions->draw_slider = tdegtk_draw_slider;
  2053. functions->draw_spinbutton_background = tdegtk_draw_spinbutton_background;
  2054. functions->draw_spinbutton_frame = tdegtk_draw_spinbutton_frame;
  2055. }