Fenster.cpp 66 KB

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