~jil26/fabathome-model1/FabInterpreter

« back to all changes in this revision

Viewing changes to software/projects/FabStudio v0/Fab@Home Studio/scbarg.cpp

  • Committer: jil26
  • Date: 2010-03-17 09:27:31 UTC
  • Revision ID: svn-v4:02918aed-e80b-b844-b231-15c4a9332dc2:trunk:7
Added FabStudio v0 to the repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/////////////////////////////////////////////////////////////////////////
 
2
//
 
3
// CSizingControlBarG           Version 2.44
 
4
// 
 
5
// Created: Jan 24, 1998        Last Modified: March 31, 2002
 
6
//
 
7
// See the official site at www.datamekanix.com for documentation and
 
8
// the latest news.
 
9
//
 
10
/////////////////////////////////////////////////////////////////////////
 
11
// Copyright (C) 1998-2002 by Cristi Posea. All rights reserved.
 
12
//
 
13
// This code is free for personal and commercial use, providing this 
 
14
// notice remains intact in the source files and all eventual changes are
 
15
// clearly marked with comments.
 
16
//
 
17
// You must obtain the author's consent before you can include this code
 
18
// in a software library.
 
19
//
 
20
// No warrantee of any kind, express or implied, is included with this
 
21
// software; use at your own risk, responsibility for damages (if any) to
 
22
// anyone resulting from the use of this software rests entirely with the
 
23
// user.
 
24
//
 
25
// Send bug reports, bug fixes, enhancements, requests, flames, etc. to
 
26
// cristi@datamekanix.com or post them at the message board at the site.
 
27
/////////////////////////////////////////////////////////////////////////
 
28
 
 
29
// sizecbar.cpp : implementation file
 
30
//
 
31
 
 
32
#include "stdafx.h"
 
33
 
 
34
#ifdef _DEBUG
 
35
#define new DEBUG_NEW
 
36
#undef THIS_FILE
 
37
static char THIS_FILE[] = __FILE__;
 
38
#endif
 
39
 
 
40
/////////////////////////////////////////////////////////////////////////
 
41
// CSizingControlBarG
 
42
 
 
43
IMPLEMENT_DYNAMIC(CSizingControlBarG, baseCSizingControlBarG);
 
44
 
 
45
CSizingControlBarG::CSizingControlBarG()
 
46
{
 
47
    m_cyGripper = 12;
 
48
}
 
49
 
 
50
CSizingControlBarG::~CSizingControlBarG()
 
51
{
 
52
}
 
53
 
 
54
BEGIN_MESSAGE_MAP(CSizingControlBarG, baseCSizingControlBarG)
 
55
    //{{AFX_MSG_MAP(CSizingControlBarG)
 
56
    ON_WM_NCLBUTTONUP()
 
57
    ON_WM_NCHITTEST()
 
58
    //}}AFX_MSG_MAP
 
59
    ON_MESSAGE(WM_SETTEXT, OnSetText)
 
60
END_MESSAGE_MAP()
 
61
 
 
62
/////////////////////////////////////////////////////////////////////////
 
63
// CSizingControlBarG message handlers
 
64
 
 
65
/////////////////////////////////////////////////////////////////////////
 
66
// Mouse Handling
 
67
//
 
68
 
 
69
void CSizingControlBarG::OnNcLButtonUp(UINT nHitTest, CPoint point)
 
70
{
 
71
    if (nHitTest == HTCLOSE)
 
72
        m_pDockSite->ShowControlBar(this, FALSE, FALSE); // hide
 
73
 
 
74
    baseCSizingControlBarG::OnNcLButtonUp(nHitTest, point);
 
75
}
 
76
 
 
77
void CSizingControlBarG::NcCalcClient(LPRECT pRc, UINT nDockBarID)
 
78
{
 
79
    CRect rcBar(pRc); // save the bar rect
 
80
 
 
81
    // subtract edges
 
82
    baseCSizingControlBarG::NcCalcClient(pRc, nDockBarID);
 
83
 
 
84
    if (!HasGripper())
 
85
        return;
 
86
 
 
87
    CRect rc(pRc); // the client rect as calculated by the base class
 
88
 
 
89
    BOOL bHorz = (nDockBarID == AFX_IDW_DOCKBAR_TOP) ||
 
90
                 (nDockBarID == AFX_IDW_DOCKBAR_BOTTOM);
 
91
 
 
92
    if (bHorz)
 
93
        rc.DeflateRect(m_cyGripper, 0, 0, 0);
 
94
    else
 
95
        rc.DeflateRect(0, m_cyGripper, 0, 0);
 
96
 
 
97
    // set position for the "x" (hide bar) button
 
98
    CPoint ptOrgBtn;
 
99
    if (bHorz)
 
100
        ptOrgBtn = CPoint(rc.left - 13, rc.top);
 
101
    else
 
102
        ptOrgBtn = CPoint(rc.right - 12, rc.top - 13);
 
103
 
 
104
    m_biHide.Move(ptOrgBtn - rcBar.TopLeft());
 
105
 
 
106
    *pRc = rc;
 
107
}
 
108
 
 
109
void CSizingControlBarG::NcPaintGripper(CDC* pDC, CRect rcClient)
 
