OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [tools/] [configtool/] [common/] [win32/] [SplitterWndEx.cpp] - Blame information for rev 574

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 unneback
//####COPYRIGHTBEGIN####
2
//                                                                          
3
// ----------------------------------------------------------------------------
4
// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
5
//
6
// This program is part of the eCos host tools.
7
//
8
// This program is free software; you can redistribute it and/or modify it 
9
// under the terms of the GNU General Public License as published by the Free 
10
// Software Foundation; either version 2 of the License, or (at your option) 
11
// any later version.
12
// 
13
// This program is distributed in the hope that it will be useful, but WITHOUT 
14
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
15
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
16
// more details.
17
// 
18
// You should have received a copy of the GNU General Public License along with
19
// this program; if not, write to the Free Software Foundation, Inc., 
20
// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
//
22
// ----------------------------------------------------------------------------
23
//                                                                          
24
//####COPYRIGHTEND####
25
//
26
//===========================================================================
27
//#####DESCRIPTIONBEGIN####
28
//
29
// Author(s):   sdf
30
// Contact(s):  sdf
31
// Date:                1998/08/11
32
// Version:             0.01
33
// Purpose:     
34
// Description: This is the implementation of the extended splitter window class.
35
// Requires:    
36
// Provides:    
37
// See also:    
38
// Known bugs:  
39
// Usage:       
40
//
41
//####DESCRIPTIONEND####
42
//
43
//===========================================================================
44
#include "stdafx.h"
45
#include "SplitterWndEx.h"
46
 
47
#ifdef _DEBUG
48
#define new DEBUG_NEW
49
#undef THIS_FILE
50
static char THIS_FILE[] = __FILE__;
51
#endif
52
 
53
////////////////////////////////////////////////////////////////////////////
54
//
55
// CSplitterWndEx
56
 
57
CSplitterWndEx::CSplitterWndEx():
58
        m_fRowColumnRatio(0.0)
59
{
60
        m_bParentHide=FALSE;
61
        m_pwnd1=m_pwnd2=NULL;
62
}
63
 
64
BEGIN_MESSAGE_MAP(CSplitterWndEx, CSplitterWnd)
65
//{{AFX_MSG_MAP(CSplitterWndEx)
66
        ON_WM_MOUSEWHEEL()
67
        ON_WM_SIZE()
68
        //}}AFX_MSG_MAP
69
END_MESSAGE_MAP()
70
 
71
void CSplitterWndEx::ShowPane(CWnd * pWnd,BOOL bShow)
72
{
73
        if(m_pwnd1==NULL){
74
                m_pwnd1=GetPane(0,0);
75
                m_pwnd2=GetPane(!IsHorizontal(),IsHorizontal());
76
        }
77
 
78
        ASSERT(pWnd==m_pwnd1 || pWnd==m_pwnd2);
79
 
80
        int &nRowCols=IsHorizontal()?m_nCols:m_nRows;
81
 
82
        if(bShow){
83
                if(!pWnd->IsWindowVisible()){
84
                        if(m_bParentHide){
85
                                ((CSplitterWndEx *)GetParent())->ShowPane(this,TRUE);
86
                                // Ensure the correct pane reappears
87
                                if(GetPane(0,0)!=pWnd){
88
                                        // Need to swap the entries
89
                                        SwapRowColInfo();
90
                                }
91
                                m_bParentHide=FALSE;
92
                        } else { // maybe nothing to do
93
                                nRowCols++;
94
                                if(pWnd==m_pwnd1){
95
                                        // Need to swap the entries
96
                                        SwapRowColInfo();
97
                                }
98
                        }
99
 
100
                        pWnd->ShowWindow(SW_SHOW);
101
                }
102
                if(pWnd==m_pwnd1){
103
                        m_pwnd1->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
104
                        m_pwnd2->SetDlgCtrlID(AFX_IDW_PANE_FIRST+(IsHorizontal()?1:16));
105
                }
106
        } else {
107
                if(pWnd->IsWindowVisible()){
108
 
109
                        pWnd->ShowWindow(SW_HIDE);
110
                        if(nRowCols == 1) {
111
                                m_bParentHide=TRUE;
112
                                ((CSplitterWndEx *)GetParent())->ShowPane(this,FALSE);
113
                        } else {
114
                                // Both panes currently active
115
                                int rowActive, colActive;
116
                                if (GetActivePane(&rowActive, &colActive) != NULL && pWnd==GetPane(rowActive, colActive)){
117
          int bHorz=IsHorizontal();
118
                                        SetActivePane((!bHorz)&(rowActive^1), (bHorz)&(colActive^1));
119
                                }
120
                                if(pWnd==m_pwnd1){
121
                                        SwapRowColInfo();
122
                                        m_pwnd2->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
123
                                        m_pwnd1->SetDlgCtrlID(AFX_IDW_PANE_FIRST+1);
124
                                }
125
                                nRowCols--;
126
                        }
127
                }
128
        }
129
        RecalcLayout();
130
}
131
 
132
void CSplitterWndEx::SwapRowColInfo()
133
{
134
        CRowColInfo*& pRowColInfo=IsHorizontal()?m_pColInfo:m_pRowInfo;
135
 
136
        // Need to swap the entries
137
        CRowColInfo save;
138
        memcpy(&save,&pRowColInfo[0],sizeof CRowColInfo);
139
        memcpy(&pRowColInfo[0],&pRowColInfo[1],sizeof CRowColInfo);
140
        memcpy(&pRowColInfo[1],&save,sizeof CRowColInfo);
141
}
142
 
143
 
144
// We do this because the CSplitterWnd implementation assumes both children are derived
145
// from CScrollView - so here we just let the children handle the message themselves.
146
BOOL CSplitterWndEx::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
147
{
148
        return TRUE;
149
        UNUSED_ALWAYS(nFlags);
150
        UNUSED_ALWAYS(zDelta);
151
        UNUSED_ALWAYS(pt);
152
}
153
 
154
void CSplitterWndEx::OnSize(UINT nType, int cx, int cy)
155
{
156
        int &nRowCols=IsHorizontal()?m_nCols:m_nRows;
157
        CRowColInfo *&RowColInfo=IsHorizontal()?m_pColInfo:m_pRowInfo;
158
        if(nRowCols>1 && (cx|cy) && m_fRowColumnRatio!=0.0){
159
                RowColInfo[0].nIdealSize=int(0.5 + m_fRowColumnRatio * double(IsHorizontal()?cx:cy));
160
        }
161
        CSplitterWnd::OnSize( nType, cx, cy );
162
}
163
 
164
void CSplitterWndEx::RecalcLayout()
165
{
166
        CSplitterWnd::RecalcLayout();
167
        CRowColInfo *&RowColInfo=IsHorizontal()?m_pColInfo:m_pRowInfo;
168
        int &nRowCols=IsHorizontal()?m_nCols:m_nRows;
169
        if (nRowCols==2 && RowColInfo[0].nCurSize && RowColInfo[1].nCurSize){
170
                CRect rect;
171
                GetClientRect(rect);
172
                m_fRowColumnRatio=double(RowColInfo[0].nCurSize)/double(IsHorizontal()?rect.Width():rect.Height());
173
        }
174
}
175
 
176
double CSplitterWndEx::GetSplitPoint()
177
{
178
  return m_fRowColumnRatio;
179
}
180
 
181
void CSplitterWndEx::SetSplitPoint(double fSplit)
182
{
183
  m_fRowColumnRatio=fSplit;
184
  CRect rc;
185
  GetClientRect(rc);
186
  OnSize(SIZE_RESTORED,rc.Width(),rc.Height());
187
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.