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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [configtool/] [common/] [win32/] [messagebox.h] - 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
//===========================================================================
23
//===========================================================================
24
//#####DESCRIPTIONBEGIN####
25
//
26
// Author(s):   sdf
27
// Contact(s):  sdf
28
// Date:                1998/10/06
29
// Version:             0.01
30
// Purpose:     
31
// Description: This is the interface of the messagebox class
32
// Requires:    
33
// Provides:    
34
// See also:    
35
// Known bugs:  
36
// Usage:       
37
//
38
//####DESCRIPTIONEND####
39
//
40
//===========================================================================
41
#if !defined(AFX_MessageBox_H__A7F011B1_4736_11D2_B377_444553540000__INCLUDED_)
42
#define AFX_MessageBox_H__A7F011B1_4736_11D2_B377_444553540000__INCLUDED_
43
 
44
#if _MSC_VER >= 1000
45
#pragma once
46
#endif // _MSC_VER >= 1000
47
 
48
/////////////////////////////////////////////////////////////////////////////
49
//
50
// CMessageBox dialog
51
// Simon FitzMaurice, October 1998
52
//
53
// CMessageBox replicates the functionality of CWnd::MessageBox(), but also
54
// allows the creation of custom and modeless messageboxes.
55
//
56
// Use the 3-parameter constructor and DoModal() to obtain the usual results.
57
// [Create() may be used to invoke a modeless dialog]
58
// All flags described in "Message-Box Styles" are supported with the
59
// exception of MB_TASKMODAL (not useful within an MFC app).
60
// In addition, two new styles are available: MB_YESNOALL and MB_YESNOALLCANCEL.  These
61
// add "Yes All" and "No All" buttons to the normal MB_YESNO and MB_YESNOCANCEL,
62
// respectively (with ids of IDYESALL and IDNOALL).  The MB_DEFBUTTON(n) macro 
63
// may be used to extend extend the series MB_DEFBUTTON1, MB_DEFBUTTON2, 
64
// MB_DEFBUTTON3 ...
65
//
66
// Use the parameterless constructor to customize the messagebox.  Buttons must
67
// be added [using AddButton()] and other attributes changed before calling 
68
// DoModal() or Create().
69
//
70
// In the case of Create(), the CMessageBox object must be allocated on the heap;
71
// it deletes itself when the dialog is dismissed.  The parameters of Create()
72
// may be used to specify that the parent be sent a notification message when 
73
// this happens.
74
//
75
/////////////////////////////////////////////////////////////////////////////
76
 
77
#define MB_YESNOALL 13
78
#define MB_YESNOALLCANCEL 14
79
 
80
// Extend the series MB_DEFBUTTON1, MB_DEFBUTTON2, MB_DEFBUTTON3 ...
81
#define MB_DEFBUTTON(n) ((n<<8)&MB_DEFMASK)
82
 
83
#define IDYESALL 14
84
#define IDNOALL 15
85
 
86
#include <afxtempl.h>
87
 
