~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to lib/cppunit-1.10.0/src/msvc6/testrunner/DynamicWindow/SizeCBar.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2006-11-11 10:32:06 UTC
  • Revision ID: james.westby@ubuntu.com-20061111103206-f3p0r9g0vq44rp3r
Tags: upstream-3.0.PRE5
ImportĀ upstreamĀ versionĀ 3.0.PRE5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/////////////////////////////////////////////////////////////////////////
 
2
// Copyright (C) 1998, 1999 by Cristi Posea
 
3
// All rights reserved
 
4
//
 
5
// Use and distribute freely, except: don't remove my name from the
 
6
// source or documentation (don't take credit for my work), mark your
 
7
// changes (don't get me blamed for your possible bugs), don't alter
 
8
// or remove this notice.
 
9
// No warrantee of any kind, express or implied, is included with this
 
10
// software; use at your own risk, responsibility for damages (if any) to
 
11
// anyone resulting from the use of this software rests entirely with the
 
12
// user.
 
13
//
 
14
// This class is intended to be used as a base class. Do not simply add
 
15
// your code to this file - instead create a new class derived from
 
16
// CSizingControlBar and put there what you need.
 
17
// Modify this file only to fix bugs, and don't forget to send me a copy.
 
18
//
 
19
// Send bug reports, bug fixes, enhancements, requests, flames, etc.,
 
20
// and I'll try to keep a version up to date.  I can be reached at:
 
21
//    cristip@dundas.com
 
22
//
 
23
// More details at MFC Programmer's SourceBook
 
24
// http://www.codeguru.com/docking/docking_window.shtml or search
 
25
// www.codeguru.com for my name if the article was moved.
 
26
//
 
27
/////////////////////////////////////////////////////////////////////////
 
28
//
 
29
// Acknowledgements:
 
30
//  o   Thanks to Harlan R. Seymour (harlans@dundas.com) for his continuous
 
31
//      support during development of this code.
 
32
//  o   Thanks to Dundas Software for the opportunity to test this code
 
33
//      on real-life applications.
 
34
//      If you don't know who they are, visit them at www.dundas.com .
 
35
//      Their award winning components and development suites are
 
36
//      a pile of gold.
 
37
//  o   Thanks to Chris Maunder (chrism@dundas.com) who came with the
 
38
//      simplest way to query "Show window content while dragging" system
 
39
//      setting.
 
40
//  o   Thanks to Zafir Anjum (zafir@codeguru.com) for publishing this
 
41
//      code on his cool site (www.codeguru.com).
 
42
//  o   Some ideas for the gripper came from the CToolBarEx flat toolbar
 
43
//      by Joerg Koenig (Joerg.Koenig@rhein-neckar.de). Also he inspired
 
44
//      me on writing this notice:) . Thanks, Joerg!
 
45
//  o   Thanks to Jakawan Ratiwanich (jack@alpha.fsec.ucf.edu) and to
 
46
//      Udo Schaefer (Udo.Schaefer@vcase.de) for the dwStyle bug fix under
 
47
//      VC++ 6.0.
 
48
//  o   And, of course, many thanks to all of you who used this code,
 
49
//      for the invaluable feedback I received.
 
50
//      
 
51
/////////////////////////////////////////////////////////////////////////
 
52
 
 
53
 
 
54
// sizecbar.cpp : implementation file
 
55
//
 
56
 
 
57
#include "stdafx.h"
 
58
#include "sizecbar.h"
 
59
 
 
60
#ifdef _DEBUG
 
61
#define new DEBUG_NEW
 
62
#undef THIS_FILE
 
63
static char THIS_FILE[] = __FILE__;
 
64
#endif
 
65
 
 
66
/////////////////////////////////////////////////////////////////////////
 
67
// CSizingControlBar
 
68
 
 
69
CSCBArray CSizingControlBar::m_arrBars; // static member
 
70
 
 
71
IMPLEMENT_DYNAMIC(CSizingControlBar, baseCSizingControlBar);
 
72
 
 
73
CSizingControlBar::CSizingControlBar()
 
74
{
 
75
    m_szMin = CSize(33, 32);
 
76
    m_szHorz = CSize(200, 200);
 
77
    m_szVert = CSize(200, 200);
 
78
    m_szFloat = CSize(200, 200);
 
79
    m_bTracking = FALSE;
 
80
    m_bKeepSize = FALSE;
 
81
    m_bParentSizing = FALSE;
 
82
    m_cxEdge = 5;
 
83
    m_bDragShowContent = FALSE;
 
84
    m_nDockBarID = 0;
 
85
    m_dwSCBStyle = 0;
 
86
}
 
87
 
 
88
CSizingControlBar::~CSizingControlBar()
 
89
{
 
90
}
 
91
 
 
92
BEGIN_MESSAGE_MAP(CSizingControlBar, baseCSizingControlBar)
 
93
    //{{AFX_MSG_MAP(CSizingControlBar)
 
94
    ON_WM_CREATE()
 
95
    ON_WM_PAINT()
 
96
    ON_WM_NCPAINT()
 
97
    ON_WM_NCCALCSIZE()
 
98
    ON_WM_WINDOWPOSCHANGING()
 
99
    ON_WM_CAPTURECHANGED()
 
100
    ON_WM_SETTINGCHANGE()
 
101
    ON_WM_LBUTTONUP()
 
102
    ON_WM_MOUSEMOVE()
 
103
    ON_WM_NCLBUTTONDOWN()
 
104
    ON_WM_LBUTTONDOWN()
 
105
    ON_WM_LBUTTONDBLCLK()
 
106
    ON_WM_RBUTTONDOWN()
 
107
    ON_WM_NCLBUTTONUP()
 
108
    ON_WM_NCMOUSEMOVE()
 
109
    ON_WM_NCHITTEST()
 
110
    //}}AFX_MSG_MAP
 
111
END_MESSAGE_MAP()
 
112
 
 
113
BOOL CSizingControlBar::Create(LPCTSTR lpszWindowName, CWnd* pParentWnd,
 
114
                               CSize sizeDefault, BOOL bHasGripper,
 
115
                               UINT nID, DWORD dwStyle)
 
