Knopf.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  1. #include "Knopf.h"
  2. #include "AlphaFeld.h"
  3. #include "Bild.h"
  4. #include "Datei.h"
  5. #include "DateiSystem.h"
  6. #include "Globals.h"
  7. #include "MausEreignis.h"
  8. #include "Rahmen.h"
  9. #include "Schrift.h"
  10. #include "Scroll.h"
  11. #include "TastaturEreignis.h"
  12. #include "Text.h"
  13. #include "ToolTip.h"
  14. using namespace Framework;
  15. // Contents of the Knopf class from Knopf.h
  16. // Constructor
  17. Knopf::Knopf()
  18. : TextFeld(),
  19. klickFarbe(0xFF000000),
  20. klickBild(0),
  21. klickBuffer(0),
  22. klickIndex(0)
  23. {
  24. style
  25. = Style::Erlaubt | Style::Buffered | Style::KlickBuffer | Style::Rahmen;
  26. this->setMausEreignis(_ret1ME);
  27. setSchriftFarbe(0xFFFFFFFF);
  28. setSchriftSize(12);
  29. setRahmenBreite(2);
  30. setRahmenFarbe(0xFF00FF00);
  31. setAlphaFeldFarbe(0x5500FF00);
  32. setAlphaFeldStrength(-5);
  33. setKBFarbe(0xFF000000);
  34. setKBStrength(20);
  35. addStyle(TextFeld::Style::Center);
  36. }
  37. // Destructor
  38. Knopf::~Knopf()
  39. {
  40. if (klickBuffer) klickBuffer->release();
  41. if (klickBild) klickBild->release();
  42. }
  43. void Knopf::doMausEreignis(MausEreignis& me, bool userRet) // Mouse event
  44. {
  45. if (hatStyleNicht(Style::Erlaubt) || !userRet) return;
  46. if (me.id == ME_Betritt)
  47. {
  48. klickIndex = MausStand[M_Links];
  49. if (klickIndex) rend = 1;
  50. }
  51. if (me.id == ME_RLinks || me.id == ME_Leaves)
  52. {
  53. if (klickIndex) rend = 1;
  54. klickIndex = 0;
  55. }
  56. if (!me.verarbeitet)
  57. {
  58. if (me.id == ME_PLinks)
  59. {
  60. klickIndex = 1;
  61. rend = 1;
  62. }
  63. me.verarbeitet = 1;
  64. }
  65. }
  66. // non-constant
  67. void Knopf::setKlickFarbe(int fc) // sets the click color
  68. {
  69. klickFarbe = fc;
  70. rend = 1;
  71. }
  72. void Knopf::setKlickBild(Bild* bild) // sets the click image
  73. {
  74. if (bild)
  75. {
  76. if (!klickBild) klickBild = new Bild();
  77. klickBild->neuBild(bild->getBreite(), bild->getHeight(), 0);
  78. int* buff1 = klickBild->getBuffer();
  79. int* buff2 = bild->getBuffer();
  80. for (int i = 0; i < bild->getBreite() * bild->getHeight(); ++i)
  81. buff1[i] = buff2[i];
  82. bild->release();
  83. rend = 1;
  84. }
  85. }
  86. void Knopf::setKlickBildZ(Bild* bild) // sets a pointer to the click image
  87. {
  88. if (klickBild) klickBild->release();
  89. klickBild = bild;
  90. rend = 1;
  91. }
  92. void Knopf::setKBZ(AlphaFeld* af)
  93. {
  94. if (klickBuffer) klickBuffer->release();
  95. klickBuffer = af;
  96. rend = 1;
  97. }
  98. void Knopf::setKBStrength(int st) // sets the click buffer strength
  99. {
  100. if (!klickBuffer) klickBuffer = new AlphaFeld();
  101. klickBuffer->setStrength(st);
  102. rend = 1;
  103. }
  104. void Knopf::setKBFarbe(int fc) // sets the click buffer color
  105. {
  106. if (!klickBuffer) klickBuffer = new AlphaFeld();
  107. klickBuffer->setFarbe(fc);
  108. rend = 1;
  109. }
  110. // Processes mouse messages
  111. // te: The event triggered by the keyboard input
  112. void Knopf::doTastaturEreignis(TastaturEreignis& te) {}
  113. void Knopf::render(Bild& zRObj) // renders int zRObj
  114. {
  115. if (!hatStyle(Style::Sichtbar)) return;
  116. addStyle(TextFeld::Style::Center);
  117. bool erlaubt = hatStyle(Style::Erlaubt);
  118. bool rA = 0;
  119. if (!hatStyle(Style::Erlaubt))
  120. {
  121. zRObj.setAlpha(0x20);
  122. rA = 1;
  123. }
  124. bool tmpRend = rend;
  125. removeStyle(Style::VScroll | Style::HScroll | Style::Erlaubt);
  126. TextFeld::render(zRObj);
  127. if (!zRObj.setDrawOptions(innenPosition, innenSize))
  128. {
  129. if (rA) zRObj.releaseAlpha();
  130. setStyle(Style::Erlaubt, erlaubt);
  131. return;
  132. }
  133. if (hatStyle(Style::Sichtbar) && klickIndex == 1)
  134. {
  135. if (hatStyle(Style::KlickFarbe))
  136. {
  137. if (hatStyle(Style::KlickAlpha))
  138. zRObj.alphaRegion(0, 0, innenSize.x, innenSize.y, klickFarbe);
  139. else
  140. zRObj.fillRegion(0, 0, innenSize.x, innenSize.y, klickFarbe);
  141. }
  142. if (hatStyle(Style::KlickBild) && klickBild)
  143. {
  144. if (hatStyle(Style::KlickAlpha))
  145. zRObj.alphaBild(0, 0, innenSize.x, innenSize.y, *klickBild);
  146. else
  147. zRObj.drawBild(0, 0, innenSize.x, innenSize.y, *klickBild);
  148. }
  149. if (hatStyle(Style::KlickBuffer) && klickBuffer)
  150. {
  151. klickBuffer->setSize(innenSize.x, innenSize.y);
  152. klickBuffer->render(zRObj);
  153. }
  154. }
  155. if (rA) zRObj.releaseAlpha();
  156. zRObj.releaseDrawOptions();
  157. setStyle(Style::Erlaubt, erlaubt);
  158. rend = tmpRend;
  159. }
  160. // constant
  161. int Knopf::getKlickFarbe() const // returns the click color
  162. {
  163. return klickFarbe;
  164. }
  165. Bild* Knopf::getKlickBild() const // returns the click image
  166. {
  167. if (!klickBild) return 0;
  168. return dynamic_cast<Bild*>(klickBild->getThis());
  169. }
  170. Bild* Knopf::zKlickBild() const // returns a pointer to the click image
  171. {
  172. return klickBild;
  173. }
  174. AlphaFeld* Knopf::getKB() const // returns the click buffer
  175. {
  176. if (!klickBuffer) return 0;
  177. return dynamic_cast<AlphaFeld*>(klickBuffer->getThis());
  178. }
  179. AlphaFeld*
  180. Knopf::zKB() const // returns the click buffer without reference counter
  181. {
  182. return klickBuffer;
  183. }
  184. int Knopf::getKBFarbe() const // returns the click buffer color
  185. {
  186. if (!klickBuffer) return 0;
  187. return klickBuffer->getFarbe();
  188. }
  189. int Knopf::getKBStrength() const // returns the click buffer strength
  190. {
  191. if (!klickBuffer) return 0;
  192. return klickBuffer->getStrength();
  193. }
  194. Zeichnung*
  195. Knopf::dublizieren() const // creates a copy of the drawing and returns it
  196. {
  197. Knopf* obj = new Knopf();
  198. obj->setPosition(pos);
  199. obj->setSize(gr);
  200. obj->setMausEreignisParameter(makParam);
  201. obj->setTastaturEreignisParameter(takParam);
  202. obj->setMausEreignis(mak);
  203. obj->setTastaturEreignis(tak);
  204. if (toolTip) obj->setToolTipZ((ToolTip*)toolTip->dublizieren());
  205. obj->setStyle(style);
  206. obj->setSchriftSize(getSchriftSize());
  207. if (zSchrift()) obj->setSchriftZ(getSchrift());
  208. if (zText()) obj->setText(zText()->getText());
  209. obj->setHintergrundFarbe(hintergrundFarbe);
  210. obj->setSchriftFarbe(getSchriftFarbe());
  211. if (hintergrundFeld)
  212. obj->setAlphaFeldZ((AlphaFeld*)hintergrundFeld->dublizieren());
  213. if (rahmen) obj->setRahmenZ((Rahmen*)rahmen->dublizieren());
  214. if (hintergrundBild)
  215. obj->setHintergrundBild(
  216. dynamic_cast<Bild*>(hintergrundBild->getThis()));
  217. if (vertikalScrollBar)
  218. {
  219. obj->setVertikalKlickScroll(vertikalScrollBar->getKlickScroll());
  220. obj->setVertikalScrollPos(vertikalScrollBar->getScroll());
  221. obj->setVertikalScrollFarbe(
  222. vertikalScrollBar->getFarbe(), vertikalScrollBar->getBgFarbe());
  223. }
  224. if (horizontalScrollBar)
  225. {
  226. obj->setHorizontalKlickScroll(horizontalScrollBar->getKlickScroll());
  227. obj->setHorizontalScrollPos(horizontalScrollBar->getScroll());
  228. obj->setHorizontalScrollFarbe(
  229. horizontalScrollBar->getFarbe(), horizontalScrollBar->getBgFarbe());
  230. }
  231. obj->setSchowChar(getShowChar());
  232. // obj->setAuswahl( getSelectionPos(), getCursorPos() );
  233. obj->setKlickFarbe(klickFarbe);
  234. if (klickBild) obj->setKlickBild(dynamic_cast<Bild*>(klickBild->getThis()));
  235. if (klickBuffer) obj->setKBZ((AlphaFeld*)klickBuffer->dublizieren());
  236. return obj;
  237. }
  238. // Contents of the KontrollKnopf class from Knopf.h
  239. // Constructor
  240. KontrollKnopf::KontrollKnopf()
  241. : ZeichnungHintergrund(),
  242. txt(0),
  243. sTxt(0),
  244. sBgF(0),
  245. kBgF(0),
  246. sBgB(0),
  247. kBgB(0),
  248. sAf(0),
  249. kAf(0),
  250. kasten(0),
  251. sKasten(0),
  252. textRd(0),
  253. sF(0xFFFFFFFF),
  254. sGr(12)
  255. {
  256. style = Style::Erlaubt | Style::KlickBuffer;
  257. setKAFFarbe(0x00007500);
  258. setKAFStrength(-30);
  259. }
  260. // Destructor
  261. KontrollKnopf::~KontrollKnopf()
  262. {
  263. if (txt) txt->release();
  264. if (sTxt) sTxt->release();
  265. if (sBgB) sBgB->release();
  266. if (kBgB) kBgB->release();
  267. if (sAf) sAf->release();
  268. if (kAf) kAf->release();
  269. if (kasten) kasten->release();
  270. if (sKasten) sKasten->release();
  271. if (textRd) textRd->release();
  272. }
  273. void KontrollKnopf::doMausEreignis(
  274. MausEreignis& me, bool userRet) // process mouse events
  275. {
  276. if (me.id == ME_Leaves || !userRet) style &= ~Style::MausKlick;
  277. if (hatStyleNicht(TextFeld::Style::Erlaubt) || !userRet) return;
  278. if (me.id == ME_Betritt && hatStyle(Style::MausKlick) != MausStand[M_Links])
  279. setStyle(Style::MausKlick, MausStand[M_Links]);
  280. if (me.id == ME_PLinks) addStyle(Style::MausKlick);
  281. if (me.id == ME_RLinks)
  282. {
  283. removeStyle(Style::MausKlick);
  284. setStyle(Style::Selected, !hatStyle(Style::Selected));
  285. }
  286. me.verarbeitet = 1;
  287. }
  288. // non-constant
  289. void KontrollKnopf::setTextZ(Text* txt) // sets the text
  290. {
  291. if (this->txt) this->txt->release();
  292. this->txt = txt;
  293. rend = 1;
  294. }
  295. void KontrollKnopf::setText(Text* txt)
  296. {
  297. if (!this->txt) this->txt = new Text();
  298. this->txt->setText(txt->getText());
  299. txt->release();
  300. rend = 1;
  301. }
  302. void KontrollKnopf::setText(const char* txt)
  303. {
  304. if (!this->txt) this->txt = new Text();
  305. this->txt->setText(txt);
  306. rend = 1;
  307. }
  308. void KontrollKnopf::setSTextZ(Text* txt) // sets the text when selected
  309. {
  310. if (sTxt) sTxt->release();
  311. sTxt = txt;
  312. rend = 1;
  313. }
  314. void KontrollKnopf::setSText(Text* txt)
  315. {
  316. if (!sTxt) sTxt = new Text();
  317. sTxt->setText(txt->getText());
  318. txt->release();
  319. rend = 1;
  320. }
  321. void KontrollKnopf::setSText(const char* txt)
  322. {
  323. if (!sTxt) sTxt = new Text();
  324. sTxt->setText(txt);
  325. rend = 1;
  326. }
  327. void KontrollKnopf::setTextRendererZ(TextRenderer* textRd)
  328. {
  329. if (this->textRd) this->textRd->release();
  330. this->textRd = textRd;
  331. }
  332. void KontrollKnopf::setSchriftZ(Schrift* schrift) // sets the font
  333. {
  334. if (!this->textRd)
  335. textRd = new TextRenderer(schrift);
  336. else
  337. textRd->setSchriftZ(schrift);
  338. rend = 1;
  339. }
  340. void KontrollKnopf::setSFarbe(int f) // sets the font color
  341. {
  342. sF = f;
  343. rend = 1;
  344. }
  345. void KontrollKnopf::setSSize(int gr) // sets the font size
  346. {
  347. sGr = gr;
  348. rend = 1;
  349. }
  350. void KontrollKnopf::setSBgFarbe(int f) // sets the select background color
  351. {
  352. sBgF = f;
  353. rend = 1;
  354. }
  355. void KontrollKnopf::setKBgFarbe(int f) // sets the click background color
  356. {
  357. kBgF = f;
  358. rend = 1;
  359. }
  360. void KontrollKnopf::setSBgBildZ(Bild* b) // sets the select background image
  361. {
  362. if (sBgB) sBgB->release();
  363. sBgB = b;
  364. rend = 1;
  365. }
  366. void KontrollKnopf::setSBgBild(Bild* b)
  367. {
  368. if (!sBgB) sBgB = new Bild();
  369. sBgB->neuBild(b->getBreite(), b->getHeight(), 0);
  370. sBgB->drawBild(0, 0, b->getBreite(), b->getHeight(), *b);
  371. b->release();
  372. rend = 1;
  373. }
  374. void KontrollKnopf::setKBgBildZ(Bild* b) // sets the click background image
  375. {
  376. if (kBgB) kBgB->release();
  377. kBgB = b;
  378. rend = 1;
  379. }
  380. void KontrollKnopf::setKBgBild(Bild* b)
  381. {
  382. if (!kBgB) kBgB = new Bild();
  383. kBgB->neuBild(b->getBreite(), b->getHeight(), 0);
  384. kBgB->drawBild(0, 0, b->getBreite(), b->getHeight(), *b);
  385. b->release();
  386. rend = 1;
  387. }
  388. void KontrollKnopf::setSAlphaFeldZ(AlphaFeld* af) // sets the select AlphaFeld
  389. {
  390. if (sAf) sAf->release();
  391. sAf = af;
  392. rend = 1;
  393. }
  394. void KontrollKnopf::setSAFFarbe(int f) // sets the select AlphaFeld color
  395. {
  396. if (!sAf) sAf = new AlphaFeld();
  397. sAf->setFarbe(f);
  398. rend = 1;
  399. }
  400. void KontrollKnopf::setSAFStrength(int st) // sets the select AlphaFeld strength
  401. {
  402. if (!sAf) sAf = new AlphaFeld();
  403. sAf->setStrength(st);
  404. rend = 1;
  405. }
  406. void KontrollKnopf::setKAlphaFeldZ(AlphaFeld* af) // sets the click AlphaFeld
  407. {
  408. if (kAf) kAf->release();
  409. kAf = af;
  410. rend = 1;
  411. }
  412. void KontrollKnopf::setKAFFarbe(int f) // sets the click AlphaFeld color
  413. {
  414. if (!kAf) kAf = new AlphaFeld();
  415. kAf->setFarbe(f);
  416. rend = 1;
  417. }
  418. void KontrollKnopf::setKAFStrength(int st) // sets the click AlphaFeld strength
  419. {
  420. if (!kAf) kAf = new AlphaFeld();
  421. kAf->setStrength(st);
  422. rend = 1;
  423. }
  424. void KontrollKnopf::loadData(LTDBDatei* dat) // loading the system images
  425. {
  426. if (DateiExistiert(new Text("data/normal.ltdb"))
  427. && (!dat || !dat->istOffen()))
  428. {
  429. LTDBDatei* dat = new LTDBDatei();
  430. dat->setDatei(new Text("data/normal.ltdb"));
  431. dat->leseDaten(0);
  432. kasten = dat->laden(0, new Text("kasten.gif"));
  433. sKasten = dat->laden(0, new Text("skasten.gif"));
  434. dat->release();
  435. }
  436. else
  437. {
  438. kasten = dat->laden(0, new Text("kasten.gif"));
  439. sKasten = dat->laden(0, new Text("skasten.gif"));
  440. }
  441. rend = 1;
  442. }
  443. void KontrollKnopf::loadData(
  444. const char* ltdb) // loading the system images with a specified LTDB file
  445. {
  446. if (DateiExistiert(new Text(ltdb)))
  447. {
  448. LTDBDatei* dat = new LTDBDatei();
  449. dat->setDatei(new Text(ltdb));
  450. dat->leseDaten(0);
  451. kasten = dat->laden(0, new Text("kasten.gif"));
  452. sKasten = dat->laden(0, new Text("skasten.gif"));
  453. dat->release();
  454. rend = 1;
  455. }
  456. }
  457. void KontrollKnopf::render(Bild& zRObj) // renders into zRObj
  458. {
  459. if (!hatStyle(Style::Sichtbar)) return;
  460. removeStyle(Style::VScroll | Style::HScroll);
  461. ZeichnungHintergrund::render(zRObj);
  462. lockZeichnung();
  463. if (!zRObj.setDrawOptions(innenPosition, innenSize))
  464. {
  465. unlockZeichnung();
  466. return;
  467. }
  468. if (hatStyle(Style::MausKlick))
  469. {
  470. if (hatStyle(Style::KlickFarbe))
  471. {
  472. if (hatStyle(Style::KlickAlpha))
  473. zRObj.alphaRegion(0, 0, innenSize.x, innenSize.y, kBgF);
  474. else
  475. zRObj.fillRegion(0, 0, innenSize.x, innenSize.y, kBgF);
  476. }
  477. if (hatStyle(Style::KlickBild) && kBgB)
  478. {
  479. if (hatStyle(Style::KlickAlpha))
  480. zRObj.alphaBild(0, 0, innenSize.x, innenSize.y, *kBgB);
  481. else
  482. zRObj.drawBild(0, 0, innenSize.x, innenSize.y, *kBgB);
  483. }
  484. if (hatStyle(Style::KlickBuffer) && kAf)
  485. {
  486. kAf->setSize(innenSize.x, innenSize.y);
  487. kAf->render(zRObj);
  488. }
  489. int kbr = 0;
  490. if (hatStyle(Style::Selected) && sKasten)
  491. {
  492. if (sTxt && textRd)
  493. zRObj.drawBild(0,
  494. (gr.y / 2 - sKasten->getHeight() / 2) < 0
  495. ? 0
  496. : (gr.y / 2 - sKasten->getHeight() / 2),
  497. innenSize.x,
  498. innenSize.y,
  499. *sKasten);
  500. else
  501. zRObj.drawBild(gr.x / 2 - sKasten->getBreite() / 2,
  502. (gr.y / 2 - sKasten->getHeight() / 2) < 0
  503. ? 0
  504. : (gr.y / 2 - sKasten->getHeight() / 2),
  505. innenSize.x,
  506. innenSize.y,
  507. *sKasten);
  508. kbr = sKasten->getBreite();
  509. if (sTxt && textRd)
  510. {
  511. textRd->setSchriftSize(sGr);
  512. textRd->renderText(kbr + 5,
  513. gr.y / 2 - textRd->getTextHeight(sTxt->getText()) / 2,
  514. sTxt->getText(),
  515. zRObj,
  516. sF);
  517. }
  518. }
  519. else if (kasten)
  520. {
  521. if (txt && textRd)
  522. zRObj.drawBild(0,
  523. (gr.y / 2 - kasten->getHeight() / 2) < 0
  524. ? 0
  525. : (gr.y / 2 - kasten->getHeight() / 2),
  526. innenSize.x,
  527. innenSize.y,
  528. *kasten);
  529. else
  530. zRObj.drawBild(gr.x / 2 - kasten->getBreite() / 2,
  531. (gr.y / 2 - kasten->getHeight() / 2) < 0
  532. ? 0
  533. : (gr.y / 2 - kasten->getHeight() / 2),
  534. innenSize.x,
  535. innenSize.y,
  536. *kasten);
  537. kbr = kasten->getBreite();
  538. if (txt && textRd)
  539. {
  540. textRd->setSchriftSize(sGr);
  541. textRd->renderText(kbr + 5,
  542. gr.y / 2 - textRd->getTextHeight(txt->getText()) / 2,
  543. txt->getText(),
  544. zRObj,
  545. sF);
  546. }
  547. }
  548. }
  549. else if (hatStyle(Style::Selected))
  550. {
  551. if (hatStyle(Style::SelectFarbe))
  552. {
  553. if (hatStyle(Style::SelectAlpha))
  554. zRObj.alphaRegion(0, 0, innenSize.x, innenSize.y, sBgF);
  555. else
  556. zRObj.fillRegion(0, 0, innenSize.x, innenSize.y, sBgF);
  557. }
  558. if (hatStyle(Style::SelectBild) && sBgB)
  559. {
  560. if (hatStyle(Style::SelectAlpha))
  561. zRObj.alphaBild(0, 0, innenSize.x, innenSize.y, *sBgB);
  562. else
  563. zRObj.drawBild(0, 0, innenSize.x, innenSize.y, *sBgB);
  564. }
  565. if (hatStyle(Style::SelectBuffer) && sAf)
  566. {
  567. sAf->setSize(innenSize.x, innenSize.y);
  568. sAf->render(zRObj);
  569. }
  570. int kbr = 0;
  571. if (sKasten)
  572. {
  573. if (sTxt && textRd)
  574. zRObj.drawBild(0,
  575. (gr.y / 2 - sKasten->getHeight() / 2) < 0
  576. ? 0
  577. : (gr.y / 2 - sKasten->getHeight() / 2),
  578. innenSize.x,
  579. innenSize.y,
  580. *sKasten);
  581. else
  582. zRObj.drawBild(gr.x / 2 - sKasten->getBreite() / 2,
  583. (gr.y / 2 - sKasten->getHeight() / 2) < 0
  584. ? 0
  585. : (gr.y / 2 - sKasten->getHeight() / 2),
  586. innenSize.x,
  587. innenSize.y,
  588. *sKasten);
  589. kbr = sKasten->getBreite();
  590. }
  591. if (sTxt && textRd)
  592. {
  593. textRd->setSchriftSize(sGr);
  594. textRd->renderText(kbr + 5,
  595. gr.y / 2 - textRd->getTextHeight(sTxt->getText()) / 2,
  596. sTxt->getText(),
  597. zRObj,
  598. sF);
  599. }
  600. }
  601. else
  602. {
  603. int kbr = 0;
  604. if (kasten)
  605. {
  606. if (txt && textRd)
  607. zRObj.drawBild(0,
  608. (gr.y / 2 - kasten->getHeight() / 2) < 0
  609. ? 0
  610. : (gr.y / 2 - kasten->getHeight() / 2),
  611. innenSize.x,
  612. innenSize.y,
  613. *kasten);
  614. else
  615. zRObj.drawBild(gr.x / 2 - kasten->getBreite() / 2,
  616. (gr.y / 2 - kasten->getHeight() / 2) < 0
  617. ? 0
  618. : (gr.y / 2 - kasten->getHeight() / 2),
  619. innenSize.x,
  620. innenSize.y,
  621. *kasten);
  622. kbr = kasten->getBreite();
  623. }
  624. if (txt && textRd)
  625. {
  626. textRd->setSchriftSize(sGr);
  627. textRd->renderText(kbr + 5,
  628. gr.y / 2 - textRd->getTextHeight(txt->getText()) / 2,
  629. txt->getText(),
  630. zRObj,
  631. sF);
  632. }
  633. }
  634. zRObj.releaseDrawOptions();
  635. unlockZeichnung();
  636. }
  637. // constant
  638. Text* KontrollKnopf::getText() const // returns the text
  639. {
  640. return txt ? dynamic_cast<Text*>(txt->getThis()) : 0;
  641. }
  642. Text* KontrollKnopf::zText() const
  643. {
  644. return txt;
  645. }
  646. Text* KontrollKnopf::getSText() const // returns the select text
  647. {
  648. return sTxt ? dynamic_cast<Text*>(sTxt->getThis()) : 0;
  649. }
  650. Text* KontrollKnopf::zSText() const
  651. {
  652. return sTxt;
  653. }
  654. Schrift* KontrollKnopf::getSchrift() const // returns the font
  655. {
  656. return textRd ? textRd->getSchrift() : 0;
  657. }
  658. Schrift* KontrollKnopf::zSchrift() const
  659. {
  660. return textRd ? textRd->zSchrift() : 0;
  661. }
  662. int KontrollKnopf::getSFarbe() const // returns the font color
  663. {
  664. return sF;
  665. }
  666. int KontrollKnopf::getSSize() const // returns the font size
  667. {
  668. return sGr;
  669. }
  670. int KontrollKnopf::getSBgFarbe() const // returns the select background color
  671. {
  672. return sBgF;
  673. }
  674. int KontrollKnopf::getKBgFarbe() const // returns the click background color
  675. {
  676. return kBgF;
  677. }
  678. Bild* KontrollKnopf::getSBgBild() const // returns the select background image
  679. {
  680. return sBgB ? dynamic_cast<Bild*>(sBgB->getThis()) : 0;
  681. }
  682. Bild* KontrollKnopf::zSBgBild() const
  683. {
  684. return sBgB;
  685. }
  686. Bild* KontrollKnopf::getKBgBild() const // returns the click background image
  687. {
  688. return kBgB ? dynamic_cast<Bild*>(kBgB->getThis()) : 0;
  689. }
  690. Bild* KontrollKnopf::zKBgBild() const
  691. {
  692. return kBgB;
  693. }
  694. AlphaFeld* KontrollKnopf::getSAlphaFeld() const // returns the select AlphaFeld
  695. {
  696. return sAf ? dynamic_cast<AlphaFeld*>(sAf->getThis()) : 0;
  697. }
  698. AlphaFeld* KontrollKnopf::zSAlphaFeld() const
  699. {
  700. return sAf;
  701. }
  702. AlphaFeld* KontrollKnopf::getKAlphaFeld() const // returns the click AlphaFeld
  703. {
  704. if (!kAf) return 0;
  705. return dynamic_cast<AlphaFeld*>(kAf->getThis());
  706. }
  707. AlphaFeld* KontrollKnopf::zKAlphaFeld() const
  708. {
  709. return kAf;
  710. }