88
class CMessageBox : public CDialog
89
{
90
        // Construction
91
public:
92
 
93
        // Ctor to build standard messagebox:
94
        CMessageBox(const CString &strText,const CString &strCaption=_T("Error"),UINT Flag=MB_OK);  // standard constructor
95
 
96
        // Use this ctor if using custom buttons:
97
        CMessageBox();
98
 
99
        virtual  ~CMessageBox();
100
 
101
        // Run the messagebox as a modeless dialog.  If msg is non-zero, post pWnd 
102
        // msg when the dialog is dismissed.  The loword of wParam of msg will 
103
        // contain the id of the button clicked and the hiword wParamHigh.  By 
104
        // specifying msg as WM_COMMAND and wParamHigh as BN_CLICKED (the default 
105
        // values), ON_BN_CLICKED handlers may be used.
106
        BOOL Create(CWnd *pWnd=NULL,UINT msg=0,WORD wParamHigh=BN_CLICKED);
107
 
108
        // Set the caption
109
        void SetCaption (const CString &strCaption);
110
 
111
        // Set static text color (this function does not affect the color of button text)
112
        void SetTextColor(COLORREF cr){m_crText=cr;}
113
 
114
        // Make the messagebox topmost
115
        void SetTopMost() { m_bTopMost=true; }
116
 
117
        // Set the static text
118
        void SetText (const CString &str){m_strText=str;}
119
 
120
        // This member is public to allow the caller to manipulate it directly
121
        // (e.g. by means of CString::Format):
122
        CString m_strText;
123
 
124
        // Set the font (for static text and buttons)
125
        void SetFont (CFont *pFont){m_pFont=pFont;}
126
 
127
        // Justify text left, center or right
128
        void SetTextJustification (UINT n) { ASSERT(SS_LEFT==n||SS_CENTER==n||SS_RIGHT==n); m_nJustify=n; }
129
 
130
        // Add a button with given caption, id and whether enabled:
131
        void AddButton (const CString &strCaption,UINT id, bool bEnabled=true);
132
 
133
        // Set the nth button as default
134
        void SetDefaultButton (UINT nIndex);
135
 
136
        // Count of buttons created
137
        UINT ButtonCount() const { return (UINT)m_arBInfo.GetSize(); }
138
 
139
        // Look up a button by its id.  If the button is not found, -1 is returned.
140
        int IndexOf (UINT id);
141
 
142
        // Overrides
143
        // ClassWizard generated virtual function overrides
144
        //{{AFX_VIRTUAL(CMessageBox)
145
        public:
146
        virtual BOOL PreTranslateMessage(MSG* pMsg);
147
        protected:
148
        virtual void PostNcDestroy();
149
        //}}AFX_VIRTUAL
150
 
151
// Implementation
152
protected:
153
        bool m_bDialogCreated;
154
        CWnd *m_pParentNotify; // Window to tell about dismissal
155
        UINT m_nParentNotifcationMessage;        // Message to send
156
        WORD m_nParentNotifcationwParamHigh; // hi of wParam
157
        bool m_bModeless;
158
        COLORREF m_crText; // Text and button color
159
 
160
        void Init();
161
 
162
        // Dialog Data
163
        typedef struct {
164
                DLGTEMPLATE tmpl;
165
                short wMenu[1];
166
                short wClass[1];
167
                short wTitle[1];
168
        } DLGDATA;
169
        static DLGDATA DlgData;
170
 
171
        // Per-button information
172
        struct CButtonInfo {
173
                UINT m_id;
174
                bool m_bEnabled;
175
                CString m_strCaption;
176
                CButton *m_pWnd;
177
        public:
178
                CButtonInfo (UINT id=0,bool bEnabled=false,const CString &strCaption=_T("")):
179
                        m_id(id),
180
                        m_bEnabled(bEnabled),
181
                        m_strCaption(strCaption),
182
                        m_pWnd(NULL)
183
                        {}
184
        };
185
        CArray<CButtonInfo,CButtonInfo&> m_arBInfo;
186
 
187
        int m_nEscapeButton;
188
        int m_nJustify; // SS_LEFT,SS_CENTER or SS_RIGHT
189
        CButton &Button(int nIndex) const{return *(m_arBInfo[nIndex].m_pWnd);}
190
        HICON m_hIcon;
191
        bool m_bTopMost;
192
        CString m_strCaption;
193
        int m_nFocusButton;
194
        UINT m_nDefaultButton;
195
 
196
        CStatic * m_pStaticText;
197
        CStatic * m_pStaticIcon;
198
 
199
        CFont   * m_pFont;
200
 
201
        // Generated message map functions
202
        //{{AFX_MSG(CMessageBox)
203
        virtual BOOL OnInitDialog();
204
        afx_msg void OnFontChange();
205
        afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
206
        afx_msg void OnClose();
207
        //}}AFX_MSG
208
        afx_msg void OnButton(UINT);
209
        DECLARE_MESSAGE_MAP()
210
};
211
 
212
int MessageBoxEx (const CString &strText,const CString &strCaption,UINT Flag);
213
 
214
//{{AFX_INSERT_LOCATION}}
215
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
216
 
217
#endif // !defined(AFX_MessageBox_H__A7F011B1_4736_11D2_B377_444553540000__INCLUDED_)

powered by: WebSVN 2.1.0

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