CScrollerThumb Class Reference

This OIL class represents a scroll bar "thumb", which sends drag messages to its parent CScroller object. More...

#include <scrlthmb.h>

List of all members.

Public Member Functions

 CScrollerThumb ()
 Constructs a CScrollerThumb C++ object. Sets an internal variable to indicate that the thumb is currently NOT in dragging mode.
virtual ~CScrollerThumb ()
 Destructor for class CScrollerThumb. Doesn't precisely nothing.
virtual BOOL Create (LPCTSTR, LPCTSTR, DWORD style, const RECT &rect, CWnd *parent, UINT32 id, CCreateContext *ctxt=0)

Protected Member Functions

afx_msg void OnPaint ()
 Responds to a WM_PAINT message sent by Windows. Paints the light and dark shading around the edge of the thumb, so it looks like the genuine Windows article.
afx_msg void OnLButtonDown (UINT32 nFlags, CPoint point)
 Captures the mouse and sends a WM_GRABTHUMB message to the parent CScroller.
afx_msg void OnRButtonDown (UINT32 nFlags, CPoint point)
 Captures the mouse and sends a WM_GRABTHUMBADJ message to the parent CScroller.
afx_msg void OnMouseMove (UINT32 nFlags, CPoint point)
 Sends a WM_DRAGTHUMB message to the parent CScroller.
afx_msg void OnLButtonUp (UINT32 nFlags, CPoint point)
 Releases the captured mouse and sends a WM_RELEASETHUMB message to the parent CScroller.
afx_msg void OnRButtonUp (UINT32 nFlags, CPoint point)
 Releases the captured mouse and sends a WM_RELEASETHUMB message to the parent CScroller.

Private Member Functions

void PostMsgToScroller (UINT32 msg, CPoint pt) const
 Posts a private message to the parent CScroller window. Converts the coordinates passed in so that they are relative to the CScroller's client area.
void OnWin95Paint ()
 Responds to a WM_PAINT message sent by Windows. Paints the light and dark shading around the edge of the thumb, so it looks like the genuine Windows 95 article.

Private Attributes

BOOL Dragging
BOOL DragIsAdjust


Detailed Description

This OIL class represents a scroll bar "thumb", which sends drag messages to its parent CScroller object.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
ages ago

Definition at line 120 of file scrlthmb.h.


Constructor & Destructor Documentation

CScrollerThumb::CScrollerThumb  ) 
 

Constructs a CScrollerThumb C++ object. Sets an internal variable to indicate that the thumb is currently NOT in dragging mode.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
ages ago
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: - Scope: Public

See also:
CScrollerThumb::Create(); CScroller::ConstructThumb()

Definition at line 170 of file scrlthmb.cpp.

00170                                : Dragging(FALSE)
00171 {
00172     // Nothing to do.
00173 }

CScrollerThumb::~CScrollerThumb  )  [virtual]
 

Destructor for class CScrollerThumb. Doesn't precisely nothing.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/11/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 193 of file scrlthmb.cpp.

00194 {
00195     // Nothing to do.
00196     // if (Dragging) ::ReleaseCapture();
00197 }


Member Function Documentation

BOOL CScrollerThumb::Create LPCTSTR  ,
LPCTSTR  ,
DWORD  style,
const RECT rect,
CWnd *  parent,
UINT32  id,
CCreateContext *  ctxt = 0
[virtual]
 

Definition at line 219 of file scrlthmb.cpp.

00221 {
00222     return CWnd::Create(AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW | CS_BYTEALIGNCLIENT,
00223                                             Cursor::Arrow->Handle(),
00224                                             0,
00225                                             0),
00226                         "",
00227                         style | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS,
00228                         rect,
00229                         parent,
00230                         id,
00231                         ctxt);
00232 }

void CScrollerThumb::OnLButtonDown UINT32  nFlags,
CPoint  point
[protected]
 

Captures the mouse and sends a WM_GRABTHUMB message to the parent CScroller.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
ages ago
Parameters:
Some flags detailing which buttons and keys were down when the mouse message [INPUTS] was generated; the coordinates of the mouse cursor.
- [OUTPUTS]
Returns:
-

