00001 /********************************************************************** 00002 * File: debugwin.h 00003 * Description: Portable debug window class. 00004 * Author: Ray Smith 00005 * Created: Wed Feb 21 15:36:59 MST 1996 00006 * 00007 * (C) Copyright 1996, Hewlett-Packard Co. 00008 ** Licensed under the Apache License, Version 2.0 (the "License"); 00009 ** you may not use this file except in compliance with the License. 00010 ** You may obtain a copy of the License at 00011 ** http://www.apache.org/licenses/LICENSE-2.0 00012 ** Unless required by applicable law or agreed to in writing, software 00013 ** distributed under the License is distributed on an "AS IS" BASIS, 00014 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 ** See the License for the specific language governing permissions and 00016 ** limitations under the License. 00017 * 00018 **********************************************************************/ 00019 00020 #ifndef DEBUGWIN_H 00021 #define DEBUGWIN_H 00022 00023 #include "host.h" 00024 #include "varable.h" 00025 00026 #ifdef __MAC__ 00027 #include <lwindow.h> 00028 #include <lcommander.h> 00029 #endif 00030 00031 //the following define the default position of a debug window 00032 //if not specified at construction 00033 #define DEBUG_WIN_XPOS 50 //default position 00034 #define DEBUG_WIN_YPOS 30 //default position 00035 #define DEBUG_WIN_XSIZE 700 //default size 00036 #define DEBUG_WIN_YSIZE 300 //default size 00037 00038 //number of lines in the scrollable area of the window 00039 extern DLLSYM INT_VAR_H (debug_lines, 256, "Number of lines in debug window"); 00040 00041 //the API for the debug window is simple, see below. 00042 //Most of its behaviour is its UI. 00043 //It has a scrollable text area (most of the window) 00044 //It has a stop control. 00045 //It has a clear button. 00046 //A dprintf to the window causes the text to be sent to the 00047 //text area. If the stop control is set, then the dprintf 00048 //blocks (does not display anything or return) until the stop 00049 //is released. 00050 //In multi-threaded apps, other threads and the UI continue to 00051 //function during the stop. Only the calling thread is blocked. 00052 //Pressing the clear button erases all text from the window. 00053 //As text is sent to the window, it scrolls up so that the most 00054 //recent output is visible. If the user has scrolled back, this 00055 //does not happen. If the user scrolls back to the bottom, then 00056 //the scrolling turns back on. 00057 //If the user destroys the window, it never comes back. 00058 00059 class DLLSYM DEBUG_WIN 00060 { 00061 public: 00062 //the constructor creates the window, the destructor kills it 00063 DEBUG_WIN ( //constructor 00064 const char *title, //of window 00065 inT32 xpos = DEBUG_WIN_XPOS,//initial position 00066 inT32 ypos = DEBUG_WIN_YPOS,//in pixels 00067 //initial size 00068 inT32 xsize = DEBUG_WIN_XSIZE, 00069 //in pixels 00070 inT32 ysize = DEBUG_WIN_YSIZE, 00071 //default scroll size (textlines) 00072 inT32 buflines = debug_lines); 00073 00074 ~DEBUG_WIN (); //destructor 00075 00076 void dprintf ( //printf to window 00077 const char *format, ...); //message 00078 00079 void await_destruction(); //wait for user to close 00080 00081 #ifdef __MAC__ 00082 static void SetCommander(LCommander *pCommander); 00083 #endif 00084 00085 private: 00086 00087 #ifdef __MSW32__ 00088 HWND handle; //handle to window 00089 char *shm_mem; //shared memory 00090 char *msg_end; //current string 00091 HANDLE shm_hand; //handle to it 00092 HANDLE dbg_process; //handle to it 00093 HANDLE dbg_thread; //handle to it 00094 #endif 00095 #ifdef __UNIX__ 00096 FILE *fp; /*return file */ 00097 #endif 00098 00099 #ifdef __MAC__ 00100 LWindow *pWindow; 00101 #endif 00102 }; 00103 #endif