Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
5.9 KiB

  1. // =========================================================================== // UAMDLOGText.c � 1997 Microsoft Corp. All rights reserved. // =========================================================================== // Utilities for maintaining a scrolling text field in a dialog. // // =========================================================================== #include <ControlDefinitions.h> #include "UAMDLOGUtils.h" #include "UAMDLOGText.h" // --------------------------------------------------------------------------- // � UAM_AdjustText() // --------------------------------------------------------------------------- void UAM_AdjustText(ControlHandle theScrollBar) { DialogPtr dialog; TEHandle dTE; short scrollValue; char saveState; dialog = (*theScrollBar)->contrlOwner; dTE = UAM_DLOG(dialog).dialogTE; saveState = HGetState((Handle)dTE); HLock((Handle)dTE); scrollValue = GetControlValue( theScrollBar); UAM_DLOG(dialog).deltaV = Abs(UAM_DLOG(dialog).vOffset) - scrollValue; UAM_DLOG(dialog).vOffset = scrollValue; if (UAM_DLOG(dialog).deltaV) TEScroll(0, UAM_DLOG(dialog).deltaV, dTE); UAM_DLOG(dialog).deltaV = 0; HSetState((Handle)dTE, saveState); } // --------------------------------------------------------------------------- // � UAM_ScrollText() // --------------------------------------------------------------------------- pascal void UAM_ScrollText(ControlHandle theControl, short thePart) { short delta, newValue; short ctlMin, ctlMax; UInt32 tix; DialogPtr dialog; Rect r; dialog = (*theControl)->contrlOwner; r = (*(UAM_DLOG(dialog).dialogTE))->viewRect; switch(thePart) { case kControlUpButtonPart: delta = -16; break; case kControlDownButtonPart: delta = 16; break; case kControlPageUpPart: delta = Min(-(r.bottom - r.top) / 2, -1); Delay(10, &tix); break; case kControlPageDownPart: delta = Max((r.bottom - r.top) / 2, 1); Delay(10, &tix); break; default: return; break; } newValue = GetControlValue( theControl) + delta; ctlMax = GetControlMaximum( theControl); ctlMin = GetControlMinimum( theControl); if (newValue > ctlMax) newValue = ctlMax; else if (newValue < ctlMin) newValue = ctlMin; SetControlValue( theControl, newValue); UAM_AdjustText( theControl); } // --------------------------------------------------------------------------- // � UAM_SetScrollBar() // --------------------------------------------------------------------------- void UAM_SetScrollBar(ControlHandle theScrollBar) { short theHeight; DialogPtr dialog; Rect winRect; TEHandle dTE; dialog = (*theScrollBar)->contrlOwner; dTE = UAM_DLOG(dialog).dialogTE; winRect = UAM_DLOG(dialog).dialogTERect; theHeight = TEGetHeight( (*dTE)->nLines, 0, dTE); if (theHeight > (winRect.bottom - winRect.top)) SetControlMaximum( theScrollBar, (theHeight - (winRect.bottom - winRect.top))); else { SetControlValue( theScrollBar, 0); SetControlMaximum( theScrollBar, 0); } } // --------------------------------------------------------------------------- // � UAM_UpdateText() // --------------------------------------------------------------------------- void UAM_UpdateText(DialogPtr dialog) { Rect r; r = UAM_DLOG(dialog).dialogTERect; InsetRect(&r, textMargin, textMargin); TEUpdate(&r, UAM_DLOG(dialog).dialogTE); FrameRect(&UAM_DLOG(dialog).dialogTERect); } // --------------------------------------------------------------------------- // � UAM_FixText() // --------------------------------------------------------------------------- void UAM_FixText(DialogPtr dialog) { TEHandle dTE; char saveState; dTE = UAM_DLOG(dialog).dialogTE; saveState = HGetState((Handle)dTE); HLock((Handle)dTE); (*dTE)->viewRect = UAM_DLOG(dialog).dialogTERect; (*dTE)->viewRect.right = (*dTE)->viewRect.right; (*dTE)->viewRect.bottom = (*dTE)->viewRect.bottom; InsetRect( &((*dTE)->viewRect), textMargin, textMargin); (*dTE)->destRect = (*dTE)->viewRect; TECalText( dTE); HSetState((Handle)dTE, saveState); } // --