110
{
 
111
    if (!HasGripper())
 
112
        return;
 
113
 
 
114
    // paints a simple "two raised lines" gripper
 
115
    // override this if you want a more sophisticated gripper
 
116
    CRect gripper = rcClient;
 
117
    CRect rcbtn = m_biHide.GetRect();
 
118
    BOOL bHorz = IsHorzDocked();
 
119
 
 
120
    gripper.DeflateRect(1, 1);
 
121
    if (bHorz)
 
122
    {   // gripper at left
 
123
        gripper.left -= m_cyGripper;
 
124
        gripper.right = gripper.left + 3;
 
125
        gripper.top = rcbtn.bottom + 3;
 
126
    }
 
127
    else
 
128
    {   // gripper at top
 
129
        gripper.top -= m_cyGripper;
 
130
        gripper.bottom = gripper.top + 3;
 
131
        gripper.right = rcbtn.left - 3;
 
132
    }
 
133
 
 
134
    pDC->Draw3dRect(gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT),
 
135
        ::GetSysColor(COLOR_BTNSHADOW));
 
136
 
 
137
    gripper.OffsetRect(bHorz ? 3 : 0, bHorz ? 0 : 3);
 
138
 
 
139
    pDC->Draw3dRect(gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT),
 
140
        ::GetSysColor(COLOR_BTNSHADOW));
 
141
 
 
142
    m_biHide.Paint(pDC);
 
143
}
 
144
 
 
145
LRESULT CSizingControlBarG::OnNcHitTest(CPoint point)
 
146
{
 
147
    CRect rcBar;
 
148
    GetWindowRect(rcBar);
 
149
 
 
150
    UINT nRet = baseCSizingControlBarG::OnNcHitTest(point);
 
151
    if (nRet != HTCLIENT)
 
152
        return nRet;
 
153
 
 
154
    CRect rc = m_biHide.GetRect();
 
155
    rc.OffsetRect(rcBar.TopLeft());
 
156
    if (rc.PtInRect(point))
 
157
        return HTCLOSE;
 
158
 
 
159
    return HTCLIENT;
 
160
}
 
161
 
 
162
/////////////////////////////////////////////////////////////////////////
 
163
// CSizingControlBarG implementation helpers
 
164
 
 
165
void CSizingControlBarG::OnUpdateCmdUI(CFrameWnd* pTarget,
 
166
                                      BOOL bDisableIfNoHndler)
 
167
{
 
168
    UNUSED_ALWAYS(bDisableIfNoHndler);
 
169
    UNUSED_ALWAYS(pTarget);
 
170
 
 
171
    if (!HasGripper())
 
172
        return;
 
173
 
 
174
    BOOL bNeedPaint = FALSE;
 
175
 
 
176
    CPoint pt;
 
177
    ::GetCursorPos(&pt);
 
178
    BOOL bHit = (OnNcHitTest(pt) == HTCLOSE);
 
179
    BOOL bLButtonDown = (::GetKeyState(VK_LBUTTON) < 0);
 
180
 
 
181
    BOOL bWasPushed = m_biHide.bPushed;
 
182
    m_biHide.bPushed = bHit && bLButtonDown;
 
183
 
 
184
    BOOL bWasRaised = m_biHide.bRaised;
 
185
    m_biHide.bRaised = bHit && !bLButtonDown;
 
186
 
 
187
    bNeedPaint |= (m_biHide.bPushed ^ bWasPushed) ||
 
188
                  (m_biHide.bRaised ^ bWasRaised);
 
189
 
 
190
    if (bNeedPaint)
 
191
        SendMessage(WM_NCPAINT);
 
192
}
 
193
 
 
194
/////////////////////////////////////////////////////////////////////////
 
195
// CSCBButton
 
196
 
 
197
CSCBButton::CSCBButton()
 
198
{
 
199
    bRaised = FALSE;
 
200
    bPushed = FALSE;
 
201
}
 
202
 
 
203
void CSCBButton::Paint(CDC* pDC)
 
204
{
 
205
    CRect rc = GetRect();
 
206
 
 
207
    if (bPushed)
 
208
        pDC->Draw3dRect(rc, ::GetSysColor(COLOR_BTNSHADOW),
 
209
            ::GetSysColor(COLOR_BTNHIGHLIGHT));
 
210
    else
 
211
        if (bRaised)
 
212
            pDC->Draw3dRect(rc, ::GetSysColor(COLOR_BTNHIGHLIGHT),
 
213
                ::GetSysColor(COLOR_BTNSHADOW));
 
214
 
 
215
    COLORREF clrOldTextColor = pDC->GetTextColor();
 
216
    pDC->SetTextColor(::GetSysColor(COLOR_BTNTEXT));
 
217
    int nPrevBkMode = pDC->SetBkMode(TRANSPARENT);
 
218
    CFont font;
 
219
    int ppi = pDC->GetDeviceCaps(LOGPIXELSX);
 
220
    int pointsize = MulDiv(60, 96, ppi); // 6 points at 96 ppi
 
221
    font.CreatePointFont(pointsize, _T("Marlett"));
 
222
    CFont* oldfont = pDC->SelectObject(&font);
 
223
 
 
224
    pDC->TextOut(ptOrg.x + 2, ptOrg.y + 2, CString(_T("r"))); // x-like
 
225
 
 
226
    pDC->SelectObject(oldfont);
 
227
    pDC->SetBkMode(nPrevBkMode);
 
228
    pDC->SetTextColor(clrOldTextColor);
 
229
}
 
230
 
 
231
BOOL CSizingControlBarG::HasGripper() const
 
232
{
 
233
#if defined(_SCB_MINIFRAME_CAPTION) || !defined(_SCB_REPLACE_MINIFRAME)
 
234
    // if the miniframe has a caption, don't display the gripper
 
235
    if (IsFloating())
 
236
        return FALSE;
 
237
#endif //_SCB_MINIFRAME_CAPTION
 
238
 
 
239
    return TRUE;
 
240
}
 
 
b'\\ No newline at end of file'