1 /********************************************************************** 2 * File: debugwin.h 3 * Description: Portable debug window class. 4 * Author: Ray Smith 5 * Created: Wed Feb 21 15:36:59 MST 1996 6 * 7 * (C) Copyright 1996, Hewlett-Packard Co. 8 ** Licensed under the Apache License, Version 2.0 (the "License"); 9 ** you may not use this file except in compliance with the License. 10 ** You may obtain a copy of the License at 11 ** http://www.apache.org/licenses/LICENSE-2.0 12 ** Unless required by applicable law or agreed to in writing, software 13 ** distributed under the License is distributed on an "AS IS" BASIS, 14 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 ** See the License for the specific language governing permissions and 16 ** limitations under the License. 17 * 18 **********************************************************************/ 19 20 #ifndef DEBUGWIN_H 21 #define DEBUGWIN_H 22 23 #include "host.h" 24 #include "varable.h" 25 26 #ifdef __MAC__ 27 #include <lwindow.h> 28 #include <lcommander.h> 29 #endif 30 31 //the following define the default position of a debug window 32 //if not specified at construction 33 #define DEBUG_WIN_XPOS 50 //default position 34 #define DEBUG_WIN_YPOS 30 //default position 35 #define DEBUG_WIN_XSIZE 700 //default size 36 #define DEBUG_WIN_YSIZE 300 //default size 37 38 //number of lines in the scrollable area of the window 39 extern DLLSYM INT_VAR_H (debug_lines, 256, "Number of lines in debug window"); 40 41 //the API for the debug window is simple, see below. 42 //Most of its behaviour is its UI. 43 //It has a scrollable text area (most of the window) 44 //It has a stop control. 45 //It has a clear button. 46 //A dprintf to the window causes the text to be sent to the 47 //text area. If the stop control is set, then the dprintf 48 //blocks (does not display anything or return) until the stop 49 //is released. 50 //In multi-threaded apps, other threads and the UI continue to 51 //function during the stop. Only the calling thread is blocked. 52 //Pressing the clear button erases all text from the window. 53 //As text is sent to the window, it scrolls up so that the most 54 //recent output is visible. If the user has scrolled back, this 55 //does not happen. If the user scrolls back to the bottom, then 56 //the scrolling turns back on. 57 //If the user destroys the window, it never comes back. 58 59 class DLLSYM DEBUG_WIN 60 { 61 public: 62 //the constructor creates the window, the destructor kills it 63 DEBUG_WIN ( //constructor 64 const char *title, //of window 65 inT32 xpos = DEBUG_WIN_XPOS,//initial position 66 inT32 ypos = DEBUG_WIN_YPOS,//in pixels 67 //initial size 68 inT32 xsize = DEBUG_WIN_XSIZE, 69 //in pixels 70 inT32 ysize = DEBUG_WIN_YSIZE, 71 //default scroll size (textlines) 72 inT32 buflines = debug_lines); 73 74 ~DEBUG_WIN (); //destructor 75 76 void dprintf ( //printf to window 77 const char *format, ...); //message 78 79 void await_destruction(); //wait for user to close 80 81 #ifdef __MAC__ 82 static void SetCommander(LCommander *pCommander); 83 #endif 84 85 private: 86 87 #ifdef __MSW32__ 88 HWND handle; //handle to window 89 char *shm_mem; //shared memory 90 char *msg_end; //current string 91 HANDLE shm_hand; //handle to it 92 HANDLE dbg_process; //handle to it 93 HANDLE dbg_thread; //handle to it 94 #endif 95 #ifdef __UNIX__ 96 FILE *fp; /*return file */ 97 #endif 98 99 #ifdef __MAC__ 100 LWindow *pWindow; 101 #endif 102 }; 103 #endif 104