1 /********************************************************************************
2 * *
3 * D e b u g - T a r g e t O b j e c t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,2005 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXDebugTarget.cpp,v 1.26 2005/01/16 16:06:06 fox Exp $ *
23 ********************************************************************************/
24 #include "xincs.h"
25 #include "fxver.h"
26 #include "fxdefs.h"
27 #include "FXHash.h"
28 #include "FXStream.h"
29 #include "FXDebugTarget.h"
30
31 /*
32
33 Notes:
34 - The point of this object is simply to accept all messages,
35 and print out where they came from, which type they were, etc.
36 - So purely for debugging purposes.
37 */
38
39 using namespace FX;
40
41 /*******************************************************************************/
42
43 namespace FX {
44
45
46 // Table of message type names
47 const char *const FXDebugTarget::messageTypeName[]={
48 "SEL_NONE",
49 "SEL_KEYPRESS",
50 "SEL_KEYRELEASE",
51 "SEL_LEFTBUTTONPRESS",
52 "SEL_LEFTBUTTONRELEASE",
53 "SEL_MIDDLEBUTTONPRESS",
54 "SEL_MIDDLEBUTTONRELEASE",
55 "SEL_RIGHTBUTTONPRESS",
56 "SEL_RIGHTBUTTONRELEASE",
57 "SEL_MOTION",
58 "SEL_ENTER",
59 "SEL_LEAVE",
60 "SEL_FOCUSIN",
61 "SEL_FOCUSOUT",
62 "SEL_KEYMAP",
63 "SEL_UNGRABBED",
64 "SEL_PAINT",
65 "SEL_CREATE",
66 "SEL_DESTROY",
67 "SEL_UNMAP",
68 "SEL_MAP",
69 "SEL_CONFIGURE",
70 "SEL_SELECTION_LOST",
71 "SEL_SELECTION_GAINED",
72 "SEL_SELECTION_REQUEST",
73 "SEL_RAISED",
74 "SEL_LOWERED",
75 "SEL_CLOSE",
76 "SEL_DELETE",
77 "SEL_MINIMIZE",
78 "SEL_RESTORE",
79 "SEL_MAXIMIZE",
80 "SEL_UPDATE",
81 "SEL_COMMAND",
82 "SEL_CLICKED",
83 "SEL_DOUBLECLICKED",
84 "SEL_TRIPLECLICKED",
85 "SEL_MOUSEWHEEL",
86 "SEL_CHANGED",
87 "SEL_VERIFY",
88 "SEL_DESELECTED",
89 "SEL_SELECTED",
90 "SEL_INSERTED",
91 "SEL_REPLACED",
92 "SEL_DELETED",
93 "SEL_OPENED",
94 "SEL_CLOSED",
95 "SEL_EXPANDED",
96 "SEL_COLLAPSED",
97 "SEL_BEGINDRAG",
98 "SEL_ENDDRAG",
99 "SEL_DRAGGED",
100 "SEL_LASSOED",
101 "SEL_TIMEOUT",
102 "SEL_SIGNAL",
103 "SEL_CLIPBOARD_LOST",
104 "SEL_CLIPBOARD_GAINED",
105 "SEL_CLIPBOARD_REQUEST",
106 "SEL_CHORE",
107 "SEL_FOCUS_SELF",
108 "SEL_FOCUS_RIGHT",
109 "SEL_FOCUS_LEFT",
110 "SEL_FOCUS_DOWN",
111 "SEL_FOCUS_UP",
112 "SEL_FOCUS_NEXT",
113 "SEL_FOCUS_PREV",
114 "SEL_DND_ENTER",
115 "SEL_DND_LEAVE",
116 "SEL_DND_DROP",
117 "SEL_DND_MOTION",
118 "SEL_DND_REQUEST",
119 "SEL_IO_READ",
120 "SEL_IO_WRITE",
121 "SEL_IO_EXCEPT",
122 "SEL_PICKED",
123 "SEL_QUERY_TIP",
124 "SEL_QUERY_HELP"
125 };
126
127
128 // Map
129 FXDEFMAP(FXDebugTarget) FXDebugTargetMap[]={
130 FXMAPTYPES(SEL_KEYPRESS,SEL_LAST,FXDebugTarget::onMessage),
131 };
132
133
134 // Object implementation
FXIMPLEMENT(FXDebugTarget,FXObject,FXDebugTargetMap,ARRAYNUMBER (FXDebugTargetMap))135 FXIMPLEMENT(FXDebugTarget,FXObject,FXDebugTargetMap,ARRAYNUMBER(FXDebugTargetMap))
136
137
138 // Init
139 FXDebugTarget::FXDebugTarget(){
140 lastsender=NULL;
141 lastsel=0;
142 count=0;
143 }
144
145
146 // Got one
onMessage(FXObject * sender,FXSelector sel,void * ptr)147 long FXDebugTarget::onMessage(FXObject* sender,FXSelector sel,void* ptr){
148 FXuint type=FXSELTYPE(sel);
149 FXuint msid=FXSELID(sel);
150 FXASSERT(ARRAYNUMBER(messageTypeName)==SEL_LAST);
151 if(sender!=lastsender || sel!=lastsel){
152 fxmessage("\nTYPE:%-23s ID:%-5d SENDER: %-15s PTR: 0x%08lx #%-4d",type<SEL_LAST?messageTypeName[type]:"ILLEGAL",msid,sender?sender->getClassName():"NULL",(unsigned long)ptr,1);
153 lastsender=sender;
154 lastsel=sel;
155 count=1;
156 }
157 else{
158 count++;
159 fxmessage("\b\b\b\b%-4d",count);
160 }
161 return 0;
162 }
163
164 }
165