116
{
 
117
    // must have a parent
 
118
    ASSERT_VALID(pParentWnd);
 
119
    // cannot be both fixed and dynamic
 
120
    // (CBRS_SIZE_DYNAMIC is used for resizng when floating)
 
121
    ASSERT (!((dwStyle & CBRS_SIZE_FIXED) &&
 
122
              (dwStyle & CBRS_SIZE_DYNAMIC)));
 
123
 
 
124
    m_dwStyle = dwStyle & CBRS_ALL; // save the control bar styles
 
125
 
 
126
    m_szHorz = sizeDefault; // set the size members
 
127
    m_szVert = sizeDefault;
 
128
    m_szFloat = sizeDefault;
 
129
 
 
130
    m_cyGripper = bHasGripper ? 12 : 0; // set the gripper width
 
131
 
 
132
    // register and create the window - skip CControlBar::Create()
 
133
    CString wndclass = ::AfxRegisterWndClass(CS_DBLCLKS,
 
134
        ::LoadCursor(NULL, IDC_ARROW),
 
135
        ::GetSysColorBrush(COLOR_BTNFACE), 0);
 
136
 
 
137
    dwStyle &= ~CBRS_ALL; // keep only the generic window styles
 
138
    dwStyle |= WS_CLIPCHILDREN; // prevents flashing
 
139
    if (!CWnd::Create(wndclass, lpszWindowName, dwStyle,
 
140
        CRect(0, 0, 0, 0), pParentWnd, nID))
 
141
        return FALSE;
 
142
 
 
143
    return TRUE;
 
144
}
 
145
 
 
146
/////////////////////////////////////////////////////////////////////////
 
147
// CSizingControlBar message handlers
 
148
 
 
149
int CSizingControlBar::OnCreate(LPCREATESTRUCT lpCreateStruct) 
 
150
{
 
151
    if (baseCSizingControlBar::OnCreate(lpCreateStruct) == -1)
 
152
        return -1;
 
153
    
 
154
    // querry SPI_GETDRAGFULLWINDOWS system parameter
 
155
    // OnSettingChange() will update m_bDragShowContent
 
156
    m_bDragShowContent = FALSE;
 
157
    ::SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0,
 
158
        &m_bDragShowContent, 0);
 
159
 
 
160
    m_arrBars.Add(this);        // register
 
161
    
 
162
//    m_dwSCBStyle |= SCBS_SHOWEDGES;
 
163
 
 
164
    return 0;
 
165
}
 
166
 
 
167
BOOL CSizingControlBar::DestroyWindow() 
 
168
{
 
169
    int nPos = FindSizingBar(this);
 
170
    ASSERT(nPos >= 0);
 
171
 
 
172
    m_arrBars.RemoveAt(nPos);   // unregister
 
173
 
 
174
    return baseCSizingControlBar::DestroyWindow();
 
175
}
 
176
 
 
177
const BOOL CSizingControlBar::IsFloating() const
 
178
{
 
179
    return !IsHorzDocked() && !IsVertDocked();
 
180
}
 
181
 
 
182
const BOOL CSizingControlBar::IsHorzDocked() const
 
183
{
 
184
    return (m_nDockBarID == AFX_IDW_DOCKBAR_TOP ||
 
185
        m_nDockBarID == AFX_IDW_DOCKBAR_BOTTOM);
 
186
}
 
187
 
 
188
const BOOL CSizingControlBar::IsVertDocked() const
 
189
{
 
190
    return (m_nDockBarID == AFX_IDW_DOCKBAR_LEFT ||
 
191
        m_nDockBarID == AFX_IDW_DOCKBAR_RIGHT);
 
192
}
 
193
 
 
194
const BOOL CSizingControlBar::IsSideTracking() const
 
195
{
 
196
    // don't call this when not tracking
 
197
    ASSERT(m_bTracking && !IsFloating());
 
198
 
 
199
    return (m_htEdge == HTLEFT || m_htEdge == HTRIGHT) ?
 
200
        IsHorzDocked() : IsVertDocked();
 
201
}
 
202
 
 
203
CSize CSizingControlBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
 
204
{
 
205
    if (bStretch) // the bar is stretched (is not the child of a dockbar)
 
206
        if (bHorz)
 
207
            return CSize(32767, m_szHorz.cy);
 
208
        else
 
209
            return CSize(m_szVert.cx, 32767);
 
210
 
 
211
    // dirty cast - using CSCBDockBar to access protected CDockBar members
 
212
    CSCBDockBar* pDockBar = (CSCBDockBar*) m_pDockBar;
 
213
 
 
214
    // force imediate RecalcDelayShow() for all sizing bars on the row
 
215
    // with delayShow/delayHide flags set to avoid IsVisible() problems
 
216
    CSCBArray arrSCBars;
 
217
    GetRowSizingBars(arrSCBars);
 
218
    AFX_SIZEPARENTPARAMS layout;
 
219
    layout.hDWP = pDockBar->m_bLayoutQuery ?
 
220
        NULL : ::BeginDeferWindowPos(arrSCBars.GetSize());
 
221
    for (int i = 0; i < arrSCBars.GetSize(); i++)
 
222
        arrSCBars[i]->RecalcDelayShow(&layout);
 
223
    if (layout.hDWP != NULL)
 
224
        ::EndDeferWindowPos(layout.hDWP);
 
225
 
 
226
    // get available length
 
227
    CRect rc = pDockBar->m_rectLayout;
 
228
    if (rc.IsRectEmpty())
 
229
        m_pDockSite->GetClientRect(&rc);
 
230
    int nLengthAvail = bHorz ? rc.Width() + 2 : rc.Height() - 2;
 
231
 
 
232
    if (IsVisible() && !IsFloating() &&
 
233
        m_bParentSizing && arrSCBars[0] == this)
 
234
        if (NegociateSpace(nLengthAvail, (bHorz != FALSE)))
 
235
            AlignControlBars();
 
236
 
 
237
    m_bParentSizing = FALSE;
 
238
    
 
239
    CSize szRet = bHorz ? m_szHorz : m_szVert;
 
240
    szRet.cx = max(m_szMin.cx, szRet.cx);
 
241
    szRet.cy = max(m_szMin.cy, szRet.cy);
 
242
 
 
243
    return szRet;
 
244
}
 
245
 
 
246
CSize CSizingControlBar::CalcDynamicLayout(int nLength, DWORD dwMode)
 
247
{
 
248
    if (dwMode & (LM_HORZDOCK | LM_VERTDOCK)) // docked ?
 
249
    {
 
250
        if (nLength == -1)
 
251
            m_bParentSizing = TRUE;
 
252
 
 
253
        return baseCSizingControlBar::CalcDynamicLayout(nLength, dwMode);
 
254
    }
 
255
 
 
256
    if (dwMode & LM_MRUWIDTH) return m_szFloat;
 
257
    if (dwMode & LM_COMMIT) return m_szFloat; // already committed
 
258
 
 
259
    ((dwMode & LM_LENGTHY) ? m_szFloat.cy : m_szFloat.cx) = nLength;
 
260
 
 
261
    m_szFloat.cx = max(m_szFloat.cx, m_szMin.cx);
 
262
    m_szFloat.cy = max(m_szFloat.cy, m_szMin.cy);
 
263
 
 
264
    return m_szFloat;
 
265
}
 