Errors: - Scope: Protected

See also:
CScrollerThumb::PostMsgToScroller(); CScroller::OnGrabThumb(); CScrollerThumb::OnMouseMove(); CScrollerThumb::OnLButtonUp()

Definition at line 410 of file scrlthmb.cpp.

00411 {
00412     CWnd::OnLButtonDown(nFlags, point);
00413     if (!Dragging)
00414     {
00415         Dragging = TRUE;
00416         DragIsAdjust = FALSE;
00417         SetCapture();
00418         PostMsgToScroller(WM_GRABTHUMB, point);
00419     }
00420 }

void CScrollerThumb::OnLButtonUp UINT32  nFlags,
CPoint  point
[protected]
 

Releases the captured mouse and sends a WM_RELEASETHUMB message to the parent CScroller.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
ages ago
Parameters:
Some flags detailing which buttons and keys were down when the mouse message [INPUTS] was generated; the coordinates of the mouse cursor.
- [OUTPUTS]
Returns:
-

Errors: - Scope: Protected

See also:
CScrollerThumb::PostMsgToScroller(); CScroller::OnDragThumb(); CScrollerThumb::OnLButtonDown(); CScrollerThumb::OnMouseMove()

Definition at line 505 of file scrlthmb.cpp.

00506 {
00507     CWnd::OnLButtonUp(nFlags, point);
00508     if (Dragging)
00509     {
00510         Dragging = FALSE;
00511         ::ReleaseCapture();
00512         PostMsgToScroller((DragIsAdjust) ? WM_RELEASETHUMBADJ : WM_RELEASETHUMB, point);
00513     }
00514     // tell people the screen has changed
00515     BROADCAST_TO_ALL(ScreenChangeMsg(TRUE));
00516 }

void CScrollerThumb::OnMouseMove UINT32  nFlags,
CPoint  point
[protected]
 

Sends a WM_DRAGTHUMB message to the parent CScroller.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
ages ago
Parameters:
Some flags detailing which buttons and keys were down when the mouse message [INPUTS] was generated; the coordinates of the mouse cursor.
- [OUTPUTS]
Returns:
-

Errors: - Scope: Protected

See also:
CScrollerThumb::PostMsgToScroller(); CScroller::OnDragThumb(); CScrollerThumb::OnLButtonDown(); CScrollerThumb::OnLButtonUp()

Definition at line 480 of file scrlthmb.cpp.

00481 {
00482     CWnd::OnMouseMove(nFlags, point);
00483     if (Dragging) PostMsgToScroller((DragIsAdjust) ? WM_DRAGTHUMBADJ : WM_DRAGTHUMB, point);
00484 }

void CScrollerThumb::OnPaint  )  [protected]
 

Responds to a WM_PAINT message sent by Windows. Paints the light and dark shading around the edge of the thumb, so it looks like the genuine Windows article.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
ages ago
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: - Scope: Protected

See also:
-

Definition at line 349 of file scrlthmb.cpp.

