Fenster.cpp 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462
  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( std::function< bool( void*, void*, MausEreignis ) > closingMe ) // setzt das Schließen Mausereignis
  1267. {
  1268. this->closingMe = closingMe;
  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. return Zeichnung::tick( tickval );
  1465. }
  1466. void Fenster::doMausEreignis( MausEreignis &me )
  1467. {
  1468. bool nmakc = !me.verarbeitet;
  1469. if( me.verarbeitet || ( me.mx < pos.x || me.mx > pos.x + gr.x || me.my < pos.y || me.my > pos.y + gr.y ) )
  1470. {
  1471. if( mausIn )
  1472. {
  1473. mausIn = 0;
  1474. MausEreignis me2;
  1475. me2.id = ME_Leaves;
  1476. me2.mx = me.mx;
  1477. me2.my = me.my;
  1478. me2.verarbeitet = 0;
  1479. doMausEreignis( me2 );
  1480. return;
  1481. }
  1482. }
  1483. else if( !mausIn && me.id != ME_Leaves )
  1484. {
  1485. mausIn = 1;
  1486. MausEreignis me2;
  1487. me2.id = ME_Betritt;
  1488. me2.mx = me.mx;
  1489. me2.my = me.my;
  1490. me2.verarbeitet = 0;
  1491. doMausEreignis( me2 );
  1492. }
  1493. if( hatStyle( Style::Sichtbar ) )
  1494. {
  1495. bool mvtmp = me.verarbeitet;
  1496. if( !mak )
  1497. return;
  1498. if( hatStyleNicht( Style::Erlaubt ) )
  1499. me.verarbeitet = 1;
  1500. bool mpr = 0;
  1501. me.mx -= pos.x;
  1502. me.my -= pos.y;
  1503. int rbr = 0;
  1504. if( hatStyle( Style::Rahmen ) && rahmen )
  1505. rbr = rahmen->getRBreite();
  1506. int th = 0;
  1507. if( hatStyle( Style::Titel ) && titel )
  1508. th = titel->getHeight();
  1509. bool hSc = hatStyle( Style::HScroll ) && hScroll;
  1510. bool vSc = hatStyle( Style::VScroll ) && vScroll;
  1511. if( !me.verarbeitet && me.id == ME_Bewegung && klick )
  1512. {
  1513. if( hatStyle( Style::Beweglich ) || hatStyle( Style::HeightChangeable ) || hatStyle( Style::BreiteChangeable ) || hatStyle( Style::TitelHeightChangeable ) )
  1514. {
  1515. if( mak( makParam, this, me ) )
  1516. {
  1517. mpr = 1;
  1518. bool ret1 = 0;
  1519. bool mset = 0;
  1520. int schi = 0;
  1521. int scbr = 0;
  1522. if( hSc )
  1523. {
  1524. schi = 15;
  1525. scbr = 40;
  1526. }
  1527. if( vSc )
  1528. {
  1529. scbr += 15;
  1530. schi = 40;
  1531. }
  1532. bool minXb, maxXb, minYb, maxYb;
  1533. bool kMinXb, kMaxXb, kMinYb, kMaxYb;
  1534. minXb = hatStyle( Style::MinBr );
  1535. maxXb = hatStyle( Style::MaxBr );
  1536. minYb = hatStyle( Style::MinHi );
  1537. maxYb = hatStyle( Style::MaxHi );
  1538. kMinXb = hatStyle( Style::BodyMinBr );
  1539. kMaxXb = hatStyle( Style::BodyMaxBr );
  1540. kMinYb = hatStyle( Style::BodyMinHi );
  1541. kMaxYb = hatStyle( Style::BodyMaxHi );
  1542. int fMinBr = rbr * 2 + scbr;
  1543. if( minXb )
  1544. fMinBr = fMinBr < min.x ? min.x : fMinBr;
  1545. if( kMinXb )
  1546. fMinBr = fMinBr < ( rbr * 2 + kMin.x + scbr ) ? ( rbr * 2 + kMin.x + scbr ) : fMinBr;
  1547. int fMinHi = rbr * 2 + th + schi;
  1548. if( minYb )
  1549. fMinHi = fMinHi < min.y ? min.y : fMinHi;
  1550. if( kMinYb )
  1551. fMinHi = fMinHi < ( rbr * 2 + kMin.y + th + schi ) ? ( rbr * 2 + kMin.y + th + schi ) : fMinHi;
  1552. int fMaxBr = 0;
  1553. if( maxXb )
  1554. fMaxBr = max.x;
  1555. if( kMaxXb )
  1556. fMaxBr = fMaxBr < ( rbr * 2 + kMax.x + scbr ) ? ( rbr * 2 + kMax.x + scbr ) : fMaxBr;
  1557. int fMaxHi = 0;
  1558. if( maxYb )
  1559. fMaxHi = max.y;
  1560. if( kMaxYb )
  1561. fMaxHi = fMaxHi < ( rbr * 2 + kMax.y + th + schi ) ? ( rbr * 2 + kMax.y + th + schi ) : fMaxHi;
  1562. minXb |= kMinXb, maxXb |= kMaxXb, minYb |= kMinYb, maxYb |= kMaxYb;
  1563. if( hatStyle( Style::HeightChangeable ) )
  1564. {
  1565. if( mx > -5 && mx < gr.x + 5 && my > -5 && my < rbr )
  1566. {
  1567. pos.y -= my - me.my;
  1568. gr.y += my - me.my;
  1569. if( gr.y < fMinHi )
  1570. {
  1571. pos.y += fMinHi - gr.y;
  1572. gr.y = fMinHi;
  1573. }
  1574. else if( maxYb && gr.y > fMaxHi )
  1575. {
  1576. pos.y += gr.y - fMaxHi;
  1577. gr.y = fMaxHi;
  1578. }
  1579. else if( vSc )
  1580. vScroll->getScrollData()->anzeige = gr.y;
  1581. rend = 1;
  1582. ret1 = 1;
  1583. }
  1584. else if( mx > -5 && mx < gr.x + 5 && my > gr.y - rbr && my < gr.y + 5 )
  1585. {
  1586. gr.y += me.my - my;
  1587. if( gr.y < fMinHi )
  1588. gr.y = fMinHi;
  1589. else if( maxYb && gr.y > fMaxHi )
  1590. gr.y = fMaxHi;
  1591. else
  1592. {
  1593. mset = 1;
  1594. if( vSc )
  1595. vScroll->getScrollData()->anzeige = gr.y;
  1596. }
  1597. rend = 1;
  1598. ret1 = 1;
  1599. }
  1600. }
  1601. if( hatStyle( Style::BreiteChangeable ) )
  1602. {
  1603. if( mx > -5 && mx < rbr && my > -5 && my < gr.y + 5 )
  1604. {
  1605. pos.x -= mx - me.mx;
  1606. gr.x += mx - me.mx;
  1607. if( gr.x < fMinBr )
  1608. {
  1609. pos.x += fMinBr - gr.x;
  1610. gr.x = fMinBr;
  1611. }
  1612. else if( maxXb && gr.x > fMaxBr )
  1613. {
  1614. pos.x += gr.x - fMaxBr;
  1615. gr.x = fMaxBr;
  1616. }
  1617. else if( hSc )
  1618. hScroll->getScrollData()->anzeige = gr.x;
  1619. rend = 1;
  1620. ret1 = 1;
  1621. }
  1622. else if( mx > gr.x - rbr && mx < gr.x + 5 && my > -5 && my < gr.y + 5 )
  1623. {
  1624. gr.x += me.mx - mx;
  1625. if( gr.x < rbr * 2 + fMinBr )
  1626. gr.x = rbr * 2 + fMinBr;
  1627. else if( maxXb && gr.x > fMaxBr )
  1628. gr.x = fMaxBr;
  1629. else
  1630. {
  1631. mset = 1;
  1632. if( hSc )
  1633. hScroll->getScrollData()->anzeige = gr.x;
  1634. }
  1635. rend = 1;
  1636. ret1 = 1;
  1637. }
  1638. }
  1639. if( hatStyle( Style::TitelHeightChangeable ) && titel && mx > -5 && mx < gr.x + 5 && my < rbr + th + 5 && my > rbr + th )
  1640. {
  1641. int maxTh = gr.y - rbr * 2 - schi;
  1642. if( kMaxYb )
  1643. maxTh = maxTh < ( gr.x - rbr * 2 - kMin.y ) ? maxTh : ( gr.x - rbr * 2 - kMin.y );
  1644. if( hatStyle( Style::Closable ) )
  1645. maxTh = ( gr.x - th - 5 - rbr * 2 - me.my + my ) < 0 ? th : maxTh;
  1646. titel->setSize( titel->getBreite(), titel->getHeight() + me.my - my );
  1647. if( titel->getHeight() > maxTh )
  1648. titel->setSize( titel->getBreite(), maxTh );
  1649. else if( titel->getHeight() < 5 )
  1650. titel->setSize( titel->getBreite(), 5 );
  1651. else
  1652. mset = 1;
  1653. rend = 1;
  1654. ret1 = 1;
  1655. }
  1656. if( ret1 )
  1657. {
  1658. if( mset )
  1659. mx = me.mx, my = me.my;
  1660. me.verarbeitet = 1;
  1661. }
  1662. if( hatStyle( Style::Beweglich ) && mx > rbr && mx < gr.x - th - rbr && my > rbr && my < rbr + th )
  1663. {
  1664. pos.x += me.mx - mx;
  1665. pos.y += me.my - my;
  1666. rend = 1;
  1667. ret1 = 1;
  1668. }
  1669. if( ret1 )
  1670. me.verarbeitet = 1;
  1671. }
  1672. }
  1673. }
  1674. bool inside = me.mx >= 0 && me.mx <= gr.x && me.my >= 0 && me.my <= gr.y;
  1675. if( mpr || me.verarbeitet || ( !inside || mak( makParam, this, me ) ) )
  1676. {
  1677. if( me.id == ME_RLinks )
  1678. {
  1679. if( closeKlick )
  1680. rend = 1;
  1681. closeKlick = 0, klick = 0;
  1682. mx = -1, my = -1;
  1683. }
  1684. if( me.id == ME_Leaves )
  1685. {
  1686. if( closeKlick != 0 )
  1687. rend = 1;
  1688. closeKlick = 0, klick = 0;
  1689. mx = -1, my = -1;
  1690. }
  1691. if( !me.verarbeitet )
  1692. {
  1693. if( me.id == ME_PLinks )
  1694. {
  1695. klick = 1;
  1696. mx = me.mx, my = me.my;
  1697. }
  1698. if( hatStyle( Style::Closable ) && me.my <= th + rbr && me.mx >= gr.x + rbr - th && me.my >= rbr && me.mx <= gr.x - rbr )
  1699. {
  1700. if( !closingMe || closingMe( closingMeParam, this, me ) )
  1701. {
  1702. if( me.id == ME_PLinks )
  1703. {
  1704. closeKlick = 1;
  1705. rend = 1;
  1706. }
  1707. if( !closeKlick && MausStand[ M_Links ] )
  1708. {
  1709. closeKlick = 1;
  1710. rend = 1;
  1711. }
  1712. me.verarbeitet = 1;
  1713. }
  1714. }
  1715. else if( closeKlick )
  1716. {
  1717. closeKlick = 0;
  1718. rend = 1;
  1719. }
  1720. }
  1721. if( members && me.id != ME_Betritt && me.id != ME_Leaves )
  1722. {
  1723. if( vSc )
  1724. {
  1725. vScroll->doMausMessage( gr.x - rbr - 16, rbr + th, 15, gr.y - rbr * 2 - th - 1, me );
  1726. if( hSc )
  1727. hScroll->doMausMessage( rbr, gr.y - rbr - 16, gr.x - rbr * 2 - 16, 15, me );
  1728. }
  1729. else
  1730. if( hSc )
  1731. hScroll->doMausMessage( rbr, gr.y - rbr - 16, gr.x - rbr * 2 - 1, 15, me );
  1732. me.mx -= rbr;
  1733. me.my -= rbr + th;
  1734. if( hatStyle( Style::VScroll ) && vScroll )
  1735. me.my += vScroll->getScroll();
  1736. if( hatStyle( Style::HScroll ) && hScroll )
  1737. me.mx += hScroll->getScroll();
  1738. members->sendMausAll( me );
  1739. me.mx += rbr;
  1740. me.my += rbr + th;
  1741. if( hatStyle( Style::VScroll ) && vScroll )
  1742. me.my -= vScroll->getScroll();
  1743. if( hatStyle( Style::HScroll ) && hScroll )
  1744. me.mx -= hScroll->getScroll();
  1745. }
  1746. if( inside && hatStyleNicht( Style::METransparenz ) )
  1747. me.verarbeitet = 1;
  1748. }
  1749. if( nmakc && me.verarbeitet && nMak )
  1750. me.verarbeitet = nMak( nmakParam, this, me );
  1751. me.mx += pos.x;
  1752. me.my += pos.y;
  1753. if( hatStyleNicht( Style::Erlaubt ) )
  1754. me.verarbeitet = mvtmp;
  1755. }
  1756. else if( members )
  1757. {
  1758. MausEreignis me;
  1759. me.verarbeitet = 1;
  1760. me.id = 0;
  1761. me.mx = -1000000;
  1762. me.my = -1000000;
  1763. members->sendMausAll( me );
  1764. }
  1765. }
  1766. void Fenster::doTastaturEreignis( TastaturEreignis &te )
  1767. {
  1768. bool ntakc = !te.verarbeitet;
  1769. if( hatStyle( Style::Sichtbar ) )
  1770. {
  1771. if( te.verarbeitet )
  1772. {
  1773. if( members )
  1774. members->sendTastaturAll( te );
  1775. }
  1776. else
  1777. {
  1778. if( tak && tak( takParam, this, te ) )
  1779. {
  1780. if( members )
  1781. members->sendTastaturAll( te );
  1782. }
  1783. }
  1784. }
  1785. if( ntakc && te.verarbeitet && nTak )
  1786. te.verarbeitet = nTak( ntakParam, this, te );
  1787. }
  1788. // -- Render --
  1789. void Fenster::render( Bild &zRObj ) // zeichent nach zRObj
  1790. {
  1791. if( hatStyle( Style::Sichtbar ) )
  1792. {
  1793. lockZeichnung();
  1794. if( !zRObj.setDrawOptions( pos, gr ) )
  1795. {
  1796. unlockZeichnung();
  1797. return;
  1798. }
  1799. Zeichnung::render( zRObj );
  1800. int rbr = 0;
  1801. if( hatStyle( Style::Rahmen ) && rahmen )
  1802. {
  1803. rahmen->setSize( gr );
  1804. rahmen->render( zRObj );
  1805. rbr = rahmen->getRBreite();
  1806. }
  1807. int th = 0;
  1808. if( hatStyle( Style::Titel ) && titel )
  1809. {
  1810. titel->setStyle( TextFeld::Style::Hintergrund, hatStyle( Style::TitelHintergrund ) );
  1811. titel->setStyle( TextFeld::Style::HAlpha, hatStyle( Style::TitelHAlpha ) );
  1812. titel->setStyle( TextFeld::Style::HBild, hatStyle( Style::TitelHBild ) );
  1813. titel->setStyle( TextFeld::Style::Buffered, hatStyle( Style::TitelBuffered ) );
  1814. th = titel->getHeight();
  1815. if( !zRObj.setDrawOptions( rbr, rbr, gr.x - rbr * 2, th ) )
  1816. {
  1817. zRObj.releaseDrawOptions();
  1818. unlockZeichnung();
  1819. return;
  1820. }
  1821. int sbr = 0;
  1822. if( hatStyle( Style::Closable ) )
  1823. {
  1824. sbr = th;
  1825. if( hatStyle( Style::ClosingHintergrund ) )
  1826. {
  1827. if( hatStyle( Style::ClosingHAlpha ) )
  1828. zRObj.alphaRegion( gr.x - th - rbr * 2, 0, th, th, bgClosingFarbe );
  1829. else
  1830. zRObj.fillRegion( gr.x - th - rbr * 2, 0, th, th, bgClosingFarbe );
  1831. if( hatStyle( Style::ClosingHBild ) && bgClosingBild )
  1832. {
  1833. if( hatStyle( Style::ClosingHAlpha ) )
  1834. zRObj.alphaBild( gr.x - th - rbr * 2, 0, th, th, *bgClosingBild );
  1835. else
  1836. zRObj.drawBild( gr.x - th - rbr * 2, 0, th, th, *bgClosingBild );
  1837. }
  1838. }
  1839. if( !hatStyle( Style::ClosingHBild ) || !bgClosingBild )
  1840. {
  1841. zRObj.drawLinie( Punkt( gr.x - th - rbr * 2, 0 ), Punkt( gr.x - rbr * 2, th ), 0xFFFFFFFF );
  1842. zRObj.drawLinie( Punkt( gr.x - rbr * 2, 0 ), Punkt( gr.x - th - rbr * 2, th ), 0xFFFFFFFF );
  1843. }
  1844. if( hatStyle( Style::ClosingBuffer ) && closeBuffer )
  1845. {
  1846. closeBuffer->setPosition( gr.x - th - rbr * 2, 0 );
  1847. closeBuffer->setSize( th, th );
  1848. closeBuffer->render( zRObj );
  1849. }
  1850. if( hatStyle( Style::ClosingKlickBuffer ) && closeKlickBuffer && closeKlick )
  1851. {
  1852. closeKlickBuffer->setPosition( gr.x - th - rbr * 2, 0 );
  1853. closeKlickBuffer->setSize( th, th );
  1854. closeKlickBuffer->render( zRObj );
  1855. }
  1856. }
  1857. titel->setSize( gr.x - rbr * 2 - sbr, th );
  1858. titel->render( zRObj );
  1859. zRObj.releaseDrawOptions();
  1860. }
  1861. bool vSc = hatStyle( Style::VScroll ) && vScroll;
  1862. bool hSc = hatStyle( Style::HScroll ) && hScroll;
  1863. if( vSc )
  1864. {
  1865. vScroll->render( gr.x - rbr - 16, rbr + th, 15, gr.y - rbr * 2 - th - 1, zRObj );
  1866. if( hSc )
  1867. hScroll->render( rbr, gr.y - rbr - 16, gr.x - rbr * 2 - 16, 15, zRObj );
  1868. }
  1869. else
  1870. if( hSc )
  1871. hScroll->render( rbr, gr.y - rbr - 16, gr.x - rbr * 2 - 1, 15, zRObj );
  1872. int x = rbr;
  1873. int y = rbr + th;
  1874. int br = gr.x - rbr * 2;
  1875. int hi = gr.y - rbr * 2 - th;
  1876. if( vSc )
  1877. br -= 16;
  1878. if( hSc )
  1879. hi -= 16;
  1880. if( !zRObj.setDrawOptions( x, y, br, hi ) )
  1881. {
  1882. zRObj.releaseDrawOptions();
  1883. unlockZeichnung();
  1884. return;
  1885. }
  1886. if( hatStyle( Style::BodyHintergrund ) )
  1887. {
  1888. if( hatStyle( Style::BodyHAlpha ) )
  1889. zRObj.alphaRegion( 0, 0, br, hi, bgBodyColor );
  1890. else
  1891. zRObj.fillRegion( 0, 0, br, hi, bgBodyColor );
  1892. if( hatStyle( Style::BodyHBild ) && bgBodyPicture )
  1893. {
  1894. if( hatStyle( Style::BodyHAlpha ) )
  1895. zRObj.alphaBild( 0, 0, br, hi, *bgBodyPicture );
  1896. else
  1897. zRObj.drawBild( 0, 0, br, hi, *bgBodyPicture );
  1898. }
  1899. }
  1900. if( hatStyle( Style::BodyBuffered ) && bodyBuffer )
  1901. {
  1902. bodyBuffer->setSize( br, hi );
  1903. bodyBuffer->render( zRObj );
  1904. }
  1905. if( members )
  1906. {
  1907. if( !vSc && !hSc )
  1908. members->render( zRObj );
  1909. else
  1910. {
  1911. zRObj.addScrollOffset( hSc ? hScroll->getScroll() : 0, vSc ? vScroll->getScroll() : 0 );
  1912. members->render( zRObj );
  1913. }
  1914. }
  1915. zRObj.releaseDrawOptions();
  1916. zRObj.releaseDrawOptions();
  1917. unlockZeichnung();
  1918. }
  1919. }
  1920. // constant
  1921. // -- Rahmen --
  1922. LRahmen *Fenster::getRahmen() const // gibt den Rahmen zurück
  1923. {
  1924. if( !rahmen )
  1925. return 0;
  1926. return rahmen->getThis();
  1927. }
  1928. LRahmen *Fenster::zRahmen() const
  1929. {
  1930. return rahmen;
  1931. }
  1932. int Fenster::getRFarbe() const // gibt die Farbe des Rahmens zurück
  1933. {
  1934. if( !rahmen )
  1935. return 0;
  1936. return rahmen->getFarbe();
  1937. }
  1938. int Fenster::getRBreite() const // gibt die breite des Rahmens zurück
  1939. {
  1940. if( !rahmen )
  1941. return 0;
  1942. return rahmen->getRBreite();
  1943. }
  1944. // -- Titel --
  1945. Text *Fenster::getTitel() const // gibt den Titel zurück
  1946. {
  1947. if( !titel )
  1948. return 0;
  1949. return titel->getText();
  1950. }
  1951. Text *Fenster::zTitel() const
  1952. {
  1953. if( !titel )
  1954. return 0;
  1955. return titel->zText();
  1956. }
  1957. TextFeld *Fenster::getTTextFeld() const // gibt das Titel TextFeld zurück
  1958. {
  1959. if( !titel )
  1960. return 0;
  1961. return titel->getThis();
  1962. }
  1963. TextFeld *Fenster::zTTextFeld() const
  1964. {
  1965. return titel;
  1966. }
  1967. // -- Titel Schrift --
  1968. Schrift *Fenster::getTSchrift() const // gibt die Titel Schrift zurück
  1969. {
  1970. if( !titel )
  1971. return 0;
  1972. return titel->getSchrift();
  1973. }
  1974. Schrift *Fenster::zTSchrift() const
  1975. {
  1976. if( !titel )
  1977. return 0;
  1978. return titel->zSchrift();
  1979. }
  1980. int Fenster::getTSFarbe() const // gibt die Titel Schrift Farbe zurück
  1981. {
  1982. if( !titel )
  1983. return 0;
  1984. return titel->getSchriftFarbe();
  1985. }
  1986. int Fenster::getTSSize() const // gibt die Titel Schrift Größe zurück
  1987. {
  1988. if( !titel )
  1989. return 0;
  1990. return titel->getSchriftSize();
  1991. }
  1992. // -- Titel Hintergrund --
  1993. int Fenster::getTBgFarbe() const // gibt die Titel Hintergrund Farbe zurück
  1994. {
  1995. if( !titel )
  1996. return 0;
  1997. return titel->getHintergrundFarbe();
  1998. }
  1999. // -- Titel AlphaFeld --
  2000. AlphaFeld *Fenster::getTAlphaFeld() const // gibt das Titel AlphaFeld zurück
  2001. {
  2002. if( !titel )
  2003. return 0;
  2004. return titel->getAlphaFeld();
  2005. }
  2006. AlphaFeld *Fenster::zTAlphaFeld() const
  2007. {
  2008. if( !titel )
  2009. return 0;
  2010. return titel->zAlphaFeld();
  2011. }
  2012. int Fenster::getTAfFarbe() const // gibt die Farbe des Titel AlphaFeldes zurück
  2013. {
  2014. if( !titel )
  2015. return 0;
  2016. return titel->getAlphaFeldFarbe();
  2017. }
  2018. int Fenster::getTAfStrength() const // gibt die Stärke des TitelAlphaFeldes zurück
  2019. {
  2020. if( !titel )
  2021. return 0;
  2022. return titel->getAlphaFeldStrength();
  2023. }
  2024. // -- Titel Hintergrund Bild --
  2025. Bild *Fenster::getTBgBild() const // gibt das Titel Hintergrund Bild zurück
  2026. {
  2027. if( !titel )
  2028. return 0;
  2029. return titel->getHintergrundBild();
  2030. }
  2031. Bild *Fenster::zTBgBild() const
  2032. {
  2033. if( !titel )
  2034. return 0;
  2035. return titel->zHintergrundBild();
  2036. }
  2037. // -- Titel Rahmen --
  2038. LRahmen *Fenster::getTRahmen() const // gibt den Titel Rahmen zurück
  2039. {
  2040. if( !titel )
  2041. return 0;
  2042. return titel->getLinienRahmen();
  2043. }
  2044. LRahmen *Fenster::zTRahmen() const
  2045. {
  2046. if( !titel )
  2047. return 0;
  2048. return titel->zLinienRahmen();
  2049. }
  2050. int Fenster::getTRFarbe() const // gibt die Farbe des Titel Rahmens zurück
  2051. {
  2052. if( !titel )
  2053. return 0;
  2054. return titel->getLinienRahmenFarbe();
  2055. }
  2056. int Fenster::getTRBreite() const // gibt die Breite des Titel Rahmens zurück
  2057. {
  2058. if( !titel )
  2059. return 0;
  2060. return titel->getLinienRahmenBreite();
  2061. }
  2062. // -- Körper Hintergrund --
  2063. int Fenster::getKBgFarbe() const // gibt die Körper Hintergrund Farbe zurück
  2064. {
  2065. return bgBodyColor;
  2066. }
  2067. // -- Körper Hintergrund Bild --
  2068. Bild *Fenster::getKBgBild() const // gibt das Körper Hintergrund Bild zurück
  2069. {
  2070. if( !bgBodyPicture )
  2071. return 0;
  2072. return bgBodyPicture->getThis();
  2073. }
  2074. Bild *Fenster::zKBgBild() const
  2075. {
  2076. return bgBodyPicture;
  2077. }
  2078. // -- Körper AlphaFeld --
  2079. AlphaFeld *Fenster::getKAlphaFeld() const // gibt das Körper AlphaFeld zurück
  2080. {
  2081. if( !bodyBuffer )
  2082. return 0;
  2083. return bodyBuffer->getThis();
  2084. }
  2085. AlphaFeld *Fenster::zKAlphaFeld() const
  2086. {
  2087. return bodyBuffer;
  2088. }
  2089. int Fenster::getKAfFarbe() const // gibt die Farbe des Körper AlphaFeldes zurück
  2090. {
  2091. if( !bodyBuffer )
  2092. return 0;
  2093. return bodyBuffer->getFarbe();
  2094. }
  2095. int Fenster::getKAfStrength() const // gibt die Stärke des Körper AlphaFeldes zurück
  2096. {
  2097. if( !bodyBuffer )
  2098. return 0;
  2099. return bodyBuffer->getStrength();
  2100. }
  2101. // -- Schließen Hintergrund --
  2102. int Fenster::getSBgFarbe() const // gibt die Schließ Hintergrund Farbe zurück
  2103. {
  2104. return bgClosingFarbe;
  2105. }
  2106. // -- Schließen Hintergrund Bild --
  2107. Bild *Fenster::getSBgBild() const // gibt das Schließ Hintergrund Bild zurück
  2108. {
  2109. if( !bgClosingBild )
  2110. return 0;
  2111. return bgClosingBild->getThis();
  2112. }
  2113. Bild *Fenster::zSBgBild() const
  2114. {
  2115. return bgClosingBild;
  2116. }
  2117. // -- Schließen AlphaFeld --
  2118. AlphaFeld *Fenster::getSAlphaFeld() const // gibt das Schließ AlphaFeld zurück
  2119. {
  2120. if( !closeBuffer )
  2121. return 0;
  2122. return closeBuffer->getThis();
  2123. }
  2124. AlphaFeld *Fenster::zSAlphaFeld() const
  2125. {
  2126. return closeBuffer;
  2127. }
  2128. int Fenster::getSAfFarbe() const // gibt die Farbe des Schließ AlphaFeldes zurück
  2129. {
  2130. if( !closeBuffer )
  2131. return 0;
  2132. return closeBuffer->getFarbe();
  2133. }
  2134. int Fenster::getSAfStrength() const // gibt die Stärke des Schließ AlphaFeldes zurück
  2135. {
  2136. if( !closeBuffer )
  2137. return 0;
  2138. return closeBuffer->getStrength();
  2139. }
  2140. // -- Schließen Klick AlphaFeld --
  2141. AlphaFeld *Fenster::getSKAlphaFeld() const // gibt das Schließ Klick AlphaFeld zurück
  2142. {
  2143. if( !closeKlickBuffer )
  2144. return 0;
  2145. return closeKlickBuffer->getThis();
  2146. }
  2147. AlphaFeld *Fenster::zSKAlphaFeld() const
  2148. {
  2149. return closeKlickBuffer;
  2150. }
  2151. int Fenster::getSKAfFarbe() const // gibt die Farbe des Schließ Klick AlphaFeldes zurück
  2152. {
  2153. if( !closeKlickBuffer )
  2154. return 0;
  2155. return closeKlickBuffer->getFarbe();
  2156. }
  2157. int Fenster::getSKAfStrength() const // gibt die Stärke des Schließ Klick AlphaFeldes zurück
  2158. {
  2159. if( !closeKlickBuffer )
  2160. return 0;
  2161. return closeKlickBuffer->getStrength();
  2162. }
  2163. // -- min max --
  2164. const Punkt &Fenster::getMin() const // gibt die minimale Fenstergröße zurück
  2165. {
  2166. return min;
  2167. }
  2168. const Punkt &Fenster::getMax() const // gibt die maximale Fenstergröße zurück
  2169. {
  2170. return max;
  2171. }
  2172. const Punkt &Fenster::getKMin() const // gibt die minimale Fenstergröße zurück
  2173. {
  2174. return kMin;
  2175. }
  2176. const Punkt &Fenster::getKMax() const // gibt die maximale Fenstergröße zurück
  2177. {
  2178. return kMax;
  2179. }
  2180. // -- scroll --
  2181. VScrollBar *Fenster::getVScrollBar() const // gibt die Vertikale Scroll Bar zurück
  2182. {
  2183. if( !vScroll )
  2184. return 0;
  2185. return (VScrollBar*)vScroll->getThis();
  2186. }
  2187. VScrollBar *Fenster::zVScrollBar() const
  2188. {
  2189. return vScroll;
  2190. }
  2191. HScrollBar *Fenster::getHScrollBar() const // gibt die Horizontale Scroll Bar zurück
  2192. {
  2193. if( !hScroll )
  2194. return 0;
  2195. return (HScrollBar*)hScroll->getThis();
  2196. }
  2197. HScrollBar *Fenster::zHScrollBar() const
  2198. {
  2199. return hScroll;
  2200. }
  2201. // -- Members --
  2202. ZeichnungArray *Fenster::getMembers() const // gibt die Members zurück
  2203. {
  2204. return members;
  2205. }
  2206. // -- Kopie --
  2207. Zeichnung *Fenster::dublizieren() const // Erzeugt eine Kopie des Fensters
  2208. {
  2209. Fenster *ret = new Fenster();
  2210. ret->setPosition( pos );
  2211. ret->setSize( gr );
  2212. ret->setMausEreignisParameter( makParam );
  2213. ret->setTastaturEreignisParameter( takParam );
  2214. ret->setMausEreignis( mak );
  2215. ret->setTastaturEreignis( tak );
  2216. if( toolTip )
  2217. ret->setToolTipText( toolTip->zText()->getText(), toolTip->zBildschirm() );
  2218. ret->setStyle( style );
  2219. ret->setClosingMeParam( closingMeParam );
  2220. ret->setClosingMe( closingMe );
  2221. if( rahmen )
  2222. {
  2223. ret->setRBreite( rahmen->getRBreite() );
  2224. ret->setRFarbe( rahmen->getFarbe() );
  2225. }
  2226. if( titel )
  2227. ret->setTTextFeldZ( (TextFeld*)titel->dublizieren() );
  2228. ret->setKBgFarbe( bgBodyColor );
  2229. if( bgBodyPicture )
  2230. ret->setKBgBild( bgBodyPicture->getThis() );
  2231. if( bodyBuffer )
  2232. {
  2233. ret->setKAfFarbe( bodyBuffer->getFarbe() );
  2234. ret->setKAfStrength( bodyBuffer->getStrength() );
  2235. }
  2236. ret->setSBgFarbe( bgClosingFarbe );
  2237. if( bgClosingBild )
  2238. ret->setSBgBild( bgClosingBild->getThis() );
  2239. if( closeBuffer )
  2240. {
  2241. ret->setSAfFarbe( closeBuffer->getFarbe() );
  2242. ret->setSAfStrength( closeBuffer->getStrength() );
  2243. }
  2244. if( closeKlickBuffer )
  2245. {
  2246. ret->setSKAfFarbe( closeKlickBuffer->getFarbe() );
  2247. ret->setSKAfStrength( closeKlickBuffer->getStrength() );
  2248. }
  2249. if( vScroll )
  2250. {
  2251. ret->setVSBMax( vScroll->getScrollData()->max );
  2252. ret->setVSBScroll( vScroll->getScroll() );
  2253. }
  2254. if( hScroll )
  2255. {
  2256. ret->setHSBMax( hScroll->getScrollData()->max );
  2257. ret->setHSBScroll( hScroll->getScroll() );
  2258. }
  2259. ret->setMin( min );
  2260. ret->setMax( max );
  2261. ret->setKMin( kMin );
  2262. ret->setKMax( kMax );
  2263. return ret;
  2264. }
  2265. // Reference Counting
  2266. Fenster *Fenster::getThis()
  2267. {
  2268. ++ref;
  2269. return this;
  2270. }
  2271. Fenster *Fenster::release()
  2272. {
  2273. --ref;
  2274. if( ref == 0 )
  2275. delete this;
  2276. return 0;
  2277. }