266
 
 
267
void CSizingControlBar::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
 
268
{
 
269
    // force non-client recalc if moved or resized
 
270
    lpwndpos->flags |= SWP_FRAMECHANGED;
 
271
 
 
272
    baseCSizingControlBar::OnWindowPosChanging(lpwndpos);
 
273
 
 
274
    // find on which side are we docked
 
275
    UINT nOldDockBarID = m_nDockBarID;
 
276
    m_nDockBarID = GetParent()->GetDlgCtrlID();
 
277
 
 
278
    if (!IsFloating())
 
279
        if (lpwndpos->flags & SWP_SHOWWINDOW)
 
280
            m_bKeepSize = TRUE;
 
281
}
 
282
 
 
283
/////////////////////////////////////////////////////////////////////////
 
284
// Mouse Handling
 
285
//
 
286
void CSizingControlBar::OnLButtonDown(UINT nFlags, CPoint point) 
 
287
{
 
288
    if (m_pDockBar != NULL)
 
289
    {
 
290
        // start the drag
 
291
        ASSERT(m_pDockContext != NULL);
 
292
        ClientToScreen(&point);
 
293
        m_pDockContext->StartDrag(point);
 
294
    }
 
295
    else
 
296
        CWnd::OnLButtonDown(nFlags, point);
 
297
}
 
298
 
 
299
void CSizingControlBar::OnLButtonDblClk(UINT nFlags, CPoint point) 
 
300
{
 
301
    if (m_pDockBar != NULL)
 
302
    {
 
303
        // toggle docking
 
304
        ASSERT(m_pDockContext != NULL);
 
305
        m_pDockContext->ToggleDocking();
 
306
    }
 
307
    else
 
308
        CWnd::OnLButtonDblClk(nFlags, point);
 
309
}
 
310
 
 
311
void CSizingControlBar::OnNcLButtonDown(UINT nHitTest, CPoint point) 
 
312
{
 
313
    if (IsFloating())
 
314
    {
 
315
        baseCSizingControlBar::OnNcLButtonDown(nHitTest, point);
 
316
        return;
 
317
    }
 
318
 
 
319
    if (m_bTracking) return;
 
320
 
 
321
    if ((nHitTest >= HTSIZEFIRST) && (nHitTest <= HTSIZELAST))
 
322
        StartTracking(nHitTest); // sizing edge hit
 
323
}
 
324
 
 
325
void CSizingControlBar::OnNcLButtonUp(UINT nHitTest, CPoint point) 
 
326
{
 
327
    if (nHitTest == HTCLOSE)
 
328
        m_pDockSite->ShowControlBar(this, FALSE, FALSE); // hide
 
329
 
 
330
    baseCSizingControlBar::OnNcLButtonUp(nHitTest, point);
 
331
}
 
332
 
 
333
void CSizingControlBar::OnLButtonUp(UINT nFlags, CPoint point) 
 
334
{
 
335
    if (m_bTracking)
 
336
        StopTracking();
 
337
 
 
338
    baseCSizingControlBar::OnLButtonUp(nFlags, point);
 
339
}
 
340
 
 
341
void CSizingControlBar::OnRButtonDown(UINT nFlags, CPoint point) 
 
342
{
 
343
    if (m_bTracking)
 
344
        StopTracking();
 
345
    
 
346
    baseCSizingControlBar::OnRButtonDown(nFlags, point);
 
347
}
 
348
 
 
349
void CSizingControlBar::OnMouseMove(UINT nFlags, CPoint point) 
 
350
{
 
351
    if (m_bTracking)
 
352
        OnTrackUpdateSize(point);
 
353
    
 
354
    baseCSizingControlBar::OnMouseMove(nFlags, point);
 
355
}
 
356
 
 
357
void CSizingControlBar::OnCaptureChanged(CWnd *pWnd) 
 
358
{
 
359
    if (m_bTracking && (pWnd != this))
 
360
        StopTracking();
 
361
 
 
362
    baseCSizingControlBar::OnCaptureChanged(pWnd);
 
363
}
 
364
 
 
365
void CSizingControlBar::OnNcCalcSize(BOOL bCalcValidRects,
 
366
                                     NCCALCSIZE_PARAMS FAR* lpncsp) 
 
367
{
 
368
    // compute the the client area
 
369
    CRect rcClient = lpncsp->rgrc[0];
 
370
    rcClient.DeflateRect(5, 5);
 
371
 
 
372
    m_dwSCBStyle &= ~SCBS_EDGEALL;
 
373
 
 
374
    switch(m_nDockBarID)
 
375
    {
 
376
    case AFX_IDW_DOCKBAR_TOP:
 
377
        m_dwSCBStyle |= SCBS_EDGEBOTTOM;
 
378
        rcClient.DeflateRect(m_cyGripper, 0, 0, 0);
 
379
        break;
 
380
    case AFX_IDW_DOCKBAR_BOTTOM:
 
381
        m_dwSCBStyle |= SCBS_EDGETOP;
 
382
        rcClient.DeflateRect(m_cyGripper, 0, 0, 0);
 
383
        break;
 
384
    case AFX_IDW_DOCKBAR_LEFT:
 
385
        m_dwSCBStyle |= SCBS_EDGERIGHT;
 
386
        rcClient.DeflateRect(0, m_cyGripper, 0, 0);
 
387
        break;
 
388
    case AFX_IDW_DOCKBAR_RIGHT:
 
389
        m_dwSCBStyle |= SCBS_EDGELEFT;
 
390
        rcClient.DeflateRect(0, m_cyGripper, 0, 0);
 
391
        break;
 
392
    default:
 
393
        break;
 
394
    }
 
395
 
 
396
    if (!IsFloating() && m_pDockBar != NULL)
 
397
    {
 
398
        CSCBArray arrSCBars;
 
399
        GetRowSizingBars(arrSCBars);
 
400
 
 
401
        for (int i = 0; i < arrSCBars.GetSize(); i++)
 
402
            if (arrSCBars[i] == this)
 
403
            {
 
404
                if (i > 0)
 
405
                    m_dwSCBStyle |= IsHorzDocked() ?
 
406
                        SCBS_EDGELEFT : SCBS_EDGETOP;
 
407
                if (i < arrSCBars.GetSize() - 1)
 
408
                    m_dwSCBStyle |= IsHorzDocked() ?
 
409
                        SCBS_EDGERIGHT : SCBS_EDGEBOTTOM;
 
410
            }
 
411
    }
 
412
 
 
413
    // make room for edges only if they will be painted
 
414
    if (m_dwSCBStyle & SCBS_SHOWEDGES)
 
415
        rcClient.DeflateRect(
 
416
            (m_dwSCBStyle & SCBS_EDGELEFT) ? m_cxEdge : 0,
 
417
            (m_dwSCBStyle & SCBS_EDGETOP) ? m_cxEdge : 0,
 
418
            (m_dwSCBStyle & SCBS_EDGERIGHT) ? m_cxEdge : 0,
 
419
            (m_dwSCBStyle & SCBS_EDGEBOTTOM) ? m_cxEdge : 0);
 
420
 
 
421
    // "hide" button positioning
 
422
    CPoint ptOrgBtn;
 
423
    if (IsHorzDocked())
 
424
        ptOrgBtn = CPoint(rcClient.left - m_cyGripper - 1,
 
425
            rcClient.top - 1);
 
426
    else
 
427
        ptOrgBtn = CPoint(rcClient.right - 11,
 
428
            rcClient.top - m_cyGripper - 1);
 
429
 
 
430
    m_biHide.Move(ptOrgBtn - CRect(lpncsp->rgrc[0]).TopLeft());
 
431
 
 
432
    lpncsp->rgrc[0] = rcClient;
 
433
}
 
