]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - tools/src/tools/configtool/common/win32/AddRemoveDialog.h
Initial revision
[karo-tx-redboot.git] / tools / src / tools / configtool / common / win32 / AddRemoveDialog.h
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 #if !defined(AFX_ADDREMOVEDIALOG_H__6D1D20B4_2BA5_11D3_8567_9AA54FC2F74D__INCLUDED_)
26 #define AFX_ADDREMOVEDIALOG_H__6D1D20B4_2BA5_11D3_8567_9AA54FC2F74D__INCLUDED_
27
28 #if _MSC_VER > 1000
29 #pragma once
30 #endif // _MSC_VER > 1000
31 // AddRemoveDialog.h : header file
32 //
33 #include "resource.h"
34 #include "eCosDialog.h"
35 /////////////////////////////////////////////////////////////////////////////
36 // CAddRemoveDialog dialog
37
38 class CAddRemoveDialog : public CeCosDialog
39 {
40 // Construction
41 private:
42         void AfxDataInit();
43 public:
44         void SetHorizontalResizingLimit (int nPercent=100);
45         void SetMessage (LPCTSTR pszText1,LPCTSTR pszText2);
46         void SetCaption (LPCTSTR pszCaption);
47     void SetSortMode (bool bSort) { m_bSort=bSort; }
48         
49     // Use this function to prepopulate the two list boxes:
50     // The optional third parameter sets the descriptions (to be displayed
51     // when the given item is the sole selected in a listbox)
52         void Insert (LPCTSTR pszItem,bool bAdded,LPCTSTR pszDesc=NULL);
53         
54     // Use these functions to determine results after the dialog has been run:
55     // (will assert for items not previously inserted)
56     bool IsAdded(LPCTSTR pszItem) const;
57     bool IsAdded(int nIndex) const { return 0!=m_arnItems[nIndex]; }
58     
59     // Can be used at any time:
60     int GetCount() const { return m_arnItems.GetSize(); }
61
62     CAddRemoveDialog(CWnd* pParent = NULL);   // standard constructor
63     CAddRemoveDialog(UINT nIDTemplate, CWnd* pParent = NULL); // template constructor
64
65 // Dialog Data
66         //{{AFX_DATA(CAddRemoveDialog)
67         enum { IDD = IDD_ADDREMOVE_DIALOG };
68         CEdit           m_wndDesc;
69         CListBox        m_List2;
70         CListBox        m_List1;
71         CButton         m_Add;
72         CButton         m_Remove;
73         //}}AFX_DATA
74
75
76 // Overrides
77         // ClassWizard generated virtual function overrides
78         //{{AFX_VIRTUAL(CAddRemoveDialog)
79         public:
80         virtual BOOL PreTranslateMessage(MSG* pMsg);
81         protected:
82         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
83         //}}AFX_VIRTUAL
84
85 // Implementation
86 protected:
87         int m_nHorizontalResizingLimit;
88         bool m_bHaveDescs;
89         void UpdateDescription (CListBox &lb);
90     enum MoveType {Move,Stretch,Up};
91         void MoveChild (UINT id,int delta,MoveType how);
92         void SetSortMode(CListBox &lb);
93         int * m_arbSel;
94         CString m_strMessage1,m_strMessage2;
95         CString m_strCaption;
96
97     // Move item from lb1 to lb2
98         void Xfer (CListBox &lb1,CListBox &lp2,int nItem);
99     // Clear all selected items in a list box:
100         static void ClearSel (CListBox &lb);
101     // I have doubleclicked on lb1.  Item will be moved to lb2:
102         void OnDblclk(CListBox &lb1,CListBox &lb2);
103     // Move all selected items from lb1 to lb2:
104         int Add (CListBox &lb1,CListBox &lb2);
105
106     CStringArray m_arstrItems; // List of items
107     CStringArray m_arstrDescs; // List of descriptions
108     CDWordArray  m_arnItems;   // Whether selected (1) or not (0)
109
110     bool m_bSort;              // Whether listboxes should be sorted
111
112         // Generated message map functions
113         //{{AFX_MSG(CAddRemoveDialog)
114         afx_msg void OnAdd();
115         afx_msg void OnRemove();
116         virtual BOOL OnInitDialog();
117         afx_msg void OnDblclkList1();
118         afx_msg void OnDblclkList2();
119         afx_msg void OnSelchangeList1();
120         afx_msg void OnSelchangeList2();
121         afx_msg void OnDestroy();
122         //}}AFX_MSG
123         DECLARE_MESSAGE_MAP()
124 };
125
126 //{{AFX_INSERT_LOCATION}}
127 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
128
129 #endif // !defined(AFX_ADDREMOVEDIALOG_H__6D1D20B4_2BA5_11D3_8567_9AA54FC2F74D__INCLUDED_)