Fenster.cpp 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390
  1. #include "Fenster.h"
  2. #include "AlphaFeld.h"
  3. #include "Bild.h"
  4. #include "Bildschirm.h"
  5. #include "Globals.h"
  6. #include "MausEreignis.h"
  7. #include "Rahmen.h"
  8. #include "Scroll.h"
  9. #include "TastaturEreignis.h"
  10. #include "Text.h"
  11. #include "TextFeld.h"
  12. #include "ToolTip.h"
  13. #ifdef WIN32
  14. # include "Maus.h"
  15. #endif
  16. #include <iostream>
  17. #include "Logging.h"
  18. #include "Zeit.h"
  19. using namespace Framework;
  20. #ifdef WIN32
  21. // Create window class
  22. WNDCLASS Framework::F_Normal(HINSTANCE hInst) // Creates a normal window class
  23. {
  24. if (!hInst) hInst = _hinst;
  25. WNDCLASS ret;
  26. ret.cbClsExtra = 0;
  27. ret.cbWndExtra = 0;
  28. ret.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  29. ret.hCursor = LoadCursor(NULL, IDC_ARROW);
  30. ret.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  31. ret.hInstance = hInst;
  32. ret.lpszMenuName = "";
  33. ret.lpfnWndProc = WindowProc;
  34. ret.style = CS_HREDRAW | CS_VREDRAW;
  35. return ret;
  36. }
  37. WNDCLASSEX Framework::F_NormalEx(HINSTANCE hInst)
  38. {
  39. if (!hInst) hInst = _hinst;
  40. WNDCLASSEX ret;
  41. ret.cbSize = sizeof(WNDCLASSEX);
  42. ret.cbClsExtra = 0;
  43. ret.cbWndExtra = 0;
  44. ret.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  45. ret.hCursor = LoadCursor(NULL, IDC_ARROW);
  46. ret.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  47. ret.hInstance = hInst;
  48. ret.lpszMenuName = "";
  49. ret.lpfnWndProc = WindowProc;
  50. ret.style = CS_HREDRAW | CS_VREDRAW;
  51. ret.hIconSm = 0;
  52. return ret;
  53. }
  54. // WinAPI
  55. LRESULT CALLBACK Framework::WindowProc(
  56. HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
  57. {
  58. setShowCursor(cursorVisible);
  59. if (msgExit) return (DefWindowProc(hwnd, message, wparam, lparam));
  60. switch (message)
  61. {
  62. case WM_SETCURSOR: // Mouse cursor
  63. MausZeiger.update();
  64. return 0;
  65. case WM_SIZE: // Window
  66. if (wparam == SIZE_RESTORED) WFensterA.sendRestoreMessage(hwnd);
  67. break;
  68. case WM_CLOSE: // Close
  69. if (WFensterA.sendVSchliessMessage(hwnd)) return 0;
  70. break;
  71. case WM_DESTROY:
  72. if (WFensterA.sendNSchliessMessage(hwnd)) return 0;
  73. break; // Mouse
  74. case WM_LBUTTONDOWN: // Left click
  75. {
  76. MausStand[M_Links] = 1;
  77. MausEreignis me = {ME_PLinks,
  78. (int)LOWORD(lparam),
  79. (int)HIWORD(lparam),
  80. 0,
  81. 1,
  82. (int)LOWORD(lparam),
  83. (int)HIWORD(lparam)};
  84. WFensterA.sendMausMessage(hwnd, me);
  85. break;
  86. }
  87. case WM_RBUTTONDOWN: // Right click
  88. {
  89. MausStand[M_Rechts] = 1;
  90. MausEreignis me = {ME_PRechts,
  91. (int)LOWORD(lparam),
  92. (int)HIWORD(lparam),
  93. 0,
  94. 1,
  95. (int)LOWORD(lparam),
  96. (int)HIWORD(lparam)};
  97. WFensterA.sendMausMessage(hwnd, me);
  98. break;
  99. }
  100. case WM_MBUTTONDOWN: // Middle click
  101. {
  102. MausStand[M_Mitte] = 1;
  103. MausEreignis me = {ME_PMitte,
  104. (int)LOWORD(lparam),
  105. (int)HIWORD(lparam),
  106. 0,
  107. 1,
  108. (int)LOWORD(lparam),
  109. (int)HIWORD(lparam)};
  110. WFensterA.sendMausMessage(hwnd, me);
  111. break;
  112. }
  113. case WM_LBUTTONUP: // Left release
  114. {
  115. MausStand[M_Links] = 0;
  116. MausEreignis me = {ME_RLinks,
  117. (int)LOWORD(lparam),
  118. (int)HIWORD(lparam),
  119. 0,
  120. 1,
  121. (int)LOWORD(lparam),
  122. (int)HIWORD(lparam)};
  123. WFensterA.sendMausMessage(hwnd, me);
  124. break;
  125. }
  126. case WM_RBUTTONUP: // Right release
  127. {
  128. MausStand[M_Rechts] = 0;
  129. MausEreignis me = {ME_RRechts,
  130. (int)LOWORD(lparam),
  131. (int)HIWORD(lparam),
  132. 0,
  133. 1,
  134. (int)LOWORD(lparam),
  135. (int)HIWORD(lparam)};
  136. WFensterA.sendMausMessage(hwnd, me);
  137. break;
  138. }
  139. case WM_MBUTTONUP: // Middle release
  140. {
  141. MausStand[M_Mitte] = 0;
  142. MausEreignis me = {ME_RMitte,
  143. (int)LOWORD(lparam),
  144. (int)HIWORD(lparam),
  145. 0,
  146. 1,
  147. (int)LOWORD(lparam),
  148. (int)HIWORD(lparam)};
  149. WFensterA.sendMausMessage(hwnd, me);
  150. break;
  151. }
  152. case WM_LBUTTONDBLCLK: // Left double click
  153. {
  154. MausEreignis me = {ME_DKLinks,
  155. (int)LOWORD(lparam),
  156. (int)HIWORD(lparam),
  157. 0,
  158. 1,
  159. (int)LOWORD(lparam),
  160. (int)HIWORD(lparam)};
  161. WFensterA.sendMausMessage(hwnd, me);
  162. break;
  163. }
  164. case WM_RBUTTONDBLCLK: // Right double click
  165. {
  166. MausEreignis me = {ME_DKRechts,
  167. (int)LOWORD(lparam),
  168. (int)HIWORD(lparam),
  169. 0,
  170. 1,
  171. (int)LOWORD(lparam),
  172. (int)HIWORD(lparam)};
  173. WFensterA.sendMausMessage(hwnd, me);
  174. break;
  175. }
  176. case WM_MBUTTONDBLCLK: // Middle double click
  177. {
  178. MausEreignis me = {ME_DKMitte,
  179. (int)LOWORD(lparam),
  180. (int)HIWORD(lparam),
  181. 0,
  182. 1,
  183. (int)LOWORD(lparam),
  184. (int)HIWORD(lparam)};
  185. WFensterA.sendMausMessage(hwnd, me);
  186. break;
  187. }
  188. case WM_MOUSEHOVER: // Mouse enters window
  189. {
  190. MausTrack = 1;
  191. MausEreignis me = {ME_Betritt,
  192. (int)LOWORD(lparam),
  193. (int)HIWORD(lparam),
  194. 0,
  195. 1,
  196. (int)LOWORD(lparam),
  197. (int)HIWORD(lparam)};
  198. WFensterA.sendMausMessage(hwnd, me);
  199. break;
  200. }
  201. case WM_MOUSELEAVE: // Mouse leaves window
  202. {
  203. MausTrack = 1;
  204. MausEreignis me = {ME_Leaves,
  205. (int)LOWORD(lparam),
  206. (int)HIWORD(lparam),
  207. 0,
  208. 1,
  209. (int)LOWORD(lparam),
  210. (int)HIWORD(lparam)};
  211. WFensterA.sendMausMessage(hwnd, me);
  212. break;
  213. }
  214. case WM_MOUSEMOVE: // Mouse is moving
  215. {
  216. if (MausTrack)
  217. {
  218. TRACKMOUSEEVENT lptme;
  219. lptme.cbSize = sizeof(TRACKMOUSEEVENT);
  220. lptme.dwFlags = TME_HOVER | TME_LEAVE;
  221. lptme.dwHoverTime = 0;
  222. lptme.hwndTrack = hwnd;
  223. TrackMouseEvent(&lptme);
  224. MausTrack = 0;
  225. }
  226. MausEreignis me = {ME_Bewegung,
  227. (int)LOWORD(lparam),
  228. (int)HIWORD(lparam),
  229. 0,
  230. 1,
  231. (int)LOWORD(lparam),
  232. (int)HIWORD(lparam)};
  233. WFensterA.sendMausMessage(hwnd, me);
  234. break;
  235. }
  236. case WM_MOUSEWHEEL: // Mouse scroll
  237. {
  238. Punkt pos = getMausPos();
  239. RECT r;
  240. GetWindowRect(hwnd, &r);
  241. pos.x -= r.left;
  242. pos.y -= r.top;
  243. MausEreignis me = {0, pos.x, pos.y, 0, 1, pos.x, pos.y};
  244. if ((int)(short)HIWORD(wparam) < 0)
  245. me.id = !getTastenStand(T_Shift) ? ME_DScroll : ME_RScroll;
  246. else
  247. me.id = !getTastenStand(T_Shift) ? ME_UScroll : ME_LScroll;
  248. WFensterA.sendMausMessage(hwnd, me);
  249. break;
  250. }
  251. // Keyboard
  252. case WM_KEYDOWN:
  253. {
  254. TastaturEreignis te = {
  255. TE_Press, {0, 0, 0},
  256. 0, 0
  257. };
  258. CalculateEnteredString((int)wparam, 0, te);
  259. WFensterA.sendTastaturMessage(hwnd, te);
  260. return 0;
  261. } // Key is pressed
  262. case WM_KEYUP:
  263. {
  264. TastaturEreignis te = {
  265. TE_Release, {0, 0, 0},
  266. 0, 0
  267. };
  268. CalculateEnteredString((int)wparam, HIWORD(lparam) & 0xFF, te);
  269. WFensterA.sendTastaturMessage(hwnd, te);
  270. return 0;
  271. } // Key is released
  272. }
  273. return (DefWindowProc(hwnd, message, wparam, lparam));
  274. }
  275. void Framework::StartNachrichtenSchleife()
  276. {
  277. MSG msg;
  278. while (GetMessage(&msg, NULL, 0, 0) > 0 && !msgExit)
  279. {
  280. if (!msgExit)
  281. {
  282. TranslateMessage(&msg);
  283. DispatchMessage(&msg);
  284. }
  285. }
  286. msgExit = 0;
  287. }
  288. void Framework::StopNachrichtenSchleife(HWND hwnd)
  289. {
  290. msgExit = 1;
  291. PostMessage(hwnd, WM_MOUSELEAVE, 0, 0);
  292. }
  293. void Framework::CalculateEnteredString(
  294. int virtualKeyCode, int scanCode, TastaturEreignis& te)
  295. {
  296. memset(te.taste, 0, sizeof(te.taste));
  297. te.virtualKey = virtualKeyCode;
  298. # ifdef WIN32
  299. unsigned char keyState[256];
  300. memset(keyState, 0, sizeof(keyState));
  301. if (GetKeyboardState(keyState))
  302. {
  303. unsigned short str[2] = {0, 0};
  304. int count = ToAscii(virtualKeyCode, scanCode, keyState, str, 0);
  305. if (count == 1 && (str[0] & 0xFF) == str[0])
  306. te.taste[0] = (unsigned char)str[0];
  307. else if (count == 2 && (str[0] & 0xFF) == str[0]
  308. && (str[1] & 0xFF) == str[1])
  309. te.taste[0] = (unsigned char)str[0],
  310. te.taste[1] = (unsigned char)str[1];
  311. }
  312. # endif // WIN32
  313. }
  314. // Contents of the WFenster class from Fenster.h
  315. // Constructor
  316. WFenster::WFenster()
  317. : ReferenceCounter(),
  318. hWnd(0),
  319. style(0),
  320. makParam(0),
  321. sakParam(0),
  322. takParam(0),
  323. mausAktion(0),
  324. vCloseAktion(0),
  325. nCloseAktion(0),
  326. tastaturAktion(0),
  327. screen(0),
  328. mx(-1),
  329. my(-1),
  330. verschiebbar(0),
  331. rahmen(0),
  332. bitmap(0),
  333. hdc(0)
  334. {
  335. WFensterA.addFenster(this);
  336. }
  337. WFenster::WFenster(HWND hwnd)
  338. : WFenster()
  339. {
  340. hWnd = hwnd;
  341. }
  342. // Destructor
  343. WFenster::~WFenster()
  344. {
  345. if (WFensterA.removeFenster(this))
  346. {
  347. WFensterA.del();
  348. }
  349. if (hWnd) zerstoeren();
  350. if (screen) screen->release();
  351. }
  352. // non-constant
  353. void WFenster::erstellen(int style, WNDCLASS wc) // Creates a window in Windows
  354. {
  355. if (!GetClassInfo(wc.hInstance, wc.lpszClassName, &wc))
  356. {
  357. # pragma warning(suppress : 6102)
  358. if (!RegisterClass(&wc)) // Register window class
  359. {
  360. MessageBox(hWnd,
  361. "Fehler beim Registrieren der Fensterklasse!",
  362. "Error",
  363. MB_ICONERROR); // Error message on failure
  364. return;
  365. }
  366. }
  367. hWnd = CreateWindow(wc.lpszClassName,
  368. wc.lpszClassName,
  369. style,
  370. 0,
  371. 0,
  372. 0,
  373. 0,
  374. 0,
  375. 0,
  376. wc.hInstance,
  377. 0); // Create window
  378. if (hWnd == 0)
  379. {
  380. MessageBox(hWnd,
  381. "Fehler beim erstellen des Fensters!",
  382. "Error",
  383. MB_ICONERROR); // Error message on failure
  384. return;
  385. }
  386. this->style = style;
  387. }
  388. void WFenster::erstellenEx(
  389. int exStyle, int style, WNDCLASSEX wc) // Create the window
  390. {
  391. if (!GetClassInfoEx(wc.hInstance, wc.lpszClassName, &wc))
  392. {
  393. # pragma warning(suppress : 6102)
  394. if (!RegisterClassEx(&wc)) // Register window class
  395. {
  396. MessageBox(hWnd,
  397. "Fehler beim Registrieren der Fensterklasse!",
  398. "Error",
  399. MB_ICONERROR); // Error message on failure
  400. return;
  401. }
  402. }
  403. hWnd = CreateWindowEx(exStyle,
  404. wc.lpszClassName,
  405. wc.lpszClassName,
  406. style,
  407. 0,
  408. 0,
  409. 0,
  410. 0,
  411. 0,
  412. 0,
  413. wc.hInstance,
  414. 0); // Create window
  415. if (hWnd == 0)
  416. {
  417. MessageBox(hWnd,
  418. "Fehler beim erstellen des Fensters!",
  419. "Error",
  420. MB_ICONERROR); // Error message on failure
  421. return;
  422. }
  423. this->style = style;
  424. }
  425. void WFenster::setAnzeigeModus(int mod) // Display window
  426. {
  427. if (rahmen)
  428. {
  429. if (mod == 2)
  430. ShowWindow(rahmen, 0);
  431. else
  432. ShowWindow(rahmen, mod);
  433. }
  434. ShowWindow(hWnd, mod);
  435. }
  436. bool WFenster::setFokus() // Sets the focus on the window
  437. {
  438. DWORD dwCurrentThread = GetCurrentThreadId();
  439. DWORD dwFGThread = GetWindowThreadProcessId(GetForegroundWindow(), NULL);
  440. AttachThreadInput(dwCurrentThread, dwFGThread, TRUE);
  441. SetFocus(hWnd);
  442. AttachThreadInput(dwCurrentThread, dwFGThread, FALSE);
  443. SetWindowPos(hWnd,
  444. HWND_TOPMOST,
  445. 0,
  446. 0,
  447. 0,
  448. 0,
  449. SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
  450. SetWindowPos(hWnd,
  451. HWND_NOTOPMOST,
  452. 0,
  453. 0,
  454. 0,
  455. 0,
  456. SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
  457. return GetFocus() == hWnd;
  458. }
  459. void WFenster::setPosition(const Punkt& p) // Window position
  460. {
  461. setPosition(p.x, p.y);
  462. }
  463. void WFenster::setPosition(int x, int y)
  464. {
  465. RECT r;
  466. GetWindowRect(hWnd, &r); // Find previous position
  467. RECT res;
  468. res.left = x, res.top = y, res.right = r.right - r.left,
  469. res.bottom = r.bottom - r.top;
  470. AdjustWindowRect(&res, style, 0);
  471. SetWindowPos(hWnd,
  472. 0,
  473. res.left,
  474. res.top,
  475. res.right,
  476. res.bottom,
  477. 0); // Change position
  478. }
  479. void WFenster::setSize(Punkt& g) // Window size
  480. {
  481. RECT r;
  482. GetWindowRect(hWnd, &r); // Find previous size
  483. RECT res;
  484. res.left = r.left, res.top = r.top, res.right = g.x, res.bottom = g.y;
  485. AdjustWindowRect(&res, style, 0);
  486. SetWindowPos(
  487. hWnd, 0, res.left, res.top, res.right, res.bottom, 0); // Change size
  488. }
  489. void WFenster::setSize(int breite, int hoehe)
  490. {
  491. RECT r;
  492. GetWindowRect(hWnd, &r); // Find previous size
  493. RECT res;
  494. res.left = r.left, res.top = r.top, res.right = breite, res.bottom = hoehe;
  495. AdjustWindowRect(&res, style, 0);
  496. SetWindowPos(
  497. hWnd, 0, res.left, res.top, res.right, res.bottom, 0); // Change size
  498. }
  499. void WFenster::setBounds(
  500. const Punkt& p, const Punkt& g) // sets size and position
  501. {
  502. SetWindowPos(hWnd, 0, p.x, p.y, g.x, g.y, 0); // Change size and position
  503. }
  504. void WFenster::setBildschirm(Bildschirm* screen)
  505. {
  506. if (this->screen) this->screen->release();
  507. this->screen = screen;
  508. }
  509. void WFenster::zerstoeren()
  510. {
  511. DestroyWindow(hWnd);
  512. hWnd = 0;
  513. if (rahmen) DestroyWindow(rahmen);
  514. rahmen = 0;
  515. if (bitmap) DeleteObject(bitmap);
  516. bitmap = 0;
  517. if (hdc) DeleteDC(hdc);
  518. hdc = 0;
  519. }
  520. void WFenster::doMausAktion(MausEreignis& me)
  521. {
  522. if (!mausAktion || !mausAktion(makParam, this, me)) return;
  523. if (screen && me.id != ME_Betritt && me.id != ME_Leaves)
  524. {
  525. screen->doMausEreignis(me);
  526. if (!me.verarbeitet && verschiebbar)
  527. {
  528. if (mx != -1 && my != -1) // move
  529. {
  530. RECT r;
  531. if (rahmen)
  532. {
  533. GetWindowRect(rahmen, &r);
  534. r.right -= r.left, r.bottom -= r.top;
  535. r.left += me.mx - mx;
  536. r.top += me.my - my;
  537. SetWindowPos(rahmen,
  538. 0,
  539. r.left,
  540. r.top,
  541. r.right,
  542. r.bottom,
  543. 0); // Set position
  544. }
  545. GetWindowRect(hWnd, &r); // Find previous position
  546. r.right -= r.left, r.bottom -= r.top; // Update position
  547. r.left += me.mx - mx;
  548. r.top += me.my - my;
  549. SetWindowPos(hWnd,
  550. 0,
  551. r.left,
  552. r.top,
  553. r.right,
  554. r.bottom,
  555. 0); // Set position
  556. }
  557. else if (me.id == ME_PLinks) // start moving
  558. mx = me.mx, my = me.my;
  559. if (me.id == ME_RLinks) // stop moving
  560. mx = -1, my = -1;
  561. me.verarbeitet = 1;
  562. }
  563. }
  564. }
  565. void WFenster::doVSchliessAktion()
  566. {
  567. if (!vCloseAktion) return;
  568. vCloseAktion(sakParam, this);
  569. }
  570. void WFenster::doNSchliessAktion()
  571. {
  572. if (!nCloseAktion) return;
  573. nCloseAktion(sakParam, this);
  574. }
  575. void WFenster::doTastaturAktion(TastaturEreignis& te)
  576. {
  577. if (!tastaturAktion || !tastaturAktion(takParam, this, te)) return;
  578. if (screen) screen->doTastaturEreignis(te);
  579. }
  580. void WFenster::doRestoreMessage() // makes the border visible
  581. {
  582. if (rahmen) ShowWindow(rahmen, 1);
  583. ShowWindow(hWnd, 1);
  584. }
  585. void WFenster::setMausEreignisParameter(
  586. void* p) // sets the mouse event parameter
  587. {
  588. makParam = p;
  589. }
  590. void WFenster::setSchliessEreignisParameter(
  591. void* p) // sets the close event parameter
  592. {
  593. sakParam = p;
  594. }
  595. void WFenster::setTastaturEreignisParameter(
  596. void* p) // sets the keyboard event parameter
  597. {
  598. takParam = p;
  599. }
  600. void WFenster::setMausAktion(MausAktion mausAk)
  601. {
  602. mausAktion = mausAk;
  603. }
  604. void WFenster::setVSchliessAktion(std::function<void(void*, void*)> vSchliessAk)
  605. {
  606. vCloseAktion = vSchliessAk;
  607. }
  608. void WFenster::setNSchliessAktion(std::function<void(void*, void*)> nSchliessAk)
  609. {
  610. nCloseAktion = nSchliessAk;
  611. }
  612. void WFenster::setTastaturAktion(TastaturAktion tastaturAk)
  613. {
  614. tastaturAktion = tastaturAk;
  615. }
  616. void WFenster::setFensterHandle(HWND hWnd) // sets the operation window
  617. {
  618. this->hWnd = hWnd;
  619. }
  620. void WFenster::setVerschiebbar(
  621. bool verschiebbar) // determines whether the window can be
  622. // moved by dragging with the mouse
  623. {
  624. this->verschiebbar = verschiebbar;
  625. }
  626. void WFenster::ladeRahmenFenster(Bild* zBild,
  627. HINSTANCE hinst) // sets a transparent border around the window
  628. {
  629. if (!zBild) return;
  630. // Create window
  631. WNDCLASSEX wcl = {0};
  632. wcl.cbSize = sizeof(wcl);
  633. wcl.style = CS_HREDRAW | CS_VREDRAW;
  634. wcl.lpfnWndProc = WindowProc;
  635. wcl.cbClsExtra = 0;
  636. wcl.cbWndExtra = 0;
  637. wcl.hInstance = hinst;
  638. wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  639. wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
  640. wcl.hbrBackground = NULL;
  641. wcl.lpszMenuName = NULL;
  642. wcl.lpszClassName = TEXT("LayeredWindowClass");
  643. wcl.hIconSm = NULL;
  644. // Create bitmap
  645. hdc = CreateCompatibleDC(NULL);
  646. if (!hdc) return;
  647. BITMAPINFO info;
  648. info.bmiHeader.biSize = sizeof(info.bmiHeader);
  649. info.bmiHeader.biBitCount = 32;
  650. info.bmiHeader.biWidth = zBild->getBreite();
  651. info.bmiHeader.biHeight = -zBild->getHeight();
  652. info.bmiHeader.biCompression = BI_RGB;
  653. info.bmiHeader.biPlanes = 1;
  654. unsigned char* pPixels = 0;
  655. bitmap
  656. = CreateDIBSection(hdc, &info, DIB_RGB_COLORS, (void**)&pPixels, 0, 0);
  657. if (!bitmap) DeleteDC(hdc);
  658. GdiFlush();
  659. // Fill bitmap
  660. int pitch = ((zBild->getBreite() * 32 + 31) & ~31) >> 3;
  661. unsigned char* pRow = 0;
  662. int* buffer = zBild->getBuffer();
  663. for (int i = 0; i < zBild->getHeight(); ++i)
  664. {
  665. pRow = &pPixels[i * pitch];
  666. for (int i2 = 0; i2 < zBild->getBreite(); ++i2)
  667. {
  668. pRow[i2 * 4]
  669. = (unsigned char)((buffer[i2 + i * zBild->getBreite()] >> 16)
  670. & 0xFF);
  671. pRow[i2 * 4 + 1]
  672. = (unsigned char)((buffer[i2 + i * zBild->getBreite()] >> 8)
  673. & 0xFF);
  674. pRow[i2 * 4 + 2]
  675. = (unsigned char)((buffer[i2 + i * zBild->getBreite()]) & 0xFF);
  676. pRow[i2 * 4 + 3]
  677. = (unsigned char)((buffer[i2 + i * zBild->getBreite()] >> 24)
  678. & 0xFF);
  679. }
  680. }
  681. // Calculate alpha
  682. unsigned char* pPixel = 0;
  683. if (zBild->getBreite() * 4 == pitch)
  684. {
  685. int i = 0;
  686. int totalBytes = zBild->getBreite() * zBild->getHeight() * 4;
  687. for (i = 0; i < totalBytes; i += 4)
  688. {
  689. pPixel = &pPixels[i];
  690. pPixel[0] *= (unsigned char)((float)pPixel[3] / 255.0f);
  691. pPixel[1] *= (unsigned char)((float)pPixel[3] / 255.0f);
  692. pPixel[2] *= (unsigned char)((float)pPixel[3] / 255.0f);
  693. }
  694. }
  695. else
  696. {
  697. int x = 0;
  698. int y = 0;
  699. for (y = 0; y < zBild->getHeight(); ++y)
  700. {
  701. for (x = 0; x < zBild->getBreite(); ++x)
  702. {
  703. pPixel = &pPixels[(y * pitch) + (x * 4)];
  704. pPixel[0] *= (unsigned char)((float)pPixel[3] / 255.0f);
  705. pPixel[1] *= (unsigned char)((float)pPixel[3] / 255.0f);
  706. pPixel[2] *= (unsigned char)((float)pPixel[3] / 255.0f);
  707. }
  708. }
  709. }
  710. // Continue creating window
  711. if (RegisterClassEx(&wcl))
  712. {
  713. rahmen = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_LAYERED,
  714. wcl.lpszClassName,
  715. TEXT("Transparentes Fenster"),
  716. WS_POPUP,
  717. 0,
  718. 0,
  719. zBild->getBreite(),
  720. zBild->getHeight(),
  721. 0,
  722. 0,
  723. wcl.hInstance,
  724. 0);
  725. if (rahmen)
  726. {
  727. // draw
  728. HDC h = 0;
  729. if ((h = GetDC(rahmen)) && bitmap)
  730. {
  731. HGDIOBJ hPrevObj = NULL;
  732. POINT ptDest = {0, 0};
  733. POINT ptSrc = {0, 0};
  734. SIZE client = {zBild->getBreite(), zBild->getHeight()};
  735. BLENDFUNCTION blendFunc = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA};
  736. hPrevObj = SelectObject(hdc, bitmap);
  737. ClientToScreen(rahmen, &ptDest);
  738. UpdateLayeredWindow(rahmen,
  739. h,
  740. &ptDest,
  741. &client,
  742. hdc,
  743. &ptSrc,
  744. 0,
  745. &blendFunc,
  746. ULW_ALPHA);
  747. SelectObject(hdc, hPrevObj);
  748. ReleaseDC(rahmen, h);
  749. }
  750. UpdateWindow(rahmen);
  751. Punkt pos = getPosition() + (getGroesse() - zBild->getSize()) / 2;
  752. SetWindowPos(rahmen,
  753. 0,
  754. pos.x,
  755. pos.y,
  756. zBild->getBreite(),
  757. zBild->getHeight(),
  758. 0);
  759. }
  760. }
  761. }
  762. // constant
  763. Punkt WFenster::getPosition() const // returns the position
  764. {
  765. RECT r;
  766. GetWindowRect(hWnd, &r); // Find position
  767. return {r.left, r.top};
  768. }
  769. Punkt WFenster::getGroesse() const // returns the size
  770. {
  771. RECT r;
  772. GetWindowRect(hWnd, &r); // Find size
  773. return {r.right - r.left, r.bottom - r.top};
  774. }
  775. Punkt WFenster::getKoerperGroesse() const // returns the window body size
  776. {
  777. RECT r;
  778. GetClientRect(hWnd, &r); // Find size
  779. return {r.right - r.left, r.bottom - r.top};
  780. }
  781. int WFenster::getKoerperBreite() const // returns the window body width
  782. {
  783. RECT r;
  784. GetClientRect(hWnd, &r); // Find size
  785. return r.right;
  786. }
  787. int WFenster::getKoerperHoehe() const // returns the window body height
  788. {
  789. RECT r;
  790. GetClientRect(hWnd, &r); // Find size
  791. return r.bottom;
  792. }
  793. HWND WFenster::getFensterHandle() const // returns a handle to the window
  794. {
  795. return hWnd;
  796. }
  797. bool WFenster::hatMausAktion() const
  798. {
  799. return mausAktion != 0;
  800. }
  801. bool WFenster::hatVSchliessAktion() const
  802. {
  803. return vCloseAktion != 0;
  804. }
  805. bool WFenster::hatNSchliessAktion() const
  806. {
  807. return nCloseAktion != 0;
  808. }
  809. bool WFenster::hatTastaturAktion() const
  810. {
  811. return tastaturAktion != 0;
  812. }
  813. Bildschirm* WFenster::getBildschirm() const
  814. {
  815. if (!screen) return 0;
  816. return dynamic_cast<Bildschirm*>(screen->getThis());
  817. }
  818. Bildschirm* WFenster::zBildschirm() const
  819. {
  820. return screen;
  821. }
  822. bool WFenster::istVerschiebbar()
  823. const // checks if the window can be moved by dragging with the mouse
  824. {
  825. return verschiebbar;
  826. }
  827. // Contents of the WFensterArray class from Fenster.h
  828. // Constructor
  829. WFensterArray::WFensterArray()
  830. : next(0),
  831. This(0)
  832. {}
  833. // Destructor
  834. WFensterArray::~WFensterArray()
  835. {
  836. if (next) delete next;
  837. }
  838. // add und remove
  839. bool WFensterArray::addFenster(WFenster* fenster)
  840. {
  841. if (fenster == This) return 0;
  842. if (!This)
  843. {
  844. This = fenster;
  845. return 1;
  846. }
  847. if (!next) next = new WFensterArray();
  848. return next->addFenster(fenster);
  849. }
  850. bool WFensterArray::removeFenster(WFenster* fenster)
  851. {
  852. if (fenster == This) return 1;
  853. if (!next) return 0;
  854. if (next->removeFenster(fenster))
  855. {
  856. WFensterArray* tmp = next->getNext();
  857. next->setNext0();
  858. delete next;
  859. next = tmp;
  860. }
  861. return 0;
  862. }
  863. WFensterArray* WFensterArray::getNext()
  864. {
  865. return next;
  866. }
  867. void WFensterArray::setNext0()
  868. {
  869. next = 0;
  870. }
  871. void WFensterArray::del()
  872. {
  873. if (next)
  874. {
  875. This = next->getThis();
  876. WFensterArray* tmp = next->getNext();
  877. next->setNext0();
  878. delete next;
  879. next = tmp;
  880. }
  881. else
  882. This = 0;
  883. }
  884. // Messages
  885. bool WFensterArray::sendVSchliessMessage(HWND hwnd)
  886. {
  887. if (!This) return 0;
  888. bool ret = 0;
  889. if (This->getFensterHandle() == hwnd && This->hatVSchliessAktion())
  890. {
  891. This->doVSchliessAktion();
  892. ret = 1;
  893. }
  894. if (!next) return ret;
  895. return ret || next->sendVSchliessMessage(hwnd);
  896. }
  897. bool WFensterArray::sendNSchliessMessage(HWND hwnd)
  898. {
  899. if (!This) return 0;
  900. bool ret = 0;
  901. if (This->getFensterHandle() == hwnd && This->hatNSchliessAktion())
  902. {
  903. This->doNSchliessAktion();
  904. ret = 1;
  905. }
  906. if (!next) return ret;
  907. return ret || next->sendNSchliessMessage(hwnd);
  908. }
  909. bool WFensterArray::sendMausMessage(HWND hwnd, MausEreignis& me)
  910. {
  911. if (!This) return 0;
  912. bool ret = 0;
  913. if (This->getFensterHandle() == hwnd && This->hatMausAktion())
  914. {
  915. This->doMausAktion(me);
  916. ret = 1;
  917. }
  918. if (!next) return ret;
  919. return ret || next->sendMausMessage(hwnd, me);
  920. }
  921. bool WFensterArray::sendTastaturMessage(HWND hwnd, TastaturEreignis& te)
  922. {
  923. if (!This) return 0;
  924. bool ret = 0;
  925. if (This->getFensterHandle() == hwnd && This->hatTastaturAktion())
  926. {
  927. This->doTastaturAktion(te);
  928. ret = 1;
  929. }
  930. if (!next) return ret;
  931. return ret || next->sendTastaturMessage(hwnd, te);
  932. }
  933. bool WFensterArray::sendRestoreMessage(HWND hwnd)
  934. {
  935. if (!This) return 0;
  936. bool ret = 0;
  937. if (This->getFensterHandle() == hwnd && This->hatMausAktion())
  938. {
  939. This->doRestoreMessage();
  940. ret = 1;
  941. }
  942. if (!next) return ret;
  943. return ret || next->sendRestoreMessage(hwnd);
  944. }
  945. WFenster* WFensterArray::getThis()
  946. {
  947. return This;
  948. }
  949. // WMessageBox
  950. void Framework::WMessageBox(HWND hWnd, Text* titel, Text* meldung, UINT style)
  951. {
  952. MessageBox(
  953. hWnd, meldung->getText(), titel->getText(), style); // Message Box
  954. titel->release();
  955. meldung->release();
  956. }
  957. #endif
  958. // Contents of the Fenster class from Fenster.h
  959. // Constructor
  960. Fenster::Fenster()
  961. : Zeichnung(),
  962. closingMe(0),
  963. closingMeParam(0),
  964. rahmen(0),
  965. titel(0),
  966. members(new RCArray<Zeichnung>()),
  967. bgBodyColor(0xFF000000),
  968. bgBodyPicture(0),
  969. bodyBuffer(0),
  970. bgClosingFarbe(0xFF000000),
  971. bgClosingBild(0),
  972. closeBuffer(0),
  973. closeKlickBuffer(0),
  974. vScroll(0),
  975. hScroll(0),
  976. kMin(0, 0),
  977. kMax(0, 0),
  978. closeKlick(0),
  979. klick(0),
  980. moving(0),
  981. mx(0),
  982. my(0)
  983. {
  984. style = Style::MEIgnoreVerarbeitet | Style::MEIgnoreSichtbar
  985. | Style::MEIgnoreParentInside | Style::MEIgnoreInside;
  986. this->setMausEreignis(_ret1ME);
  987. this->setTastaturEreignis(_ret1TE);
  988. min = Punkt(0, 0), max = Punkt(0, 0);
  989. }
  990. // Destructor
  991. Fenster::~Fenster()
  992. {
  993. if (rahmen) rahmen->release();
  994. if (titel) titel->release();
  995. members->release();
  996. if (bodyBuffer) bodyBuffer->release();
  997. if (bgBodyPicture) bgBodyPicture->release();
  998. if (bgClosingBild) bgClosingBild->release();
  999. if (closeBuffer) closeBuffer->release();
  1000. if (closeKlickBuffer) closeKlickBuffer->release();
  1001. if (vScroll) vScroll->release();
  1002. if (hScroll) hScroll->release();
  1003. }
  1004. void Fenster::doMausEreignis(MausEreignis& me, bool userRet)
  1005. {
  1006. if (me.id == ME_Leaves)
  1007. {
  1008. if (closeKlick != 0) rend = 1;
  1009. closeKlick = 0, klick = 0;
  1010. }
  1011. if (hatStyleNicht(Style::Sichtbar) || !me.insideParent || me.verarbeitet
  1012. || me.mx < 0 || me.my < 0 || me.mx >= gr.x || me.my >= gr.y || !userRet)
  1013. {
  1014. bool insideParent = me.insideParent;
  1015. bool verarbeitet = me.verarbeitet;
  1016. me.verarbeitet |= hatStyleNicht(Style::Sichtbar);
  1017. me.insideParent = 0;
  1018. int rbr = 0;
  1019. if (hatStyle(Style::Rahmen) && rahmen) rbr = rahmen->getRBreite();
  1020. int th = 0;
  1021. if (hatStyle(Style::Titel) && titel) th = titel->getHeight();
  1022. me.mx -= rbr;
  1023. me.my -= rbr + th;
  1024. if (hatStyle(Style::VScroll) && vScroll) me.my += vScroll->getScroll();
  1025. if (hatStyle(Style::HScroll) && hScroll) me.mx += hScroll->getScroll();
  1026. if (me.id != ME_Betritt && me.id != ME_Leaves)
  1027. {
  1028. for (int i = members->getEintragAnzahl() - 1; i >= 0; i--)
  1029. members->z(i)->doPublicMausEreignis(me);
  1030. }
  1031. me.mx += rbr;
  1032. me.my += rbr + th;
  1033. if (hatStyle(Style::VScroll) && vScroll) me.my -= vScroll->getScroll();
  1034. if (hatStyle(Style::HScroll) && hScroll) me.mx -= hScroll->getScroll();
  1035. me.insideParent = insideParent;
  1036. if (hatStyleNicht(Style::Sichtbar)) me.verarbeitet = verarbeitet;
  1037. if (!moving) return;
  1038. }
  1039. bool mvtmp = me.verarbeitet;
  1040. if (hatStyleNicht(Style::Erlaubt)) me.verarbeitet = 1;
  1041. int rbr = 0;
  1042. if (hatStyle(Style::Rahmen) && rahmen) rbr = rahmen->getRBreite();
  1043. int th = 0;
  1044. if (hatStyle(Style::Titel) && titel) th = titel->getHeight();
  1045. bool hSc = hatStyle(Style::HScroll) && hScroll;
  1046. bool vSc = hatStyle(Style::VScroll) && vScroll;
  1047. if (me.id == ME_Bewegung && moving && getMausStand(M_Links))
  1048. {
  1049. if (hatStyle(Style::Beweglich) || hatStyle(Style::HeightChangeable)
  1050. || hatStyle(Style::BreiteChangeable)
  1051. || hatStyle(Style::TitelHeightChangeable))
  1052. {
  1053. bool ret1 = 0;
  1054. bool mset = 0;
  1055. int schi = 0;
  1056. int scbr = 0;
  1057. if (hSc)
  1058. {
  1059. schi = 15;
  1060. }
  1061. if (vSc)
  1062. {
  1063. scbr += 15;
  1064. }
  1065. bool minXb, maxXb, minYb, maxYb;
  1066. bool kMinXb, kMaxXb, kMinYb, kMaxYb;
  1067. minXb = hatStyle(Style::MinBr);
  1068. maxXb = hatStyle(Style::MaxBr);
  1069. minYb = hatStyle(Style::MinHi);
  1070. maxYb = hatStyle(Style::MaxHi);
  1071. kMinXb = hatStyle(Style::BodyMinBr);
  1072. kMaxXb = hatStyle(Style::BodyMaxBr);
  1073. kMinYb = hatStyle(Style::BodyMinHi);
  1074. kMaxYb = hatStyle(Style::BodyMaxHi);
  1075. int fMinBr = rbr * 2 + scbr;
  1076. if (minXb) fMinBr = fMinBr < min.x ? min.x : fMinBr;
  1077. if (kMinXb)
  1078. fMinBr = fMinBr < (rbr * 2 + kMin.x + scbr)
  1079. ? (rbr * 2 + kMin.x + scbr)
  1080. : fMinBr;
  1081. int fMinHi = rbr * 2 + th + schi;
  1082. if (minYb) fMinHi = fMinHi < min.y ? min.y : fMinHi;
  1083. if (kMinYb)
  1084. fMinHi = fMinHi < (rbr * 2 + kMin.y + th + schi)
  1085. ? (rbr * 2 + kMin.y + th + schi)
  1086. : fMinHi;
  1087. int fMaxBr = 0;
  1088. if (maxXb) fMaxBr = max.x;
  1089. if (kMaxXb)
  1090. fMaxBr = fMaxBr < (rbr * 2 + kMax.x + scbr)
  1091. ? (rbr * 2 + kMax.x + scbr)
  1092. : fMaxBr;
  1093. int fMaxHi = 0;
  1094. if (maxYb) fMaxHi = max.y;
  1095. if (kMaxYb)
  1096. fMaxHi = fMaxHi < (rbr * 2 + kMax.y + th + schi)
  1097. ? (rbr * 2 + kMax.y + th + schi)
  1098. : fMaxHi;
  1099. minXb |= kMinXb, maxXb |= kMaxXb, minYb |= kMinYb, maxYb |= kMaxYb;
  1100. if (hatStyle(Style::HeightChangeable))
  1101. {
  1102. if ((moving | 0x1) == moving) // top
  1103. {
  1104. pos.y -= my - me.my;
  1105. gr.y += my - me.my;
  1106. if (gr.y < fMinHi)
  1107. {
  1108. pos.y -= fMinHi - gr.y;
  1109. gr.y = fMinHi;
  1110. }
  1111. else if (maxYb && gr.y > fMaxHi)
  1112. {
  1113. pos.y -= gr.y - fMaxHi;
  1114. gr.y = fMaxHi;
  1115. }
  1116. else if (vSc)
  1117. vScroll->getScrollData()->anzeige = gr.y;
  1118. rend = 1;
  1119. ret1 = 1;
  1120. }
  1121. else if ((moving | 0x2) == moving) // bottom
  1122. {
  1123. gr.y += me.my - my;
  1124. if (gr.y < fMinHi)
  1125. gr.y = fMinHi;
  1126. else if (maxYb && gr.y > fMaxHi)
  1127. gr.y = fMaxHi;
  1128. else
  1129. {
  1130. mset = 1;
  1131. if (vSc) vScroll->getScrollData()->anzeige = gr.y;
  1132. }
  1133. rend = 1;
  1134. ret1 = 1;
  1135. }
  1136. }
  1137. if (hatStyle(Style::BreiteChangeable))
  1138. {
  1139. if ((moving | 0x4) == moving) // left
  1140. {
  1141. pos.x -= mx - me.mx;
  1142. gr.x += mx - me.mx;
  1143. if (gr.x < fMinBr)
  1144. {
  1145. pos.x -= fMinBr - gr.x;
  1146. gr.x = fMinBr;
  1147. }
  1148. else if (maxXb && gr.x > fMaxBr)
  1149. {
  1150. pos.x -= gr.x - fMaxBr;
  1151. gr.x = fMaxBr;
  1152. }
  1153. else if (hSc)
  1154. hScroll->getScrollData()->anzeige = gr.x;
  1155. rend = 1;
  1156. ret1 = 1;
  1157. }
  1158. else if ((moving | 0x8) == moving) // right
  1159. {
  1160. gr.x += me.mx - mx;
  1161. if (gr.x < rbr * 2 + fMinBr)
  1162. gr.x = rbr * 2 + fMinBr;
  1163. else if (maxXb && gr.x > fMaxBr)
  1164. gr.x = fMaxBr;
  1165. else
  1166. {
  1167. mset = 1;
  1168. if (hSc) hScroll->getScrollData()->anzeige = gr.x;
  1169. }
  1170. rend = 1;
  1171. ret1 = 1;
  1172. }
  1173. }
  1174. if (hatStyle(Style::TitelHeightChangeable) && titel
  1175. && (moving | 0x10) == moving) // titel height
  1176. {
  1177. int maxTh = gr.y - rbr * 2 - schi;
  1178. if (kMaxYb)
  1179. maxTh = maxTh < (gr.x - rbr * 2 - kMin.y)
  1180. ? maxTh
  1181. : (gr.x - rbr * 2 - kMin.y);
  1182. if (hatStyle(Style::Closable))
  1183. maxTh = (gr.x - th - 5 - rbr * 2 - me.my + my) < 0 ? th
  1184. : maxTh;
  1185. titel->setSize(
  1186. titel->getBreite(), titel->getHeight() + me.my - my);
  1187. if (titel->getHeight() > maxTh)
  1188. titel->setSize(titel->getBreite(), maxTh);
  1189. else if (titel->getHeight() < 5)
  1190. titel->setSize(titel->getBreite(), 5);
  1191. else
  1192. mset = 1;
  1193. rend = 1;
  1194. ret1 = 1;
  1195. }
  1196. if (ret1)
  1197. {
  1198. if (mset) mx = me.mx, my = me.my;
  1199. me.verarbeitet = 1;
  1200. }
  1201. if (hatStyle(Style::Beweglich) && (moving | 0x20) == moving) // move
  1202. {
  1203. pos.x += me.mx - mx;
  1204. pos.y += me.my - my;
  1205. rend = 1;
  1206. ret1 = 1;
  1207. }
  1208. if (ret1) me.verarbeitet = 1;
  1209. }
  1210. }
  1211. if (me.id == ME_RLinks)
  1212. {
  1213. if (closeKlick) rend = 1;
  1214. closeKlick = 0, klick = 0;
  1215. moving = 0;
  1216. mx = -1, my = -1;
  1217. }
  1218. if (me.id == ME_Leaves)
  1219. {
  1220. if (closeKlick != 0) rend = 1;
  1221. closeKlick = 0, klick = 0;
  1222. }
  1223. if (hatStyleNicht(Style::Sichtbar) || !me.insideParent || me.verarbeitet
  1224. || me.mx < 0 || me.my < 0 || me.mx >= gr.x || me.my >= gr.y || !userRet)
  1225. return;
  1226. if (!me.verarbeitet)
  1227. {
  1228. if (hatStyle(Style::Closable) && me.my <= th + rbr
  1229. && me.mx >= gr.x + rbr - th && me.my >= rbr && me.mx <= gr.x - rbr)
  1230. {
  1231. if (!closingMe || closingMe(closingMeParam, this, me))
  1232. {
  1233. if (me.id == ME_PLinks)
  1234. {
  1235. closeKlick = 1;
  1236. rend = 1;
  1237. }
  1238. if (!closeKlick && MausStand[M_Links])
  1239. {
  1240. closeKlick = 1;
  1241. rend = 1;
  1242. }
  1243. me.verarbeitet = 1;
  1244. }
  1245. }
  1246. else if (closeKlick)
  1247. {
  1248. closeKlick = 0;
  1249. rend = 1;
  1250. }
  1251. if (me.id == ME_PLinks && !closeKlick)
  1252. {
  1253. klick = 1;
  1254. mx = me.mx, my = me.my;
  1255. if (me.mx >= 0 && me.mx < gr.x && me.my >= 0 && me.my < rbr + 5
  1256. && !hatStyle(Style::TopPositionFixed))
  1257. moving |= 0x1;
  1258. if (me.mx >= 0 && me.mx < gr.x && me.my >= gr.y - (rbr + 5)
  1259. && me.my < gr.y && !hatStyle(Style::BottomPositionFixed))
  1260. moving |= 0x2;
  1261. if (me.mx >= 0 && me.mx < rbr + 5 && me.my >= 0 && me.my < gr.y
  1262. && !hatStyle(Style::LeftPositionFixed))
  1263. moving |= 0x4;
  1264. if (me.mx >= gr.x - rbr - 5 && me.mx < gr.x && me.my >= 0
  1265. && me.my < gr.y && !hatStyle(Style::RightPositionFixed))
  1266. moving |= 0x8;
  1267. if (titel && me.mx >= 0 && me.mx < gr.x
  1268. && me.my >= titel->getHeight()
  1269. && me.my < titel->getHeight() + 2 * (rbr + 5))
  1270. moving |= 0x10;
  1271. if (titel && me.mx >= 0 && me.mx < gr.x && me.my >= rbr + 5
  1272. && me.my < titel->getHeight())
  1273. moving |= 0x20;
  1274. }
  1275. }
  1276. if (vSc)
  1277. {
  1278. vScroll->doMausMessage(
  1279. gr.x - rbr - 15, rbr + th, 15, gr.y - rbr * 2 - th, me);
  1280. if (hSc)
  1281. hScroll->doMausMessage(
  1282. rbr, gr.y - rbr - 15, gr.x - rbr * 2 - 15, 15, me);
  1283. }
  1284. else if (hSc)
  1285. hScroll->doMausMessage(rbr, gr.y - rbr - 15, gr.x - rbr * 2, 15, me);
  1286. me.mx -= rbr;
  1287. me.my -= rbr + th;
  1288. if (hatStyle(Style::VScroll) && vScroll) me.my += vScroll->getScroll();
  1289. if (hatStyle(Style::HScroll) && hScroll) me.mx += hScroll->getScroll();
  1290. if (me.id != ME_Betritt && me.id != ME_Leaves)
  1291. {
  1292. for (int i = members->getEintragAnzahl() - 1; i >= 0; i--)
  1293. members->z(i)->doPublicMausEreignis(me);
  1294. }
  1295. me.mx += rbr;
  1296. me.my += rbr + th;
  1297. if (hatStyle(Style::VScroll) && vScroll) me.my -= vScroll->getScroll();
  1298. if (hatStyle(Style::HScroll) && hScroll) me.mx -= hScroll->getScroll();
  1299. if (hatStyleNicht(Style::METransparenz)) me.verarbeitet = 1;
  1300. if (hatStyleNicht(Style::Erlaubt)) me.verarbeitet = mvtmp;
  1301. }
  1302. // non-const
  1303. // -- Border --
  1304. void Fenster::setRahmenZ(Rahmen* ram) // sets the border
  1305. {
  1306. if (rahmen) rahmen->release();
  1307. rahmen = ram;
  1308. rend = 1;
  1309. }
  1310. void Fenster::setRFarbe(int f) // sets the border color
  1311. {
  1312. if (!rahmen) rahmen = new LRahmen();
  1313. rahmen->setFarbe(f);
  1314. rend = 1;
  1315. }
  1316. void Fenster::setRBreite(int br) // sets the border width
  1317. {
  1318. if (!rahmen) rahmen = new LRahmen();
  1319. rahmen->setRamenBreite(br);
  1320. rend = 1;
  1321. }
  1322. // -- Title --
  1323. void Fenster::setTitel(Text* txt) // sets the title
  1324. {
  1325. if (!titel) titel = new TextFeld();
  1326. titel->setText(txt);
  1327. rend = 1;
  1328. }
  1329. void Fenster::setTitelZ(Text* txt)
  1330. {
  1331. if (!titel) titel = new TextFeld();
  1332. titel->setTextZ(txt);
  1333. rend = 1;
  1334. }
  1335. void Fenster::setTitel(const char* txt)
  1336. {
  1337. if (!titel) titel = new TextFeld();
  1338. titel->setText(txt);
  1339. rend = 1;
  1340. }
  1341. void Fenster::setTTextFeldZ(TextFeld* tf) // sets the title text field
  1342. {
  1343. if (titel) titel->release();
  1344. titel = tf;
  1345. rend = 1;
  1346. }
  1347. // -- Font --
  1348. void Fenster::setTSchriftZ(Schrift* schrift) // sets the title font
  1349. {
  1350. if (!titel) titel = new TextFeld();
  1351. titel->setSchriftZ(schrift);
  1352. rend = 1;
  1353. }
  1354. void Fenster::setTSFarbe(int f) // sets the title font color
  1355. {
  1356. if (!titel) titel = new TextFeld();
  1357. titel->setSchriftFarbe(f);
  1358. rend = 1;
  1359. }
  1360. void Fenster::setTSSize(int gr) // sets the title font size
  1361. {
  1362. if (!titel) titel = new TextFeld();
  1363. titel->setSchriftSize((unsigned char)gr);
  1364. rend = 1;
  1365. }
  1366. // -- Title Background --
  1367. void Fenster::setTBgFarbe(int f) // sets title background color
  1368. {
  1369. if (!titel) titel = new TextFeld();
  1370. titel->setHintergrundFarbe(f);
  1371. rend = 1;
  1372. }
  1373. // -- Title AlphaFeld --
  1374. void Fenster::setTAlphaFeldZ(AlphaFeld* af) // sets the title AlphaFeld
  1375. {
  1376. if (!titel) titel = new TextFeld();
  1377. titel->setAlphaFeldZ(af);
  1378. rend = 1;
  1379. }
  1380. void Fenster::setTAfFarbe(int f) // sets the title AlphaFeld color
  1381. {
  1382. if (!titel) titel = new TextFeld();
  1383. titel->setAlphaFeldFarbe(f);
  1384. rend = 1;
  1385. }
  1386. void Fenster::setTAfStrength(int st) // sets the strength of the title AlphaFeld
  1387. {
  1388. if (!titel) titel = new TextFeld();
  1389. titel->setAlphaFeldStrength(st);
  1390. rend = 1;
  1391. }
  1392. // -- Title Background Image --
  1393. void Fenster::setTBgBild(Bild* b) // sets the title background image
  1394. {
  1395. if (!titel) titel = new TextFeld();
  1396. titel->setHintergrundBild(b);
  1397. rend = 1;
  1398. }
  1399. void Fenster::setTBgBildZ(Bild* b)
  1400. {
  1401. if (!titel) titel = new TextFeld();
  1402. titel->setHintergrundBildZ(b);
  1403. rend = 1;
  1404. }
  1405. // -- Title Border --
  1406. void Fenster::setTRahmenZ(Rahmen* ram) // sets the title border
  1407. {
  1408. if (!titel) titel = new TextFeld();
  1409. titel->setRahmenZ(ram);
  1410. rend = 1;
  1411. }
  1412. void Fenster::setTRFarbe(int f) // sets the title border color
  1413. {
  1414. if (!titel) titel = new TextFeld();
  1415. titel->setRahmenFarbe(f);
  1416. rend = 1;
  1417. }
  1418. void Fenster::setTRBreite(int br) // sets the title border width
  1419. {
  1420. if (!titel) titel = new TextFeld();
  1421. titel->setRahmenBreite(br);
  1422. rend = 1;
  1423. }
  1424. // -- Body Background --
  1425. void Fenster::setKBgFarbe(int f) // sets the body background color
  1426. {
  1427. bgBodyColor = f;
  1428. rend = 1;
  1429. }
  1430. // -- Body Background Image --
  1431. void Fenster::setKBgBild(Bild* b) // sets the body background image
  1432. {
  1433. if (!bgBodyPicture) bgBodyPicture = new Bild();
  1434. bgBodyPicture->neuBild(b->getBreite(), b->getHeight(), 0);
  1435. int* buff1 = bgBodyPicture->getBuffer();
  1436. int* buff2 = b->getBuffer();
  1437. int gr = bgBodyPicture->getBreite() * bgBodyPicture->getHeight();
  1438. for (int i = 0; i < gr; ++i)
  1439. buff1[i] = buff2[i];
  1440. b->release();
  1441. rend = 1;
  1442. }
  1443. void Fenster::setKBgBildZ(Bild* b)
  1444. {
  1445. if (bgBodyPicture) bgBodyPicture->release();
  1446. bgBodyPicture = b;
  1447. rend = 1;
  1448. }
  1449. // -- Body AlphaFeld --
  1450. void Fenster::setKAlphaFeldZ(AlphaFeld* af) // sets the body AlphaFeld
  1451. {
  1452. if (bodyBuffer) bodyBuffer->release();
  1453. bodyBuffer = af;
  1454. rend = 1;
  1455. }
  1456. void Fenster::setKAfFarbe(int f) // sets body AlphaFeld color
  1457. {
  1458. if (!bodyBuffer) bodyBuffer = new AlphaFeld();
  1459. bodyBuffer->setFarbe(f);
  1460. rend = 1;
  1461. }
  1462. void Fenster::setKAfStrength(int st) // sets the strength of the body AlphaFeld
  1463. {
  1464. if (!bodyBuffer) bodyBuffer = new AlphaFeld();
  1465. bodyBuffer->setStrength(st);
  1466. rend = 1;
  1467. }
  1468. // -- Close --
  1469. void Fenster::setClosingMeParam(void* param)
  1470. {
  1471. closingMeParam = param;
  1472. }
  1473. void Fenster::setClosingMe(MausAktion closingMe) // sets the close mouse event
  1474. {
  1475. this->closingMe = closingMe;
  1476. }
  1477. // -- Close Background --
  1478. void Fenster::setSBgFarbe(int f) // sets the close background color
  1479. {
  1480. bgClosingFarbe = f;
  1481. rend = 1;
  1482. }
  1483. // -- Close Background Image --
  1484. void Fenster::setSBgBild(Bild* b) // sets the close background image
  1485. {
  1486. if (!bgClosingBild) bgClosingBild = new Bild();
  1487. bgClosingBild->neuBild(b->getBreite(), b->getHeight(), 0);
  1488. int* buff1 = bgClosingBild->getBuffer();
  1489. int* buff2 = b->getBuffer();
  1490. int gr = bgClosingBild->getBreite() * bgClosingBild->getHeight();
  1491. for (int i = 0; i < gr; ++i)
  1492. buff1[i] = buff2[i];
  1493. b->release();
  1494. rend = 1;
  1495. }
  1496. void Fenster::setSBgBildZ(Bild* b)
  1497. {
  1498. if (bgClosingBild) bgClosingBild->release();
  1499. bgClosingBild = b;
  1500. rend = 1;
  1501. }
  1502. // -- Close AlphaFeld --
  1503. void Fenster::setSAlphaFeldZ(AlphaFeld* af) // sets the close AlphaFeld
  1504. {
  1505. if (closeBuffer) closeBuffer->release();
  1506. closeBuffer = af;
  1507. rend = 1;
  1508. }
  1509. void Fenster::setSAfFarbe(int f) // sets the color of the close AlphaFeld
  1510. {
  1511. if (!closeBuffer) closeBuffer = new AlphaFeld();
  1512. closeBuffer->setFarbe(f);
  1513. rend = 1;
  1514. }
  1515. void Fenster::setSAfStrength(int st) // sets the strength of the close AlphaFeld
  1516. {
  1517. if (!closeBuffer) closeBuffer = new AlphaFeld();
  1518. closeBuffer->setStrength(st);
  1519. rend = 1;
  1520. }
  1521. // -- Close Click AlphaFeld --
  1522. void Fenster::setSKAlphaFeldZ(AlphaFeld* af) // sets the close click AlphaFeld
  1523. {
  1524. if (closeKlickBuffer) closeKlickBuffer->release();
  1525. closeKlickBuffer = af;
  1526. rend = 1;
  1527. }
  1528. void Fenster::setSKAfFarbe(int f) // sets the color of the close click AlphaFeld
  1529. {
  1530. if (!closeKlickBuffer) closeKlickBuffer = new AlphaFeld();
  1531. closeKlickBuffer->setFarbe(f);
  1532. rend = 1;
  1533. }
  1534. void Fenster::setSKAfStrength(
  1535. int st) // sets the strength of the close click AlphaFeld
  1536. {
  1537. if (!closeKlickBuffer) closeKlickBuffer = new AlphaFeld();
  1538. closeKlickBuffer->setStrength(st);
  1539. rend = 1;
  1540. }
  1541. // -- min max --
  1542. void Fenster::setMin(int mx, int my) // sets the minimum window size
  1543. {
  1544. min.x = mx;
  1545. min.y = my;
  1546. }
  1547. void Fenster::setMin(const Punkt& min)
  1548. {
  1549. this->min = min;
  1550. }
  1551. void Fenster::setMax(int mx, int my) // sets the maximum window size
  1552. {
  1553. max.x = mx;
  1554. max.y = my;
  1555. }
  1556. void Fenster::setMax(const Punkt& max)
  1557. {
  1558. this->max = max;
  1559. }
  1560. void Fenster::setKMin(int mx, int my) // sets the minimum body size
  1561. {
  1562. kMin.x = mx;
  1563. kMin.y = my;
  1564. }
  1565. void Fenster::setKMin(const Punkt& min)
  1566. {
  1567. kMin = min;
  1568. }
  1569. void Fenster::setKMax(int mx, int my) // sets the maximum body size
  1570. {
  1571. kMax.x = mx;
  1572. kMax.y = my;
  1573. }
  1574. void Fenster::setKMax(const Punkt& max)
  1575. {
  1576. kMax = max;
  1577. }
  1578. // -- scroll --
  1579. void Fenster::setHScrollBarZ(
  1580. HScrollBar* hScroll) // sets the horizontal scroll bar
  1581. {
  1582. if (this->hScroll) this->hScroll->release();
  1583. this->hScroll = hScroll;
  1584. rend = 1;
  1585. }
  1586. void Fenster::setVScrollBarZ(
  1587. VScrollBar* vScroll) // sets the vertical scroll bar
  1588. {
  1589. if (this->vScroll) this->vScroll->release();
  1590. this->vScroll = vScroll;
  1591. rend = 1;
  1592. }
  1593. void Fenster::setHSBMax(int max) // sets the scroll maximum
  1594. {
  1595. if (!hScroll) hScroll = new HScrollBar();
  1596. int rbr = 0;
  1597. if (hatStyle(Style::Rahmen) && rahmen) rbr = rahmen->getRBreite();
  1598. int vsh = 0;
  1599. if (hatStyle(Style::VScroll) && vScroll) vsh = 15;
  1600. hScroll->update(max, gr.x - rbr * 2 - vsh);
  1601. rend = 1;
  1602. }
  1603. void Fenster::setVSBMax(int max)
  1604. {
  1605. if (!vScroll) vScroll = new VScrollBar();
  1606. int rbr = 0;
  1607. int th = 0;
  1608. if (hatStyle(Style::Rahmen) && rahmen) rbr = rahmen->getRBreite();
  1609. if (hatStyle(Style::Titel) && titel) th = titel->getHeight();
  1610. int hsh = 0;
  1611. if (hatStyle(Style::HScroll) && hScroll) hsh = 15;
  1612. vScroll->update(max, gr.y - rbr * 2 - th - hsh);
  1613. rend = 1;
  1614. }
  1615. void Fenster::setHSBScroll(int scroll) // sets the current scroll position
  1616. {
  1617. if (!hScroll) hScroll = new HScrollBar();
  1618. hScroll->scroll(scroll);
  1619. rend = 1;
  1620. }
  1621. void Fenster::setVSBScroll(int scroll)
  1622. {
  1623. if (!vScroll) vScroll = new VScrollBar();
  1624. vScroll->scroll(scroll);
  1625. rend = 1;
  1626. }
  1627. void Framework::Fenster::updateHScroll()
  1628. {
  1629. if (hScroll)
  1630. {
  1631. hScroll->update(getNeededChildWidth(), getInnenBreite());
  1632. }
  1633. }
  1634. void Framework::Fenster::updateVScroll()
  1635. {
  1636. if (vScroll)
  1637. {
  1638. vScroll->update(getNeededChildHeight(), getInnenHeight());
  1639. }
  1640. }
  1641. // -- Members --
  1642. void Fenster::addMember(Zeichnung* obj) // adds a member
  1643. {
  1644. members->add(obj);
  1645. rend = 1;
  1646. }
  1647. void Framework::Fenster::setMemberIndex(Zeichnung* zMember, int index)
  1648. {
  1649. if (index < 0 || index >= members->getEintragAnzahl()) return;
  1650. int currentIndex = members->indexOf(zMember);
  1651. members->setPosition(currentIndex, index);
  1652. }
  1653. void Fenster::removeMember(Zeichnung* zObj) // removes a member
  1654. {
  1655. for (int i = 0; i < members->getEintragAnzahl(); i++)
  1656. {
  1657. if (members->z(i) == zObj)
  1658. {
  1659. members->remove(i);
  1660. rend = 1;
  1661. }
  1662. }
  1663. }
  1664. void Fenster::removeAll()
  1665. {
  1666. members->leeren();
  1667. rend = 1;
  1668. }
  1669. // -- Messages --
  1670. bool Fenster::tick(double tickval) // tick
  1671. {
  1672. if (hatStyle(Style::Sichtbar))
  1673. {
  1674. for (Zeichnung* i : *members)
  1675. rend |= i->tick(tickval);
  1676. }
  1677. else
  1678. {
  1679. for (Zeichnung* i : *members)
  1680. i->tick(tickval);
  1681. }
  1682. if (vScroll && hatStyle(Style::VScroll)) rend |= vScroll->getRend();
  1683. if (hScroll && hatStyle(Style::HScroll)) rend |= hScroll->getRend();
  1684. return Zeichnung::tick(tickval);
  1685. }
  1686. void Fenster::doTastaturEreignis(TastaturEreignis& te)
  1687. {
  1688. bool ntakc = !te.verarbeitet;
  1689. if (hatStyle(Style::Sichtbar))
  1690. {
  1691. if (te.verarbeitet)
  1692. {
  1693. for (int i = members->getEintragAnzahl() - 1; i >= 0; i--)
  1694. members->z(i)->doTastaturEreignis(te);
  1695. }
  1696. else
  1697. {
  1698. if (tak && tak(takParam, this, te))
  1699. {
  1700. for (int i = members->getEintragAnzahl() - 1; i >= 0; i--)
  1701. members->z(i)->doTastaturEreignis(te);
  1702. }
  1703. }
  1704. }
  1705. if (ntakc && te.verarbeitet && nTak)
  1706. te.verarbeitet = nTak(ntakParam, this, te);
  1707. }
  1708. // -- Render --
  1709. void Fenster::render(Bild& zRObj) // draws to zRObj
  1710. {
  1711. if (hatStyle(Style::Sichtbar))
  1712. {
  1713. lockZeichnung();
  1714. if (!zRObj.setDrawOptions(pos, gr))
  1715. {
  1716. unlockZeichnung();
  1717. return;
  1718. }
  1719. Zeichnung::render(zRObj);
  1720. int rbr = 0;
  1721. if (hatStyle(Style::Rahmen) && rahmen)
  1722. {
  1723. rahmen->setSize(gr);
  1724. rahmen->render(zRObj);
  1725. rbr = rahmen->getRBreite();
  1726. }
  1727. int th = 0;
  1728. if (titel)
  1729. titel->setStyle(TextFeld::Style::Sichtbar, hatStyle(Style::Titel));
  1730. if (hatStyle(Style::Titel) && titel)
  1731. {
  1732. titel->setStyle(TextFeld::Style::Hintergrund,
  1733. hatStyle(Style::TitelHintergrund));
  1734. titel->setStyle(
  1735. TextFeld::Style::HAlpha, hatStyle(Style::TitelHAlpha));
  1736. titel->setStyle(
  1737. TextFeld::Style::HBild, hatStyle(Style::TitelHBild));
  1738. titel->setStyle(
  1739. TextFeld::Style::Buffered, hatStyle(Style::TitelBuffered));
  1740. th = titel->getHeight();
  1741. if (!zRObj.setDrawOptions(rbr, rbr, gr.x - rbr * 2, th))
  1742. {
  1743. zRObj.releaseDrawOptions();
  1744. unlockZeichnung();
  1745. return;
  1746. }
  1747. int sbr = 0;
  1748. if (hatStyle(Style::Closable))
  1749. {
  1750. sbr = th;
  1751. if (hatStyle(Style::ClosingHintergrund))
  1752. {
  1753. if (hatStyle(Style::ClosingHAlpha))
  1754. zRObj.alphaRegion(
  1755. gr.x - th - rbr * 2, 0, th, th, bgClosingFarbe);
  1756. else
  1757. zRObj.fillRegion(
  1758. gr.x - th - rbr * 2, 0, th, th, bgClosingFarbe);
  1759. if (hatStyle(Style::ClosingHBild) && bgClosingBild)
  1760. {
  1761. if (hatStyle(Style::ClosingHAlpha))
  1762. zRObj.alphaBild(
  1763. gr.x - th - rbr * 2, 0, th, th, *bgClosingBild);
  1764. else
  1765. zRObj.drawBild(
  1766. gr.x - th - rbr * 2, 0, th, th, *bgClosingBild);
  1767. }
  1768. }
  1769. if (!hatStyle(Style::ClosingHBild) || !bgClosingBild)
  1770. {
  1771. zRObj.drawLinie(Punkt(gr.x - th - rbr * 2, 0),
  1772. Punkt(gr.x - rbr * 2, th),
  1773. 0xFFFFFFFF);
  1774. zRObj.drawLinie(Punkt(gr.x - rbr * 2, 0),
  1775. Punkt(gr.x - th - rbr * 2, th),
  1776. 0xFFFFFFFF);
  1777. }
  1778. if (hatStyle(Style::ClosingBuffer) && closeBuffer)
  1779. {
  1780. closeBuffer->setPosition(gr.x - th - rbr * 2, 0);
  1781. closeBuffer->setSize(th, th);
  1782. closeBuffer->render(zRObj);
  1783. }
  1784. if (hatStyle(Style::ClosingKlickBuffer) && closeKlickBuffer
  1785. && closeKlick)
  1786. {
  1787. closeKlickBuffer->setPosition(gr.x - th - rbr * 2, 0);
  1788. closeKlickBuffer->setSize(th, th);
  1789. closeKlickBuffer->render(zRObj);
  1790. }
  1791. }
  1792. if (!hatStyle(Style::CustomTitle))
  1793. titel->setSize(gr.x - rbr * 2 - sbr, th);
  1794. titel->render(zRObj);
  1795. zRObj.releaseDrawOptions();
  1796. }
  1797. bool vSc = hatStyle(Style::VScroll) && vScroll;
  1798. bool hSc = hatStyle(Style::HScroll) && hScroll;
  1799. if (vSc)
  1800. {
  1801. vScroll->render(
  1802. gr.x - rbr - 15, rbr + th, 15, gr.y - rbr * 2 - th, zRObj);
  1803. if (hSc)
  1804. hScroll->render(
  1805. rbr, gr.y - rbr - 15, gr.x - rbr * 2 - 15, 15, zRObj);
  1806. }
  1807. else if (hSc)
  1808. hScroll->render(rbr, gr.y - rbr - 15, gr.x - rbr * 2, 15, zRObj);
  1809. int x = rbr;
  1810. int y = rbr + th;
  1811. int br = gr.x - rbr * 2;
  1812. int hi = gr.y - rbr * 2 - th;
  1813. if (vSc) br -= 15;
  1814. if (hSc) hi -= 15;
  1815. if (!zRObj.setDrawOptions(x, y, br, hi))
  1816. {
  1817. zRObj.releaseDrawOptions();
  1818. unlockZeichnung();
  1819. return;
  1820. }
  1821. if (hatStyle(Style::BodyHintergrund))
  1822. {
  1823. if (hatStyle(Style::BodyHAlpha))
  1824. zRObj.alphaRegion(0, 0, br, hi, bgBodyColor);
  1825. else
  1826. zRObj.fillRegion(0, 0, br, hi, bgBodyColor);
  1827. if (hatStyle(Style::BodyHBild) && bgBodyPicture)
  1828. {
  1829. if (hatStyle(Style::BodyHAlpha))
  1830. zRObj.alphaBild(0, 0, br, hi, *bgBodyPicture);
  1831. else
  1832. zRObj.drawBild(0, 0, br, hi, *bgBodyPicture);
  1833. }
  1834. }
  1835. if (hatStyle(Style::BodyBuffered) && bodyBuffer)
  1836. {
  1837. bodyBuffer->setSize(br, hi);
  1838. bodyBuffer->render(zRObj);
  1839. }
  1840. if (!vSc && !hSc)
  1841. {
  1842. for (Zeichnung* i : *members)
  1843. i->render(zRObj);
  1844. }
  1845. else
  1846. {
  1847. zRObj.addScrollOffset(
  1848. hSc ? hScroll->getScroll() : 0, vSc ? vScroll->getScroll() : 0);
  1849. for (Zeichnung* i : *members)
  1850. i->render(zRObj);
  1851. }
  1852. zRObj.releaseDrawOptions();
  1853. zRObj.releaseDrawOptions();
  1854. unlockZeichnung();
  1855. }
  1856. }
  1857. // constant
  1858. // Returns the width of the interior area of the drawing in pixels
  1859. int Fenster::getInnenBreite() const
  1860. {
  1861. return getBreite() - 2 * getRBreite();
  1862. }
  1863. // Returns the height of the interior area of the drawing in pixels
  1864. int Fenster::getInnenHeight() const
  1865. {
  1866. int th = 0;
  1867. if (hatStyle(Style::Titel) && titel) th += titel->getHeight();
  1868. return getHeight() - 2 * getRBreite() - th;
  1869. }
  1870. // -- Border --
  1871. Rahmen* Fenster::getRahmen() const // returns the border
  1872. {
  1873. if (!rahmen) return 0;
  1874. return dynamic_cast<Rahmen*>(rahmen->getThis());
  1875. }
  1876. Rahmen* Fenster::zRahmen() const
  1877. {
  1878. return rahmen;
  1879. }
  1880. int Fenster::getRFarbe() const // returns the border color
  1881. {
  1882. if (!rahmen) return 0;
  1883. return rahmen->getFarbe();
  1884. }
  1885. int Fenster::getRBreite() const // returns the border width
  1886. {
  1887. if (!rahmen || hatStyleNicht(Style::Rahmen)) return 0;
  1888. return rahmen->getRBreite();
  1889. }
  1890. // -- Title --
  1891. Text* Fenster::getTitel() const // returns the title
  1892. {
  1893. if (!titel) return 0;
  1894. return titel->getText();
  1895. }
  1896. Text* Fenster::zTitel() const
  1897. {
  1898. if (!titel) return 0;
  1899. return titel->zText();
  1900. }
  1901. TextFeld* Fenster::getTTextFeld() const // returns the title text field
  1902. {
  1903. if (!titel) return 0;
  1904. return dynamic_cast<TextFeld*>(titel->getThis());
  1905. }
  1906. TextFeld* Fenster::zTTextFeld() const
  1907. {
  1908. return titel;
  1909. }
  1910. // -- Title Font --
  1911. Schrift* Fenster::getTSchrift() const // returns the title font
  1912. {
  1913. if (!titel) return 0;
  1914. return titel->getSchrift();
  1915. }
  1916. Schrift* Fenster::zTSchrift() const
  1917. {
  1918. if (!titel) return 0;
  1919. return titel->zSchrift();
  1920. }
  1921. int Fenster::getTSFarbe() const // returns the title font color
  1922. {
  1923. if (!titel) return 0;
  1924. return titel->getSchriftFarbe();
  1925. }
  1926. int Fenster::getTSSize() const // returns the title font size
  1927. {
  1928. if (!titel) return 0;
  1929. return titel->getSchriftSize();
  1930. }
  1931. // -- Title Background --
  1932. int Fenster::getTBgFarbe() const // returns the title background color
  1933. {
  1934. if (!titel) return 0;
  1935. return titel->getHintergrundFarbe();
  1936. }
  1937. // -- Title AlphaFeld --
  1938. AlphaFeld* Fenster::getTAlphaFeld() const // returns the title AlphaFeld
  1939. {
  1940. if (!titel) return 0;
  1941. return titel->getAlphaFeld();
  1942. }
  1943. AlphaFeld* Fenster::zTAlphaFeld() const
  1944. {
  1945. if (!titel) return 0;
  1946. return titel->zAlphaFeld();
  1947. }
  1948. int Fenster::getTAfFarbe() const // returns the color of the title AlphaFeld
  1949. {
  1950. if (!titel) return 0;
  1951. return titel->getAlphaFeldFarbe();
  1952. }
  1953. int Fenster::getTAfStrength()
  1954. const // returns the strength of the title AlphaFeld
  1955. {
  1956. if (!titel) return 0;
  1957. return titel->getAlphaFeldStrength();
  1958. }
  1959. // -- Title Background Image --
  1960. Bild* Fenster::getTBgBild() const // returns the title background image
  1961. {
  1962. if (!titel) return 0;
  1963. return titel->getHintergrundBild();
  1964. }
  1965. Bild* Fenster::zTBgBild() const
  1966. {
  1967. if (!titel) return 0;
  1968. return titel->zHintergrundBild();
  1969. }
  1970. // -- Title Border --
  1971. Rahmen* Fenster::getTRahmen() const // returns the title border
  1972. {
  1973. if (!titel) return 0;
  1974. return titel->getRahmen();
  1975. }
  1976. Rahmen* Fenster::zTRahmen() const
  1977. {
  1978. if (!titel) return 0;
  1979. return titel->zRahmen();
  1980. }
  1981. int Fenster::getTRFarbe() const // returns the title border color
  1982. {
  1983. if (!titel) return 0;
  1984. return titel->getRahmenFarbe();
  1985. }
  1986. int Fenster::getTRBreite() const // returns the title border width
  1987. {
  1988. if (!titel) return 0;
  1989. return titel->getRahmenBreite();
  1990. }
  1991. // -- Body Background --
  1992. int Fenster::getKBgFarbe() const // returns the body background color
  1993. {
  1994. return bgBodyColor;
  1995. }
  1996. // -- Body Background Image --
  1997. Bild* Fenster::getKBgBild() const // returns the body background image
  1998. {
  1999. if (!bgBodyPicture) return 0;
  2000. return dynamic_cast<Bild*>(bgBodyPicture->getThis());
  2001. }
  2002. Bild* Fenster::zKBgBild() const
  2003. {
  2004. return bgBodyPicture;
  2005. }
  2006. // -- Body AlphaFeld --
  2007. AlphaFeld* Fenster::getKAlphaFeld() const // returns the body AlphaFeld
  2008. {
  2009. if (!bodyBuffer) return 0;
  2010. return dynamic_cast<AlphaFeld*>(bodyBuffer->getThis());
  2011. }
  2012. AlphaFeld* Fenster::zKAlphaFeld() const
  2013. {
  2014. return bodyBuffer;
  2015. }
  2016. int Fenster::getKAfFarbe() const // returns the body AlphaFeld color
  2017. {
  2018. if (!bodyBuffer) return 0;
  2019. return bodyBuffer->getFarbe();
  2020. }
  2021. int Fenster::getKAfStrength()
  2022. const // returns the strength of the body AlphaFeld
  2023. {
  2024. if (!bodyBuffer) return 0;
  2025. return bodyBuffer->getStrength();
  2026. }
  2027. // -- Close Background --
  2028. int Fenster::getSBgFarbe() const // returns the close background color
  2029. {
  2030. return bgClosingFarbe;
  2031. }
  2032. // -- Close Background Image --
  2033. Bild* Fenster::getSBgBild() const // returns the close background image
  2034. {
  2035. if (!bgClosingBild) return 0;
  2036. return dynamic_cast<Bild*>(bgClosingBild->getThis());
  2037. }
  2038. Bild* Fenster::zSBgBild() const
  2039. {
  2040. return bgClosingBild;
  2041. }
  2042. // -- Close AlphaFeld --
  2043. AlphaFeld* Fenster::getSAlphaFeld() const // returns the close AlphaFeld
  2044. {
  2045. if (!closeBuffer) return 0;
  2046. return dynamic_cast<AlphaFeld*>(closeBuffer->getThis());
  2047. }
  2048. AlphaFeld* Fenster::zSAlphaFeld() const
  2049. {
  2050. return closeBuffer;
  2051. }
  2052. int Fenster::getSAfFarbe() const // returns the close AlphaFeld color
  2053. {
  2054. if (!closeBuffer) return 0;
  2055. return closeBuffer->getFarbe();
  2056. }
  2057. int Fenster::getSAfStrength()
  2058. const // returns the strength of the close AlphaFeld
  2059. {
  2060. if (!closeBuffer) return 0;
  2061. return closeBuffer->getStrength();
  2062. }
  2063. // -- Close Click AlphaFeld --
  2064. AlphaFeld* Fenster::getSKAlphaFeld() const // returns the close click AlphaFeld
  2065. {
  2066. if (!closeKlickBuffer) return 0;
  2067. return dynamic_cast<AlphaFeld*>(closeKlickBuffer->getThis());
  2068. }
  2069. AlphaFeld* Fenster::zSKAlphaFeld() const
  2070. {
  2071. return closeKlickBuffer;
  2072. }
  2073. int Fenster::getSKAfFarbe() const // returns the close click AlphaFeld color
  2074. {
  2075. if (!closeKlickBuffer) return 0;
  2076. return closeKlickBuffer->getFarbe();
  2077. }
  2078. int Fenster::getSKAfStrength()
  2079. const // returns the strength of the close click AlphaFeld
  2080. {
  2081. if (!closeKlickBuffer) return 0;
  2082. return closeKlickBuffer->getStrength();
  2083. }
  2084. // -- min max --
  2085. const Punkt& Fenster::getMin() const // returns the minimum window size
  2086. {
  2087. return min;
  2088. }
  2089. const Punkt& Fenster::getMax() const // returns the maximum window size
  2090. {
  2091. return max;
  2092. }
  2093. const Punkt& Fenster::getKMin() const // returns the minimum body size
  2094. {
  2095. return kMin;
  2096. }
  2097. const Punkt& Fenster::getKMax() const // returns the maximum body size
  2098. {
  2099. return kMax;
  2100. }
  2101. // -- scroll --
  2102. VScrollBar* Fenster::getVScrollBar() const // returns the vertical scroll bar
  2103. {
  2104. if (!vScroll) return 0;
  2105. return dynamic_cast<VScrollBar*>(vScroll->getThis());
  2106. }
  2107. VScrollBar* Fenster::zVScrollBar() const
  2108. {
  2109. return vScroll;
  2110. }
  2111. HScrollBar* Fenster::getHScrollBar() const // returns the horizontal scroll bar
  2112. {
  2113. if (!hScroll) return 0;
  2114. return dynamic_cast<HScrollBar*>(hScroll->getThis());
  2115. }
  2116. HScrollBar* Fenster::zHScrollBar() const
  2117. {
  2118. return hScroll;
  2119. }
  2120. // -- Members --
  2121. const RCArray<Zeichnung>& Fenster::getMembers() const // returns the members
  2122. {
  2123. return *members;
  2124. }
  2125. int Framework::Fenster::getNeededChildWidth() const
  2126. {
  2127. int max = 0;
  2128. for (Zeichnung* z : *members)
  2129. {
  2130. if (z->getX() + z->getBreite() > max) max = z->getX() + z->getBreite();
  2131. }
  2132. return max;
  2133. }
  2134. int Framework::Fenster::getNeededChildHeight() const
  2135. {
  2136. int max = 0;
  2137. for (Zeichnung* z : *members)
  2138. {
  2139. if (z->getY() + z->getHeight() > max) max = z->getY() + z->getHeight();
  2140. }
  2141. return max;
  2142. }
  2143. // -- Copy --
  2144. Zeichnung* Fenster::dublizieren() const // Creates a copy of the window
  2145. {
  2146. Fenster* ret = new Fenster();
  2147. ret->setPosition(pos);
  2148. ret->setSize(gr);
  2149. ret->setMausEreignisParameter(makParam);
  2150. ret->setTastaturEreignisParameter(takParam);
  2151. ret->setMausEreignis(mak);
  2152. ret->setTastaturEreignis(tak);
  2153. if (toolTip) ret->setToolTipZ((ToolTip*)toolTip->dublizieren());
  2154. ret->setStyle(style);
  2155. ret->setClosingMeParam(closingMeParam);
  2156. ret->setClosingMe(closingMe);
  2157. if (rahmen)
  2158. {
  2159. ret->setRBreite(rahmen->getRBreite());
  2160. ret->setRFarbe(rahmen->getFarbe());
  2161. }
  2162. if (titel) ret->setTTextFeldZ((TextFeld*)titel->dublizieren());
  2163. ret->setKBgFarbe(bgBodyColor);
  2164. if (bgBodyPicture)
  2165. ret->setKBgBild(dynamic_cast<Bild*>(bgBodyPicture->getThis()));
  2166. if (bodyBuffer)
  2167. {
  2168. ret->setKAfFarbe(bodyBuffer->getFarbe());
  2169. ret->setKAfStrength(bodyBuffer->getStrength());
  2170. }
  2171. ret->setSBgFarbe(bgClosingFarbe);
  2172. if (bgClosingBild)
  2173. ret->setSBgBild(dynamic_cast<Bild*>(bgClosingBild->getThis()));
  2174. if (closeBuffer)
  2175. {
  2176. ret->setSAfFarbe(closeBuffer->getFarbe());
  2177. ret->setSAfStrength(closeBuffer->getStrength());
  2178. }
  2179. if (closeKlickBuffer)
  2180. {
  2181. ret->setSKAfFarbe(closeKlickBuffer->getFarbe());
  2182. ret->setSKAfStrength(closeKlickBuffer->getStrength());
  2183. }
  2184. if (vScroll)
  2185. {
  2186. ret->setVSBMax(vScroll->getScrollData()->max);
  2187. ret->setVSBScroll(vScroll->getScroll());
  2188. }
  2189. if (hScroll)
  2190. {
  2191. ret->setHSBMax(hScroll->getScrollData()->max);
  2192. ret->setHSBScroll(hScroll->getScroll());
  2193. }
  2194. ret->setMin(min);
  2195. ret->setMax(max);
  2196. ret->setKMin(kMin);
  2197. ret->setKMax(kMax);
  2198. return ret;
  2199. }