00350 {
00351     if(CScroller::IsChicago())
00352     {
00353         OnWin95Paint();
00354         return;
00355     }
00356     // Create a device context to paint on, and find out the extent of this window.
00357     CPaintDC dc(this);
00358     dc.SetROP2(R2_COPYPEN);
00359     CRect rect;
00360     GetClientRect(&rect);
00361     
00362     // Fill the inside of the thumb, drawing a thin black border around it.
00363     CBrush interior(::GetSysColor(COLOR_BTNFACE));
00364     CBrush* oldbrush = dc.SelectObject(&interior);
00365     dc.Rectangle(&rect);
00366     
00367     // Draw the shade inside the bottom and right edges.
00368     CPen shade(PS_SOLID, 2, ::GetSysColor(COLOR_BTNSHADOW));
00369     CPen* oldpen = dc.SelectObject(&shade);
00370     
00371     dc.MoveTo(rect.left + 2, rect.bottom - 2);
00372     dc.LineTo(rect.right - 2, rect.bottom - 2);
00373     dc.LineTo(rect.right - 2, rect.top + 2);
00374 
00375     // Draw the highlight, half as wide, inside the left and top edges.
00376     CPen highlight(PS_SOLID, 1, ::GetSysColor(COLOR_BTNHIGHLIGHT));
00377     dc.SelectObject(&highlight);
00378     dc.MoveTo(rect.left + 1, rect.bottom - 3);
00379     dc.LineTo(rect.left + 1, rect.top + 1);
00380     dc.LineTo(rect.right - 2, rect.top + 1);
00381     
00382     // For some reason Windows sometimes refuses to draw the first pixel of the highlight,
00383     // so draw that one ourselves.  I'm not wasting any more time debugging the display
00384     // driver!!
00385     dc.SetPixel(rect.left + 1, rect.bottom - 3, ::GetSysColor(COLOR_BTNHIGHLIGHT));
00386     
00387     // Deselect our drawing tools before they are destroyed.
00388     dc.SelectObject(oldbrush);
00389     dc.SelectObject(oldpen);
00390 }

void CScrollerThumb::OnRButtonDown UINT32  nFlags,
CPoint  point
[protected]
 

Captures the mouse and sends a WM_GRABTHUMBADJ message to the parent CScroller.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/11/94
Parameters:
Some flags detailing which buttons and keys were down when the mouse message [INPUTS] was generated; the coordinates of the mouse cursor.
- [OUTPUTS]
Returns:
-

Errors: - Scope: Protected

See also:
CScrollerThumb::PostMsgToScroller(); CScroller::OnGrabThumb(); CScrollerThumb::OnMouseMove(); CScrollerThumb::OnLButtonUp()

Definition at line 440 of file scrlthmb.cpp.

00441 {
00442     CWnd::OnRButtonDown(nFlags, point);
00443     if (!Dragging)
00444     {
00445         Dragging = TRUE;
00446         DragIsAdjust = TRUE;
00447         SetCapture();
00448 
00449         if (((CScroller *)GetParent())->LinkedScroller != NULL) // If adjust-drag is enabled...
00450         {
00451             // Try to set new pointer shape for the drag
00452             if (AdjustDragCursor == NULL)
00453                 AdjustDragCursor = new Cursor(_R(IDC_ADJUSTSCROLL));
00454             if (AdjustDragCursor != NULL)
00455                 DragCursorID = CursorStack::GPush(AdjustDragCursor);
00456         }
00457 
00458         PostMsgToScroller(WM_GRABTHUMBADJ, point);
00459     }
00460 }

void CScrollerThumb::OnRButtonUp UINT32  nFlags,
CPoint  point
[protected]
 

Releases the captured mouse and sends a WM_RELEASETHUMB message to the parent CScroller.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com> (Jason copied OnLButtonUp, 16/11/94)
Date:
ages ago
Parameters:
Some flags detailing which buttons and keys were down when the mouse message [INPUTS] was generated; the coordinates of the mouse cursor.
- [OUTPUTS]
Returns:
-

Errors: - Scope: Protected

See also:
CScrollerThumb::PostMsgToScroller(); CScroller::OnDragThumb(); CScrollerThumb::OnLButtonDown(); CScrollerThumb::OnMouseMove()

Definition at line 537 of file scrlthmb.cpp.

00538 {
00539     CWnd::OnRButtonUp(nFlags, point);
00540     if (Dragging)
00541     {
00542         Dragging = FALSE;
00543         ::ReleaseCapture();
00544 
00545         // Restore old pointer shape after the drag
00546         if (AdjustDragCursor != NULL)
00547         {
00548             CursorStack::GPop(DragCursorID);
00549             delete AdjustDragCursor;
00550             AdjustDragCursor = NULL;
00551             DragCursorID = 0;
00552         }
00553 
00554         PostMsgToScroller((DragIsAdjust) ? WM_RELEASETHUMBADJ : WM_RELEASETHUMB, point);
00555     }
00556     // tell people things have changed on screen
00557     BROADCAST_TO_ALL(ScreenChangeMsg(TRUE));
00558 }

