void miSetShape(WindowPtr pWin) { Bool WasViewable = (Bool)(pWin->viewable); ScreenPtr pScreen = pWin->drawable.pScreen; Bool anyMarked = FALSE; WindowPtr pLayerWin; if (WasViewable) { anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin); if (pWin->valdata) { if (HasBorder (pWin)) { RegionPtr borderVisible; borderVisible = REGION_CREATE(pScreen, NullBox, 1); REGION_SUBTRACT(pScreen, borderVisible, &pWin->borderClip, &pWin->winSize); pWin->valdata->before.borderVisible = borderVisible; } pWin->valdata->before.resized = TRUE; } } SetWinSize (pWin); SetBorderSize (pWin); ResizeChildrenWinSize(pWin, 0, 0, 0, 0); if (WasViewable) { anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL); if (anyMarked) (*pScreen->ValidateTree)(pLayerWin->parent, NullWindow, VTOther); } if (WasViewable) { if (anyMarked) (*pScreen->HandleExposures)(pLayerWin->parent); if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, NullWindow, VTOther); } if (pWin->realized) WindowsRestructured (); CheckCursorConfinement(pWin); }
void ChInfoWin::FitToChars( int char_width, int char_height ) { wxSize size; int adjust = 1; #ifdef __WXOSX__ adjust = 2; #endif #ifdef __OCPN__ANDROID__ adjust = 4; #endif size.x = GetCharWidth() * char_width; size.y = GetCharHeight() * ( char_height + adjust ); size.x = wxMin(size.x, g_Platform->getDisplaySize().x-10); SetWinSize( size ); }
void miSlideAndSizeWindow(WindowPtr pWin, int x, int y, unsigned int w, unsigned int h, WindowPtr pSib) { WindowPtr pParent; Bool WasViewable = (Bool)(pWin->viewable); unsigned short width = pWin->drawable.width, height = pWin->drawable.height; short oldx = pWin->drawable.x, oldy = pWin->drawable.y; int bw = wBorderWidth (pWin); short dw, dh; DDXPointRec oldpt; RegionPtr oldRegion = NULL; Bool anyMarked = FALSE; ScreenPtr pScreen; WindowPtr pFirstChange; WindowPtr pChild; RegionPtr gravitate[StaticGravity + 1]; unsigned g; int nx, ny; /* destination x,y */ int newx, newy; /* new inner window position */ RegionPtr pRegion = NULL; RegionPtr destClip; /* portions of destination already written */ RegionPtr oldWinClip = NULL; /* old clip list for window */ RegionPtr borderVisible = NullRegion; /* visible area of the border */ Bool shrunk = FALSE; /* shrunk in an inner dimension */ Bool moved = FALSE; /* window position changed */ WindowPtr pLayerWin; /* if this is a root window, can't be resized */ if (!(pParent = pWin->parent)) return ; pScreen = pWin->drawable.pScreen; newx = pParent->drawable.x + x + bw; newy = pParent->drawable.y + y + bw; if (WasViewable) { anyMarked = FALSE; /* * save the visible region of the window */ oldRegion = REGION_CREATE(pScreen, NullBox, 1); REGION_COPY(pScreen, oldRegion, &pWin->winSize); /* * categorize child windows into regions to be moved */ for (g = 0; g <= StaticGravity; g++) gravitate[g] = (RegionPtr) NULL; for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) { g = pChild->winGravity; if (g != UnmapGravity) { if (!gravitate[g]) gravitate[g] = REGION_CREATE(pScreen, NullBox, 1); REGION_UNION(pScreen, gravitate[g], gravitate[g], &pChild->borderClip); } else { UnmapWindow(pChild, TRUE); anyMarked = TRUE; } } anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin); oldWinClip = NULL; if (pWin->bitGravity != ForgetGravity) { oldWinClip = REGION_CREATE(pScreen, NullBox, 1); REGION_COPY(pScreen, oldWinClip, &pWin->clipList); } /* * if the window is changing size, borderExposed * can't be computed correctly without some help. */ if (pWin->drawable.height > h || pWin->drawable.width > w) shrunk = TRUE; if (newx != oldx || newy != oldy) moved = TRUE; if ((pWin->drawable.height != h || pWin->drawable.width != w) && HasBorder (pWin)) { borderVisible = REGION_CREATE(pScreen, NullBox, 1); /* for tiled borders, we punt and draw the whole thing */ if (pWin->borderIsPixel || !moved) { if (shrunk || moved) REGION_SUBTRACT(pScreen, borderVisible, &pWin->borderClip, &pWin->winSize); else REGION_COPY(pScreen, borderVisible, &pWin->borderClip); } } } pWin->origin.x = x + bw; pWin->origin.y = y + bw; pWin->drawable.height = h; pWin->drawable.width = w; x = pWin->drawable.x = newx; y = pWin->drawable.y = newy; SetWinSize (pWin); SetBorderSize (pWin); dw = (int)w - (int)width; dh = (int)h - (int)height; ResizeChildrenWinSize(pWin, x - oldx, y - oldy, dw, dh); /* let the hardware adjust background and border pixmaps, if any */ (*pScreen->PositionWindow)(pWin, x, y); pFirstChange = MoveWindowInStack(pWin, pSib); if (WasViewable) { pRegion = REGION_CREATE(pScreen, NullBox, 1); if (pLayerWin == pWin) anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange, NULL); else anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pLayerWin, NULL); if (pWin->valdata) { pWin->valdata->before.resized = TRUE; pWin->valdata->before.borderVisible = borderVisible; } if (anyMarked) (*pScreen->ValidateTree)(pLayerWin->parent, pFirstChange, VTOther); /* * the entire window is trashed unless bitGravity * recovers portions of it */ REGION_COPY(pScreen, &pWin->valdata->after.exposed, &pWin->clipList); } GravityTranslate (x, y, oldx, oldy, dw, dh, pWin->bitGravity, &nx, &ny); if (WasViewable) { /* avoid the border */ if (HasBorder (pWin)) { int offx, offy, dx, dy; /* kruft to avoid double translates for each gravity */ offx = 0; offy = 0; for (g = 0; g <= StaticGravity; g++) { if (!gravitate[g]) continue; /* align winSize to gravitate[g]. * winSize is in new coordinates, * gravitate[g] is still in old coordinates */ GravityTranslate (x, y, oldx, oldy, dw, dh, g, &nx, &ny); dx = (oldx - nx) - offx; dy = (oldy - ny) - offy; if (dx || dy) { REGION_TRANSLATE(pScreen, &pWin->winSize, dx, dy); offx += dx; offy += dy; } REGION_INTERSECT(pScreen, gravitate[g], gravitate[g], &pWin->winSize); } /* get winSize back where it belongs */ if (offx || offy) REGION_TRANSLATE(pScreen, &pWin->winSize, -offx, -offy); } /* * add screen bits to the appropriate bucket */ if (oldWinClip) { /* * clip to new clipList */ REGION_COPY(pScreen, pRegion, oldWinClip); REGION_TRANSLATE(pScreen, pRegion, nx - oldx, ny - oldy); REGION_INTERSECT(pScreen, oldWinClip, pRegion, &pWin->clipList); /* * don't step on any gravity bits which will be copied after this * region. Note -- this assumes that the regions will be copied * in gravity order. */ for (g = pWin->bitGravity + 1; g <= StaticGravity; g++) { if (gravitate[g]) REGION_SUBTRACT(pScreen, oldWinClip, oldWinClip, gravitate[g]); } REGION_TRANSLATE(pScreen, oldWinClip, oldx - nx, oldy - ny); g = pWin->bitGravity; if (!gravitate[g]) gravitate[g] = oldWinClip; else { REGION_UNION(pScreen, gravitate[g], gravitate[g], oldWinClip); REGION_DESTROY(pScreen, oldWinClip); } } /* * move the bits on the screen */ destClip = NULL; for (g = 0; g <= StaticGravity; g++) { if (!gravitate[g]) continue; GravityTranslate (x, y, oldx, oldy, dw, dh, g, &nx, &ny); oldpt.x = oldx + (x - nx); oldpt.y = oldy + (y - ny); /* Note that gravitate[g] is *translated* by CopyWindow */ /* only copy the remaining useful bits */ REGION_INTERSECT(pScreen, gravitate[g], gravitate[g], oldRegion); /* clip to not overwrite already copied areas */ if (destClip) { REGION_TRANSLATE(pScreen, destClip, oldpt.x - x, oldpt.y - y); REGION_SUBTRACT(pScreen, gravitate[g], gravitate[g], destClip); REGION_TRANSLATE(pScreen, destClip, x - oldpt.x, y - oldpt.y); } /* and move those bits */ if (oldpt.x != x || oldpt.y != y #ifdef COMPOSITE || pWin->redirectDraw #endif ) { (*pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, gravitate[g]); } /* remove any overwritten bits from the remaining useful bits */ REGION_SUBTRACT(pScreen, oldRegion, oldRegion, gravitate[g]); /* * recompute exposed regions of child windows */ for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) { if (pChild->winGravity != g) continue; REGION_INTERSECT(pScreen, pRegion, &pChild->borderClip, gravitate[g]); TraverseTree (pChild, miRecomputeExposures, (pointer)pRegion); } /* * remove the successfully copied regions of the * window from its exposed region */ if (g == pWin->bitGravity) REGION_SUBTRACT(pScreen, &pWin->valdata->after.exposed, &pWin->valdata->after.exposed, gravitate[g]); if (!destClip) destClip = gravitate[g]; else { REGION_UNION(pScreen, destClip, destClip, gravitate[g]); REGION_DESTROY(pScreen, gravitate[g]); } } REGION_DESTROY(pScreen, oldRegion); REGION_DESTROY(pScreen, pRegion); if (destClip) REGION_DESTROY(pScreen, destClip); if (anyMarked) (*pScreen->HandleExposures)(pLayerWin->parent); if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstChange, VTOther); } if (pWin->realized) WindowsRestructured (); }
void miMoveWindow(WindowPtr pWin, int x, int y, WindowPtr pNextSib, VTKind kind) { WindowPtr pParent; Bool WasViewable = (Bool)(pWin->viewable); short bw; RegionPtr oldRegion = NULL; DDXPointRec oldpt; Bool anyMarked = FALSE; ScreenPtr pScreen; WindowPtr windowToValidate; WindowPtr pLayerWin; /* if this is a root window, can't be moved */ if (!(pParent = pWin->parent)) return ; pScreen = pWin->drawable.pScreen; bw = wBorderWidth (pWin); oldpt.x = pWin->drawable.x; oldpt.y = pWin->drawable.y; if (WasViewable) { oldRegion = REGION_CREATE(pScreen, NullBox, 1); REGION_COPY(pScreen, oldRegion, &pWin->borderClip); anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin); } pWin->origin.x = x + (int)bw; pWin->origin.y = y + (int)bw; x = pWin->drawable.x = pParent->drawable.x + x + (int)bw; y = pWin->drawable.y = pParent->drawable.y + y + (int)bw; SetWinSize (pWin); SetBorderSize (pWin); (*pScreen->PositionWindow)(pWin, x, y); windowToValidate = MoveWindowInStack(pWin, pNextSib); ResizeChildrenWinSize(pWin, x - oldpt.x, y - oldpt.y, 0, 0); if (WasViewable) { if (pLayerWin == pWin) anyMarked |= (*pScreen->MarkOverlappedWindows) (pWin, windowToValidate, NULL); else anyMarked |= (*pScreen->MarkOverlappedWindows) (pWin, pLayerWin, NULL); if (anyMarked) { (*pScreen->ValidateTree)(pLayerWin->parent, NullWindow, kind); (* pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, oldRegion); REGION_DESTROY(pScreen, oldRegion); /* XXX need to retile border if ParentRelative origin */ (*pScreen->HandleExposures)(pLayerWin->parent); } if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, NullWindow, kind); } if (pWin->realized) WindowsRestructured (); }
Bool miMarkOverlappedWindows(WindowPtr pWin, WindowPtr pFirst, WindowPtr *ppLayerWin) { BoxPtr box; WindowPtr pChild, pLast; Bool anyMarked = FALSE; MarkWindowProcPtr MarkWindow = pWin->drawable.pScreen->MarkWindow; ScreenPtr pScreen; pScreen = pWin->drawable.pScreen; /* single layered systems are easy */ if (ppLayerWin) *ppLayerWin = pWin; if (pWin == pFirst) { /* Blindly mark pWin and all of its inferiors. This is a slight * overkill if there are mapped windows that outside pWin's border, * but it's better than wasting time on RectIn checks. */ pChild = pWin; while (1) { if (pChild->viewable) { if (REGION_BROKEN (pScreen, &pChild->winSize)) SetWinSize (pChild); if (REGION_BROKEN (pScreen, &pChild->borderSize)) SetBorderSize (pChild); (* MarkWindow)(pChild); if (pChild->firstChild) { pChild = pChild->firstChild; continue; } } while (!pChild->nextSib && (pChild != pWin)) pChild = pChild->parent; if (pChild == pWin) break; pChild = pChild->nextSib; } anyMarked = TRUE; pFirst = pFirst->nextSib; } if ( (pChild = pFirst) ) { box = REGION_EXTENTS(pChild->drawable.pScreen, &pWin->borderSize); pLast = pChild->parent->lastChild; while (1) { if (pChild->viewable) { if (REGION_BROKEN (pScreen, &pChild->winSize)) SetWinSize (pChild); if (REGION_BROKEN (pScreen, &pChild->borderSize)) SetBorderSize (pChild); if (RECT_IN_REGION(pScreen, &pChild->borderSize, box)) { (* MarkWindow)(pChild); anyMarked = TRUE; if (pChild->firstChild) { pChild = pChild->firstChild; continue; } } } while (!pChild->nextSib && (pChild != pLast)) pChild = pChild->parent; if (pChild == pLast) break; pChild = pChild->nextSib; } } if (anyMarked) (* MarkWindow)(pWin->parent); return anyMarked; }
/* * RootlessMarkOverlappedWindows * MarkOverlappedWindows is modified to ignore overlapping * top-level windows. */ static Bool RootlessMarkOverlappedWindows(WindowPtr pWin, WindowPtr pFirst, WindowPtr *ppLayerWin) { RegionRec saveRoot; Bool result; ScreenPtr pScreen = pWin->drawable.pScreen; SCREEN_UNWRAP(pScreen, MarkOverlappedWindows); RL_DEBUG_MSG("MARKOVERLAPPEDWINDOWS start "); HUGE_ROOT(pWin); if (IsRoot(pWin)) { // root - mark nothing RL_DEBUG_MSG("is root not marking "); result = FALSE; } else if (! IsTopLevel(pWin)) { // not top-level window - mark normally result = pScreen->MarkOverlappedWindows(pWin, pFirst, ppLayerWin); } else { //top-level window - mark children ONLY - NO overlaps with sibs (?) // This code copied from miMarkOverlappedWindows() register WindowPtr pChild; Bool anyMarked = FALSE; MarkWindowProcPtr MarkWindow = pScreen->MarkWindow; RL_DEBUG_MSG("is top level! "); /* single layered systems are easy */ if (ppLayerWin) *ppLayerWin = pWin; if (pWin == pFirst) { /* Blindly mark pWin and all of its inferiors. This is a slight * overkill if there are mapped windows that outside pWin's border, * but it's better than wasting time on RectIn checks. */ pChild = pWin; while (1) { if (pChild->viewable) { if (RegionBroken(&pChild->winSize)) SetWinSize (pChild); if (RegionBroken(&pChild->borderSize)) SetBorderSize (pChild); (* MarkWindow)(pChild); if (pChild->firstChild) { pChild = pChild->firstChild; continue; } } while (!pChild->nextSib && (pChild != pWin)) pChild = pChild->parent; if (pChild == pWin) break; pChild = pChild->nextSib; } anyMarked = TRUE; pFirst = pFirst->nextSib; } if (anyMarked) (* MarkWindow)(pWin->parent); result = anyMarked; } NORMAL_ROOT(pWin); SCREEN_WRAP(pScreen, MarkOverlappedWindows); RL_DEBUG_MSG("MARKOVERLAPPEDWINDOWS end\n"); return result; }
LRESULT CALLBACK FileViewProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HWND hDlg = hWnd; long i=0; short win=0; while( i < NUMFILES ){ if ( hViewWindows[i] == hWnd ){ win = (short)i; break; } i++; } i = 0; //filename = fileview_name[win]; // OutDebugs( "Window %d, filename %s", win, filename ); switch (message) { case WM_PAINT:{ HDC hdc; PAINTSTRUCT ps; RECT rc; GetClientRect(hDlg, &rc); hdc = BeginPaint(hDlg, &ps); FillRect( hdc, &rc, GetSysColorBrush(COLOR_3DFACE) ); EndPaint(hDlg, &ps); UpdateWindow( GetDlgItem(hWnd, IDC_VIEWSCROLL) ); } SetText( IDC_FILEVIEWNAME, fileview_name[win] ); break; case WM_INITDIALOG: lineTooLongMsgLen = mystrlen( lineTooLongMsg ); if ( initWindowIndex >= 0 ){ hViewWindows[ initWindowIndex ] = hWnd; initWindowIndex = -1; } hMenu[win] = LoadMenu( hInst, "FILEVIEW_MENU" ); SetTimer (hWnd, FILEVIEW_TIMER, 300, NULL); // OutDebugs( "Init Dialog: Window %d, filename %s", win, fileview_name[win] ); SetText( IDC_FILEVIEWNAME, fileview_name[win] ); EnableScrollBar( GetDlgItem(hWnd, IDC_VIEWSCROLL), SB_CTL,ESB_ENABLE_BOTH ); OutDebug( fileview_name[win] ); InitWindowStats( &winStats[win] ); SetScale( fileview_name[win], 0, win, hDlg ); SetScrollRange( GetDlgItem(hWnd, IDC_VIEWSCROLL), SB_CTL, 0, winStats[win].scrollScale, 1 ); ShowScrollBar( GetDlgItem(hWnd, IDC_VIEWSCROLL), SB_CTL, 1 ); ListView_SetExtendedListViewStyleEx( GetDlgItem(hWnd, IDC_FILEVIEW), LVS_EX_FULLROWSELECT , LVS_EX_FULLROWSELECT ); { long numlines, pos = winStats[win].scrollScale+1; numlines = GetLinestoFit( hWnd, win ); winStats[win].linesInWin = numlines; i = 0; while( i < numlines-1 ){ i += UpdateFileView( hDlg, win, pos-- ); if ( pos < 0 ) break; } SetScrollPos( GetDlgItem(hDlg, IDC_VIEWSCROLL), SB_CTL, pos, 1 ); } SetFocus( GetDlgItem(hDlg, IDC_FILEVIEW) ); break; case WM_TIMER: if (wParam == FILEVIEW_TIMER ){ char title[350]; /* long x = GetScrollPos( GetDlgItem(hWnd, IDC_VIEWSCROLL), SB_CTL ); long startPos, endPos; startPos = (long)((winStats[win].fileLen/(double)winStats[win].averageLineLen) * (x/(double)winStats[win].scrollScale)); endPos = startPos + winStats[win].linesInWin; sprintf( title, "Viewing - %s (at approx. lines %d - %d)", fileview_name[win], startPos, endPos );*/ sprintf( title, "View - %s", fileview_name[win] ); SetWindowText( hWnd, title ); CheckFileViewStatus( hWnd, win ); } break; case WM_RBUTTONDOWN: // RightClick in windows client area... { POINT pnt; pnt.x = LOWORD(lParam); pnt.y = HIWORD(lParam); ClientToScreen(hWnd, (LPPOINT) &pnt); // This is where you would determine the appropriate 'context' // menu to bring up. Since this app has no real functionality, // we will just bring up the 'Help' menu: //hMenu = GetSubMenu (GetMenu (hWnd), 0); if (hMenu[win]) { TrackPopupMenu (GetSubMenu (hMenu[win], 0), 0, pnt.x, pnt.y, 0, hWnd, NULL); } } break; case WM_CLOSE: if ( hMenu[win] ) DestroyMenu( hMenu[win] ); hViewWindows[win] = 0; EndDialog(hWnd, TRUE); return (TRUE); break; case WM_DESTROY: KillTimer (hWnd, FILEVIEW_TIMER); break; case WM_NOTIFY: switch( wParam ) { case IDC_FILEVIEW: return FileViewNotifyHandler(hWnd, message, wParam, lParam, win ); } break; case WM_VSCROLL: { long x; long nScrollCode = (int) LOWORD(wParam); // scroll bar value long nPos = (short int) HIWORD(wParam); // scroll box position HWND hwndScrollBar = (HWND) lParam; // handle to scroll bar x = GetScrollPos( GetDlgItem(hWnd, IDC_VIEWSCROLL), SB_CTL ); //OutDebugs( "nPos: %d, x: %d, linesInWin: %d, scale: %d", nPos, x, winStats[win].linesInWin, winStats[win].scrollScale ); switch( nScrollCode ){ case SB_LINEDOWN: nPos = x+1; break; case SB_PAGEDOWN: nPos = x+winStats[win].linesInWin/2; break; case SB_LINEUP: nPos = x-1; break; case SB_PAGEUP: nPos = x-winStats[win].linesInWin/2; break; case SB_ENDSCROLL: return 1; } //SetScale( filename, 0, win, hDlg ); if( nPos > winStats[win].scrollScale ) nPos = winStats[win].scrollScale; if( nPos < 0 ) nPos = 0; //OutDebugs( "pos=%d", nPos ); UpdateFileView( hWnd, win,nPos ); //if ( nScrollCode == SB_THUMBTRACK ) SetScrollPos( GetDlgItem(hWnd, IDC_VIEWSCROLL), SB_CTL, nPos, 1 ); return 0; } break; case WM_SIZE: SetWinSize( hWnd, LOWORD(lParam)-40, HIWORD(lParam)-37 ); { long nPos = GetScrollPos( GetDlgItem(hWnd, IDC_VIEWSCROLL), SB_CTL ); UpdateFileView( hWnd, win, nPos ); } break; case WM_SIZING: { RECT *lprc = (LPRECT) lParam; long w,h, x,y; w = lprc->right - lprc->left; h = lprc->bottom - lprc->top; x = lprc->left; y = lprc->top; w = w -48; h = h -64; SetWinSize( hWnd, w, h ); } break; case WM_COPY: EditCopy(hWnd); break; case WM_COMMAND: switch (LOWORD(wParam) ) { case IDM_FM_COPY: EditCopy(hWnd); break; } break; //default: // return (DefWindowProc(hWnd, message, wParam, lParam)); } return FALSE; }