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