434
 
 
435
void CSizingControlBar::OnNcPaint() 
 
436
{
 
437
    // get window DC that is clipped to the non-client area
 
438
    CWindowDC dc(this);
 
439
 
 
440
    CRect rcClient, rcBar;
 
441
    GetClientRect(rcClient);
 
442
    ClientToScreen(rcClient);
 
443
    GetWindowRect(rcBar);
 
444
    rcClient.OffsetRect(-rcBar.TopLeft());
 
445
    rcBar.OffsetRect(-rcBar.TopLeft());
 
446
 
 
447
    // client area is not our bussiness :)
 
448
    dc.ExcludeClipRect(rcClient);
 
449
 
 
450
    // draw borders in non-client area
 
451
    CRect rcDraw = rcBar;
 
452
    DrawBorders(&dc, rcDraw);
 
453
 
 
454
    // erase parts not drawn
 
455
    dc.IntersectClipRect(rcDraw);
 
456
 
 
457
    // erase NC background the hard way
 
458
    HBRUSH hbr = (HBRUSH)GetClassLong(m_hWnd, GCL_HBRBACKGROUND);
 
459
    ::FillRect(dc.m_hDC, rcDraw, hbr);
 
460
 
 
461
    if (m_dwSCBStyle & SCBS_SHOWEDGES)
 
462
    {
 
463
        CRect rcEdge; // paint the sizing edges
 
464
        for (int i = 0; i < 4; i++)
 
465
            if (GetEdgeRect(rcBar, GetEdgeHTCode(i), rcEdge))
 
466
                dc.Draw3dRect(rcEdge, ::GetSysColor(COLOR_BTNHIGHLIGHT),
 
467
                    ::GetSysColor(COLOR_BTNSHADOW));
 
468
    }
 
469
 
 
470
    if (m_cyGripper && !IsFloating())
 
471
        NcPaintGripper(&dc, rcClient);
 
472
 
 
473
    ReleaseDC(&dc);
 
474
}
 
475
 
 
476
void CSizingControlBar::NcPaintGripper(CDC* pDC, CRect rcClient)
 
477
{
 
478
    // paints a simple "two raised lines" gripper
 
479
    // override this if you want a more sophisticated gripper
 
480
    CRect gripper = rcClient;
 
481
    CRect rcbtn = m_biHide.GetRect();
 
482
    BOOL bHorz = IsHorzDocked();
 
483
    
 
484
    gripper.DeflateRect(1, 1);
 
485
    if (bHorz)
 
486
    {   // gripper at left
 
487
        gripper.left -= m_cyGripper;
 
488
        gripper.right = gripper.left + 3;
 
489
        gripper.top = rcbtn.bottom + 3;
 
490
    }
 
491
    else
 
492
    {   // gripper at top
 
493
        gripper.top -= m_cyGripper;
 
494
        gripper.bottom = gripper.top + 3;
 
495
        gripper.right = rcbtn.left - 3;
 
496
    }
 
497
 
 
498
    pDC->Draw3dRect(gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT),
 
499
        ::GetSysColor(COLOR_BTNSHADOW));
 
500
 
 
501
    gripper.OffsetRect(bHorz ? 3 : 0, bHorz ? 0 : 3);
 
502
    
 
503
    pDC->Draw3dRect(gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT),
 
504
        ::GetSysColor(COLOR_BTNSHADOW));
 
505
 
 
506
    m_biHide.Paint(pDC);
 
507
}
 
508
 
 
509
void CSizingControlBar::OnPaint()
 
510
{
 
511
    // overridden to skip border painting based on clientrect
 
512
    CPaintDC dc(this);
 
513
}
 
514
 
 
515
UINT CSizingControlBar::OnNcHitTest(CPoint point)
 
516
{
 
517
    if (IsFloating())
 
518
        return baseCSizingControlBar::OnNcHitTest(point);
 
519
 
 
520
    CRect rcBar, rcEdge;
 
521
    GetWindowRect(rcBar);
 
522
 
 
523
    for (int i = 0; i < 4; i++)
 
524
        if (GetEdgeRect(rcBar, GetEdgeHTCode(i), rcEdge))
 
525
            if (rcEdge.PtInRect(point)) return GetEdgeHTCode(i);
 
526
 
 
527
    CRect rc = m_biHide.GetRect();
 
528
    rc.OffsetRect(rcBar.TopLeft());
 
529
    if (rc.PtInRect(point))
 
530
        return HTCLOSE;
 
531
 
 
532
    return HTCLIENT;
 
533
}
 
534
 
 
535
void CSizingControlBar::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) 
 
536
{
 
537
    baseCSizingControlBar::OnSettingChange(uFlags, lpszSection);
 
538
 
 
539
    m_bDragShowContent = FALSE;
 
540
    ::SystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0,
 
541
        &m_bDragShowContent, 0); // update
 
542
}
 
543
 
 
544
/////////////////////////////////////////////////////////////////////////
 
545
// CSizingControlBar implementation helpers
 
546
 
 
547
void CSizingControlBar::StartTracking(UINT nHitTest)
 
548
{
 
549
    SetCapture();
 
550
 
 
551
    // make sure no updates are pending
 
552
    RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW);
 
553
    
 
554
    BOOL bHorz = IsHorzDocked();
 
