void CObjectImageArray::PaintImageGrayed (CG16bitImage &Dest, int x, int y, int iTick, int iRotation) const // PaintImageGrayed // // Paints the image on the destination { if (m_pImage) { CG16bitImage *pSource = m_pImage->GetImage(); if (pSource == NULL) return; int xSrc = ComputeSourceX(iTick); if (m_pRotationOffset) { x += m_pRotationOffset[iRotation % m_iRotationCount].x; y -= m_pRotationOffset[iRotation % m_iRotationCount].y; } Dest.BltGray(xSrc, m_rcImage.top + (iRotation * RectHeight(m_rcImage)), RectWidth(m_rcImage), RectHeight(m_rcImage), 128, *pSource, x - (RectWidth(m_rcImage) / 2), y - (RectHeight(m_rcImage) / 2)); } }
void AlignIcons( HWND hDlg, LPALIGNOBJECTS_PARMS lpAlignParms ) /************************************************************************/ { RECT bRect, cRect; int xOffset, yOffset, i, wind; LFIXED vSpace, hSpace, fx, fy; HWND hWnd; GetClientRect( hWnd = GetDlgItem( hDlg, IDC_ALIGN_GRID ), &bRect ); vSpace = FGET( RectHeight( &bRect ) - ( ALIGN_NUM_OBJECTS * ICON_HEIGHT ), ALIGN_NUM_OBJECTS - 1 ); hSpace = FGET( RectWidth( &bRect ) - ( ALIGN_NUM_OBJECTS * ICON_WIDTH ), ALIGN_NUM_OBJECTS - 1 ); fx = fy = 0; for( i = 0, wind = GW_CHILD; i < ALIGN_NUM_OBJECTS; i++, wind = GW_HWNDNEXT ) { hWnd = GetWindow( hWnd, wind ); GetClientRect( hWnd, &cRect ); cRect.right -= 1; cRect.bottom -= 1; MapWindowPoints( hWnd, GetDlgItem( hDlg, IDC_ALIGN_GRID ), ( LPPOINT )&cRect, 2 ); ShowWindow( hWnd, SW_HIDE ); ObjAlign( &bRect, &cRect, lpAlignParms, vSpace, hSpace, &xOffset, &yOffset, &fx, &fy ); OffsetRect( &cRect, xOffset, yOffset ); MoveWindow( hWnd, cRect.left, cRect.top, RectWidth( &cRect ), RectHeight( &cRect ), TRUE ); UpdateWindow( GetDlgItem( hDlg, IDC_ALIGN_GRID ) ); ShowWindow( hWnd, SW_SHOWNA ); } }
void CObjectImageArray::CopyImage (CG16bitImage &Dest, int x, int y, int iFrame, int iRotation) const // CopyImage // // Copies entire image to the destination { if (m_pImage) { CG16bitImage *pSource = m_pImage->GetImage(); if (pSource == NULL) return; int xSrc = m_rcImage.left + (iFrame * RectWidth(m_rcImage)); int ySrc = m_rcImage.top + (iRotation * RectHeight(m_rcImage)); Dest.Blt(xSrc, ySrc, RectWidth(m_rcImage), RectHeight(m_rcImage), *pSource, x, y); Dest.CopyAlpha(xSrc, ySrc, RectWidth(m_rcImage), RectHeight(m_rcImage), *pSource, x, y); } }
void CGTextArea::Paint (CG32bitImage &Dest, const RECT &rcRect) // Paint // // Handle paint { RECT rcText = CalcTextRect(rcRect); // Paint the background if (m_iBorderRadius > 0) CGDraw::RoundedRect(Dest, rcRect.left, rcRect.top, RectWidth(rcRect), RectHeight(rcRect), m_iBorderRadius, m_rgbBackColor); else Dest.Fill(rcRect.left, rcRect.top, RectWidth(rcRect), RectHeight(rcRect), m_rgbBackColor); // Paint the editable box if (m_bEditable) { CG32bitPixel rgbBorderColor = CG32bitPixel::Blend(CG32bitPixel(0, 0, 0), m_rgbColor, (BYTE)128); CGDraw::RectOutlineDotted(Dest, rcRect.left, rcRect.top, RectWidth(rcRect), RectHeight(rcRect), rgbBorderColor); } // Paint the content if (!m_sText.IsBlank()) PaintText(Dest, rcText); else PaintRTF(Dest, rcText); }
int CGTextArea::Justify (const RECT &rcRect) // Justify // // Justify the text and return the height (in pixels) { RECT rcText = CalcTextRect(rcRect); if (!m_sText.IsBlank()) { if (m_pFont == NULL) return 0; if (m_cxJustifyWidth != RectWidth(rcText)) { m_cxJustifyWidth = RectWidth(rcText); m_Lines.DeleteAll(); m_pFont->BreakText(m_sText, m_cxJustifyWidth, &m_Lines, CG16bitFont::SmartQuotes); } return m_rcPadding.top + (m_Lines.GetCount() * m_pFont->GetHeight() + (m_Lines.GetCount() - 1) * m_cyLineSpacing) + m_rcPadding.bottom; } else if (!m_sRTF.IsBlank()) { FormatRTF(rcText); RECT rcBounds; m_RichText.GetBounds(&rcBounds); return m_rcPadding.top + RectHeight(rcBounds) + m_rcPadding.bottom; } else return 0; }
void CObjectImageArray::PaintSilhoutte (CG16bitImage &Dest, int x, int y, int iTick, int iRotation, COLORREF wColor) const // PaintSilhouette // // Paints a silhouette of the object { if (m_pImage) { CG16bitImage &Source(*m_pImage->GetImage()); int xSrc = ComputeSourceX(iTick); if (m_pRotationOffset) { x += m_pRotationOffset[iRotation % m_iRotationCount].x; y -= m_pRotationOffset[iRotation % m_iRotationCount].y; } Dest.FillMask(xSrc, m_rcImage.top + (iRotation * RectHeight(m_rcImage)), RectWidth(m_rcImage), RectHeight(m_rcImage), Source, wColor, x - (RectWidth(m_rcImage) / 2), y - (RectHeight(m_rcImage) / 2)); } }
LRESULT DockPanel_GetMinMaxInfo(DOCKPANEL *dpp, MINMAXINFO *pmmi) { if(dpp && (dpp->dwStyle & DWS_FIXED_SIZE)) { RECT rect; GetClientRect(dpp->hwndContents, &rect); AdjustRectBorders(dpp, &rect, 1); CalcFloatingRect(dpp->hwndPanel, &rect); if(dpp->dwStyle & DWS_FIXED_HORZ) { pmmi->ptMaxTrackSize.x = RectWidth(&rect); pmmi->ptMinTrackSize.x = RectWidth(&rect); } if(dpp->dwStyle & DWS_FIXED_VERT) { pmmi->ptMaxTrackSize.y = RectHeight(&rect); pmmi->ptMinTrackSize.y = RectHeight(&rect); } } return 0; }
void CObjectImageArray::PaintImageUL (CG16bitImage &Dest, int x, int y, int iTick, int iRotation, bool srcAlpha) const // PaintImageUL // // Paints the image. x,y is the upper-left corner of the destination // // Note: This should not use the rotation offsets { if (m_pImage) { CG16bitImage &Source(*m_pImage->GetImage()); int xSrc = ComputeSourceX(iTick); int ySrc; if (m_iBlending == blendLighten) { Dest.BltLighten(xSrc, m_rcImage.top + (iRotation * RectHeight(m_rcImage)), RectWidth(m_rcImage), RectHeight(m_rcImage), 255, Source, x, y); } else { ySrc = m_rcImage.top + (iRotation * RectHeight(m_rcImage)); Dest.Blt(x, y, Source, xSrc, ySrc, xSrc + RectWidth(m_rcImage), ySrc + RectHeight(m_rcImage), srcAlpha); } } }
void CAniTextInput::Create (const RECT &rcRect, const CG16bitFont *pFont, DWORD dwOptions, IAnimatron **retpAni) // Create // // Creates text with basic attributes { // Create CAniTextInput *pText = new CAniTextInput; pText->SetPropertyVector(PROP_POSITION, CVector(rcRect.left, rcRect.top)); pText->SetPropertyFont(PROP_FONT, pFont); // Make sure size is big enough to fit font if (pFont) { int cyMin = pFont->GetHeight() + PADDING_TOP + PADDING_BOTTOM; if (cyMin > RectHeight(rcRect)) pText->SetPropertyVector(PROP_SCALE, CVector(RectWidth(rcRect), cyMin)); else pText->SetPropertyVector(PROP_SCALE, CVector(RectWidth(rcRect), RectHeight(rcRect))); } // Options if (dwOptions & OPTION_PASSWORD) pText->m_bPassword = true; *retpAni = pText; }
void OverlayElementEditor::CreateEditorWindow() { m_Self = CreateDialogParam(GetWindowInstance(m_Parent), MAKEINTRESOURCE(m_ResourceId), m_Parent, s_DialogProc, (LPARAM)this); if (m_Self) { RECT parentRc; GetWindowRect(m_Parent, &parentRc); RECT rc; GetWindowRect(m_Self, &rc); // Position the editor depending on owner window position. RECT selfRect; selfRect.right = parentRc.right; selfRect.top = parentRc.top; selfRect.left = selfRect.right - RectWidth(rc); selfRect.bottom = selfRect.top + RectHeight(rc); MoveWindow(m_Self, selfRect.left, selfRect.top, RectWidth(rc), RectHeight(rc), FALSE); // Make window semi-transparent. SetWindowLong(m_Self, GWL_EXSTYLE, GetWindowLong(m_Self, GWL_EXSTYLE) | WS_EX_LAYERED); SetLayeredWindowAttributes(m_Self, RGB(0, 0, 0), 220, LWA_ALPHA); } }
int CGButtonArea::Justify (const RECT &rcRect) // Justify // // Justify the text and return the height (in pixels) { RECT rcText = CalcTextRect(rcRect); // For now, the label is always one line int cyHeight = (m_pLabelFont ? m_pLabelFont->GetHeight() : 0); // Add the height of the description, if we have one if (!m_sDesc.IsBlank() && m_pDescFont) { if (m_cxJustifyWidth != RectWidth(rcText)) { m_cxJustifyWidth = RectWidth(rcText); m_Lines.DeleteAll(); m_pDescFont->BreakText(m_sDesc, m_cxJustifyWidth, &m_Lines, CG16bitFont::SmartQuotes); } cyHeight += (m_Lines.GetCount() * m_pDescFont->GetHeight()); } // Add padding cyHeight += m_rcPadding.top + m_rcPadding.bottom; return cyHeight; }
void COptionView::Layout(bool Redraw /* = true */) { CWSFrameView::Layout(FALSE); ::MoveWindow(m_OptionView.GetHwnd(),m_rcClient.left,m_rcClient.top,RectWidth(m_rcClient),RectHeight(m_rcClient)-24,TRUE); ::MoveWindow(m_FooterBar.GetHwnd(),m_rcClient.left,m_rcClient.bottom-24,RectWidth(m_rcClient),24,TRUE); }
LRESULT CAddressBar::OnPaint(){ RECT rcViewport; GetClientRect(m_hWnd,&rcViewport); PAINTSTRUCT ps; HDC hdc = BeginPaint(m_hWnd, &ps); if(rcViewport.right==rcViewport.left || rcViewport.top==rcViewport.bottom){ ::EndPaint(m_hWnd, &ps); return 0; } HDC DCMem = ::CreateCompatibleDC(hdc); HBITMAP bmpCanvas=::CreateCompatibleBitmap(hdc, RectWidth(rcViewport),RectHeight(rcViewport)); assert(bmpCanvas); HBITMAP OldBitmap = (HBITMAP)::SelectObject(DCMem, bmpCanvas ); if(m_State & SPACE_SHOWBKG){ FillRect(DCMem,rcViewport,m_crViewBkg); } UINT OldMode = ::SetBkMode(DCMem,TRANSPARENT ); HFONT pOldFont=NULL; if (m_bConnected) { m_ConnectBnt.m_Name = _T("Break"); m_ConnectBnt.Draw(DCMem); }else{ m_ConnectBnt.m_Name = _T("Connect"); m_ConnectBnt.Draw(DCMem); } COLORREF Oldcr = ::SetTextColor(DCMem,RGB(0,0,0)); RECT rc = rcViewport; rc.left+=4; rc.right -= 100; if(rc.right<rc.left)rc.right=rc.left; ::DrawText(DCMem,m_CurAddress.c_str(),m_CurAddress.size(),&rc,DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS); if(pOldFont)::SelectObject(DCMem, pOldFont ); ::SetBkMode(DCMem, OldMode ); if(m_State & SPACE_SHOWWINBORDER){ DrawEdge(DCMem,rcViewport,m_crWinBorder);// Border } ::BitBlt(hdc, 0, 0, RectWidth(rcViewport), RectHeight(rcViewport), DCMem, 0, 0, SRCCOPY ); ::SelectObject(DCMem, OldBitmap ); ::DeleteObject(bmpCanvas); ::DeleteDC(DCMem); ::EndPaint(m_hWnd, &ps); return 0; }
void CenterWindow(HWND wnd) { RECT parent, my; GetWindowRect(GetParent(wnd), &parent); GetWindowRect(wnd, &my); MoveWindow(wnd, parent.left + (RectWidth(parent) - RectWidth(my)) / 2, parent.top + (RectHeight(parent) - RectHeight(my)) / 2, RectWidth(my), RectHeight(my), TRUE); }
RECT CalculateNonClientArea(HWND hwnd) { RECT window, client, nonclient; GetWindowRect(hwnd, &window), GetClientRect(hwnd, &client); int nonClientWidth = RectWidth(window) - RectWidth(client), nonClientHeight = RectHeight(window) - RectHeight(client); nonclient.top = nonclient.left = 0; nonclient.right = nonClientWidth; nonclient.bottom = nonClientHeight; return nonclient; }
void CLoadGameSession::CmdReadComplete (CListSaveFilesTask *pTask) // CmdReadComplete // // We've finished loading the list of games { const CVisualPalette &VI = m_HI.GetVisuals(); RECT rcRect; VI.GetWidescreenRect(m_HI.GetScreen(), &rcRect); // Done with wait animation StopPerformance(ID_CTRL_WAIT); // Check for error CString sError; if (pTask->GetResult(&sError) != NOERROR) { IAnimatron *pMsg; VI.CreateMessagePane(NULL, ID_MESSAGE, ERR_TITLE, strPatternSubst(ERR_DESC, sError), rcRect, 0, &pMsg); StartPerformance(pMsg, ID_MESSAGE, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); return; } // If we have no entries, then show a message IAnimatron *pList = pTask->GetListHandoff(); if (pList->GetPropertyInteger(PROP_COUNT) == 0) { delete pList; IAnimatron *pMsg; VI.CreateMessagePane(NULL, ID_MESSAGE, ERR_NO_ENTRIES, ERR_NO_ENTRIES_DESC, rcRect, 0, &pMsg); StartPerformance(pMsg, ID_MESSAGE, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); return; } // Show the profile RECT rcList; pList->GetSpacingRect(&rcList); pList->SetPropertyVector(PROP_POSITION, CVector(rcRect.left + (RectWidth(rcRect) - RectWidth(rcList)) / 2, rcRect.top)); pList->SetPropertyVector(PROP_SCALE, CVector(SAVE_ENTRY_WIDTH, RectHeight(rcRect))); pList->SetPropertyMetric(PROP_VIEWPORT_HEIGHT, (Metric)RectHeight(rcRect)); RegisterPerformanceEvent(pList, EVENT_ON_DOUBLE_CLICK, CMD_OK_SESSION); StartPerformance(pList, ID_LIST, CReanimator::SPR_FLAG_DELETE_WHEN_DONE); }
void CMessageSession::CreateDlgMessage (IAnimatron **retpDlg) // CreateDlgMessage // // Creates the message dialog box { const CVisualPalette &VI = m_HI.GetVisuals(); const CG16bitFont &MediumFont = VI.GetFont(fontMedium); // Figure out where the login dialog box will appear RECT rcCenter; VI.GetWidescreenRect(m_HI.GetScreen(), &rcCenter); RECT rcDlg = rcCenter; int cyDlg = 10 * VI.GetFont(fontLarge).GetHeight(); rcDlg.top = rcCenter.top + (RectHeight(rcCenter) - cyDlg) / 2; rcDlg.left = rcCenter.left + (RectWidth(rcCenter) - DLG_WIDTH) / 2; rcDlg.right = rcDlg.left + DLG_WIDTH; rcDlg.bottom = rcDlg.top + cyDlg; // Create the dialog box and a container for the controls IAnimatron *pDlg; CAniSequencer *pContainer; VI.CreateStdDialog(rcDlg, m_sTitle, &pDlg, &pContainer); int y = 0; // Add the message IAnimatron *pMessage = new CAniText; pMessage->SetPropertyVector(PROP_POSITION, CVector(0, y)); pMessage->SetPropertyVector(PROP_SCALE, CVector(RectWidth(rcDlg), RectHeight(rcDlg))); pMessage->SetPropertyColor(PROP_COLOR, VI.GetColor(colorTextDialogInput)); pMessage->SetPropertyFont(PROP_FONT, &MediumFont); pMessage->SetPropertyString(PROP_TEXT, m_sMessage); pContainer->AddTrack(pMessage, 0); // Add close button at the bottom IAnimatron *pButton; int xButtons = (RectWidth(rcDlg) - DEFAULT_BUTTON_WIDTH) / 2; int yButtons = RectHeight(rcDlg) - DEFAULT_BUTTON_HEIGHT; VI.CreateButton(pContainer, CMD_CLOSE, xButtons, yButtons, DEFAULT_BUTTON_WIDTH, DEFAULT_BUTTON_HEIGHT, CVisualPalette::OPTION_BUTTON_DEFAULT, CONSTLIT("OK"), &pButton); RegisterPerformanceEvent(pButton, EVENT_ON_CLICK, CMD_CLOSE); // Done *retpDlg = pDlg; }
STATUS_CODE ApplyColorMap(LPIMAGE lpImage, LPCOLORMAP lpColorMap, BOOL fReMap, DITHER_TYPE DitherType, ITEMID idDirty) /************************************************************************/ { UNDO_TYPE UndoType; int iMaxWidth; FRMTYPEINFO OldTypeInfo, NewTypeInfo; LPOBJECT lpObject; RECT rEdit; CFrameTypeConvert TypeConvert; UndoType = UT_COLORMAP; if (fReMap) UndoType |= UT_DATA; if (!ImgEditInit(lpImage, ET_ALLOBJECTS, UndoType, NULL)) return(SC_UNDOERROR); ProgressBegin(ImgCountObjects(lpImage), idDirty-IDS_UNDOFIRST+IDS_PROGFIRST); if (fReMap) { ImgGetTypeInfo(lpImage, &OldTypeInfo); FrameSetTypeInfo(&NewTypeInfo, FDT_PALETTECOLOR, lpColorMap); iMaxWidth = 0; lpObject = NULL; while (lpObject = ImgGetNextObject(lpImage, lpObject, YES, NO)) { if (RectWidth(&lpObject->rObject) > iMaxWidth) iMaxWidth = RectWidth(&lpObject->rObject); } if (!TypeConvert.Init(OldTypeInfo, NewTypeInfo, iMaxWidth, DitherType)) { ProgressEnd(); Message(IDS_EMEMALLOC); return(SC_MEMERROR); } } lpObject = NULL; while (lpObject = ImgGetNextObjectEx(lpImage, lpObject, YES, NO, YES)) { if (fReMap) PaletteMapPixmap(&lpObject->Pixmap, &TypeConvert); FrameSetColorMap(ObjGetEditFrame(lpObject), lpColorMap); rEdit = lpObject->rObject; ImgEditedObject(lpImage, lpObject, idDirty, &rEdit); } ImgColorMapChanged(lpImage); ProgressEnd(); return(SC_SUCCESS); }
HDWP DockWnd_DeferPanelPos(HDWP hdwp, HWND hwndMain, RECT *rect) { DOCKSERVER *dsp = GetDockServer(hwndMain); DOCKPANEL *dpp; if(dsp == 0) return 0; CopyRect(&dsp->DockRect, rect); CopyRect(&dsp->ClientRect, rect); for(dpp = dsp->PanelListHead; dpp; dpp = dpp->flink) { RECT rc = *rect; RECT rc2; if(dpp->fDocked == FALSE || dpp->fVisible == FALSE) { continue; } GetPanelClientSize(dpp, &rc2, TRUE); if(dpp->dwStyle & DWS_DOCKED_LEFT) { rc.right = rc.left + RectWidth(&rc2); } else if(dpp->dwStyle & DWS_DOCKED_RIGHT) { rc.left = rc.right - RectWidth(&rc2); } else if(dpp->dwStyle & DWS_DOCKED_TOP) { rc.bottom = rc.top + RectHeight(&rc2); } else if(dpp->dwStyle & DWS_DOCKED_BOTTOM) { rc.top = rc.bottom - RectHeight(&rc2); } SubtractRect(rect, rect, &rc); hdwp = DeferWindowPos(hdwp, dpp->hwndPanel, 0, rc.left, rc.top, rc.right-rc.left,rc.bottom-rc.top, SWP_NOACTIVATE|SWP_NOZORDER|SWP_SHOWWINDOW); } CopyRect(&dsp->ClientRect, rect); return hdwp; }
void CObjectImageArray::GenerateScaledImages (int iRotation, int cxWidth, int cyHeight) const // GenerateScaledImages // // Generate scaled images { ASSERT(iRotation >= 0 && iRotation < m_iRotationCount); // Allocate the array of images (if not already allocated) if (m_pScaledImages == NULL) m_pScaledImages = new CG16bitImage [m_iRotationCount]; // If the image for this rotation has already been initialized, then // we're done if (m_pScaledImages[iRotation].HasRGB()) return; // Otherwise we need to create the scaled image m_pScaledImages[iRotation].CreateBlank(cxWidth, cyHeight, false); // Get the extent of the source image RECT rcSrc; rcSrc.left = ComputeSourceX(0); rcSrc.top = m_rcImage.top + (iRotation * RectHeight(m_rcImage)); rcSrc.right = rcSrc.left + RectWidth(m_rcImage); rcSrc.bottom = rcSrc.top + RectHeight(m_rcImage); CG16bitImage *pSource = m_pImage->GetImage(); if (pSource == NULL) return; // Scale the image m_pScaledImages[iRotation].GaussianScaledBlt( rcSrc.left, rcSrc.top, RectWidth(rcSrc), RectHeight(rcSrc), *pSource, 0, 0, cxWidth, cyHeight); m_pScaledImages[iRotation].SetTransparentColor(0); }
void CTranscendenceWnd::ComputeScreenSize (void) // ComputeScreenSize // // Computes g_cxScreen and g_cyScreen { // By default we use the current resolution (unless in windowed mode) if (m_pTC->GetOptionBoolean(CGameSettings::windowedMode)) { RECT rcClient; ::GetClientRect(m_hWnd, &rcClient); g_cxScreen = RectWidth(rcClient); g_cyScreen = RectHeight(rcClient); } else { g_cxScreen = ::GetSystemMetrics(SM_CXSCREEN); g_cyScreen = ::GetSystemMetrics(SM_CYSCREEN); } // Switch to 1024 resolution, if requested if (m_pTC->GetOptionBoolean(CGameSettings::force1024Res)) { g_cxScreen = 1024; g_cyScreen = 768; } }
LONG CTranscendenceWnd::WMSize (int cxWidth, int cyHeight, int iSize) // WMSize // // Handle WM_SIZE { RECT rcClient; // Compute the RECT where we draw the screen (in client coordinate) ::GetClientRect(m_hWnd, &rcClient); m_rcWindowScreen.left = (RectWidth(rcClient) - g_cxScreen) / 2; m_rcWindowScreen.right = m_rcWindow.left + g_cxScreen; m_rcWindowScreen.top = (RectHeight(rcClient) - g_cyScreen) / 2; m_rcWindowScreen.bottom = m_rcWindow.top + g_cyScreen; ::IntersectRect(&m_rcWindowScreen, &m_rcWindowScreen, &rcClient); // Convert to screen coordinate m_rcWindow = m_rcWindowScreen; ::ClientToScreen(m_hWnd, (LPPOINT)&m_rcWindow); ::ClientToScreen(m_hWnd, (LPPOINT)&m_rcWindow + 1); // Repaint ::InvalidateRect(m_hWnd, NULL, TRUE); return 0; }
ALERROR CTextCrawlDisplay::Init (const RECT &rcRect, const CString &sText) // Init // // Initialize the display { m_rcRect = rcRect; m_yPos = 0; // Parse the string into multiple lines m_EpilogLines.DeleteAll(); m_pFont->BreakText(sText, RectWidth(rcRect), &m_EpilogLines); // Center the text in the region int cyHeight = m_EpilogLines.GetCount() * m_pFont->GetHeight() + 1; m_rcText.left = m_rcRect.left; m_rcText.right = m_rcRect.right; m_rcText.top = m_rcRect.top + (RectHeight(m_rcRect) - cyHeight) / 2; m_rcText.bottom = m_rcRect.bottom; return NOERROR; }
void StatusOfRectangle( /***********************************************************************/ LPRECT lpRect, LFIXED fScale) { STRING szUnit, szString1, szString2, szString3, szString4; LPSTR lpUnit; RECT rFile; int Resolution; OrderRect( lpRect, &rFile ); if ( fScale ) { Resolution = 1000; ScaleRect( &rFile, fScale ); } else if (lpImage) Resolution = FrameResolution( ImgGetBaseEditFrame(lpImage) ); if ( AstralStr( Control.Units-IDC_PREF_UNITINCHES+IDS_INCHES, &lpUnit ) ) { lstrcpy( szUnit, lpUnit ); MessageStatus( IDS_RECT_STATUS, Unit2String( FGET( RectWidth(&rFile), Resolution ), szString1 ), Unit2String( FGET( RectHeight(&rFile), Resolution ), szString2), (LPSTR)szUnit, Unit2String( FGET( rFile.left, Resolution ), szString3 ), Unit2String( FGET( rFile.top, Resolution ), szString4 ) ); } }
bool CGSelectorArea::LButtonDown (int x, int y) // LButtonDown // // Handle mouse button { int i; // All coordinates are relative to the center of the area. const RECT &rcRect = GetRect(); int xCenter = rcRect.left + (RectWidth(rcRect) / 2); int yCenter = rcRect.top + RectHeight(rcRect) / 2; // See if we've clicked on something for (i = 0; i < m_Regions.GetCount(); i++) { const SEntry &Entry = m_Regions[i]; // Convert the rect to destination coordinates RECT rcRegion; CalcRegionRect(Entry, xCenter, yCenter, &rcRegion); // If we clicked in the region, signal an action if (x >= rcRegion.left && x < rcRegion.right && y >= rcRegion.top && y < rcRegion.bottom) SignalAction(i); } return false; }
static BOOL Video_OnSetCursor(HWND hWindow, HWND hWndCursor, UINT codeHitTest, UINT msg) /***********************************************************************/ { LPVIDEO lpVideo; RECT rWindow; POINT pt; int x, y; if ( hWndCursor != hWindow ) // not in our window return( FALSE ); if ( !(lpVideo = (LPVIDEO)GetWindowLong( hWindow, GWL_DATAPTR )) ) return( FALSE ); GetCursorPos( &pt ); ScreenToClient( hWindow, &pt ); GetClientRect( hWindow, &rWindow ); x = (pt.x * 10) / RectWidth( &rWindow ); y = (pt.y * 10) / RectHeight( &rWindow ); if ( PtInHotspot( lpVideo, x, y, NO ) ) { SetCursor( LoadCursor( GetApp()->GetInstance(), MAKEINTRESOURCE(IDC_HAND_POINT_CURSOR) ) ); return( TRUE ); } return( FORWARD_WM_SETCURSOR(hWindow, hWndCursor, codeHitTest, msg, DefWindowProc) ); }
static void Video_OnLButtonDown(HWND hWindow, BOOL fDoubleClick, int x, int y, UINT keyFlags) /***********************************************************************/ { LPVIDEO lpVideo; RECT rWindow; if ( SHIFT ) return; if ( bTrack ) return; SetCapture( hWindow ); bTrack = TRUE; #ifdef _DEBUG if ( GetFocus() != hWindow ) SetFocus( hWindow ); #endif if ( !(lpVideo = (LPVIDEO)GetWindowLong( hWindow, GWL_DATAPTR )) ) return; if ( !lpVideo->lpAllShots ) // if no jump table... { FORWARD_WM_COMMAND( GetParent(hWindow), GET_WINDOW_ID(hWindow), 0, 0, SendMessage ); return; } // Process the proper event based on the "hotspot" that was clicked GetClientRect( hWindow, &rWindow ); x = (x * 10) / RectWidth( &rWindow ); y = (y * 10) / RectHeight( &rWindow ); int iEventCode = PtInHotspot( lpVideo, x, y, YES ); if ( iEventCode ) Video_ProcessEvent( hWindow, lpVideo, iEventCode ); }
////////////////// // Move all the windows. Use DeferWindowPos for speed. // void CWinMgr::SetWindowPositions(HWND hWnd) { int nWindows = CountWindows(); if (m_map && hWnd && nWindows>0) { HDWP hdwp = ::BeginDeferWindowPos(nWindows); int count=0; for (WINRECT* wrc=m_map; !wrc->IsEnd(); ++wrc) { if (wrc->IsWindow()) { assert(count < nWindows); HWND hwndChild = ::GetDlgItem(hWnd, wrc->GetID()); if (hwndChild) { const RECT& rc = wrc->GetRect(); ::DeferWindowPos(hdwp, hwndChild, NULL, // HWND insert after rc.left,rc.top,RectWidth(rc),RectHeight(rc), SWP_NOZORDER); InvalidateRect(hwndChild,NULL,TRUE); // repaint ++count; } } else { // not a window: still need to repaint background InvalidateRect(hWnd, &wrc->GetRect(), TRUE); } } ::EndDeferWindowPos(hdwp); } }
////////////////// // Position all the rects so they're as wide/high as the total and follow one // another; ie, are adjacent. This operation leaves the height (rows) and // width (columns) unaffected. For rows, set each row's width to rcTotal and // one below the other; for columns, set each column as tall as rcTotal and // each to the right of the previous. // void CWinMgr::PositionRects(WINRECT* pGroup, const RECT& rcTotal, BOOL bRow) { LONG xoryPos = bRow ? rcTotal.top : rcTotal.left; CWinGroupIterator it; for (it=pGroup; it; it.Next()) { WINRECT* wrc = it; RECT& rc = wrc->GetRect(); if (bRow) { // for ROWS: LONG height = RectHeight(rc); // height of row = total height rc.top = xoryPos; // top = running yPos rc.bottom = rc.top + height; // ... rc.left = rcTotal.left; // ... rc.right = rcTotal.right; // ... xoryPos += height; // increment yPos } else { // for COLS: LONG width = RectWidth(rc); // width = total width rc.left = xoryPos; // left = running xPos rc.right = rc.left + width; // ... rc.top = rcTotal.top; // ... rc.bottom = rcTotal.bottom; // ... xoryPos += width; // increment xPos } } }
////////////////// // Adjust the size of a single entry upwards to its desired size. // Decrement hwRemaining by amount increased. // void CWinMgr::AdjustSize(WINRECT* wrc, BOOL bRow, int& hwRemaining, HWND hWnd) { SIZEINFO szi; OnGetSizeInfo(szi, wrc, hWnd); int hw = bRow ? szi.szDesired.cy : szi.szDesired.cx; // desired ht or wid if (wrc->Type() == WRCT_REST) { // for REST type, use all remaining space RECT& rc = wrc->GetRect(); hw = hwRemaining + (bRow ? RectHeight(rc) : RectWidth(rc)); } // Now hw is the desired height or width, and the current size of the // entry is the min size. So adjust the size upwards, and decrement // hwRemaining appropriately. This is a little confusing, but necessary so // each entry gets its min size. // int hwCurrent = wrc->GetHeightOrWidth(bRow); // current size int hwExtra = hw - hwCurrent; // amount extra hwExtra = min(max(hwExtra, 0), hwRemaining); // truncate hw = hwCurrent + hwExtra; // new height-or-width wrc->SetHeightOrWidth(hw, bRow); // set... hwRemaining -= hwExtra; // and adjust remaining }