void pawsScrollBar::SetThumbLayout() { int scrollBarSize = GetScrollBarSize(); if(!thumb) return; thumb->SetSize(scrollBarSize-2*THUMB_MARGIN, scrollBarSize-2*THUMB_MARGIN); if(maxValue == 0) { if(horizontal) thumb->MoveTo(screenFrame.xmin+scrollBarSize, screenFrame.ymin+THUMB_MARGIN); else thumb->MoveTo(screenFrame.xmin+THUMB_MARGIN, screenFrame.ymin+scrollBarSize); } else { if(horizontal) thumb->MoveTo(screenFrame.xmin+scrollBarSize + int((currentValue-minValue)/(maxValue-minValue)*GetThumbScaleLength()), screenFrame.ymin+THUMB_MARGIN); else { thumb->MoveTo(screenFrame.xmin+THUMB_MARGIN, screenFrame.ymin+scrollBarSize + int((currentValue-minValue)/(maxValue-minValue)*GetThumbScaleLength())); } } }
void GetChipSize( LPINT lpDx, LPINT lpDy ) /***********************************************************************/ { GetScrollBarSize(lpDx, lpDy); *lpDx += 1; *lpDy += 1; }
int pawsScrollBar::GetThumbScaleLength() { int scrollBarSize = GetScrollBarSize(); if(horizontal) return screenFrame.Width() - 3*scrollBarSize + 2*THUMB_MARGIN; else return screenFrame.Height() - 3*scrollBarSize + 2*THUMB_MARGIN; }
static void GetDispRect( HWND hWnd, LPRECT lpRect, int iHorzMode, int iVertMode ) /************************************************************************/ // int iHorzMode; /* 0 = GetClientRect 1 = No Scrollbars 2 = With Scrollbars */ // int iVertMode; /* 0 = GetClientRect 1 = No Scrollbars 2 = With Scrollbars */ { RECT rHorz, rVert; int cy, cx; LPDISPLAY lpDisplay; GetScrollBarSize(&cx, &cy); if (iHorzMode == 2) // with horizontal scrollbar { GetRealClientRect(hWnd, &rHorz); rHorz.bottom -= cy; } else if (iHorzMode == 1) // without horizontal scrollbar { GetRealClientRect(hWnd, &rHorz); } else { // actual client size GetClientRect(hWnd, &rHorz); } if (iVertMode == 2) // with vertical scrollbar { GetRealClientRect(hWnd, &rVert); rVert.right -= cx; } else if (iVertMode == 1) // without horizontal scrollbar { GetRealClientRect(hWnd, &rVert); } else // actual client size { GetClientRect(hWnd, &rVert); } lpRect->top = rHorz.top; lpRect->bottom = rHorz.bottom; lpRect->left = rVert.left; lpRect->right = rVert.right; lpDisplay = GetDisplayPtr(hWnd); if (lpDisplay->HasRulers && !IsIconic(hWnd)) { lpRect->top += GetRulerSize(); lpRect->left += GetRulerSize(); } // adjust because our rects include right and bottom lpRect->bottom -= 1; lpRect->right -= 1; }
void pawsScrollBar::SetThumbVisibility() { if(thumb != NULL) { if(GetScrollBarSize()*0.1 < GetThumbScaleLength()) thumb->Show(); else thumb->Hide(); } }
void pawsScrollBar::SetButtonLayout() { int scrollBarSize = GetScrollBarSize(); if(upWidth == 0) upWidth = scrollBarSize; if(upHeight == 0) upHeight = scrollBarSize; if(downWidth == 0) downWidth = scrollBarSize; if(downHeight == 0) downHeight = scrollBarSize; if(upButton) upButton->SetRelativeFrame(upOffsetx, upOffsety, upWidth, upHeight); if(downButton) downButton->SetRelativeFrame(defaultFrame.Width()-downWidth-downOffsetx, defaultFrame.Height()-downHeight-downOffsety, downWidth, downHeight); }
void pawsScrollBar::MoveThumbToMouse() { psPoint mousePos; int relMouseCoord, // coordinate of mouse cursor relative to the rectangle that constraints thumb movement rectBegin, // coordinate of the constraint rectangle rectSize, // size of the constraint rectangle thumbPos; // coordinate of thumb relative to the constraint rectangle int scrollBarSize = GetScrollBarSize(); mousePos = PawsManager::GetSingleton().GetMouse()->GetPosition(); if(horizontal) { rectBegin = screenFrame.xmin + scrollBarSize; relMouseCoord = mousePos.x - rectBegin; } else { rectBegin = screenFrame.ymin + scrollBarSize; relMouseCoord = mousePos.y - rectBegin; } rectSize = GetThumbScaleLength(); if(mouseIsDraggingThumb) thumbPos = relMouseCoord - thumbDragPoint; else thumbPos = relMouseCoord - (scrollBarSize - 2*THUMB_MARGIN) / 2; thumbPos = csMax(thumbPos, 0); thumbPos = csMin(thumbPos, rectSize); if(horizontal) thumb->MoveTo(rectBegin+thumbPos, thumb->GetScreenFrame().ymin); else thumb->MoveTo(thumb->GetScreenFrame().xmin, rectBegin+thumbPos); currentValue = minValue + (float(thumbPos) / rectSize * (maxValue-minValue)); if(limited) LimitCurrentValue(); if(parent != NULL) parent->OnScroll(SCROLL_THUMB, this); }
void CalcFullViewWindowSize( LPRECT lpWindowRect, LPRECT lpFileRect, LFIXED FileRate, int npix, int nlin, int x, int y, BOOL fHasRulers, BOOL fClipToImage ) /************************************************************************/ { int dx, dy, sx, sy, rs, iImageWidth, iImageHeight, iWidth, iHeight; LFIXED DispRate; int minsize; // normal window - to goal is to size the window to fit the view // If FileRate == 0 or 1, then we make the window as big as possible // for the FileRect provided. If FileRate != 0, then we make the // the window as big as possible to fit the image at that FileRate. // If the fClipToImage flag and FileRate == 0, then we do not let // the FileRate go over 100%. This is used for a caller who wants // to display the image pixel for pixel, if possible. if (x < 0 || y < 0) GetDocumentPosition(&x, &y); dx = 2 * GetSystemMetrics(SM_CXFRAME); dy = GetSystemMetrics(SM_CYCAPTION) + (2*GetSystemMetrics(SM_CYFRAME)) - 1; // get size of scrollbars and rulers for use later GetScrollBarSize(&sx, &sy); rs = GetRulerSize(); // determine maximum area for window to occupy if (IsIconic(PictPubApp.Get_hWndAstral())) *lpWindowRect = rClient; else GetClientRect(PictPubApp.Get_hClientAstral(), lpWindowRect); lpWindowRect->top = y; lpWindowRect->left = x; lpWindowRect->right -= dx; lpWindowRect->bottom -= (dy + GetSystemMetrics(SM_CYFRAME)); // start with this maximum Client Area size minsize = MIN_WINDOW_SIZE+rs; iWidth = RectWidth(lpWindowRect); if ( iWidth < minsize ) iWidth = minsize; iHeight = RectHeight(lpWindowRect); if ( iHeight < minsize ) iHeight = minsize; // If we already have a FileRate, calculate new size of window // based on the image size if (FileRate > TINYRATE) { // calculate size of area for total image at this // FileRate DispRate = FGET(FUNITY, FileRate); iImageWidth = FMUL(npix, DispRate); iImageHeight = FMUL(nlin, DispRate); // add in additional space for rulers if necessary if (fHasRulers) { iImageWidth += rs; iImageHeight += rs; } if (iImageWidth > iWidth && iImageHeight < iHeight) iImageHeight += sy; if (iImageHeight > iHeight && iImageWidth < iWidth) iImageWidth += sx; // see if we don't need the total width // otherwise, use the maximum if (iImageWidth < iWidth) iWidth = iImageWidth; // see if we don't need the total height // otherwise, use the maximum if (iImageHeight < iHeight) iHeight = iImageHeight; } // if we have no FileRate, then somebody wants a specific // FileRect, figure out how big the window needs to be and // whether we need rulers else { // get width and height of area to be displayed iImageWidth = RectWidth(lpFileRect); iImageHeight = RectHeight(lpFileRect); // reduce the maximum area if we have rulers if (fHasRulers) { iWidth -= rs; iHeight -= rs; } // reduce the maximum area if we need scrollbars if (lpFileRect->left != 0 || lpFileRect->right != npix-1 || lpFileRect->top != 0 || lpFileRect->bottom != nlin-1) { iWidth -= sx; iHeight -= sy; } // scale maximum client area size (not including rulers and // scrollbars) to fit aspect ratio of FileRect DispRate = ScaleToFit(&iWidth, &iHeight, iImageWidth, iImageHeight); // if caller wants to clip to hires to achieve 100% view, // clip. But only if hires is smaller if (iImageWidth <= iWidth && iImageHeight <= iHeight && fClipToImage) { iWidth = iImageWidth; iHeight = iImageHeight; } // add ruler size back into client area if (fHasRulers) { iWidth += rs; iHeight += rs; } // add scrollbar size back into client area if (lpFileRect->left != 0 || lpFileRect->right != npix-1 || lpFileRect->top != 0 || lpFileRect->bottom != nlin-1) { iWidth += sx; iHeight += sy; } } // Calculate new window size based on iWidth and iHeight */ lpWindowRect->right = lpWindowRect->left + iWidth + dx - 1; lpWindowRect->bottom = lpWindowRect->top + iHeight + dy - 1; }