1 #include "bcdisplayinfo.h"
5 #include "mainsession.h"
14 MainError* MainError::main_error = 0;
21 MainErrorGUI::MainErrorGUI(MWindow *mwindow, MainError *thread, int x, int y)
22 : BC_Window(PROGRAM_NAME ": Errors",
25 mwindow->session->ewindow_w,
26 mwindow->session->ewindow_h,
36 this->mwindow = mwindow;
37 this->thread = thread;
40 MainErrorGUI::~MainErrorGUI()
44 void MainErrorGUI::create_objects()
49 add_subwindow(button = new BC_OKButton(this));
52 add_subwindow(title = new BC_Title(x, y, _("The following errors occurred:")));
53 y += title->get_h() + 5;
55 add_subwindow(list = new BC_ListBox(x,
58 button->get_y() - y - 5,
59 LISTBOX_TEXT, // Display text list or icons
60 &thread->errors, // Each column has an ArrayList of BC_ListBoxItems.
61 0, // Titles for columns. Set to 0 for no titles
62 0, // width of each column
63 1, // Total columns. Only 1 in icon mode
64 0, // Pixel of top of window.
65 0, // If this listbox is a popup window with a button
66 LISTBOX_SINGLE, // Select one item or multiple items
67 ICON_LEFT, // Position of icon relative to text of each item
74 int MainErrorGUI::resize_event(int w, int h)
76 title->reposition_window(title->get_x(), title->get_y());
79 (get_h() - list->get_y() - list->get_h());
82 (get_w() - list->get_x() - list->get_w());
83 list->reposition_window(list->get_x(),
87 mwindow->session->ewindow_w = w;
88 mwindow->session->ewindow_h = h;
97 MainError::MainError(MWindow *mwindow)
100 this->mwindow = mwindow;
101 errors_lock = new Mutex("MainError::errors_lock");
105 MainError::~MainError()
110 BC_Window* MainError::new_gui()
112 BC_DisplayInfo display_info;
113 int x = display_info.get_abs_cursor_x();
114 int y = display_info.get_abs_cursor_y();
116 MainErrorGUI *gui = new MainErrorGUI(mwindow, this, x, y);
117 gui->create_objects();
121 void MainError::append_error(char *string)
123 char *in_ptr = string;
124 char string2[BCTEXTLEN];
128 char *out_ptr = string2;
129 // Indent remaining lines
136 while(*in_ptr != '\n' &&
139 *out_ptr++ = *in_ptr++;
143 errors.append(new BC_ListBoxItem(string2));
153 void MainError::show_error_local(char *string)
156 // assume user won't get to closing the GUI here
157 lock_window("MainError::show_error_local");
162 MainErrorGUI *gui = (MainErrorGUI*)get_gui();
163 gui->lock_window("MainError::show_error_local");
165 append_error(string);
167 gui->list->update(&errors,
171 gui->list->get_xposition(),
172 gui->list->get_yposition(),
173 gui->list->get_highlighted_item(), // Flat index of item cursor is over
174 0, // set all autoplace flags to 1
177 gui->unlock_window();
187 errors.remove_all_objects();
189 append_error(string);
197 void MainError::show_error(char *string)
200 main_error->show_error_local(string);
203 printf("%s", string);
204 if(string[strlen(string) - 1] != '\n')