|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #if ! defined (MESSAGEREPORTER_H_118AA138_CDA6_46e1_9805_F9367915D3F7) |
|
23 #define MESSAGEREPORTER_H_118AA138_CDA6_46e1_9805_F9367915D3F7 |
|
24 |
|
25 #pragma warning ( disable : 4100 4245 ) |
|
26 |
|
27 #include <Statexp.h> |
|
28 #include "LogMessage.h" |
|
29 #include "WindowMessages.h" |
|
30 #include <list> |
|
31 |
|
32 ///////////////////////////////////////////////////////////////////////////// |
|
33 // MessageReporterImp |
|
34 // Concrete implementation of the class MessageReporter. |
|
35 // This class knows about the dialog window and uses Windows messages |
|
36 // to call the dialog call-back update methods. |
|
37 // Even though this class knows of the dialog class it is not wise to |
|
38 // call methods in the MFC Window class directly as we may (probably are) |
|
39 // in a different thread and calling MFC methods across treads is a bad |
|
40 // thing to do. |
|
41 ///////////////////////////////////////////////////////////////////////////// |
|
42 |
|
43 class MessageReporterImp : public MessageReporter |
|
44 { |
|
45 public: |
|
46 MessageReporterImp(HWND hWnd); |
|
47 ~MessageReporterImp(); |
|
48 |
|
49 protected: |
|
50 HWND m_hWnd; |
|
51 |
|
52 std::list<LogMessage*> logMessages; |
|
53 |
|
54 public: |
|
55 virtual void OnMessage( const char* message, const char* newtext, |
|
56 bool bMsgBox, bool bScrshot ); |
|
57 }; |
|
58 |
|
59 // These will not be implemented in-line as we are using virtual |
|
60 // meothds but putting them here saves the use of a seperate |
|
61 // source file. |
|
62 |
|
63 inline MessageReporterImp::MessageReporterImp( HWND hWnd ) |
|
64 : m_hWnd(hWnd) |
|
65 { |
|
66 ; |
|
67 } |
|
68 |
|
69 inline MessageReporterImp::~MessageReporterImp() |
|
70 { |
|
71 std::list<LogMessage*>::iterator it; |
|
72 LogMessage *logMessage = NULL; |
|
73 for( it = logMessages.begin(); it != logMessages.end(); it++ ) |
|
74 { |
|
75 logMessage = *it; |
|
76 logMessage->iMessage.Empty(); |
|
77 logMessage->iText.Empty(); |
|
78 delete logMessage; |
|
79 } |
|
80 logMessages.clear(); |
|
81 } |
|
82 |
|
83 inline void MessageReporterImp::OnMessage( const char* message, const char* text, |
|
84 bool bMsgBox, bool bScrshot ) |
|
85 { |
|
86 LogMessage *logMessage = new LogMessage; |
|
87 |
|
88 logMessage->iMessageBox = bMsgBox; |
|
89 logMessage->iScreenShot = bScrshot; |
|
90 logMessage->iMessage = message; |
|
91 logMessage->iText = text; |
|
92 |
|
93 ::PostMessage( m_hWnd, |
|
94 WM_SHOW_LOG_MESSAGE, |
|
95 0, |
|
96 reinterpret_cast<LPARAM>(logMessage) |
|
97 ); |
|
98 |
|
99 logMessages.push_back(logMessage); |
|
100 } |
|
101 |
|
102 #pragma warning ( default : 4100 4245 ) |
|
103 |
|
104 #endif // ! defined (MESSAGEREPORTER_H_118AA138_CDA6_46e1_9805_F9367915D3F7) |