Fenster.cpp 63 KB

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