bool RectComponent::IsOver(int screen_x, int screen_y) { if (behave_solid_ == true) { return Component::IsOver(screen_x, screen_y); } if (Component::IsOver(screen_x, screen_y) == false) { return false; } if (image_id_ == Painter::kInvalidImageid) { if (hollow_ == true) { Component* child = Component::GetChild(screen_x, screen_y); if (child != 0) { return child->IsOver(screen_x, screen_y); } return false; } else { return true; } } else { PixelCoord pos(GetScreenPos()); PixelCoord size(GetSize()); PixelRect rect(pos, pos + size); GUIImageManager* i_man = GetImageManager(); return i_man->IsOverImage(image_id_, screen_x, screen_y, rect); } }
bool TreeNode::ValidateIconRect(const wstr& text) { bool repaint = false; if (icon_label_ == 0) { GUIImageManager* i_man = GetImageManager(); //icon_label_ = new Label(factory_text_backg_color_, factory_text_selected_backg_color_); icon_label_ = new Label(factory_text_color_, text); icon_label_->SetIcon(collapsed_icon_id_, Label::kIconLeft); /*icon_label_->SetText(text, factory_text_color_, factory_text_backg_color_, factory_text_selected_color_, factory_text_selected_backg_color_);*/ int image_height = i_man->GetImageSize(collapsed_icon_id_).y; int font_height = i_man->GetPainter()->GetFontHeight(); icon_label_->SetPreferredHeight(image_height > font_height ? image_height : font_height); if (expand_button_) { // The layout is 1x2. AddChild(icon_label_, 0, 1); } else { // The layout is 1x1. AddChild(icon_label_, 0, 0); } repaint = true; } return repaint; }
void TreeNode::AddDefaultIconIfNeeded(Painter::ImageID& local_icon_id, Painter::ImageID& static_icon_id, void* buffer, int x_offset, int y_offset) { if (local_icon_id == Painter::kInvalidImageid || static_icon_id != Painter::kInvalidImageid) { Color palette[256]; palette[0].Set(0, 0, 0, 0); palette[1].Set(0, 0, 0, 255); palette[2].Set(251, 233, 160, 255); palette[3].Set(255, 255, 255, 255); palette[4].Set(255, 0, 0, 255); palette[106].Set(149, 149, 149, 255); palette[255].Set(0, 0, 0, 255); Canvas canvas(16, 16, Canvas::kBitdepth8Bit); canvas.SetPalette(palette); canvas.SetBuffer(buffer); Canvas alpha; uint8 transparent_color = 0; canvas.GetAlphaChannel(alpha, &transparent_color, 1); canvas.ConvertTo32BitWithAlpha(alpha); GUIImageManager* i_man = GetImageManager(); static_icon_id = i_man->AddImage(canvas, GUIImageManager::kCentered, GUIImageManager::kAlphatest, 128); i_man->SetImageOffset(static_icon_id, x_offset, y_offset); } }
bool TreeNode::ValidateExpandButton() { bool repaint = false; if (child_nodes_ != 0 && expand_button_ == 0) { GUIImageManager* i_man = GetImageManager(); /*expand_button_ = new CheckButton(expand_icon_id_, collapse_icon_id_, expand_icon_id_, collapse_icon_id_, collapse_icon_id_, expand_icon_id_, "ExpandButton");*/ expand_button_->SetPreferredSize(i_man->GetImageSize(expand_icon_id_)); expand_button_->SetMinSize(expand_button_->GetPreferredSize()); expand_button_->SetOnClick(TreeNode, OnExpandButtonUnclicked); // Create a rect with a CenterLayout in order to keep the button centered. RectComponent* rect = new RectComponent(new CenterLayout()); rect->AddChild(expand_button_); rect->SetPreferredSize(expand_button_->GetPreferredSize()); rect->SetMinSize(expand_button_->GetMinSize()); if (((GridLayout*)GetLayout())->GetNumCols() > 1) { Component* comp = ((GridLayout*)GetLayout())->GetComponentAt(0, 0); ((GridLayout*)GetLayout())->DeleteColumn(0); delete comp; } ((GridLayout*)GetLayout())->InsertColumn(0); AddChild(rect, 0, 0); repaint = true; } else if (child_nodes_ == 0 && expand_button_ == 0) { GUIImageManager* i_man = GetImageManager(); RectComponent* rect = new RectComponent(new CenterLayout()); rect->SetPreferredSize(i_man->GetImageSize(expand_icon_id_)); rect->SetMinSize(rect->GetPreferredSize()); ((GridLayout*)GetLayout())->InsertColumn(0); AddChild(rect, 0, 0); } return repaint; }
void RectComponent::RepaintBackground(Painter* painter) { painter->PushAttrib(Painter::kAttrAll); GUIImageManager* i_man = GetImageManager(); PixelCoord pos(GetScreenPos()); PixelCoord size(GetSize()); PixelRect rect(pos, pos + size); PixelRect clipping_rect(rect); clipping_rect.right_++; clipping_rect.bottom_++; //painter->ReduceClippingRect(clipping_rect); if (hollow_ == false) { if (corner_radius_ == 0) { if (image_id_ == Painter::kInvalidImageid) { painter->SetColor(color_[0], 0); painter->SetAlphaValue(color_[0].alpha_); if (shaded_ == true) { painter->SetColor(color_[1], 1); painter->SetColor(color_[2], 2); painter->SetColor(color_[3], 3); painter->FillShadedRect(rect); } else { if (color_[0].alpha_ != 0) { painter->FillRect(rect); } } } else { i_man->DrawImage(image_id_, rect); } } else { // Draw with rounded corners. painter->SetColor(color_[0], 0); painter->SetAlphaValue(color_[0].alpha_); PixelRect _rect(GetScreenPos(), GetScreenPos() + GetSize()); painter->DrawRoundedRect(_rect, corner_radius_, corner_radius_mask_, true); } } painter->PopAttrib(); }
TreeNode::TreeNode(Painter::ImageID collapsed_icon_id, Painter::ImageID expanded_icon_id, Painter::ImageID collapse_icon_id, Painter::ImageID expande_icon_id, const wstr& text): Component(new GridLayout(1, 1)), parent_node_(0), child_nodes_(0), expand_button_(0), icon_label_(0), collapse_icon_id_(collapse_icon_id), expand_icon_id_(expande_icon_id), collapsed_icon_id_(collapsed_icon_id), expanded_icon_id_(expanded_icon_id), indentation_level_(0), child_indentation_(0) { Init(text); GUIImageManager* i_man = GetImageManager(); child_indentation_ = i_man->GetImageSize(expande_icon_id).x; }
BOOL CXTPRibbonControlTab::DrawIcon(CDC* pDC, CPoint pt, CXTPTabManagerItem* pItem, BOOL bDraw, CSize& szIcon) const { if (!pItem) return GetPaintManager()->m_bShowIcons; if (pItem->GetImageIndex() == -1 || GetPaintManager()->m_bShowIcons == FALSE) return FALSE; CXTPImageManagerIcon* pImage = GetImageManager()->GetImage(pItem->GetImageIndex(), szIcon.cx); if (!pImage) return FALSE; if (!bDraw) { return TRUE; } pItem->DrawImage(pDC, CRect(pt, szIcon), pImage); return TRUE; }