00001 #include "byteorderpopup.h"
00002 #include "file.h"
00003
00004
00005 ByteOrderPopup::ByteOrderPopup(BC_WindowBase *parent_window,
00006 int x,
00007 int y,
00008 int *output)
00009 {
00010 this->parent_window = parent_window;
00011 this->output = output;
00012 this->x = x;
00013 this->y = y;
00014 }
00015
00016 ByteOrderPopup::~ByteOrderPopup()
00017 {
00018 delete menu;
00019 delete textbox;
00020 for(int i = 0; i < byteorder_items.total; i++)
00021 delete byteorder_items.values[i];
00022 }
00023
00024 int ByteOrderPopup::create_objects()
00025 {
00026 byteorder_items.append(new BC_ListBoxItem(File::byteorder_to_str(0)));
00027 byteorder_items.append(new BC_ListBoxItem(File::byteorder_to_str(1)));
00028
00029 parent_window->add_subwindow(textbox = new ByteOrderText(this, x, y));
00030 x += textbox->get_w();
00031 parent_window->add_subwindow(menu = new ByteOrderList(this, x, y));
00032 return 0;
00033 }
00034
00035 ByteOrderList::ByteOrderList(ByteOrderPopup *popup, int x, int y)
00036 : BC_ListBox(x,
00037 y,
00038 100,
00039 100,
00040 LISTBOX_TEXT,
00041 &popup->byteorder_items,
00042 0,
00043 0,
00044 1,
00045 0,
00046 1)
00047 {
00048 this->popup = popup;
00049 }
00050
00051 int ByteOrderList::handle_event()
00052 {
00053 popup->textbox->update(get_selection(0, 0)->get_text());
00054 popup->textbox->handle_event();
00055 return 1;
00056 }
00057
00058 ByteOrderText::ByteOrderText(ByteOrderPopup *popup, int x, int y)
00059 : BC_TextBox(x, y, 100, 1, File::byteorder_to_str(*popup->output))
00060 {
00061 this->popup = popup;
00062 }
00063
00064 int ByteOrderText::handle_event()
00065 {
00066 *popup->output = File::str_to_byteorder(get_text());
00067 return 1;
00068 }