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

Subversion Repositories openrisc

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

powered by: WebSVN 2.1.0

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