| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398 |
- #include "Window.h"
- #include "AlphaField.h"
- #include "Border.h"
- #include "Globals.h"
- #include "Image.h"
- #include "KeyboardEvent.h"
- #include "MouseEvent.h"
- #include "Screen.h"
- #include "Scroll.h"
- #include "Text.h"
- #include "TextField.h"
- #include "ToolTip.h"
- #ifdef WIN32
- # include "Mouse.h"
- #endif
- #include <iostream>
- #include "Logging.h"
- #include "Time.h"
- using namespace Framework;
- #ifdef WIN32
- // Create window class
- WNDCLASS Framework::F_Normal(HINSTANCE hInst) // Creates a normal window class
- {
- if (!hInst) hInst = _hinst;
- WNDCLASS ret;
- ret.cbClsExtra = 0;
- ret.cbWndExtra = 0;
- ret.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
- ret.hCursor = LoadCursor(NULL, IDC_ARROW);
- ret.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- ret.hInstance = hInst;
- ret.lpszMenuName = "";
- ret.lpfnWndProc = WindowProc;
- ret.style = CS_HREDRAW | CS_VREDRAW;
- return ret;
- }
- WNDCLASSEX Framework::F_NormalEx(HINSTANCE hInst)
- {
- if (!hInst) hInst = _hinst;
- WNDCLASSEX ret;
- ret.cbSize = sizeof(WNDCLASSEX);
- ret.cbClsExtra = 0;
- ret.cbWndExtra = 0;
- ret.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
- ret.hCursor = LoadCursor(NULL, IDC_ARROW);
- ret.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- ret.hInstance = hInst;
- ret.lpszMenuName = "";
- ret.lpfnWndProc = WindowProc;
- ret.style = CS_HREDRAW | CS_VREDRAW;
- ret.hIconSm = 0;
- return ret;
- }
- // WinAPI
- LRESULT CALLBACK Framework::WindowProc(
- HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
- {
- setShowCursor(cursorVisible);
- if (msgExit) return (DefWindowProc(hwnd, message, wparam, lparam));
- switch (message)
- {
- case WM_SETCURSOR: // Mouse cursor
- mousePointer.update();
- return 0;
- case WM_SIZE: // Window
- if (wparam == SIZE_RESTORED) nativeWindows.sendRestoreMessage(hwnd);
- break;
- case WM_CLOSE: // Close
- if (nativeWindows.sendVSchliessMessage(hwnd)) return 0;
- break;
- case WM_DESTROY:
- if (nativeWindows.sendNSchliessMessage(hwnd)) return 0;
- break; // Mouse
- case WM_LBUTTONDOWN: // Left click
- {
- MausStand[M_Links] = 1;
- MouseEvent me = {ME_PLinks,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam),
- 0,
- 1,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam)};
- nativeWindows.sendMausMessage(hwnd, me);
- break;
- }
- case WM_RBUTTONDOWN: // Right click
- {
- MausStand[M_Rechts] = 1;
- MouseEvent me = {ME_PRechts,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam),
- 0,
- 1,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam)};
- nativeWindows.sendMausMessage(hwnd, me);
- break;
- }
- case WM_MBUTTONDOWN: // Middle click
- {
- MausStand[M_Mitte] = 1;
- MouseEvent me = {ME_PMitte,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam),
- 0,
- 1,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam)};
- nativeWindows.sendMausMessage(hwnd, me);
- break;
- }
- case WM_LBUTTONUP: // Left release
- {
- MausStand[M_Links] = 0;
- MouseEvent me = {ME_RLinks,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam),
- 0,
- 1,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam)};
- nativeWindows.sendMausMessage(hwnd, me);
- break;
- }
- case WM_RBUTTONUP: // Right release
- {
- MausStand[M_Rechts] = 0;
- MouseEvent me = {ME_RRechts,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam),
- 0,
- 1,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam)};
- nativeWindows.sendMausMessage(hwnd, me);
- break;
- }
- case WM_MBUTTONUP: // Middle release
- {
- MausStand[M_Mitte] = 0;
- MouseEvent me = {ME_RMitte,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam),
- 0,
- 1,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam)};
- nativeWindows.sendMausMessage(hwnd, me);
- break;
- }
- case WM_LBUTTONDBLCLK: // Left double click
- {
- MouseEvent me = {ME_DKLinks,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam),
- 0,
- 1,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam)};
- nativeWindows.sendMausMessage(hwnd, me);
- break;
- }
- case WM_RBUTTONDBLCLK: // Right double click
- {
- MouseEvent me = {ME_DKRechts,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam),
- 0,
- 1,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam)};
- nativeWindows.sendMausMessage(hwnd, me);
- break;
- }
- case WM_MBUTTONDBLCLK: // Middle double click
- {
- MouseEvent me = {ME_DKMitte,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam),
- 0,
- 1,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam)};
- nativeWindows.sendMausMessage(hwnd, me);
- break;
- }
- case WM_MOUSEHOVER: // Mouse enters window
- {
- MausTrack = 1;
- MouseEvent me = {ME_Betritt,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam),
- 0,
- 1,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam)};
- nativeWindows.sendMausMessage(hwnd, me);
- break;
- }
- case WM_MOUSELEAVE: // Mouse leaves window
- {
- MausTrack = 1;
- MouseEvent me = {ME_Leaves,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam),
- 0,
- 1,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam)};
- nativeWindows.sendMausMessage(hwnd, me);
- break;
- }
- case WM_MOUSEMOVE: // Mouse is moving
- {
- if (MausTrack)
- {
- TRACKMOUSEEVENT lptme;
- lptme.cbSize = sizeof(TRACKMOUSEEVENT);
- lptme.dwFlags = TME_HOVER | TME_LEAVE;
- lptme.dwHoverTime = 0;
- lptme.hwndTrack = hwnd;
- TrackMouseEvent(&lptme);
- MausTrack = 0;
- }
- MouseEvent me = {ME_Bewegung,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam),
- 0,
- 1,
- (int)LOWORD(lparam),
- (int)HIWORD(lparam)};
- nativeWindows.sendMausMessage(hwnd, me);
- break;
- }
- case WM_MOUSEWHEEL: // Mouse scroll
- {
- Punkt pos = getMausPos();
- RECT r;
- GetWindowRect(hwnd, &r);
- pos.x -= r.left;
- pos.y -= r.top;
- MouseEvent me = {0, pos.x, pos.y, 0, 1, pos.x, pos.y};
- if ((int)(short)HIWORD(wparam) < 0)
- me.id = !getTastenStand(T_Shift) ? ME_DScroll : ME_RScroll;
- else
- me.id = !getTastenStand(T_Shift) ? ME_UScroll : ME_LScroll;
- nativeWindows.sendMausMessage(hwnd, me);
- break;
- }
- // Keyboard
- case WM_KEYDOWN:
- {
- KeyboardEvent te = {
- TE_Press, {0, 0, 0},
- 0, 0
- };
- CalculateEnteredString((int)wparam, 0, te);
- nativeWindows.sendTastaturMessage(hwnd, te);
- return 0;
- } // Key is pressed
- case WM_KEYUP:
- {
- KeyboardEvent te = {
- TE_Release, {0, 0, 0},
- 0, 0
- };
- CalculateEnteredString((int)wparam, HIWORD(lparam) & 0xFF, te);
- nativeWindows.sendTastaturMessage(hwnd, te);
- return 0;
- } // Key is released
- }
- return (DefWindowProc(hwnd, message, wparam, lparam));
- }
- void Framework::StartNachrichtenSchleife()
- {
- MSG msg;
- while (GetMessage(&msg, NULL, 0, 0) > 0 && !msgExit)
- {
- if (!msgExit)
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
- msgExit = 0;
- }
- void Framework::StopNachrichtenSchleife(HWND hwnd)
- {
- msgExit = 1;
- PostMessage(hwnd, WM_MOUSELEAVE, 0, 0);
- }
- void Framework::CalculateEnteredString(
- int virtualKeyCode, int scanCode, KeyboardEvent& te)
- {
- memset(te.taste, 0, sizeof(te.taste));
- te.virtualKey = virtualKeyCode;
- # ifdef WIN32
- unsigned char keyState[256];
- memset(keyState, 0, sizeof(keyState));
- if (GetKeyboardState(keyState))
- {
- unsigned short str[2] = {0, 0};
- int count = ToAscii(virtualKeyCode, scanCode, keyState, str, 0);
- if (count == 1 && (str[0] & 0xFF) == str[0])
- te.taste[0] = (unsigned char)str[0];
- else if (count == 2 && (str[0] & 0xFF) == str[0]
- && (str[1] & 0xFF) == str[1])
- te.taste[0] = (unsigned char)str[0],
- te.taste[1] = (unsigned char)str[1];
- }
- # endif // WIN32
- }
- // Contents of the NativeWindow class from Window.h
- // Constructor
- NativeWindow::NativeWindow()
- : ReferenceCounter(),
- hWnd(0),
- style(0),
- makParam(0),
- sakParam(0),
- takParam(0),
- mausAktion(0),
- vCloseAktion(0),
- nCloseAktion(0),
- tastaturAktion(0),
- screen(0),
- mx(-1),
- my(-1),
- verschiebbar(0),
- rahmen(0),
- bitmap(0),
- hdc(0)
- {
- nativeWindows.addWindow(this);
- }
- NativeWindow::NativeWindow(HWND hwnd)
- : NativeWindow()
- {
- hWnd = hwnd;
- }
- // Destructor
- NativeWindow::~NativeWindow()
- {
- if (nativeWindows.removeWindow(this))
- {
- nativeWindows.del();
- }
- if (hWnd) zerstoeren();
- if (screen) screen->release();
- }
- // non-constant
- void NativeWindow::erstellen(
- int style, WNDCLASS wc) // Creates a window in Windows
- {
- if (!GetClassInfo(wc.hInstance, wc.lpszClassName, &wc))
- {
- # pragma warning(suppress : 6102)
- if (!RegisterClass(&wc)) // Register window class
- {
- MessageBox(hWnd,
- "Fehler beim Registrieren der WindowClass!",
- "Error",
- MB_ICONERROR); // Error message on failure
- return;
- }
- }
- hWnd = CreateWindow(wc.lpszClassName,
- wc.lpszClassName,
- style,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- wc.hInstance,
- 0); // Create window
- if (hWnd == 0)
- {
- MessageBox(hWnd,
- "Fehler beim erstellen des Windows!",
- "Error",
- MB_ICONERROR); // Error message on failure
- return;
- }
- this->style = style;
- }
- void NativeWindow::erstellenEx(
- int exStyle, int style, WNDCLASSEX wc) // Create the window
- {
- if (!GetClassInfoEx(wc.hInstance, wc.lpszClassName, &wc))
- {
- # pragma warning(suppress : 6102)
- if (!RegisterClassEx(&wc)) // Register window class
- {
- MessageBox(hWnd,
- "Fehler beim Registrieren der WindowClass!",
- "Error",
- MB_ICONERROR); // Error message on failure
- return;
- }
- }
- hWnd = CreateWindowEx(exStyle,
- wc.lpszClassName,
- wc.lpszClassName,
- style,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- wc.hInstance,
- 0); // Create window
- if (hWnd == 0)
- {
- MessageBox(hWnd,
- "Fehler beim erstellen des Windows!",
- "Error",
- MB_ICONERROR); // Error message on failure
- return;
- }
- this->style = style;
- }
- void NativeWindow::setAnzeigeModus(int mod) // Display window
- {
- if (rahmen)
- {
- if (mod == 2)
- ShowWindow(rahmen, 0);
- else
- ShowWindow(rahmen, mod);
- }
- ShowWindow(hWnd, mod);
- }
- bool NativeWindow::setFokus() // Sets the focus on the window
- {
- DWORD dwCurrentThread = GetCurrentThreadId();
- DWORD dwFGThread = GetWindowThreadProcessId(GetForegroundWindow(), NULL);
- AttachThreadInput(dwCurrentThread, dwFGThread, TRUE);
- SetFocus(hWnd);
- AttachThreadInput(dwCurrentThread, dwFGThread, FALSE);
- SetWindowPos(hWnd,
- HWND_TOPMOST,
- 0,
- 0,
- 0,
- 0,
- SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
- SetWindowPos(hWnd,
- HWND_NOTOPMOST,
- 0,
- 0,
- 0,
- 0,
- SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
- return GetFocus() == hWnd;
- }
- void NativeWindow::setPosition(const Punkt& p) // Window position
- {
- setPosition(p.x, p.y);
- }
- void NativeWindow::setPosition(int x, int y)
- {
- RECT r;
- GetWindowRect(hWnd, &r); // Find previous position
- RECT res;
- res.left = x, res.top = y, res.right = r.right - r.left,
- res.bottom = r.bottom - r.top;
- AdjustWindowRect(&res, style, 0);
- SetWindowPos(hWnd,
- 0,
- res.left,
- res.top,
- res.right,
- res.bottom,
- 0); // Change position
- }
- void NativeWindow::setSize(Punkt& g) // Window size
- {
- RECT r;
- GetWindowRect(hWnd, &r); // Find previous size
- RECT res;
- res.left = r.left, res.top = r.top, res.right = g.x, res.bottom = g.y;
- AdjustWindowRect(&res, style, 0);
- SetWindowPos(
- hWnd, 0, res.left, res.top, res.right, res.bottom, 0); // Change size
- }
- void NativeWindow::setSize(int breite, int hoehe)
- {
- RECT r;
- GetWindowRect(hWnd, &r); // Find previous size
- RECT res;
- res.left = r.left, res.top = r.top, res.right = breite, res.bottom = hoehe;
- AdjustWindowRect(&res, style, 0);
- SetWindowPos(
- hWnd, 0, res.left, res.top, res.right, res.bottom, 0); // Change size
- }
- void NativeWindow::setBounds(
- const Punkt& p, const Punkt& g) // sets size and position
- {
- SetWindowPos(hWnd, 0, p.x, p.y, g.x, g.y, 0); // Change size and position
- }
- void NativeWindow::setScreen(Screen* screen)
- {
- if (this->screen) this->screen->release();
- this->screen = screen;
- }
- void NativeWindow::zerstoeren()
- {
- DestroyWindow(hWnd);
- hWnd = 0;
- if (rahmen) DestroyWindow(rahmen);
- rahmen = 0;
- if (bitmap) DeleteObject(bitmap);
- bitmap = 0;
- if (hdc) DeleteDC(hdc);
- hdc = 0;
- }
- void NativeWindow::doMausAktion(MouseEvent& me)
- {
- if (!mausAktion || !mausAktion(makParam, this, me)) return;
- if (screen && me.id != ME_Betritt && me.id != ME_Leaves)
- {
- screen->doMouseEvent(me);
- if (!me.verarbeitet && verschiebbar)
- {
- if (mx != -1 && my != -1) // move
- {
- RECT r;
- if (rahmen)
- {
- GetWindowRect(rahmen, &r);
- r.right -= r.left, r.bottom -= r.top;
- r.left += me.mx - mx;
- r.top += me.my - my;
- SetWindowPos(rahmen,
- 0,
- r.left,
- r.top,
- r.right,
- r.bottom,
- 0); // Set position
- }
- GetWindowRect(hWnd, &r); // Find previous position
- r.right -= r.left, r.bottom -= r.top; // Update position
- r.left += me.mx - mx;
- r.top += me.my - my;
- SetWindowPos(hWnd,
- 0,
- r.left,
- r.top,
- r.right,
- r.bottom,
- 0); // Set position
- }
- else if (me.id == ME_PLinks) // start moving
- mx = me.mx, my = me.my;
- if (me.id == ME_RLinks) // stop moving
- mx = -1, my = -1;
- me.verarbeitet = 1;
- }
- }
- }
- void NativeWindow::doVSchliessAktion()
- {
- if (!vCloseAktion) return;
- vCloseAktion(sakParam, this);
- }
- void NativeWindow::doNSchliessAktion()
- {
- if (!nCloseAktion) return;
- nCloseAktion(sakParam, this);
- }
- void NativeWindow::doTastaturAktion(KeyboardEvent& te)
- {
- if (!tastaturAktion || !tastaturAktion(takParam, this, te)) return;
- if (screen) screen->doKeyboardEvent(te);
- }
- void NativeWindow::doRestoreMessage() // makes the border visible
- {
- if (rahmen) ShowWindow(rahmen, 1);
- ShowWindow(hWnd, 1);
- }
- void NativeWindow::setMouseEventParameter(
- void* p) // sets the mouse event parameter
- {
- makParam = p;
- }
- void NativeWindow::setSchliessEreignisParameter(
- void* p) // sets the close event parameter
- {
- sakParam = p;
- }
- void NativeWindow::setKeyboardEventParameter(
- void* p) // sets the keyboard event parameter
- {
- takParam = p;
- }
- void NativeWindow::setMausAktion(MausAktion mausAk)
- {
- mausAktion = mausAk;
- }
- void NativeWindow::setVSchliessAktion(
- std::function<void(void*, void*)> vSchliessAk)
- {
- vCloseAktion = vSchliessAk;
- }
- void NativeWindow::setNSchliessAktion(
- std::function<void(void*, void*)> nSchliessAk)
- {
- nCloseAktion = nSchliessAk;
- }
- void NativeWindow::setTastaturAktion(TastaturAktion tastaturAk)
- {
- tastaturAktion = tastaturAk;
- }
- void NativeWindow::setWindowHandle(HWND hWnd) // sets the operation window
- {
- this->hWnd = hWnd;
- }
- void NativeWindow::setVerschiebbar(
- bool verschiebbar) // determines whether the window can be
- // moved by dragging with the mouse
- {
- this->verschiebbar = verschiebbar;
- }
- void NativeWindow::loadBorderWindow(Image* zImage,
- HINSTANCE hinst) // sets a transparent border around the window
- {
- if (!zImage) return;
- // Create window
- WNDCLASSEX wcl = {0};
- wcl.cbSize = sizeof(wcl);
- wcl.style = CS_HREDRAW | CS_VREDRAW;
- wcl.lpfnWndProc = WindowProc;
- wcl.cbClsExtra = 0;
- wcl.cbWndExtra = 0;
- wcl.hInstance = hinst;
- wcl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
- wcl.hbrBackground = NULL;
- wcl.lpszMenuName = NULL;
- wcl.lpszClassName = TEXT("LayeredWindowClass");
- wcl.hIconSm = NULL;
- // Create bitmap
- hdc = CreateCompatibleDC(NULL);
- if (!hdc) return;
- BITMAPINFO info;
- info.bmiHeader.biSize = sizeof(info.bmiHeader);
- info.bmiHeader.biBitCount = 32;
- info.bmiHeader.biWidth = zImage->getBreite();
- info.bmiHeader.biHeight = -zImage->getHeight();
- info.bmiHeader.biCompression = BI_RGB;
- info.bmiHeader.biPlanes = 1;
- unsigned char* pPixels = 0;
- bitmap
- = CreateDIBSection(hdc, &info, DIB_RGB_COLORS, (void**)&pPixels, 0, 0);
- if (!bitmap) DeleteDC(hdc);
- GdiFlush();
- // Fill bitmap
- int pitch = ((zImage->getBreite() * 32 + 31) & ~31) >> 3;
- unsigned char* pRow = 0;
- int* buffer = zImage->getBuffer();
- for (int i = 0; i < zImage->getHeight(); ++i)
- {
- pRow = &pPixels[i * pitch];
- for (int i2 = 0; i2 < zImage->getBreite(); ++i2)
- {
- pRow[i2 * 4]
- = (unsigned char)((buffer[i2 + i * zImage->getBreite()] >> 16)
- & 0xFF);
- pRow[i2 * 4 + 1]
- = (unsigned char)((buffer[i2 + i * zImage->getBreite()] >> 8)
- & 0xFF);
- pRow[i2 * 4 + 2]
- = (unsigned char)((buffer[i2 + i * zImage->getBreite()])
- & 0xFF);
- pRow[i2 * 4 + 3]
- = (unsigned char)((buffer[i2 + i * zImage->getBreite()] >> 24)
- & 0xFF);
- }
- }
- // Calculate alpha
- unsigned char* pPixel = 0;
- if (zImage->getBreite() * 4 == pitch)
- {
- int i = 0;
- int totalBytes = zImage->getBreite() * zImage->getHeight() * 4;
- for (i = 0; i < totalBytes; i += 4)
- {
- pPixel = &pPixels[i];
- pPixel[0] *= (unsigned char)((float)pPixel[3] / 255.0f);
- pPixel[1] *= (unsigned char)((float)pPixel[3] / 255.0f);
- pPixel[2] *= (unsigned char)((float)pPixel[3] / 255.0f);
- }
- }
- else
- {
- int x = 0;
- int y = 0;
- for (y = 0; y < zImage->getHeight(); ++y)
- {
- for (x = 0; x < zImage->getBreite(); ++x)
- {
- pPixel = &pPixels[(y * pitch) + (x * 4)];
- pPixel[0] *= (unsigned char)((float)pPixel[3] / 255.0f);
- pPixel[1] *= (unsigned char)((float)pPixel[3] / 255.0f);
- pPixel[2] *= (unsigned char)((float)pPixel[3] / 255.0f);
- }
- }
- }
- // Continue creating window
- if (RegisterClassEx(&wcl))
- {
- rahmen = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_LAYERED,
- wcl.lpszClassName,
- TEXT("Transparentes Window"),
- WS_POPUP,
- 0,
- 0,
- zImage->getBreite(),
- zImage->getHeight(),
- 0,
- 0,
- wcl.hInstance,
- 0);
- if (rahmen)
- {
- // draw
- HDC h = 0;
- if ((h = GetDC(rahmen)) && bitmap)
- {
- HGDIOBJ hPrevObj = NULL;
- POINT ptDest = {0, 0};
- POINT ptSrc = {0, 0};
- SIZE client = {zImage->getBreite(), zImage->getHeight()};
- BLENDFUNCTION blendFunc = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA};
- hPrevObj = SelectObject(hdc, bitmap);
- ClientToScreen(rahmen, &ptDest);
- UpdateLayeredWindow(rahmen,
- h,
- &ptDest,
- &client,
- hdc,
- &ptSrc,
- 0,
- &blendFunc,
- ULW_ALPHA);
- SelectObject(hdc, hPrevObj);
- ReleaseDC(rahmen, h);
- }
- UpdateWindow(rahmen);
- Punkt pos = getPosition() + (getGroesse() - zImage->getSize()) / 2;
- SetWindowPos(rahmen,
- 0,
- pos.x,
- pos.y,
- zImage->getBreite(),
- zImage->getHeight(),
- 0);
- }
- }
- }
- // constant
- Punkt NativeWindow::getPosition() const // returns the position
- {
- RECT r;
- GetWindowRect(hWnd, &r); // Find position
- return {r.left, r.top};
- }
- Punkt NativeWindow::getGroesse() const // returns the size
- {
- RECT r;
- GetWindowRect(hWnd, &r); // Find size
- return {r.right - r.left, r.bottom - r.top};
- }
- Punkt NativeWindow::getKoerperGroesse() const // returns the window body size
- {
- RECT r;
- GetClientRect(hWnd, &r); // Find size
- return {r.right - r.left, r.bottom - r.top};
- }
- int NativeWindow::getKoerperBreite() const // returns the window body width
- {
- RECT r;
- GetClientRect(hWnd, &r); // Find size
- return r.right;
- }
- int NativeWindow::getKoerperHoehe() const // returns the window body height
- {
- RECT r;
- GetClientRect(hWnd, &r); // Find size
- return r.bottom;
- }
- HWND NativeWindow::getWindowHandle() const // returns a handle to the window
- {
- return hWnd;
- }
- bool NativeWindow::hatMausAktion() const
- {
- return mausAktion != 0;
- }
- bool NativeWindow::hatVSchliessAktion() const
- {
- return vCloseAktion != 0;
- }
- bool NativeWindow::hatNSchliessAktion() const
- {
- return nCloseAktion != 0;
- }
- bool NativeWindow::hatTastaturAktion() const
- {
- return tastaturAktion != 0;
- }
- Screen* NativeWindow::getScreen() const
- {
- if (!screen) return 0;
- return dynamic_cast<Screen*>(screen->getThis());
- }
- Screen* NativeWindow::zScreen() const
- {
- return screen;
- }
- bool NativeWindow::istVerschiebbar()
- const // checks if the window can be moved by dragging with the mouse
- {
- return verschiebbar;
- }
- // Contents of the NativeWindowArray class from Window.h
- // Constructor
- NativeWindowArray::NativeWindowArray()
- : next(0),
- This(0)
- {}
- // Destructor
- NativeWindowArray::~NativeWindowArray()
- {
- if (next) delete next;
- }
- // add und remove
- bool NativeWindowArray::addWindow(NativeWindow* fenster)
- {
- if (fenster == This) return 0;
- if (!This)
- {
- This = fenster;
- return 1;
- }
- if (!next) next = new NativeWindowArray();
- return next->addWindow(fenster);
- }
- bool NativeWindowArray::removeWindow(NativeWindow* fenster)
- {
- if (fenster == This) return 1;
- if (!next) return 0;
- if (next->removeWindow(fenster))
- {
- NativeWindowArray* tmp = next->getNext();
- next->setNext0();
- delete next;
- next = tmp;
- }
- return 0;
- }
- NativeWindowArray* NativeWindowArray::getNext()
- {
- return next;
- }
- void NativeWindowArray::setNext0()
- {
- next = 0;
- }
- void NativeWindowArray::del()
- {
- if (next)
- {
- This = next->getThis();
- NativeWindowArray* tmp = next->getNext();
- next->setNext0();
- delete next;
- next = tmp;
- }
- else
- This = 0;
- }
- // Messages
- bool NativeWindowArray::sendVSchliessMessage(HWND hwnd)
- {
- if (!This) return 0;
- bool ret = 0;
- if (This->getWindowHandle() == hwnd && This->hatVSchliessAktion())
- {
- This->doVSchliessAktion();
- ret = 1;
- }
- if (!next) return ret;
- return ret || next->sendVSchliessMessage(hwnd);
- }
- bool NativeWindowArray::sendNSchliessMessage(HWND hwnd)
- {
- if (!This) return 0;
- bool ret = 0;
- if (This->getWindowHandle() == hwnd && This->hatNSchliessAktion())
- {
- This->doNSchliessAktion();
- ret = 1;
- }
- if (!next) return ret;
- return ret || next->sendNSchliessMessage(hwnd);
- }
- bool NativeWindowArray::sendMausMessage(HWND hwnd, MouseEvent& me)
- {
- if (!This) return 0;
- bool ret = 0;
- if (This->getWindowHandle() == hwnd && This->hatMausAktion())
- {
- This->doMausAktion(me);
- ret = 1;
- }
- if (!next) return ret;
- return ret || next->sendMausMessage(hwnd, me);
- }
- bool NativeWindowArray::sendTastaturMessage(HWND hwnd, KeyboardEvent& te)
- {
- if (!This) return 0;
- bool ret = 0;
- if (This->getWindowHandle() == hwnd && This->hatTastaturAktion())
- {
- This->doTastaturAktion(te);
- ret = 1;
- }
- if (!next) return ret;
- return ret || next->sendTastaturMessage(hwnd, te);
- }
- bool NativeWindowArray::sendRestoreMessage(HWND hwnd)
- {
- if (!This) return 0;
- bool ret = 0;
- if (This->getWindowHandle() == hwnd && This->hatMausAktion())
- {
- This->doRestoreMessage();
- ret = 1;
- }
- if (!next) return ret;
- return ret || next->sendRestoreMessage(hwnd);
- }
- NativeWindow* NativeWindowArray::getThis()
- {
- return This;
- }
- // WMessageBox
- void Framework::WMessageBox(HWND hWnd, Text* titel, Text* meldung, UINT style)
- {
- MessageBox(
- hWnd, meldung->getText(), titel->getText(), style); // Message Box
- titel->release();
- meldung->release();
- }
- #endif
- // Contents of the Window class from Window.h
- // Constructor
- Window::Window()
- : Drawable(),
- closingMe(0),
- closingMeParam(0),
- rahmen(0),
- titel(0),
- members(new RCArray<Drawable>()),
- bgBodyColor(0xFF000000),
- bgBodyPicture(0),
- bodyBuffer(0),
- bgClosingFarbe(0xFF000000),
- bgClosingImage(0),
- closeBuffer(0),
- closeKlickBuffer(0),
- vScroll(0),
- hScroll(0),
- kMin(0, 0),
- kMax(0, 0),
- closeKlick(0),
- klick(0),
- moving(0),
- mx(0),
- my(0)
- {
- style = Style::MEIgnoreVerarbeitet | Style::MEIgnoreSichtbar
- | Style::MEIgnoreParentInside | Style::MEIgnoreInside;
- this->setMouseEvent(_ret1ME);
- this->setKeyboardEvent(_ret1TE);
- min = Punkt(0, 0), max = Punkt(0, 0);
- }
- // Destructor
- Window::~Window()
- {
- if (rahmen) rahmen->release();
- if (titel) titel->release();
- members->release();
- if (bodyBuffer) bodyBuffer->release();
- if (bgBodyPicture) bgBodyPicture->release();
- if (bgClosingImage) bgClosingImage->release();
- if (closeBuffer) closeBuffer->release();
- if (closeKlickBuffer) closeKlickBuffer->release();
- if (vScroll) vScroll->release();
- if (hScroll) hScroll->release();
- }
- void Window::doMouseEvent(MouseEvent& me, bool userRet)
- {
- if (me.id == ME_Leaves)
- {
- if (closeKlick != 0) rend = 1;
- closeKlick = 0, klick = 0;
- }
- if (hatStyleNicht(Style::Sichtbar) || !me.insideParent || me.verarbeitet
- || me.mx < 0 || me.my < 0 || me.mx >= gr.x || me.my >= gr.y || !userRet)
- {
- bool insideParent = me.insideParent;
- bool verarbeitet = me.verarbeitet;
- me.verarbeitet |= hatStyleNicht(Style::Sichtbar);
- me.insideParent = 0;
- int rbr = 0;
- if (hatStyle(Style::Border) && rahmen) rbr = rahmen->getRBreite();
- int th = 0;
- if (hatStyle(Style::Titel) && titel) th = titel->getHeight();
- me.mx -= rbr;
- me.my -= rbr + th;
- if (hatStyle(Style::VScroll) && vScroll) me.my += vScroll->getScroll();
- if (hatStyle(Style::HScroll) && hScroll) me.mx += hScroll->getScroll();
- if (me.id != ME_Betritt && me.id != ME_Leaves)
- {
- for (int i = members->getEntryCount() - 1; i >= 0; i--)
- members->z(i)->doPublicMouseEvent(me);
- }
- me.mx += rbr;
- me.my += rbr + th;
- if (hatStyle(Style::VScroll) && vScroll) me.my -= vScroll->getScroll();
- if (hatStyle(Style::HScroll) && hScroll) me.mx -= hScroll->getScroll();
- me.insideParent = insideParent;
- if (hatStyleNicht(Style::Sichtbar)) me.verarbeitet = verarbeitet;
- if (!moving) return;
- }
- bool mvtmp = me.verarbeitet;
- if (hatStyleNicht(Style::Erlaubt)) me.verarbeitet = 1;
- int rbr = 0;
- if (hatStyle(Style::Border) && rahmen) rbr = rahmen->getRBreite();
- int th = 0;
- if (hatStyle(Style::Titel) && titel) th = titel->getHeight();
- bool hSc = hatStyle(Style::HScroll) && hScroll;
- bool vSc = hatStyle(Style::VScroll) && vScroll;
- if (me.id == ME_Bewegung && moving && getMausStand(M_Links))
- {
- if (hatStyle(Style::Beweglich) || hatStyle(Style::HeightChangeable)
- || hatStyle(Style::BreiteChangeable)
- || hatStyle(Style::TitelHeightChangeable))
- {
- bool ret1 = 0;
- bool mset = 0;
- int schi = 0;
- int scbr = 0;
- if (hSc)
- {
- schi = 15;
- }
- if (vSc)
- {
- scbr += 15;
- }
- bool minXb, maxXb, minYb, maxYb;
- bool kMinXb, kMaxXb, kMinYb, kMaxYb;
- minXb = hatStyle(Style::MinBr);
- maxXb = hatStyle(Style::MaxBr);
- minYb = hatStyle(Style::MinHi);
- maxYb = hatStyle(Style::MaxHi);
- kMinXb = hatStyle(Style::BodyMinBr);
- kMaxXb = hatStyle(Style::BodyMaxBr);
- kMinYb = hatStyle(Style::BodyMinHi);
- kMaxYb = hatStyle(Style::BodyMaxHi);
- int fMinBr = rbr * 2 + scbr;
- if (minXb) fMinBr = fMinBr < min.x ? min.x : fMinBr;
- if (kMinXb)
- fMinBr = fMinBr < (rbr * 2 + kMin.x + scbr)
- ? (rbr * 2 + kMin.x + scbr)
- : fMinBr;
- int fMinHi = rbr * 2 + th + schi;
- if (minYb) fMinHi = fMinHi < min.y ? min.y : fMinHi;
- if (kMinYb)
- fMinHi = fMinHi < (rbr * 2 + kMin.y + th + schi)
- ? (rbr * 2 + kMin.y + th + schi)
- : fMinHi;
- int fMaxBr = 0;
- if (maxXb) fMaxBr = max.x;
- if (kMaxXb)
- fMaxBr = fMaxBr < (rbr * 2 + kMax.x + scbr)
- ? (rbr * 2 + kMax.x + scbr)
- : fMaxBr;
- int fMaxHi = 0;
- if (maxYb) fMaxHi = max.y;
- if (kMaxYb)
- fMaxHi = fMaxHi < (rbr * 2 + kMax.y + th + schi)
- ? (rbr * 2 + kMax.y + th + schi)
- : fMaxHi;
- minXb |= kMinXb, maxXb |= kMaxXb, minYb |= kMinYb, maxYb |= kMaxYb;
- if (hatStyle(Style::HeightChangeable))
- {
- if ((moving | 0x1) == moving) // top
- {
- pos.y -= my - me.my;
- gr.y += my - me.my;
- if (gr.y < fMinHi)
- {
- pos.y -= fMinHi - gr.y;
- gr.y = fMinHi;
- }
- else if (maxYb && gr.y > fMaxHi)
- {
- pos.y -= gr.y - fMaxHi;
- gr.y = fMaxHi;
- }
- else if (vSc)
- vScroll->getScrollData()->anzeige = gr.y;
- rend = 1;
- ret1 = 1;
- }
- else if ((moving | 0x2) == moving) // bottom
- {
- gr.y += me.my - my;
- if (gr.y < fMinHi)
- gr.y = fMinHi;
- else if (maxYb && gr.y > fMaxHi)
- gr.y = fMaxHi;
- else
- {
- mset = 1;
- if (vSc) vScroll->getScrollData()->anzeige = gr.y;
- }
- rend = 1;
- ret1 = 1;
- }
- }
- if (hatStyle(Style::BreiteChangeable))
- {
- if ((moving | 0x4) == moving) // left
- {
- pos.x -= mx - me.mx;
- gr.x += mx - me.mx;
- if (gr.x < fMinBr)
- {
- pos.x -= fMinBr - gr.x;
- gr.x = fMinBr;
- }
- else if (maxXb && gr.x > fMaxBr)
- {
- pos.x -= gr.x - fMaxBr;
- gr.x = fMaxBr;
- }
- else if (hSc)
- hScroll->getScrollData()->anzeige = gr.x;
- rend = 1;
- ret1 = 1;
- }
- else if ((moving | 0x8) == moving) // right
- {
- gr.x += me.mx - mx;
- if (gr.x < rbr * 2 + fMinBr)
- gr.x = rbr * 2 + fMinBr;
- else if (maxXb && gr.x > fMaxBr)
- gr.x = fMaxBr;
- else
- {
- mset = 1;
- if (hSc) hScroll->getScrollData()->anzeige = gr.x;
- }
- rend = 1;
- ret1 = 1;
- }
- }
- if (hatStyle(Style::TitelHeightChangeable) && titel
- && (moving | 0x10) == moving) // titel height
- {
- int maxTh = gr.y - rbr * 2 - schi;
- if (kMaxYb)
- maxTh = maxTh < (gr.x - rbr * 2 - kMin.y)
- ? maxTh
- : (gr.x - rbr * 2 - kMin.y);
- if (hatStyle(Style::Closable))
- maxTh = (gr.x - th - 5 - rbr * 2 - me.my + my) < 0 ? th
- : maxTh;
- titel->setSize(
- titel->getBreite(), titel->getHeight() + me.my - my);
- if (titel->getHeight() > maxTh)
- titel->setSize(titel->getBreite(), maxTh);
- else if (titel->getHeight() < 5)
- titel->setSize(titel->getBreite(), 5);
- else
- mset = 1;
- rend = 1;
- ret1 = 1;
- }
- if (ret1)
- {
- if (mset) mx = me.mx, my = me.my;
- me.verarbeitet = 1;
- }
- if (hatStyle(Style::Beweglich) && (moving | 0x20) == moving) // move
- {
- pos.x += me.mx - mx;
- pos.y += me.my - my;
- rend = 1;
- ret1 = 1;
- }
- if (ret1) me.verarbeitet = 1;
- }
- }
- if (me.id == ME_RLinks)
- {
- if (closeKlick) rend = 1;
- closeKlick = 0, klick = 0;
- moving = 0;
- mx = -1, my = -1;
- }
- if (me.id == ME_Leaves)
- {
- if (closeKlick != 0) rend = 1;
- closeKlick = 0, klick = 0;
- }
- if (hatStyleNicht(Style::Sichtbar) || !me.insideParent || me.verarbeitet
- || me.mx < 0 || me.my < 0 || me.mx >= gr.x || me.my >= gr.y || !userRet)
- return;
- if (!me.verarbeitet)
- {
- if (hatStyle(Style::Closable) && me.my <= th + rbr
- && me.mx >= gr.x + rbr - th && me.my >= rbr && me.mx <= gr.x - rbr)
- {
- if (!closingMe || closingMe(closingMeParam, this, me))
- {
- if (me.id == ME_PLinks)
- {
- closeKlick = 1;
- rend = 1;
- }
- if (!closeKlick && MausStand[M_Links])
- {
- closeKlick = 1;
- rend = 1;
- }
- me.verarbeitet = 1;
- }
- }
- else if (closeKlick)
- {
- closeKlick = 0;
- rend = 1;
- }
- if (me.id == ME_PLinks && !closeKlick)
- {
- klick = 1;
- mx = me.mx, my = me.my;
- if (me.mx >= 0 && me.mx < gr.x && me.my >= 0 && me.my < rbr + 5
- && !hatStyle(Style::TopPositionFixed))
- moving |= 0x1;
- if (me.mx >= 0 && me.mx < gr.x && me.my >= gr.y - (rbr + 5)
- && me.my < gr.y && !hatStyle(Style::BottomPositionFixed))
- moving |= 0x2;
- if (me.mx >= 0 && me.mx < rbr + 5 && me.my >= 0 && me.my < gr.y
- && !hatStyle(Style::LeftPositionFixed))
- moving |= 0x4;
- if (me.mx >= gr.x - rbr - 5 && me.mx < gr.x && me.my >= 0
- && me.my < gr.y && !hatStyle(Style::RightPositionFixed))
- moving |= 0x8;
- if (titel && me.mx >= 0 && me.mx < gr.x
- && me.my >= titel->getHeight()
- && me.my < titel->getHeight() + 2 * (rbr + 5))
- moving |= 0x10;
- if (titel && me.mx >= 0 && me.mx < gr.x && me.my >= rbr + 5
- && me.my < titel->getHeight())
- moving |= 0x20;
- }
- }
- if (vSc)
- {
- vScroll->doMausMessage(
- gr.x - rbr - 15, rbr + th, 15, gr.y - rbr * 2 - th, me);
- if (hSc)
- hScroll->doMausMessage(
- rbr, gr.y - rbr - 15, gr.x - rbr * 2 - 15, 15, me);
- }
- else if (hSc)
- hScroll->doMausMessage(rbr, gr.y - rbr - 15, gr.x - rbr * 2, 15, me);
- me.mx -= rbr;
- me.my -= rbr + th;
- if (hatStyle(Style::VScroll) && vScroll) me.my += vScroll->getScroll();
- if (hatStyle(Style::HScroll) && hScroll) me.mx += hScroll->getScroll();
- if (me.id != ME_Betritt && me.id != ME_Leaves)
- {
- for (int i = members->getEntryCount() - 1; i >= 0; i--)
- members->z(i)->doPublicMouseEvent(me);
- }
- me.mx += rbr;
- me.my += rbr + th;
- if (hatStyle(Style::VScroll) && vScroll) me.my -= vScroll->getScroll();
- if (hatStyle(Style::HScroll) && hScroll) me.mx -= hScroll->getScroll();
- if (hatStyleNicht(Style::METransparenz)) me.verarbeitet = 1;
- if (hatStyleNicht(Style::Erlaubt)) me.verarbeitet = mvtmp;
- }
- // non-const
- // -- Border --
- void Window::setBorderZ(Border* ram) // sets the border
- {
- if (rahmen) rahmen->release();
- rahmen = ram;
- rend = 1;
- }
- void Window::setRFarbe(int f) // sets the border color
- {
- if (!rahmen) rahmen = new LBorder();
- rahmen->setFarbe(f);
- rend = 1;
- }
- void Window::setRBreite(int br) // sets the border width
- {
- if (!rahmen) rahmen = new LBorder();
- rahmen->setRamenBreite(br);
- rend = 1;
- }
- // -- Title --
- void Window::setTitel(Text* txt) // sets the title
- {
- if (!titel) titel = new TextField();
- titel->setText(txt);
- rend = 1;
- }
- void Window::setTitelZ(Text* txt)
- {
- if (!titel) titel = new TextField();
- titel->setTextZ(txt);
- rend = 1;
- }
- void Window::setTitel(const char* txt)
- {
- if (!titel) titel = new TextField();
- titel->setText(txt);
- rend = 1;
- }
- void Window::setTTextFeldZ(TextField* tf) // sets the title text field
- {
- if (titel) titel->release();
- titel = tf;
- rend = 1;
- }
- // -- Font --
- void Window::setTFontZ(Font* schrift) // sets the title font
- {
- if (!titel) titel = new TextField();
- titel->setFontZ(schrift);
- rend = 1;
- }
- void Window::setTSFarbe(int f) // sets the title font color
- {
- if (!titel) titel = new TextField();
- titel->setSchriftFarbe(f);
- rend = 1;
- }
- void Window::setTSSize(int gr) // sets the title font size
- {
- if (!titel) titel = new TextField();
- titel->setSchriftSize((unsigned char)gr);
- rend = 1;
- }
- // -- Title Background --
- void Window::setTBgFarbe(int f) // sets title background color
- {
- if (!titel) titel = new TextField();
- titel->setHintergrundFarbe(f);
- rend = 1;
- }
- // -- Title AlphaField --
- void Window::setTAlphaFieldZ(AlphaField* af) // sets the title AlphaField
- {
- if (!titel) titel = new TextField();
- titel->setAlphaFieldZ(af);
- rend = 1;
- }
- void Window::setTAfFarbe(int f) // sets the title AlphaField color
- {
- if (!titel) titel = new TextField();
- titel->setAlphaFieldColor(f);
- rend = 1;
- }
- void Window::setTAfStrength(int st) // sets the strength of the title AlphaField
- {
- if (!titel) titel = new TextField();
- titel->setAlphaFieldStrength(st);
- rend = 1;
- }
- // -- Title Background Image --
- void Window::setTBgImage(Image* b) // sets the title background image
- {
- if (!titel) titel = new TextField();
- titel->setHintergrundImage(b);
- rend = 1;
- }
- void Window::setTBgImageZ(Image* b)
- {
- if (!titel) titel = new TextField();
- titel->setHintergrundImageZ(b);
- rend = 1;
- }
- // -- Title Border --
- void Window::setTBorderZ(Border* ram) // sets the title border
- {
- if (!titel) titel = new TextField();
- titel->setBorderZ(ram);
- rend = 1;
- }
- void Window::setTRFarbe(int f) // sets the title border color
- {
- if (!titel) titel = new TextField();
- titel->setBorderColor(f);
- rend = 1;
- }
- void Window::setTRBreite(int br) // sets the title border width
- {
- if (!titel) titel = new TextField();
- titel->setBorderWidth(br);
- rend = 1;
- }
- // -- Body Background --
- void Window::setKBgFarbe(int f) // sets the body background color
- {
- bgBodyColor = f;
- rend = 1;
- }
- // -- Body Background Image --
- void Window::setKBgImage(Image* b) // sets the body background image
- {
- if (!bgBodyPicture) bgBodyPicture = new Image();
- bgBodyPicture->neuImage(b->getBreite(), b->getHeight(), 0);
- int* buff1 = bgBodyPicture->getBuffer();
- int* buff2 = b->getBuffer();
- int gr = bgBodyPicture->getBreite() * bgBodyPicture->getHeight();
- for (int i = 0; i < gr; ++i)
- buff1[i] = buff2[i];
- b->release();
- rend = 1;
- }
- void Window::setKBgImageZ(Image* b)
- {
- if (bgBodyPicture) bgBodyPicture->release();
- bgBodyPicture = b;
- rend = 1;
- }
- // -- Body AlphaField --
- void Window::setKAlphaFieldZ(AlphaField* af) // sets the body AlphaField
- {
- if (bodyBuffer) bodyBuffer->release();
- bodyBuffer = af;
- rend = 1;
- }
- void Window::setKAfFarbe(int f) // sets body AlphaField color
- {
- if (!bodyBuffer) bodyBuffer = new AlphaField();
- bodyBuffer->setFarbe(f);
- rend = 1;
- }
- void Window::setKAfStrength(int st) // sets the strength of the body AlphaField
- {
- if (!bodyBuffer) bodyBuffer = new AlphaField();
- bodyBuffer->setStrength(st);
- rend = 1;
- }
- // -- Close --
- void Window::setClosingMeParam(void* param)
- {
- closingMeParam = param;
- }
- void Window::setClosingMe(MausAktion closingMe) // sets the close mouse event
- {
- this->closingMe = closingMe;
- }
- // -- Close Background --
- void Window::setSBgFarbe(int f) // sets the close background color
- {
- bgClosingFarbe = f;
- rend = 1;
- }
- // -- Close Background Image --
- void Window::setSBgImage(Image* b) // sets the close background image
- {
- if (!bgClosingImage) bgClosingImage = new Image();
- bgClosingImage->neuImage(b->getBreite(), b->getHeight(), 0);
- int* buff1 = bgClosingImage->getBuffer();
- int* buff2 = b->getBuffer();
- int gr = bgClosingImage->getBreite() * bgClosingImage->getHeight();
- for (int i = 0; i < gr; ++i)
- buff1[i] = buff2[i];
- b->release();
- rend = 1;
- }
- void Window::setSBgImageZ(Image* b)
- {
- if (bgClosingImage) bgClosingImage->release();
- bgClosingImage = b;
- rend = 1;
- }
- // -- Close AlphaField --
- void Window::setSAlphaFieldZ(AlphaField* af) // sets the close AlphaField
- {
- if (closeBuffer) closeBuffer->release();
- closeBuffer = af;
- rend = 1;
- }
- void Window::setSAfFarbe(int f) // sets the color of the close AlphaField
- {
- if (!closeBuffer) closeBuffer = new AlphaField();
- closeBuffer->setFarbe(f);
- rend = 1;
- }
- void Window::setSAfStrength(int st) // sets the strength of the close AlphaField
- {
- if (!closeBuffer) closeBuffer = new AlphaField();
- closeBuffer->setStrength(st);
- rend = 1;
- }
- // -- Close Click AlphaField --
- void Window::setSKAlphaFieldZ(AlphaField* af) // sets the close click AlphaField
- {
- if (closeKlickBuffer) closeKlickBuffer->release();
- closeKlickBuffer = af;
- rend = 1;
- }
- void Window::setSKAfFarbe(int f) // sets the color of the close click AlphaField
- {
- if (!closeKlickBuffer) closeKlickBuffer = new AlphaField();
- closeKlickBuffer->setFarbe(f);
- rend = 1;
- }
- void Window::setSKAfStrength(
- int st) // sets the strength of the close click AlphaField
- {
- if (!closeKlickBuffer) closeKlickBuffer = new AlphaField();
- closeKlickBuffer->setStrength(st);
- rend = 1;
- }
- // -- min max --
- void Window::setMin(int mx, int my) // sets the minimum window size
- {
- min.x = mx;
- min.y = my;
- }
- void Window::setMin(const Punkt& min)
- {
- this->min = min;
- }
- void Window::setMax(int mx, int my) // sets the maximum window size
- {
- max.x = mx;
- max.y = my;
- }
- void Window::setMax(const Punkt& max)
- {
- this->max = max;
- }
- void Window::setKMin(int mx, int my) // sets the minimum body size
- {
- kMin.x = mx;
- kMin.y = my;
- }
- void Window::setKMin(const Punkt& min)
- {
- kMin = min;
- }
- void Window::setKMax(int mx, int my) // sets the maximum body size
- {
- kMax.x = mx;
- kMax.y = my;
- }
- void Window::setKMax(const Punkt& max)
- {
- kMax = max;
- }
- // -- scroll --
- void Window::setHScrollBarZ(
- HScrollBar* hScroll) // sets the horizontal scroll bar
- {
- if (this->hScroll) this->hScroll->release();
- this->hScroll = hScroll;
- rend = 1;
- }
- void Window::setVScrollBarZ(VScrollBar* vScroll) // sets the vertical scroll bar
- {
- if (this->vScroll) this->vScroll->release();
- this->vScroll = vScroll;
- rend = 1;
- }
- void Window::setHSBMax(int max) // sets the scroll maximum
- {
- if (!hScroll) hScroll = new HScrollBar();
- int rbr = 0;
- if (hatStyle(Style::Border) && rahmen) rbr = rahmen->getRBreite();
- int vsh = 0;
- if (hatStyle(Style::VScroll) && vScroll) vsh = 15;
- hScroll->update(max, gr.x - rbr * 2 - vsh);
- rend = 1;
- }
- void Window::setVSBMax(int max)
- {
- if (!vScroll) vScroll = new VScrollBar();
- int rbr = 0;
- int th = 0;
- if (hatStyle(Style::Border) && rahmen) rbr = rahmen->getRBreite();
- if (hatStyle(Style::Titel) && titel) th = titel->getHeight();
- int hsh = 0;
- if (hatStyle(Style::HScroll) && hScroll) hsh = 15;
- vScroll->update(max, gr.y - rbr * 2 - th - hsh);
- rend = 1;
- }
- void Window::setHSBScroll(int scroll) // sets the current scroll position
- {
- if (!hScroll) hScroll = new HScrollBar();
- hScroll->scroll(scroll);
- rend = 1;
- }
- void Window::setVSBScroll(int scroll)
- {
- if (!vScroll) vScroll = new VScrollBar();
- vScroll->scroll(scroll);
- rend = 1;
- }
- void Framework::Window::updateHScroll()
- {
- if (hScroll)
- {
- hScroll->update(getNeededChildWidth(), getInnenBreite());
- }
- }
- void Framework::Window::updateVScroll()
- {
- if (vScroll)
- {
- vScroll->update(getNeededChildHeight(), getInnenHeight());
- }
- }
- // -- Members --
- void Window::addMember(Drawable* obj) // adds a member
- {
- members->add(obj);
- rend = 1;
- }
- void Framework::Window::setMemberIndex(Drawable* zMember, int index)
- {
- if (index < 0 || index >= members->getEntryCount()) return;
- int currentIndex = members->indexOf(zMember);
- members->setPosition(currentIndex, index);
- }
- void Window::removeMember(Drawable* zObj) // removes a member
- {
- for (int i = 0; i < members->getEntryCount(); i++)
- {
- if (members->z(i) == zObj)
- {
- members->remove(i);
- rend = 1;
- }
- }
- }
- void Window::removeAll()
- {
- members->leeren();
- rend = 1;
- }
- // -- Messages --
- bool Window::tick(double tickval) // tick
- {
- if (hatStyle(Style::Sichtbar))
- {
- for (Drawable* i : *members)
- rend |= i->tick(tickval);
- }
- else
- {
- for (Drawable* i : *members)
- i->tick(tickval);
- }
- if (vScroll && hatStyle(Style::VScroll)) rend |= vScroll->getRend();
- if (hScroll && hatStyle(Style::HScroll)) rend |= hScroll->getRend();
- return Drawable::tick(tickval);
- }
- void Window::doKeyboardEvent(KeyboardEvent& te)
- {
- bool ntakc = !te.verarbeitet;
- if (hatStyle(Style::Sichtbar))
- {
- if (te.verarbeitet)
- {
- for (int i = members->getEntryCount() - 1; i >= 0; i--)
- members->z(i)->doKeyboardEvent(te);
- }
- else
- {
- if (tak && tak(takParam, this, te))
- {
- for (int i = members->getEntryCount() - 1; i >= 0; i--)
- members->z(i)->doKeyboardEvent(te);
- }
- }
- }
- if (ntakc && te.verarbeitet && nTak)
- te.verarbeitet = nTak(ntakParam, this, te);
- }
- // -- Render --
- void Window::render(Image& zRObj) // draws to zRObj
- {
- if (hatStyle(Style::Sichtbar))
- {
- lockDrawable();
- if (!zRObj.setDrawOptions(pos, gr))
- {
- unlockDrawable();
- return;
- }
- Drawable::render(zRObj);
- int rbr = 0;
- if (hatStyle(Style::Border) && rahmen)
- {
- rahmen->setSize(gr);
- rahmen->render(zRObj);
- rbr = rahmen->getRBreite();
- }
- int th = 0;
- if (titel)
- titel->setStyle(TextField::Style::Sichtbar, hatStyle(Style::Titel));
- if (hatStyle(Style::Titel) && titel)
- {
- titel->setStyle(TextField::Style::Hintergrund,
- hatStyle(Style::TitelHintergrund));
- titel->setStyle(
- TextField::Style::HAlpha, hatStyle(Style::TitelHAlpha));
- titel->setStyle(
- TextField::Style::HImage, hatStyle(Style::TitelHImage));
- titel->setStyle(
- TextField::Style::Buffered, hatStyle(Style::TitelBuffered));
- th = titel->getHeight();
- if (!zRObj.setDrawOptions(rbr, rbr, gr.x - rbr * 2, th))
- {
- zRObj.releaseDrawOptions();
- unlockDrawable();
- return;
- }
- int sbr = 0;
- if (hatStyle(Style::Closable))
- {
- sbr = th;
- if (hatStyle(Style::ClosingHintergrund))
- {
- if (hatStyle(Style::ClosingHAlpha))
- zRObj.alphaRegion(
- gr.x - th - rbr * 2, 0, th, th, bgClosingFarbe);
- else
- zRObj.fillRegion(
- gr.x - th - rbr * 2, 0, th, th, bgClosingFarbe);
- if (hatStyle(Style::ClosingHImage) && bgClosingImage)
- {
- if (hatStyle(Style::ClosingHAlpha))
- zRObj.alphaImage(gr.x - th - rbr * 2,
- 0,
- th,
- th,
- *bgClosingImage);
- else
- zRObj.drawImage(gr.x - th - rbr * 2,
- 0,
- th,
- th,
- *bgClosingImage);
- }
- }
- if (!hatStyle(Style::ClosingHImage) || !bgClosingImage)
- {
- zRObj.drawLinie(Punkt(gr.x - th - rbr * 2, 0),
- Punkt(gr.x - rbr * 2, th),
- 0xFFFFFFFF);
- zRObj.drawLinie(Punkt(gr.x - rbr * 2, 0),
- Punkt(gr.x - th - rbr * 2, th),
- 0xFFFFFFFF);
- }
- if (hatStyle(Style::ClosingBuffer) && closeBuffer)
- {
- closeBuffer->setPosition(gr.x - th - rbr * 2, 0);
- closeBuffer->setSize(th, th);
- closeBuffer->render(zRObj);
- }
- if (hatStyle(Style::ClosingKlickBuffer) && closeKlickBuffer
- && closeKlick)
- {
- closeKlickBuffer->setPosition(gr.x - th - rbr * 2, 0);
- closeKlickBuffer->setSize(th, th);
- closeKlickBuffer->render(zRObj);
- }
- }
- if (!hatStyle(Style::CustomTitle))
- titel->setSize(gr.x - rbr * 2 - sbr, th);
- titel->render(zRObj);
- zRObj.releaseDrawOptions();
- }
- bool vSc = hatStyle(Style::VScroll) && vScroll;
- bool hSc = hatStyle(Style::HScroll) && hScroll;
- if (vSc)
- {
- vScroll->render(
- gr.x - rbr - 15, rbr + th, 15, gr.y - rbr * 2 - th, zRObj);
- if (hSc)
- hScroll->render(
- rbr, gr.y - rbr - 15, gr.x - rbr * 2 - 15, 15, zRObj);
- }
- else if (hSc)
- hScroll->render(rbr, gr.y - rbr - 15, gr.x - rbr * 2, 15, zRObj);
- int x = rbr;
- int y = rbr + th;
- int br = gr.x - rbr * 2;
- int hi = gr.y - rbr * 2 - th;
- if (vSc) br -= 15;
- if (hSc) hi -= 15;
- if (!zRObj.setDrawOptions(x, y, br, hi))
- {
- zRObj.releaseDrawOptions();
- unlockDrawable();
- return;
- }
- if (hatStyle(Style::BodyHintergrund))
- {
- if (hatStyle(Style::BodyHAlpha))
- zRObj.alphaRegion(0, 0, br, hi, bgBodyColor);
- else
- zRObj.fillRegion(0, 0, br, hi, bgBodyColor);
- if (hatStyle(Style::BodyHImage) && bgBodyPicture)
- {
- if (hatStyle(Style::BodyHAlpha))
- zRObj.alphaImage(0, 0, br, hi, *bgBodyPicture);
- else
- zRObj.drawImage(0, 0, br, hi, *bgBodyPicture);
- }
- }
- if (hatStyle(Style::BodyBuffered) && bodyBuffer)
- {
- bodyBuffer->setSize(br, hi);
- bodyBuffer->render(zRObj);
- }
- if (!vSc && !hSc)
- {
- for (Drawable* i : *members)
- i->render(zRObj);
- }
- else
- {
- zRObj.addScrollOffset(
- hSc ? hScroll->getScroll() : 0, vSc ? vScroll->getScroll() : 0);
- for (Drawable* i : *members)
- i->render(zRObj);
- }
- zRObj.releaseDrawOptions();
- zRObj.releaseDrawOptions();
- unlockDrawable();
- }
- }
- // constant
- // Returns the width of the interior area of the drawing in pixels
- int Window::getInnenBreite() const
- {
- return getBreite() - 2 * getRBreite();
- }
- // Returns the height of the interior area of the drawing in pixels
- int Window::getInnenHeight() const
- {
- int th = 0;
- if (hatStyle(Style::Titel) && titel) th += titel->getHeight();
- return getHeight() - 2 * getRBreite() - th;
- }
- // -- Border --
- Border* Window::getBorder() const // returns the border
- {
- if (!rahmen) return 0;
- return dynamic_cast<Border*>(rahmen->getThis());
- }
- Border* Window::zBorder() const
- {
- return rahmen;
- }
- int Window::getRFarbe() const // returns the border color
- {
- if (!rahmen) return 0;
- return rahmen->getFarbe();
- }
- int Window::getRBreite() const // returns the border width
- {
- if (!rahmen || hatStyleNicht(Style::Border)) return 0;
- return rahmen->getRBreite();
- }
- // -- Title --
- Text* Window::getTitel() const // returns the title
- {
- if (!titel) return 0;
- return titel->getText();
- }
- Text* Window::zTitel() const
- {
- if (!titel) return 0;
- return titel->zText();
- }
- TextField* Window::getTTextField() const // returns the title text field
- {
- if (!titel) return 0;
- return dynamic_cast<TextField*>(titel->getThis());
- }
- TextField* Window::zTTextField() const
- {
- return titel;
- }
- // -- Title Font --
- Font* Window::getTFont() const // returns the title font
- {
- if (!titel) return 0;
- return titel->getFont();
- }
- Font* Window::zTFont() const
- {
- if (!titel) return 0;
- return titel->zFont();
- }
- int Window::getTSFarbe() const // returns the title font color
- {
- if (!titel) return 0;
- return titel->getSchriftFarbe();
- }
- int Window::getTSSize() const // returns the title font size
- {
- if (!titel) return 0;
- return titel->getSchriftSize();
- }
- // -- Title Background --
- int Window::getTBgFarbe() const // returns the title background color
- {
- if (!titel) return 0;
- return titel->getHintergrundFarbe();
- }
- // -- Title AlphaField --
- AlphaField* Window::getTAlphaField() const // returns the title AlphaField
- {
- if (!titel) return 0;
- return titel->getAlphaField();
- }
- AlphaField* Window::zTAlphaField() const
- {
- if (!titel) return 0;
- return titel->zAlphaField();
- }
- int Window::getTAfFarbe() const // returns the color of the title AlphaField
- {
- if (!titel) return 0;
- return titel->getAlphaFieldColor();
- }
- int Window::getTAfStrength()
- const // returns the strength of the title AlphaField
- {
- if (!titel) return 0;
- return titel->getAlphaFieldStrength();
- }
- // -- Title Background Image --
- Image* Window::getTBgImage() const // returns the title background image
- {
- if (!titel) return 0;
- return titel->getHintergrundImage();
- }
- Image* Window::zTBgImage() const
- {
- if (!titel) return 0;
- return titel->zHintergrundImage();
- }
- // -- Title Border --
- Border* Window::getTBorder() const // returns the title border
- {
- if (!titel) return 0;
- return titel->getBorder();
- }
- Border* Window::zTBorder() const
- {
- if (!titel) return 0;
- return titel->zBorder();
- }
- int Window::getTRFarbe() const // returns the title border color
- {
- if (!titel) return 0;
- return titel->getBorderColor();
- }
- int Window::getTRBreite() const // returns the title border width
- {
- if (!titel) return 0;
- return titel->getBorderWidth();
- }
- // -- Body Background --
- int Window::getKBgFarbe() const // returns the body background color
- {
- return bgBodyColor;
- }
- // -- Body Background Image --
- Image* Window::getKBgImage() const // returns the body background image
- {
- if (!bgBodyPicture) return 0;
- return dynamic_cast<Image*>(bgBodyPicture->getThis());
- }
- Image* Window::zKBgImage() const
- {
- return bgBodyPicture;
- }
- // -- Body AlphaField --
- AlphaField* Window::getKAlphaField() const // returns the body AlphaField
- {
- if (!bodyBuffer) return 0;
- return dynamic_cast<AlphaField*>(bodyBuffer->getThis());
- }
- AlphaField* Window::zKAlphaField() const
- {
- return bodyBuffer;
- }
- int Window::getKAfFarbe() const // returns the body AlphaField color
- {
- if (!bodyBuffer) return 0;
- return bodyBuffer->getFarbe();
- }
- int Window::getKAfStrength() const // returns the strength of the body AlphaField
- {
- if (!bodyBuffer) return 0;
- return bodyBuffer->getStrength();
- }
- // -- Close Background --
- int Window::getSBgFarbe() const // returns the close background color
- {
- return bgClosingFarbe;
- }
- // -- Close Background Image --
- Image* Window::getSBgImage() const // returns the close background image
- {
- if (!bgClosingImage) return 0;
- return dynamic_cast<Image*>(bgClosingImage->getThis());
- }
- Image* Window::zSBgImage() const
- {
- return bgClosingImage;
- }
- // -- Close AlphaField --
- AlphaField* Window::getSAlphaField() const // returns the close AlphaField
- {
- if (!closeBuffer) return 0;
- return dynamic_cast<AlphaField*>(closeBuffer->getThis());
- }
- AlphaField* Window::zSAlphaField() const
- {
- return closeBuffer;
- }
- int Window::getSAfFarbe() const // returns the close AlphaField color
- {
- if (!closeBuffer) return 0;
- return closeBuffer->getFarbe();
- }
- int Window::getSAfStrength()
- const // returns the strength of the close AlphaField
- {
- if (!closeBuffer) return 0;
- return closeBuffer->getStrength();
- }
- // -- Close Click AlphaField --
- AlphaField* Window::getSKAlphaField() const // returns the close click AlphaField
- {
- if (!closeKlickBuffer) return 0;
- return dynamic_cast<AlphaField*>(closeKlickBuffer->getThis());
- }
- AlphaField* Window::zSKAlphaField() const
- {
- return closeKlickBuffer;
- }
- int Window::getSKAfFarbe() const // returns the close click AlphaField color
- {
- if (!closeKlickBuffer) return 0;
- return closeKlickBuffer->getFarbe();
- }
- int Window::getSKAfStrength()
- const // returns the strength of the close click AlphaField
- {
- if (!closeKlickBuffer) return 0;
- return closeKlickBuffer->getStrength();
- }
- // -- min max --
- const Punkt& Window::getMin() const // returns the minimum window size
- {
- return min;
- }
- const Punkt& Window::getMax() const // returns the maximum window size
- {
- return max;
- }
- const Punkt& Window::getKMin() const // returns the minimum body size
- {
- return kMin;
- }
- const Punkt& Window::getKMax() const // returns the maximum body size
- {
- return kMax;
- }
- // -- scroll --
- VScrollBar* Window::getVScrollBar() const // returns the vertical scroll bar
- {
- if (!vScroll) return 0;
- return dynamic_cast<VScrollBar*>(vScroll->getThis());
- }
- VScrollBar* Window::zVScrollBar() const
- {
- return vScroll;
- }
- HScrollBar* Window::getHScrollBar() const // returns the horizontal scroll bar
- {
- if (!hScroll) return 0;
- return dynamic_cast<HScrollBar*>(hScroll->getThis());
- }
- HScrollBar* Window::zHScrollBar() const
- {
- return hScroll;
- }
- // -- Members --
- const RCArray<Drawable>& Window::getMembers() const // returns the members
- {
- return *members;
- }
- int Framework::Window::getNeededChildWidth() const
- {
- int max = 0;
- for (Drawable* z : *members)
- {
- if (z->getX() + z->getBreite() > max) max = z->getX() + z->getBreite();
- }
- return max;
- }
- int Framework::Window::getNeededChildHeight() const
- {
- int max = 0;
- for (Drawable* z : *members)
- {
- if (z->getY() + z->getHeight() > max) max = z->getY() + z->getHeight();
- }
- return max;
- }
- // -- Copy --
- Drawable* Window::dublizieren() const // Creates a copy of the window
- {
- Window* ret = new Window();
- ret->setPosition(pos);
- ret->setSize(gr);
- ret->setMouseEventParameter(makParam);
- ret->setKeyboardEventParameter(takParam);
- ret->setMouseEvent(mak);
- ret->setKeyboardEvent(tak);
- if (toolTip) ret->setToolTipZ((ToolTip*)toolTip->dublizieren());
- ret->setStyle(style);
- ret->setClosingMeParam(closingMeParam);
- ret->setClosingMe(closingMe);
- if (rahmen)
- {
- ret->setRBreite(rahmen->getRBreite());
- ret->setRFarbe(rahmen->getFarbe());
- }
- if (titel) ret->setTTextFeldZ((TextField*)titel->dublizieren());
- ret->setKBgFarbe(bgBodyColor);
- if (bgBodyPicture)
- ret->setKBgImage(dynamic_cast<Image*>(bgBodyPicture->getThis()));
- if (bodyBuffer)
- {
- ret->setKAfFarbe(bodyBuffer->getFarbe());
- ret->setKAfStrength(bodyBuffer->getStrength());
- }
- ret->setSBgFarbe(bgClosingFarbe);
- if (bgClosingImage)
- ret->setSBgImage(dynamic_cast<Image*>(bgClosingImage->getThis()));
- if (closeBuffer)
- {
- ret->setSAfFarbe(closeBuffer->getFarbe());
- ret->setSAfStrength(closeBuffer->getStrength());
- }
- if (closeKlickBuffer)
- {
- ret->setSKAfFarbe(closeKlickBuffer->getFarbe());
- ret->setSKAfStrength(closeKlickBuffer->getStrength());
- }
- if (vScroll)
- {
- ret->setVSBMax(vScroll->getScrollData()->max);
- ret->setVSBScroll(vScroll->getScroll());
- }
- if (hScroll)
- {
- ret->setHSBMax(hScroll->getScrollData()->max);
- ret->setHSBScroll(hScroll->getScroll());
- }
- ret->setMin(min);
- ret->setMax(max);
- ret->setKMin(kMin);
- ret->setKMax(kMax);
- return ret;
- }
|