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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [configtool/] [common/] [win32/] [SplitterWndEx.cpp] - Blame information for rev 786

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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