555
 
 
556
    m_szOld = bHorz ? m_szHorz : m_szVert;
 
557
 
 
558
    CRect rc;
 
559
    GetWindowRect(&rc);
 
560
    CRect rcEdge;
 
561
    VERIFY(GetEdgeRect(rc, nHitTest, rcEdge));
 
562
    m_ptOld = rcEdge.CenterPoint();
 
563
 
 
564
    m_htEdge = nHitTest;
 
565
    m_bTracking = TRUE;
 
566
 
 
567
    CSCBArray arrSCBars;
 
568
    GetRowSizingBars(arrSCBars);
 
569
 
 
570
    // compute the minsize as the max minsize of the sizing bars on row
 
571
    m_szMinT = m_szMin;
 
572
    for (int i = 0; i < arrSCBars.GetSize(); i++)
 
573
        if (bHorz)
 
574
            m_szMinT.cy = max(m_szMinT.cy, arrSCBars[i]->m_szMin.cy);
 
575
        else
 
576
            m_szMinT.cx = max(m_szMinT.cx, arrSCBars[i]->m_szMin.cx);
 
577
 
 
578
    if (!IsSideTracking())
 
579
    {
 
580
        // the control bar cannot grow with more than the size of 
 
581
        // remaining client area of the mainframe
 
582
        m_pDockSite->RepositionBars(0, 0xFFFF, AFX_IDW_PANE_FIRST,
 
583
            reposQuery, &rc, NULL, TRUE);
 
584
        m_szMaxT = m_szOld + rc.Size() - CSize(4, 4);
 
585
    }
 
586
    else
 
587
    {
 
588
        // side tracking: max size is the actual size plus the amount
 
589
        // the neighbour bar can be decreased to reach its minsize
 
590
        for (int i = 0; i < arrSCBars.GetSize(); i++)
 
591
            if (arrSCBars[i] == this) break;
 
592
 
 
593
        CSizingControlBar* pBar = arrSCBars[i +
 
594
            ((m_htEdge == HTTOP || m_htEdge == HTLEFT) ? -1 : 1)];
 
595
 
 
596
        m_szMaxT = m_szOld + (bHorz ? pBar->m_szHorz :
 
597
            pBar->m_szVert) - pBar->m_szMin;
 
598
    }
 
599
 
 
600
    OnTrackInvertTracker(); // draw tracker
 
601
}
 
602
 
 
603
void CSizingControlBar::StopTracking()
 
604
{
 
605
    OnTrackInvertTracker(); // erase tracker
 
606
 
 
607
    m_bTracking = FALSE;
 
608
    ReleaseCapture();
 
609
    
 
610
    m_pDockSite->DelayRecalcLayout();
 
611
}
 
612
 
 
613
void CSizingControlBar::OnTrackUpdateSize(CPoint& point)
 
614
{
 
615
    ASSERT(!IsFloating());
 
616
 
 
617
    CPoint pt = point;
 
618
    ClientToScreen(&pt);
 
619
    CSize szDelta = pt - m_ptOld;
 
620
 
 
621
    CSize sizeNew = m_szOld;
 
622
    switch (m_htEdge)
 
623
    {
 
624
    case HTLEFT:    sizeNew -= CSize(szDelta.cx, 0); break;
 
625
    case HTTOP:     sizeNew -= CSize(0, szDelta.cy); break;
 
626
    case HTRIGHT:   sizeNew += CSize(szDelta.cx, 0); break;
 
627
    case HTBOTTOM:  sizeNew += CSize(0, szDelta.cy); break;
 
628
    }
 
629
 
 
630
    // enforce the limits
 
631
    sizeNew.cx = max(m_szMinT.cx, min(m_szMaxT.cx, sizeNew.cx));
 
632
    sizeNew.cy = max(m_szMinT.cy, min(m_szMaxT.cy, sizeNew.cy));
 
633
 
 
634
    BOOL bHorz = IsHorzDocked();
 
635
    szDelta = sizeNew - (bHorz ? m_szHorz : m_szVert);
 
636
    
 
637
    if (szDelta == CSize(0, 0)) return; // no size change
 
638
 
 
639
    OnTrackInvertTracker(); // erase tracker
 
640
 
 
641
    (bHorz ? m_szHorz : m_szVert) = sizeNew; // save the new size
 
642
 
 
643
    CSCBArray arrSCBars;
 
644
    GetRowSizingBars(arrSCBars);
 
645
 
 
646
    for (int i = 0; i < arrSCBars.GetSize(); i++)
 
647
        if (!IsSideTracking())
 
648
        {   // track simultaneously
 
649
            CSizingControlBar* pBar = arrSCBars[i];
 
650
            (bHorz ? pBar->m_szHorz.cy : pBar->m_szVert.cx) =
 
651
                bHorz ? sizeNew.cy : sizeNew.cx;
 
652
        }
 
653
        else
 
654
        {   // adjust the neighbour's size too
 
655
            if (arrSCBars[i] != this) continue;
 
656
 
 
657
            CSizingControlBar* pBar = arrSCBars[i +
 
658
                ((m_htEdge == HTTOP || m_htEdge == HTLEFT) ? -1 : 1)];
 
659
 
 
660
            (bHorz ? pBar->m_szHorz.cx : pBar->m_szVert.cy) -=
 
661
                bHorz ? szDelta.cx : szDelta.cy;
 
662
        }
 
663
 
 
664
    OnTrackInvertTracker(); // redraw tracker at new pos
 
665
 
 
666
    if (m_bDragShowContent)
 
667
        m_pDockSite->DelayRecalcLayout();
 
668
}
 
669
 
 
670
void CSizingControlBar::OnTrackInvertTracker()
 
