00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "precomp.h"
00010 #include "window_default.h"
00011 #include "API/Display/Font/font.h"
00012
00013 CL_Window_Default::CL_Window_Default(
00014 CL_Window *_window,
00015 const CL_ComponentOptions &options,
00016 CL_StyleManager_Default *style)
00017 :
00018 CL_ComponentStyle(_window),
00019 window(_window),
00020 titlebar_height(21)
00021 {
00022 this->style = style;
00023
00024 resources = style->get_resources();
00025 font = CL_Font::load("Window/font", resources);
00026 font_disabled = CL_Font::load("Window/font_disabled", resources);
00027
00028
00029 move_handler = new CL_ComponentMoveHandler(
00030 CL_Rect(0, 0, window->get_width(), titlebar_height),
00031 window,
00032 style);
00033
00034
00035 CL_Rect rect(window->get_width() - 19, 3, window->get_width() - 3, 19);
00036 button_close = new CL_Button(rect, "", window, style);
00037
00038 slot_close = button_close->sig_clicked().connect(CL_CreateSlot(this, &CL_Window_Default::on_close));
00039 slot_paint = window->sig_paint().connect(CL_CreateSlot(this, &CL_Window_Default::on_paint));
00040
00041
00042
00043 }
00044
00045 CL_Window_Default::~CL_Window_Default()
00046 {
00047 delete move_handler;
00048 delete button_close;
00049 }
00050
00051 void CL_Window_Default::on_paint()
00052 {
00053 int width = window->get_width();
00054 int height = window->get_height();
00055
00056 style->draw_rect(0, 0, width, height, GUICOLOR_DARK_OUTLINE);
00057
00058 style->draw_box(1, 1, width - 1, titlebar_height, GUICOLOR_BRIGHT_SHADE, GUICOLOR_DARK_SHADE);
00059 style->draw_box(1, titlebar_height, width - 1, height - 1, GUICOLOR_BRIGHT_SHADE, GUICOLOR_DARK_SHADE);
00060
00061 style->fill_rect(2, 2, width - 2, titlebar_height - 1, GUICOLOR_WINDOW_TITLEBAR);
00062 style->fill_rect(2, titlebar_height + 1, width - 2, height - 2, GUICOLOR_WINDOW_NORMAL);
00063
00064 int y = (titlebar_height + 2 - font->get_height()) / 2;
00065
00066 if(window->is_enabled() == false)
00067 font_disabled->print_left(7, y, window->get_title().c_str());
00068 else
00069 font->print_left(7, y, window->get_title().c_str());
00070 }
00071
00072 void CL_Window_Default::on_resized(int width, int height)
00073 {
00074
00075 }
00076
00077 void CL_Window_Default::on_close()
00078 {
00079 std::cout << "on_close" << std::endl;
00080 window->quit();
00081 }