Fenster.cpp 63 KB

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