671
{
 
672
    ASSERT(m_bTracking);
 
673
 
 
674
    if (m_bDragShowContent)
 
675
        return; // don't show tracker if DragFullWindows is on
 
676
 
 
677
    BOOL bHorz = IsHorzDocked();
 
678
    CRect rc, rcBar, rcDock, rcFrame;
 
679
    GetWindowRect(rcBar);
 
680
    m_pDockBar->GetWindowRect(rcDock);
 
681
    m_pDockSite->GetWindowRect(rcFrame);
 
682
    VERIFY(GetEdgeRect(rcBar, m_htEdge, rc));
 
683
    if (!IsSideTracking())
 
684
        rc = bHorz ? 
 
685
            CRect(rcDock.left + 1, rc.top, rcDock.right - 1, rc.bottom) :
 
686
            CRect(rc.left, rcDock.top + 1, rc.right, rcDock.bottom - 1);
 
687
 
 
688
    rc.OffsetRect(-rcFrame.TopLeft());
 
689
 
 
690
    CSize sizeNew = bHorz ? m_szHorz : m_szVert;
 
691
    CSize sizeDelta = sizeNew - m_szOld;
 
692
    if (m_nDockBarID == AFX_IDW_DOCKBAR_LEFT && m_htEdge == HTTOP ||
 
693
        m_nDockBarID == AFX_IDW_DOCKBAR_RIGHT && m_htEdge != HTBOTTOM ||
 
694
        m_nDockBarID == AFX_IDW_DOCKBAR_TOP && m_htEdge == HTLEFT ||
 
695
        m_nDockBarID == AFX_IDW_DOCKBAR_BOTTOM && m_htEdge != HTRIGHT)
 
696
        sizeDelta = -sizeDelta;
 
697
    rc.OffsetRect(sizeDelta);
 
698
 
 
699
    CDC *pDC = m_pDockSite->GetDCEx(NULL,
 
700
        DCX_WINDOW | DCX_CACHE | DCX_LOCKWINDOWUPDATE);
 
701
    CBrush* pBrush = CDC::GetHalftoneBrush();
 
702
    CBrush* pBrushOld = pDC->SelectObject(pBrush);
 
703
 
 
704
    pDC->PatBlt(rc.left, rc.top, rc.Width(), rc.Height(), PATINVERT);
 
705
    
 
706
    pDC->SelectObject(pBrushOld);
 
707
    m_pDockSite->ReleaseDC(pDC);
 
708
}
 
709
 
 
710
BOOL CSizingControlBar::GetEdgeRect(CRect rcWnd, UINT nHitTest,
 
711
                                    CRect& rcEdge)
 
712
{
 
713
    rcEdge = rcWnd;
 
714
    if (m_dwSCBStyle & SCBS_SHOWEDGES)
 
715
        rcEdge.DeflateRect(1, 1);
 
716
    BOOL bHorz = IsHorzDocked();
 
717
 
 
718
    switch (nHitTest)
 
719
    {
 
720
    case HTLEFT:
 
721
        if (!(m_dwSCBStyle & SCBS_EDGELEFT)) return FALSE;
 
722
        rcEdge.right = rcEdge.left + m_cxEdge;
 
723
        rcEdge.DeflateRect(0, bHorz ? m_cxEdge: 0);
 
724
        break;
 
725
    case HTTOP:
 
726
        if (!(m_dwSCBStyle & SCBS_EDGETOP)) return FALSE;
 
727
        rcEdge.bottom = rcEdge.top + m_cxEdge;
 
728
        rcEdge.DeflateRect(bHorz ? 0 : m_cxEdge, 0);
 
729
        break;
 
730
    case HTRIGHT:
 
731
        if (!(m_dwSCBStyle & SCBS_EDGERIGHT)) return FALSE;
 
732
        rcEdge.left = rcEdge.right - m_cxEdge;
 
733
        rcEdge.DeflateRect(0, bHorz ? m_cxEdge: 0);
 
734
        break;
 
735
    case HTBOTTOM:
 
736
        if (!(m_dwSCBStyle & SCBS_EDGEBOTTOM)) return FALSE;
 
737
        rcEdge.top = rcEdge.bottom - m_cxEdge;
 
738
        rcEdge.DeflateRect(bHorz ? 0 : m_cxEdge, 0);
 
739
        break;
 
740
    default:
 
741
        ASSERT(FALSE); // invalid hit test code
 
742
    }
 
743
    return TRUE;
 
744
}
 
745
 
 
746
UINT CSizingControlBar::GetEdgeHTCode(int nEdge)
 
747
{
 
748
    if (nEdge == 0) return HTLEFT;
 
749
    if (nEdge == 1) return HTTOP;
 
750
    if (nEdge == 2) return HTRIGHT;
 
751
    if (nEdge == 3) return HTBOTTOM;
 
752
    ASSERT(FALSE); // invalid edge no
 
753
    return HTNOWHERE;
 
754
}
 
755
 
 
756
void CSizingControlBar::GetRowInfo(int& nFirst, int& nLast, int& nThis)
 
757
{
 
758
    ASSERT_VALID(m_pDockBar); // verify bounds
 
759
 
 
760
    nThis = m_pDockBar->FindBar(this);
 
761
    ASSERT(nThis != -1);
 
762
 
 
763
    int i, nBars = m_pDockBar->m_arrBars.GetSize();
 
764
 
 
765
    // find the first and the last bar in row
 
766
    for (nFirst = -1, i = nThis - 1; i >= 0 && nFirst == -1; i--)
 
767
        if (m_pDockBar->m_arrBars[i] == NULL)
 
768
            nFirst = i + 1;
 
769
    for (nLast = -1, i = nThis + 1; i < nBars && nLast == -1; i++)
 
770
        if (m_pDockBar->m_arrBars[i] == NULL)
 
771
            nLast = i - 1;
 
772
 
 
773
    ASSERT((nLast != -1) && (nFirst != -1));
 
774
}
 
775
 
 
776
void CSizingControlBar::GetRowSizingBars(CSCBArray& arrSCBars)
 
777
{
 
778
    arrSCBars.RemoveAll();
 
779
 
 
780
    int nFirst, nLast, nThis;
 
781
    GetRowInfo(nFirst, nLast, nThis);
 
782
 
 
783
    for (int i = nFirst; i <= nLast; i++)
 
784
    {
 
785
        CControlBar* pBar = (CControlBar*)m_pDockBar->m_arrBars[i];
 
786
        if (HIWORD(pBar) == 0) continue; // placeholder
 
787
        if (!pBar->IsVisible()) continue;
 
788
        if (FindSizingBar(pBar) >= 0)
 
789
            arrSCBars.Add((CSizingControlBar*)pBar);
 
790
    }
 
791
}
 
792
 
 
793
const int CSizingControlBar::FindSizingBar(CControlBar* pBar) const
 
794
{
 
795
    for (int nPos = 0; nPos < m_arrBars.GetSize(); nPos++)
 
796
        if (m_arrBars[nPos] == pBar)
 
797
            return nPos; // got it
 
798
 
 
799
    return -1; // not found
 
800
}
 
801
 
 
802
BOOL CSizingControlBar::NegociateSpace(int nLengthAvail, BOOL bHorz)
 
