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,2006 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 3297 2015-12-14 20:30:04Z arthurcnorman $                   *
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   "SEL_DOCKED",
126   "SEL_FLOATED",
127   "SEL_SESSION_NOTIFY",
128   "SEL_SESSION_CLOSED"
129   };
130 
131 
132 // Map
133 FXDEFMAP(FXDebugTarget) FXDebugTargetMap[]={
134   FXMAPTYPES(SEL_KEYPRESS,SEL_LAST,FXDebugTarget::onMessage),
135   };
136 
137 
138 // Object implementation
FXIMPLEMENT(FXDebugTarget,FXObject,FXDebugTargetMap,ARRAYNUMBER (FXDebugTargetMap))139 FXIMPLEMENT(FXDebugTarget,FXObject,FXDebugTargetMap,ARRAYNUMBER(FXDebugTargetMap))
140 
141 
142 // Init
143 FXDebugTarget::FXDebugTarget(){
144   lastsender=NULL;
145   lastsel=0;
146   count=0;
147   }
148 
149 
150 // Got one
onMessage(FXObject * sender,FXSelector sel,void * ptr)151 long FXDebugTarget::onMessage(FXObject* sender,FXSelector sel,void* ptr){
152   FXuint type=FXSELTYPE(sel);
153   FXuint msid=FXSELID(sel);
154   FXASSERT(ARRAYNUMBER(messageTypeName)==SEL_LAST);
155   if(sender!=lastsender || sel!=lastsel){
156     fxmessage("\nTYPE:%-23s ID:%-5d SENDER: %-15s PTR: 0x%08p #%-4d",type<SEL_LAST?messageTypeName[type]:"ILLEGAL",msid,sender?sender->getClassName():"NULL",ptr,1);
157     lastsender=sender;
158     lastsel=sel;
159     count=1;
160     }
161   else{
162     count++;
163     fxmessage("\b\b\b\b%-4d",count);
164     }
165   return 0;
166   }
167 
168 }
169