void WindowImpl::draw() { CL_Display::push_translate (parent->get_screen_x(), parent->get_screen_y()); CL_Color highlight(255, 255, 255); CL_Color midtone(150, 150, 150); CL_Rect rect = parent->get_position() ; Box::draw_window(CL_Rect(CL_Point(0, 0), CL_Size(rect.get_width()-1, rect.get_height()-1))); Box::draw_panel_down(client_area->get_position()); /* CL_Display::fill_rect(CL_Rect(CL_Point(0, 0), rect.get_size()), CL_Color(220, 220, 220)); CL_Display::draw_rect(CL_Rect(CL_Point(0, 0), rect.get_size()), CL_Color(0, 0, 0)); CL_Display::draw_line(1, rect.get_height()-2, rect.get_width()-2, rect.get_height()-2, midtone); CL_Display::draw_line(rect.get_width()-2, 1, rect.get_width()-2, rect.get_height()-2, midtone); CL_Display::draw_line(1, 1, rect.get_width()-2, 1, highlight); CL_Display::draw_line(1, 1, 1, rect.get_height()-2, highlight); */ CL_Display::pop_modelview(); }
void CL_TreeItem_Silver::on_paint() { CL_Rect rect = item->get_screen_rect(); int height = rect.get_height(); int font_height = font->get_height(item->get_text(0)); if(item->has_mouse_over()) CL_Display::fill_rect(rect, CL_Color(232, 236, 241)); if(item->get_node()->is_selected()) CL_Display::fill_rect(rect, CL_Color(184, 195, 209, 150)); CL_TreeView *treeview = item->get_node()->get_treeview(); int columns = treeview->get_column_count(); if(columns == 0) columns = 1; // Draw columns for(int x = 0, i = 0; i < columns; ++i) { int dx = 0; if(i == 0) { dx += item->get_text_margin(); CL_Surface *icon = item->get_icon(); if(icon) { icon->draw( rect.left + x + 1, rect.top + (height - icon->get_height()) / 2); dx += icon->get_width(); } } CL_Component *comp = item->get_component(i); if(comp) { comp->set_position(CL_Rect(x + dx + 4, 0, x + dx + 4 + treeview->get_column_width(i), height)); comp->paint(); } else { font->draw( rect.left + x + dx + 4, rect.top + (height - font_height) / 2, item->get_text(i)); } x += treeview->get_column_width(i); if(i == 0) x -= item->get_node()->get_placement_offset(); } }
void WindowImpl::on_resize(int, int) { titlebar->set_position(CL_Rect(CL_Point(3+16,3), CL_Size(parent->get_width()-6-18-18-18, 12+3))); close->set_position(3, 3); minimize->set_position(parent->get_width()-3-18-18, 3); maximize->set_position(parent->get_width()-3-18, 3); CL_Rect rect = parent->get_position(); client_area->set_position(CL_Rect(CL_Point(4, 3+12+7), CL_Size(rect.get_width()-10, rect.get_height()-28))); }
void TitlebarImpl::on_mouse_move(const CL_InputEvent& event) { if(pressed) { CL_Rect rect = window->get_position(); CL_Point move(old_pos.left - (click_pos.x - (rect.left + event.mouse_pos.x)), old_pos.top - (click_pos.y - (rect.top + event.mouse_pos.y))); window->set_position(move.x, move.y); } }
void TitlebarImpl::on_mouse_down(const CL_InputEvent& event) { if (event.id == CL_MOUSE_LEFT) { pressed = true; click_pos = event.mouse_pos; parent->capture_mouse(); window->raise(); old_pos = window->get_position(); click_pos.x += old_pos.left; click_pos.y += old_pos.top; } }
void WindowImpl::do_maximize() { // FIXME: Move this to scripting language if (!is_maximized) { is_maximized = true; old_position = parent->get_position(); parent->set_position(parent->get_parent()->get_position()); } else { is_maximized = false; parent->set_position(old_position); } }
CL_Component *CL_GUIManager_Generic::tab_previous() { // First try to find component by tab id: CL_Component *tab_component = owner->find_tab_id(--current_tab_id); if (current_tab_id == -1) // reached beginning, start from end { current_tab_id = find_highest_tab_id(owner); tab_component = owner->find_tab_id(current_tab_id); } if (tab_component) { set_focus(tab_component); return comp_focus; } if(comp_focus == 0) return 0; // No tab ids - fall back to tree walking: CL_Component *cur = comp_focus; while (true) { CL_Component *parent = cur->get_parent(); if (parent == 0) break; // Search siblings: std::list<CL_Component *>::const_iterator it; for (it = parent->get_children().begin(); it != parent->get_children().end(); it++) { if (*it == cur) { // no more siblings if (it == parent->get_children().begin()) break; it--; // give sibling focus set_focus(*it); return comp_focus; } } // Was last sibling, continue search in parent (uncles) cur = parent; } // walked through all components. Restart at end component: cur = owner; while (!cur->get_children().empty()) cur = cur->get_children().back(); set_focus(cur); return comp_focus; }
CL_Component *CL_GUIManager_Generic::tab_next() { // First try to find component by tab id: CL_Component *tab_component = owner->find_tab_id(++current_tab_id); if (tab_component == 0) // reached end, start from beginning { current_tab_id = 0; tab_component = owner->find_tab_id(current_tab_id); } if (tab_component) { set_focus(tab_component); return comp_focus; } if(comp_focus == 0) return 0; // No tab ids - fall back to tree walking: if (comp_focus->get_children().empty()) // tab to sibling or uncle { CL_Component *cur = comp_focus; while (true) { CL_Component *parent = cur->get_parent(); if (parent == 0) break; // Search siblings: std::list<CL_Component *>::const_iterator it; for (it = parent->get_children().begin(); it != parent->get_children().end(); it++) { if (*it == cur) { it++; // no more siblings if (it == parent->get_children().end()) break; // give sibling focus set_focus(*it); return comp_focus; } } // Was last sibling, continue search in parent (uncles) cur = parent; } // if we are top node (no siblings), and got no children: if (cur == comp_focus) return comp_focus; // walked through all components. Restart at first component: set_focus(owner); return comp_focus; } else // tab to children { // give first child focus set_focus(comp_focus->get_children().front()); return comp_focus; } }
void CL_TreeView_Silver::on_paint_node(CL_TreeNode *node, CL_Point &point) { CL_Component *component = node->get_component(); CL_Component *client_area = treeview->get_client_area(); int height = component->get_height(); int mid = (height) / 2; // Should we draw decoration ? bool draw_decoration = true; if(node->is_root()) draw_decoration = node->get_treeview()->is_root_decoration_visible(); // Find what y offset we're drawing at point.y -= scrollbar->get_value(); // Find what x offset we're drawing at int x_offset = 0; if(draw_decoration) x_offset = 12; int screen_x = client_area->get_screen_x(); int screen_y = client_area->get_screen_y(); // Is the node visible? if (point.y + height >= 0 && point.y <= client_area->get_height()) { if(draw_decoration) { // Draw collapse box if(node->has_children()) { CL_Display::draw_rect( CL_Rect( screen_x + point.x, screen_y + point.y + mid - 5, screen_x + point.x + 9, screen_y + point.y + mid + 4), CL_Color(128, 142, 159)); CL_Display::fill_rect( CL_Rect( screen_x + point.x + 1, screen_y + point.y + mid - 4, screen_x + point.x + 8, screen_y + point.y + mid + 3), CL_Gradient( CL_Color::white, CL_Color::white, CL_Color(230, 235, 240), CL_Color(230, 235, 240))); CL_Display::fill_rect( CL_Rect( screen_x + point.x + 2, screen_y + point.y + mid - 3, screen_x + point.x + 7, screen_y + point.y + mid + 2), CL_Gradient( CL_Color(217, 222, 227), CL_Color(217, 222, 227), CL_Color::white, CL_Color::white)); // Horizontal line CL_Display::draw_line( screen_x + point.x + 2.0f, screen_y + point.y + mid - 1.0f, screen_x + point.x + 7.0f, screen_y + point.y + mid - 1, CL_Color::black); // Vertical line if(node->is_collapsed()) CL_Display::draw_line( screen_x + point.x + 4.0f, screen_y + point.y + mid - 3.0f, screen_x + point.x + 4.0f, screen_y + point.y + mid + 2.0f, CL_Color::black); } } // Size and place child component component->set_position(point.x + x_offset, point.y); node->set_placement_offset(point.x + x_offset); // Draw component component->show(true); component->sig_begin_paint(); component->sig_paint()(); component->sig_end_paint(); } else { component->show(false); } // Move down for next component point.y += scrollbar->get_value(); point.y += height; // If it has any children, adjust the x-position for the children if(node->is_collapsed() == false) point.x += 3 + x_offset; }
void WindowImpl::do_close() { parent->show(false); }