803
{
 
804
    ASSERT(bHorz == IsHorzDocked());
 
805
 
 
806
    int nFirst, nLast, nThis;
 
807
    GetRowInfo(nFirst, nLast, nThis);
 
808
 
 
809
    // step 1: subtract the visible fixed bars' lengths
 
810
    for (int i = nFirst; i <= nLast; i++)
 
811
    {
 
812
        CControlBar* pFBar = (CControlBar*)m_pDockBar->m_arrBars[i];
 
813
        if (HIWORD(pFBar) == 0) continue; // placeholder
 
814
        if (!pFBar->IsVisible() || (FindSizingBar(pFBar) >= 0)) continue;
 
815
 
 
816
        CRect rcBar;
 
817
        pFBar->GetWindowRect(&rcBar);
 
818
 
 
819
        nLengthAvail -= (bHorz ? rcBar.Width() - 2 : rcBar.Height() - 2);
 
820
    }
 
821
 
 
822
    CSCBArray arrSCBars;
 
823
    GetRowSizingBars(arrSCBars);
 
824
    CSizingControlBar* pBar;
 
825
 
 
826
    // step 2: compute actual and min lengths; also the common width
 
827
    int nActualLength = 0;
 
828
    int nMinLength = 2;
 
829
    int nWidth = 0;
 
830
    for (i = 0; i < arrSCBars.GetSize(); i++)
 
831
    {
 
832
        pBar = arrSCBars[i];
 
833
        nActualLength += bHorz ? pBar->m_szHorz.cx - 2 :
 
834
            pBar->m_szVert.cy - 2;
 
835
        nMinLength += bHorz ? pBar->m_szMin.cx - 2:
 
836
            pBar->m_szMin.cy - 2;
 
837
        nWidth = max(nWidth, bHorz ? pBar->m_szHorz.cy :
 
838
            pBar->m_szVert.cx);
 
839
    }
 
840
    
 
841
    // step 3: pop the bar out of the row if not enough room
 
842
    if (nMinLength > nLengthAvail)
 
843
    {
 
844
        if (nFirst < nThis || nThis < nLast)
 
845
        {   // not enough room - create a new row
 
846
            m_pDockBar->m_arrBars.InsertAt(nLast + 1, this);
 
847
            m_pDockBar->m_arrBars.InsertAt(nLast + 1, (CControlBar*) NULL);
 
848
            m_pDockBar->m_arrBars.RemoveAt(nThis);
 
849
        }
 
850
        return FALSE;
 
851
    }
 
852
 
 
853
    // step 4: make the bars same width
 
854
    for (i = 0; i < arrSCBars.GetSize(); i++)
 
855
        if (bHorz)
 
856
            arrSCBars[i]->m_szHorz.cy = nWidth;
 
857
        else
 
858
            arrSCBars[i]->m_szVert.cx = nWidth;
 
859
 
 
860
    if (nActualLength == nLengthAvail)
 
861
        return TRUE; // no change
 
862
 
 
863
    // step 5: distribute the difference between the bars, but
 
864
    //         don't shrink them below minsize
 
865
    int nDelta = nLengthAvail - nActualLength;
 
866
 
 
867
    while (nDelta != 0)
 
868
    {
 
869
        int nDeltaOld = nDelta;
 
870
        for (i = 0; i < arrSCBars.GetSize(); i++)
 
871
        {
 
872
            pBar = arrSCBars[i];
 
873
            int nLMin = bHorz ? pBar->m_szMin.cx : pBar->m_szMin.cy;
 
874
            int nL = bHorz ? pBar->m_szHorz.cx : pBar->m_szVert.cy;
 
875
            
 
876
            if ((nL == nLMin) && (nDelta < 0) || // already at min length
 
877
                pBar->m_bKeepSize) // or wants to keep its size
 
878
                continue;
 
879
            
 
880
            // sign of nDelta
 
881
            int nDelta2 = (nDelta == 0) ? 0 : ((nDelta < 0) ? -1 : 1);
 
882
 
 
883
            (bHorz ? pBar->m_szHorz.cx : pBar->m_szVert.cy) += nDelta2;
 
884
            nDelta -= nDelta2;
 
885
            if (nDelta == 0) break;
 
886
        }
 
887
        // clear m_bKeepSize flags
 
888
        if ((nDeltaOld == nDelta) || (nDelta == 0))
 
889
            for (i = 0; i < arrSCBars.GetSize(); i++)
 
890
                arrSCBars[i]->m_bKeepSize = FALSE;
 
891
    }
 
892
 
 
893
    return TRUE;
 
894
}
 
895
 
 
896
void CSizingControlBar::AlignControlBars()
 
897
{
 
898
    int nFirst, nLast, nThis;
 
899
    GetRowInfo(nFirst, nLast, nThis);
 
900
 
 
901
    BOOL bHorz = IsHorzDocked();
 
902
    BOOL bNeedRecalc = FALSE;
 
903
    int nPos, nAlign = bHorz ? -2 : 0;
 
904
 
 
905
    CRect rc, rcDock;
 
906
    m_pDockBar->GetWindowRect(&rcDock);
 
907
 
 
908
    for (int i = nFirst; i <= nLast; i++)
 
909
    {
 
910
        CControlBar* pBar = (CControlBar*)m_pDockBar->m_arrBars[i];
 
911
        if (HIWORD(pBar) == 0) continue; // placeholder
 
912
        if (!pBar->IsVisible()) continue;
 
913
 
 
914
        pBar->GetWindowRect(&rc);
 
915
        rc.OffsetRect(-rcDock.TopLeft());
 
916
 
 
917
        if ((nPos = FindSizingBar(pBar)) >= 0)
 
918
            rc = CRect(rc.TopLeft(), bHorz ?
 
919
                m_arrBars[nPos]->m_szHorz : m_arrBars[nPos]->m_szVert);
 
920
 
 
921
        if ((bHorz ? rc.left : rc.top) != nAlign)
 
922
        {
 
923
            if (!bHorz)
 
924
                rc.OffsetRect(0, nAlign - rc.top - 2);
 
925
            else if (m_nDockBarID == AFX_IDW_DOCKBAR_TOP)
 
926
                rc.OffsetRect(nAlign - rc.left, -2);
 
927
            else
 
928
                rc.OffsetRect(nAlign - rc.left, 0);
 
929
            pBar->MoveWindow(rc);
 
930
            bNeedRecalc = TRUE;
 
931
        }
 
932
        nAlign += (bHorz ? rc.Width() : rc.Height()) - 2;
 
933
    }
 
934
 
 
935
    if (bNeedRecalc)
 
936
    {
 
937
        m_pDockSite->DelayRecalcLayout();
 
938
        TRACE("ccc\n");
 
939
    }
 
940
}
 
941
 
 
942
void CSizingControlBar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler)
 
