Fenster.cpp 54 KB

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