2 * Copyright (C) 2003-2006 Gabest
3 * http://www.gabest.org
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 // PlayerInfoBar.cpp : implementation file
27 #include "PlayerInfoBar.h"
33 IMPLEMENT_DYNAMIC(CPlayerInfoBar
, CDialogBar
)
34 CPlayerInfoBar::CPlayerInfoBar(int nFirstColWidth
) : m_nFirstColWidth(nFirstColWidth
)
38 CPlayerInfoBar::~CPlayerInfoBar()
42 void CPlayerInfoBar::SetLine(CString label
, CString info
)
50 for(size_t idx
= 0; idx
< m_label
.GetCount(); idx
++)
53 m_label
[idx
]->GetWindowText(tmp
);
56 m_info
[idx
]->GetWindowText(tmp
);
57 if(info
!= tmp
) m_info
[idx
]->SetWindowText(info
);
62 CAutoPtr
<CStatusLabel
> l(new CStatusLabel(true, false));
63 l
->Create(label
, WS_CHILD
|WS_VISIBLE
|WS_CLIPCHILDREN
|WS_CLIPSIBLINGS
|SS_OWNERDRAW
, CRect(0,0,0,0), this);
66 CAutoPtr
<CStatusLabel
> i(new CStatusLabel(false, true));
67 i
->Create(info
, WS_CHILD
|WS_VISIBLE
|WS_CLIPCHILDREN
|WS_CLIPSIBLINGS
|SS_OWNERDRAW
, CRect(0,0,0,0), this);
73 void CPlayerInfoBar::GetLine(CString label
, CString
& info
)
77 for(size_t idx
= 0; idx
< m_label
.GetCount(); idx
++)
80 m_label
[idx
]->GetWindowText(tmp
);
83 m_info
[idx
]->GetWindowText(tmp
);
90 void CPlayerInfoBar::RemoveLine(CString label
)
92 for(size_t i
= 0; i
< m_label
.GetCount(); i
++)
95 m_label
[i
]->GetWindowText(tmp
);
107 void CPlayerInfoBar::RemoveAllLines()
115 BOOL
CPlayerInfoBar::Create(CWnd
* pParentWnd
)
117 return CDialogBar::Create(pParentWnd
, IDD_PLAYERINFOBAR
, WS_CHILD
|WS_VISIBLE
|CBRS_ALIGN_BOTTOM
, IDD_PLAYERINFOBAR
);
120 BOOL
CPlayerInfoBar::PreCreateWindow(CREATESTRUCT
& cs
)
122 if(!CDialogBar::PreCreateWindow(cs
))
125 m_dwStyle
&= ~CBRS_BORDER_TOP
;
126 m_dwStyle
&= ~CBRS_BORDER_BOTTOM
;
131 CSize
CPlayerInfoBar::CalcFixedLayout(BOOL bStretch
, BOOL bHorz
)
134 GetParent()->GetClientRect(&r
);
135 r
.bottom
= r
.top
+ m_label
.GetCount() * 17 + (m_label
.GetCount() ? 4 : 0);
139 void CPlayerInfoBar::Relayout()
142 GetParent()->GetClientRect(&r
);
144 int w
= m_nFirstColWidth
, h
= 17, y
= 2;
146 for(size_t i
= 0; i
< m_label
.GetCount(); i
++)
148 CDC
* pDC
= m_label
[i
]->GetDC();
150 m_label
[i
]->GetWindowText(str
);
151 w
= max(w
, pDC
->GetTextExtent(str
).cx
);
152 m_label
[i
]->ReleaseDC(pDC
);
155 for(size_t i
= 0; i
< m_label
.GetCount(); i
++, y
+= h
)
157 m_label
[i
]->MoveWindow(1, y
, w
- 10, h
);
158 m_info
[i
]->MoveWindow(w
+ 10, y
, r
.Width()-(w
+10)-1, h
);
162 BEGIN_MESSAGE_MAP(CPlayerInfoBar
, CDialogBar
)
170 // CPlayerInfoBar message handlers
172 BOOL
CPlayerInfoBar::OnEraseBkgnd(CDC
* pDC
)
174 for(CWnd
* pChild
= GetWindow(GW_CHILD
); pChild
; pChild
= pChild
->GetNextWindow())
177 pChild
->GetClientRect(&r
);
178 pChild
->MapWindowPoints(this, &r
);
179 pDC
->ExcludeClipRect(&r
);
185 CMainFrame
* pFrame
= ((CMainFrame
*)GetParentFrame());
187 if(pFrame
->m_pLastBar
!= this || pFrame
->m_fFullScreen
)
188 r
.InflateRect(0, 0, 0, 1);
190 if(pFrame
->m_fFullScreen
)
191 r
.InflateRect(1, 0, 1, 0);
193 pDC
->Draw3dRect(&r
, GetSysColor(COLOR_3DSHADOW
), GetSysColor(COLOR_3DHILIGHT
));
197 pDC
->FillSolidRect(&r
, 0);
202 void CPlayerInfoBar::OnSize(UINT nType
, int cx
, int cy
)
204 CDialogBar::OnSize(nType
, cx
, cy
);
211 void CPlayerInfoBar::OnLButtonDown(UINT nFlags
, CPoint point
)
213 CMainFrame
* pFrame
= ((CMainFrame
*)GetParentFrame());
214 if(!pFrame
->m_fFullScreen
)
216 MapWindowPoints(pFrame
, &point
, 1);
217 pFrame
->PostMessage(WM_NCLBUTTONDOWN
, HTCAPTION
, MAKELPARAM(point
.x
, point
.y
));