Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PlayerNavigationBar.cpp « mpc-hc « src - github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 04c21e4ed1ad0b0396ef2e8985d7420efaa2de9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
 * (C) 2010-2014 see Authors.txt
 *
 * This file is part of MPC-HC.
 *
 * MPC-HC is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * MPC-HC is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include "stdafx.h"
#include "PlayerNavigationBar.h"
#include "DSUtil.h"
#include "mplayerc.h"

// CPlayerNavigationBar

IMPLEMENT_DYNAMIC(CPlayerNavigationBar, CPlayerBar)
CPlayerNavigationBar::CPlayerNavigationBar(CMainFrame* pMainFrame)
    : m_pParent(nullptr)
    , m_navdlg(pMainFrame)
{
}

BOOL CPlayerNavigationBar::Create(CWnd* pParentWnd, UINT defDockBarID)
{
    if (!CPlayerBar::Create(ResStr(IDS_NAVIGATION_BAR), pParentWnd, ID_VIEW_NAVIGATION, defDockBarID, _T("Navigation Bar"))) {
        return FALSE;
    }

    m_pParent = pParentWnd;
    m_navdlg.Create(this);
    m_navdlg.ShowWindow(SW_SHOWNORMAL);

    CRect r;
    m_navdlg.GetWindowRect(r);
    m_szMinVert = m_szVert = r.Size();
    m_szMinHorz = m_szHorz = r.Size();
    m_szMinFloat = m_szFloat = r.Size();
    m_bFixedFloat = true;
    m_szFixedFloat = r.Size();

    return TRUE;
}

void CPlayerNavigationBar::ReloadTranslatableResources()
{
    SetWindowText(ResStr(IDS_NAVIGATION_BAR));

    m_navdlg.DestroyWindow();
    m_navdlg.Create(this);
    CRect r;
    GetClientRect(r);
    m_navdlg.MoveWindow(r);
    m_navdlg.UpdateElementList();
    m_navdlg.ShowWindow(SW_SHOWNORMAL);
}

static WNDPROC g_parentFrameOrigWndProc = nullptr;
LRESULT CALLBACK ParentFrameSubclassWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    ASSERT(g_parentFrameOrigWndProc);
    if (message == WM_SYSCOMMAND && wParam == SC_CLOSE) {
        AfxGetAppSettings().fHideNavigation = true;
    }
    return CallWindowProc(g_parentFrameOrigWndProc, hwnd, message, wParam, lParam);
}

void CPlayerNavigationBar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler)
{
    __super::OnUpdateCmdUI(pTarget, bDisableIfNoHndler);

    m_navdlg.UpdateDialogControls(&m_navdlg, bDisableIfNoHndler);
}

BOOL CPlayerNavigationBar::PreTranslateMessage(MSG* pMsg)
{
    if (CWnd* pParent1 = GetParent()) {
        CWnd* pParent2 = pParent1->GetParent();
        if (pParent2 != m_pParent) {
            if (!g_parentFrameOrigWndProc) {
                g_parentFrameOrigWndProc = SubclassWindow(pParent2->m_hWnd, ParentFrameSubclassWndProc);
            }
        } else {
            g_parentFrameOrigWndProc = nullptr;
        }
    }

    if (IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) {
        if (IsDialogMessage(pMsg)) {
            return TRUE;
        }
    }

    return __super::PreTranslateMessage(pMsg);
}

BEGIN_MESSAGE_MAP(CPlayerNavigationBar, CPlayerBar)
    ON_WM_SIZE()
    ON_WM_NCLBUTTONUP()
END_MESSAGE_MAP()

// CPlayerNavigationBar message handlers

void CPlayerNavigationBar::OnSize(UINT nType, int cx, int cy)
{
    __super::OnSize(nType, cx, cy);
    if (::IsWindow(m_navdlg.m_hWnd)) {
        CRect r;
        GetClientRect(r);
        m_navdlg.MoveWindow(r);
    }
}

void CPlayerNavigationBar::OnNcLButtonUp(UINT nHitTest, CPoint point)
{
    __super::OnNcLButtonUp(nHitTest, point);

    if (nHitTest == HTCLOSE) {
        AfxGetAppSettings().fHideNavigation = true;
    }
}