Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Side by Side Diff: media/player/list.h

Issue 100078: media player: list management. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file.
4
5 // list.h : class for Recent Files list
6
7 #ifndef MEDIA_PLAYER_LIST_H_
8 #define MEDIA_PLAYER_LIST_H_
9
10 class CMruList : public CWindowImpl<CMruList, CListBox> {
11 public:
12
13 CMruList() {
14 m_size.cx = 400;
15 m_size.cy = 150;
16 }
17
18 HWND Create(HWND hWndParent) {
19 CWindowImpl<CMruList, CListBox>::Create(hWndParent, rcDefault, NULL,
20 WS_POPUP | WS_THICKFRAME | WS_CLIPCHILDREN | WS_CLIPSIBLINGS |
21 WS_VSCROLL | LBS_NOINTEGRALHEIGHT,
22 WS_EX_CLIENTEDGE);
23 if (IsWindow())
24 SetFont(AtlGetStockFont(DEFAULT_GUI_FONT));
25 return m_hWnd;
26 }
27
28 BOOL BuildList(CRecentDocumentList& mru) {
29 ATLASSERT(IsWindow());
30
31 ResetContent();
32
33 int nSize = mru.m_arrDocs.GetSize();
34 for (int i = 0; i < nSize; i++)
35 InsertString(0, mru.m_arrDocs[i].szDocName); // Reverse order in array.
36
37 if (nSize > 0) {
38 SetCurSel(0);
39 SetTopIndex(0);
40 }
41
42 return TRUE;
43 }
44
45 BOOL ShowList(int x, int y) {
46 return SetWindowPos(NULL, x, y, m_size.cx, m_size.cy,
47 SWP_NOZORDER | SWP_SHOWWINDOW);
48 }
49
50 void HideList() {
51 RECT rect;
52 GetWindowRect(&rect);
53 m_size.cx = rect.right - rect.left;
54 m_size.cy = rect.bottom - rect.top;
55 ShowWindow(SW_HIDE);
56 }
57
58 void FireCommand() {
59 int nSel = GetCurSel();
60 if (nSel != LB_ERR) {
61 ::SetFocus(GetParent()); // Will hide this window.
62 ::SendMessage(GetParent(), WM_COMMAND,
63 MAKEWPARAM((WORD)(ID_FILE_MRU_FIRST + nSel),
64 LBN_DBLCLK), (LPARAM)m_hWnd);
65 }
66 }
67
68 BEGIN_MSG_MAP(CMruList)
69 MESSAGE_HANDLER(WM_KEYDOWN, OnKeyDown)
70 MESSAGE_HANDLER(WM_LBUTTONDBLCLK, OnLButtonDblClk)
71 MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus)
72 MESSAGE_HANDLER(WM_NCHITTEST, OnNcHitTest)
73 END_MSG_MAP()
74
75 LRESULT OnKeyDown(UINT /*uMsg*/,
76 WPARAM wParam,
77 LPARAM /*lParam*/,
78 BOOL& bHandled) {
79 if (wParam == VK_RETURN)
80 FireCommand();
81 else
82 bHandled = FALSE;
83 return 0;
84 }
85
86 LRESULT OnLButtonDblClk(UINT /*uMsg*/,
87 WPARAM /*wParam*/,
88 LPARAM /*lParam*/,
89 BOOL& /*bHandled*/) {
90 FireCommand();
91 return 0;
92 }
93
94 LRESULT OnKillFocus(UINT /*uMsg*/,
95 WPARAM /*wParam*/,
96 LPARAM /*lParam*/,
97 BOOL& /*bHandled*/) {
98 HideList();
99 return 0;
100 }
101
102 LRESULT OnNcHitTest(UINT uMsg,
103 WPARAM wParam,
104 LPARAM lParam,
105 BOOL& /*bHandled*/) {
106 LRESULT lRet = DefWindowProc(uMsg, wParam, lParam);
107 switch (lRet) {
108 case HTLEFT:
109 case HTTOP:
110 case HTTOPLEFT:
111 case HTTOPRIGHT:
112 case HTBOTTOMLEFT:
113 lRet = HTCLIENT; // Don't allow resizing here.
114 break;
115 default:
116 break;
117 }
118 return lRet;
119 }
120
121 private:
122
123 SIZE m_size;
124 };
125
126 #endif // MEDIA_PLAYER_LIST_H_
127
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698