943
{
 
944
    BOOL bNeedPaint = FALSE;
 
945
 
 
946
    CPoint pt;
 
947
    ::GetCursorPos(&pt);
 
948
    BOOL bHit = (OnNcHitTest(pt) == HTCLOSE);
 
949
    BOOL bLButtonDown = (::GetKeyState(VK_LBUTTON) < 0);
 
950
 
 
951
    BOOL bWasPushed = m_biHide.bPushed;
 
952
    m_biHide.bPushed = bHit && bLButtonDown;
 
953
 
 
954
    BOOL bWasRaised = m_biHide.bRaised;
 
955
    m_biHide.bRaised = bHit && !bLButtonDown;
 
956
 
 
957
    bNeedPaint |= (m_biHide.bPushed ^ bWasPushed) || 
 
958
                  (m_biHide.bRaised ^ bWasRaised);
 
959
 
 
960
    if (bNeedPaint)
 
961
        SendMessage(WM_NCPAINT);
 
962
}
 
963
 
 
964
void CSizingControlBar::LoadState(LPCTSTR lpszProfileName)
 
965
{
 
966
    ASSERT_VALID(this);
 
967
    ASSERT(GetSafeHwnd()); // must be called after Create()
 
968
 
 
969
    CWinApp* pApp = AfxGetApp();
 
970
 
 
971
    TCHAR szSection[256];
 
972
    wsprintf(szSection, _T("%s-SCBar-%d"), lpszProfileName,
 
973
        GetDlgCtrlID());
 
974
 
 
975
    m_szHorz.cx = max(m_szMin.cx, (int) pApp->GetProfileInt(szSection,
 
976
        _T("sizeHorzCX"), m_szHorz.cx));
 
977
    m_szHorz.cy = max(m_szMin.cy, (int) pApp->GetProfileInt(szSection, 
 
978
        _T("sizeHorzCY"), m_szHorz.cy));
 
979
 
 
980
    m_szVert.cx = max(m_szMin.cx, (int) pApp->GetProfileInt(szSection, 
 
981
        _T("sizeVertCX"), m_szVert.cx));
 
982
    m_szVert.cy = max(m_szMin.cy, (int) pApp->GetProfileInt(szSection, 
 
983
        _T("sizeVertCY"), m_szVert.cy));
 
984
 
 
985
    m_szFloat.cx = max(m_szMin.cx, (int) pApp->GetProfileInt(szSection,
 
986
        _T("sizeFloatCX"), m_szFloat.cx));
 
987
    m_szFloat.cy = max(m_szMin.cy, (int) pApp->GetProfileInt(szSection,
 
988
        _T("sizeFloatCY"), m_szFloat.cy));
 
989
}
 
990
 
 
991
void CSizingControlBar::SaveState(LPCTSTR lpszProfileName)
 
992
{
 
993
    // place your SaveState or GlobalSaveState call in
 
994
    // CMainFrame::DestroyWindow(), not in OnDestroy()
 
995
    ASSERT_VALID(this);
 
996
    ASSERT(GetSafeHwnd());
 
997
 
 
998
    CWinApp* pApp = AfxGetApp();
 
999
 
 
1000
    TCHAR szSection[256];
 
1001
    wsprintf(szSection, _T("%s-SCBar-%d"), lpszProfileName,
 
1002
        GetDlgCtrlID());
 
1003
 
 
1004
    pApp->WriteProfileInt(szSection, _T("sizeHorzCX"), m_szHorz.cx);
 
1005
    pApp->WriteProfileInt(szSection, _T("sizeHorzCY"), m_szHorz.cy);
 
1006
 
 
1007
    pApp->WriteProfileInt(szSection, _T("sizeVertCX"), m_szVert.cx);
 
1008
    pApp->WriteProfileInt(szSection, _T("sizeVertCY"), m_szVert.cy);
 
1009
 
 
1010
    pApp->WriteProfileInt(szSection, _T("sizeFloatCX"), m_szFloat.cx);
 
1011
    pApp->WriteProfileInt(szSection, _T("sizeFloatCY"), m_szFloat.cy);
 
1012
}
 
1013
 
 
1014
void CSizingControlBar::GlobalLoadState(LPCTSTR lpszProfileName)
 
1015
{
 
1016
    for (int i = 0; i < m_arrBars.GetSize(); i++)
 
1017
        ((CSizingControlBar*) m_arrBars[i])->LoadState(lpszProfileName);
 
1018
}
 
1019
 
 
1020
void CSizingControlBar::GlobalSaveState(LPCTSTR lpszProfileName)
 
1021
{
 
1022
    for (int i = 0; i < m_arrBars.GetSize(); i++)
 
1023
        ((CSizingControlBar*) m_arrBars[i])->SaveState(lpszProfileName);
 
1024
}
 
1025
 
 
1026
/////////////////////////////////////////////////////////////////////////
 
1027
// CSCBButton
 
1028
 
 
1029
CSCBButton::CSCBButton()
 
1030
{
 
1031
    bRaised = FALSE;
 
1032
    bPushed = FALSE;
 
1033
}
 
1034
 
 
1035
void CSCBButton::Paint(CDC* pDC)
 
1036
{
 
1037
    CRect rc = GetRect();
 
1038
 
 
1039
    if (bPushed)
 
1040
        pDC->Draw3dRect(rc, ::GetSysColor(COLOR_BTNSHADOW),
 
1041
            ::GetSysColor(COLOR_BTNHIGHLIGHT));
 
1042
    else
 
1043
        if (bRaised)
 
1044
            pDC->Draw3dRect(rc, ::GetSysColor(COLOR_BTNHIGHLIGHT),
 
1045
                ::GetSysColor(COLOR_BTNSHADOW));
 
1046
 
 
1047
    COLORREF clrOldTextColor = pDC->GetTextColor();
 
1048
    pDC->SetTextColor(::GetSysColor(COLOR_BTNTEXT));
 
1049
    int nPrevBkMode = pDC->SetBkMode(TRANSPARENT);
 
1050
    CFont font;
 
1051
    int ppi = pDC->GetDeviceCaps(LOGPIXELSX);
 
1052
    int pointsize = MulDiv(60, 96, ppi); // 6 points at 96 ppi
 
1053
    font.CreatePointFont(pointsize, _T("Marlett"));
 
1054
    CFont* oldfont = pDC->SelectObject(&font);
 
1055
 
 
1056
    pDC->TextOut(ptOrg.x + 2, ptOrg.y + 2, CString(_T("r"))); // x-like
 
1057
    
 
1058
    pDC->SelectObject(oldfont);
 
1059
    pDC->SetBkMode(nPrevBkMode);
 
1060
    pDC->SetTextColor(clrOldTextColor);
 
1061
}