00001 #ifndef MAINERROR_H 00002 #define MAINERROR_H 00003 00004 00005 #include "bcdialog.h" 00006 #include "mainerror.inc" 00007 #include "mutex.inc" 00008 #include "mwindow.inc" 00009 00010 // This is needed for errors which are too verbose to fit in the 00011 // status bar. 00012 00013 // Once created, it accumulates errors in a listbox until it's closed. 00014 00015 // Macro to enable the simplest possible error output 00016 //#define eprintf(format, ...) {char error_string[1024]; sprintf(sprintf(error_string, "%s: " format, __PRETTY_FUNCTION__, ## __VA_ARGS__); MainError::show_error(error_string); } 00017 // We have to use longer version if we want to gettext error messages 00018 #define eprintf(...) {char error_string[1024]; sprintf(error_string, "%s: ", __PRETTY_FUNCTION__); sprintf(error_string + strlen(error_string), __VA_ARGS__); MainError::show_error(error_string); } 00019 00020 00021 00022 class MainErrorGUI : public BC_Window 00023 { 00024 public: 00025 MainErrorGUI(MWindow *mwindow, MainError *thread, int x, int y); 00026 ~MainErrorGUI(); 00027 00028 void create_objects(); 00029 int resize_event(int w, int h); 00030 00031 MWindow *mwindow; 00032 MainError *thread; 00033 BC_ListBox *list; 00034 BC_Title *title; 00035 }; 00036 00037 00038 class MainError : public BC_DialogThread 00039 { 00040 public: 00041 MainError(MWindow *mwindow); 00042 ~MainError(); 00043 00044 friend class MainErrorGUI; 00045 00046 BC_Window* new_gui(); 00047 00048 00049 // Display error message to command line or GUI, depending on what exists. 00050 static void show_error(char *string); 00051 00052 00053 private: 00054 void show_error_local(char *string); 00055 00056 // Split errors into multiple lines based on carriage returns. 00057 void append_error(char *string); 00058 00059 00060 MWindow *mwindow; 00061 ArrayList<BC_ListBoxItem*> errors; 00062 Mutex *errors_lock; 00063 00064 // Main error dialog. Won't exist if no GUI. 00065 static MainError *main_error; 00066 }; 00067 00068 00069 00070 00071 #endif
1.5.5