void CScrollerThumb::OnWin95Paint  )  [private]
 

Responds to a WM_PAINT message sent by Windows. Paints the light and dark shading around the edge of the thumb, so it looks like the genuine Windows 95 article.

Author:
Chris_Parks (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/10/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: - Scope: Protected

See also:
-

Definition at line 287 of file scrlthmb.cpp.

00288 {
00289     // Create a device context to paint on, and find out the extent of this window.
00290     CPaintDC dc(this);
00291     dc.SetROP2(R2_COPYPEN);
00292     CRect rect;
00293     GetClientRect(&rect);
00294     
00295     // Fill the inside of the thumb, drawing a thin black border around it.
00296     CBrush interior(::GetSysColor(COLOR_BTNFACE));
00297     CBrush* oldbrush = dc.SelectObject(&interior);
00298         
00299     // Draw the shade inside the bottom and right edges.
00300     CPen shade(PS_SOLID, 1,RGB(255,0,0));// ::GetSysColor(COLOR_BTNSHADOW));
00301     CPen* oldpen = dc.SelectObject(&shade);
00302 
00303     dc.Rectangle(&rect);
00304     
00305     COLORREF TopLeft        = GetSysColor(COLOR_BTNFACE);
00306     COLORREF BotRight       = GetSysColor(COLOR_WINDOWFRAME);
00307     COLORREF TopLeftInside  = GetSysColor(COLOR_BTNHIGHLIGHT);
00308     COLORREF BotRightInside = GetSysColor(COLOR_BTNSHADOW);
00309 
00310     INT32 x  = rect.left;
00311     INT32 y  = rect.top;
00312     INT32 dx = rect.Width();
00313     INT32 dy = rect.Height();
00314 
00315     // The plinth is always made up of 4 right-angle elements
00316     // When indented, the colours are swapped, but the elements retain position
00317     PatB(&dc, x, y, 1, dy-1, TopLeft);
00318     PatB(&dc, x, y, dx-1, 1, TopLeft);
00319 
00320     PatB(&dc, x+dx-1, y, 1, dy, BotRight);
00321     PatB(&dc, x, y+dy-1, dx, 1, BotRight);
00322   
00323     PatB(&dc, x+1, y+1, 1, dy-2, TopLeftInside);
00324     PatB(&dc, x+1, y+1, dx-2, 1, TopLeftInside);
00325 
00326     PatB(&dc, x+dx-2, y+1, 1, dy-2, BotRightInside);
00327     PatB(&dc, x+1, y+dy-2, dx-2, 1, BotRightInside);
00328   
00329     dc.SelectObject(oldbrush);
00330     dc.SelectObject(oldpen);
00331 }

void CScrollerThumb::PostMsgToScroller UINT32  msg,
CPoint  pt
const [private]
 

Posts a private message to the parent CScroller window. Converts the coordinates passed in so that they are relative to the CScroller's client area.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
ages ago
Parameters:
The message ID to posted; the (mouse) coordinates, relative to the thumb's [INPUTS] client area, to be posted along with the message.
- [OUTPUTS]
Returns:
-

Errors: - Scope: Private

See also:
CScrollerThumb::OnLButtonDown(); CScrollerThumb::OnMouseMove(); CScrollerThumb::OnLButtonUp()

Definition at line 258 of file scrlthmb.cpp.

00259 {
00260     ClientToScreen(&pt);
00261     GetParent()->ScreenToClient(&pt);
00262     GetParent()->PostMessage(msg, pt.x, pt.y);
00263 }


Member Data Documentation

BOOL CScrollerThumb::Dragging [private]
 

Definition at line 127 of file scrlthmb.h.

BOOL CScrollerThumb::DragIsAdjust [private]
 

Definition at line 128 of file scrlthmb.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:53:17 2007 for Camelot by  doxygen 1.4.4