]> git.karo-electronics.de Git - karo-tx-redboot.git/blob - tools/src/tools/testtool/win32/FileListBox.cpp
f0dedae770dd979145930370363eddb3f0b7d3a7
[karo-tx-redboot.git] / tools / src / tools / testtool / win32 / FileListBox.cpp
1 //####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 // FileListBox.cpp : implementation file
26 //
27
28 #include "stdafx.h"
29 #include "FileListBox.h"
30 #include "TestToolRes.h"                // main symbols
31
32 #ifdef _DEBUG
33 #define new DEBUG_NEW
34 #undef THIS_FILE
35 static char THIS_FILE[] = __FILE__;
36 #endif
37
38 /////////////////////////////////////////////////////////////////////////////
39 // CFileListBox
40
41 CFileListBox::CFileListBox()
42 {
43 }
44
45 CFileListBox::~CFileListBox()
46 {
47 }
48
49
50 BEGIN_MESSAGE_MAP(CFileListBox, CCheckListBox)
51         //{{AFX_MSG_MAP(CFileListBox)
52         ON_WM_CONTEXTMENU()
53         ON_COMMAND(IDC_TT_REMOVE, OnRemove)
54         ON_COMMAND(IDC_TT_ADD, OnAdd)
55         ON_WM_KEYDOWN()
56         //}}AFX_MSG_MAP
57 END_MESSAGE_MAP()
58
59 /////////////////////////////////////////////////////////////////////////////
60 // CFileListBox message handlers
61
62 void CFileListBox::OnContextMenu(CWnd* pWnd, CPoint point) 
63 {
64     UNUSED_ALWAYS(pWnd);
65         CMenu menu;
66         menu.LoadMenu(IDR_TT_CONTEXTMENU);
67         CMenu *pPopup=menu.GetSubMenu(0);
68     /*
69     ScreenToClient(&point);
70     BOOL bOutside;
71     m_nIndex=ItemFromPoint(point,bOutside);
72     CRect rect;
73     GetItemRect(m_nIndex,rect);
74     if(bOutside || !rect.PtInRect(point)){
75         pPopup->EnableMenuItem(IDC_TT_REMOVE,MF_BYCOMMAND|MF_GRAYED);
76     }
77     ClientToScreen(&point);
78     */
79     for(int i=0;i<GetCount();i++){
80         if(GetSel(i)){
81             break;
82         }
83     }
84     if(i==GetCount()){
85         pPopup->EnableMenuItem(IDC_TT_REMOVE,MF_BYCOMMAND|MF_GRAYED);
86     }
87
88         pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, point.x,point.y,this);
89 }
90
91 void CFileListBox::OnRemove() 
92 {
93     bool *arb=new bool[GetCount()];
94     for(int i=0;i<GetCount();i++){
95         arb[i]=(GetSel(i)>0);
96     }
97     for(i=GetCount()-1;i>=0;--i){
98         if(arb[i]){
99             DeleteString(i);
100         }
101     }
102     delete [] arb;
103 }
104
105 void CFileListBox::OnAdd() 
106 {
107     GetParent()->SendMessage(WM_COMMAND,IDC_TT_ADD,0);
108 }
109
110 void CFileListBox::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
111 {
112     if(VK_DELETE==nChar){
113         SendMessage(WM_COMMAND,IDC_TT_REMOVE,0);
114     } else {
115             CCheckListBox::OnKeyDown(nChar, nRepCnt, nFlags);
116     }
117 }