void placeholder::Draw(BRect) { if( ((designview *)Parent())->ShowHandles == true) { rgb_color handlecolor; if(active) { handlecolor = darkgreen; } else { handlecolor = red; } //box1 BRect drect(Bounds().right-4,Bounds().bottom-4,Bounds().right,Bounds().bottom); SetHighColor(handlecolor); StrokeRect(drect); SetHighColor(white); FillRect(BRect(drect.left+1,drect.top+1,drect.right-1,drect.bottom-1)); SetHighColor(lightgrey); FillRect(BRect(drect.left+3,drect.top+3,drect.right-1,drect.bottom-1)); //box2 drect.OffsetBy(0,-6); SetHighColor(handlecolor); StrokeRect(drect); SetHighColor(white); FillRect(BRect(drect.left+1,drect.top+1,drect.right-1,drect.bottom-1)); SetHighColor(lightgrey); FillRect(BRect(drect.left+2,drect.top+2,drect.right-2,drect.bottom-2)); } }
void CDrawMetaFile::Paint(CContext &dc,paint_options options) { CDPoint sma = m_point_a; CDPoint smb = m_point_b; CDRect drect(sma.x,sma.y,smb.x,smb.y); CRect rect = dc.GetTransform().Scale( drect ); int rotmir = dc.GetTransform().GetRotMir(); CImage *pImage = m_pDesign->GetOptions()->GetImage(m_metafile); if (pImage) { pImage->Paint( *dc.GetDC(), rect, rotmir ); } else { CImage::PaintInvalid( *dc.GetDC(), rect ); } }
void TextureButton::_notification(int p_what) { switch (p_what) { case NOTIFICATION_DRAW: { DrawMode draw_mode = get_draw_mode(); Ref<Texture> texdraw; switch (draw_mode) { case DRAW_NORMAL: { if (normal.is_valid()) texdraw = normal; } break; case DRAW_PRESSED: { if (pressed.is_null()) { if (hover.is_null()) { if (normal.is_valid()) texdraw = normal; } else texdraw = hover; } else texdraw = pressed; } break; case DRAW_HOVER: { if (hover.is_null()) { if (pressed.is_valid() && is_pressed()) texdraw = pressed; else if (normal.is_valid()) texdraw = normal; } else texdraw = hover; } break; case DRAW_DISABLED: { if (disabled.is_null()) { if (normal.is_valid()) texdraw = normal; } else texdraw = disabled; } break; } if (texdraw.is_valid()) { Point2 ofs; Size2 size = texdraw->get_size(); Rect2 tex_regin = Rect2(Point2(), texdraw->get_size()); bool tile = false; if (expand) { switch (stretch_mode) { case STRETCH_KEEP: size = texdraw->get_size(); break; case STRETCH_SCALE: size = get_size(); break; case STRETCH_TILE: size = get_size(); tile = true; break; case STRETCH_KEEP_CENTERED: ofs = (get_size() - texdraw->get_size()) / 2; size = texdraw->get_size(); break; case STRETCH_KEEP_ASPECT_CENTERED: case STRETCH_KEEP_ASPECT: { Size2 _size = get_size(); float tex_width = texdraw->get_width() * _size.height / texdraw->get_height(); float tex_height = _size.height; if (tex_width > _size.width) { tex_width = _size.width; tex_height = texdraw->get_height() * tex_width / texdraw->get_width(); } if (stretch_mode == STRETCH_KEEP_ASPECT_CENTERED) { ofs.x = (_size.width - tex_width) / 2; ofs.y = (_size.height - tex_height) / 2; } size.width = tex_width; size.height = tex_height; } break; case STRETCH_KEEP_ASPECT_COVERED: { size = get_size(); Size2 tex_size = texdraw->get_size(); Size2 scaleSize(size.width / tex_size.width, size.height / tex_size.height); float scale = scaleSize.width > scaleSize.height ? scaleSize.width : scaleSize.height; Size2 scaledTexSize = tex_size * scale; Point2 ofs = ((scaledTexSize - size) / scale).abs() / 2.0f; tex_regin = Rect2(ofs, size / scale); } break; } } if (tile) draw_texture_rect(texdraw, Rect2(ofs, size), tile); else draw_texture_rect_region(texdraw, Rect2(ofs, size), tex_regin); } if (has_focus() && focused.is_valid()) { Rect2 drect(Point2(), get_size()); draw_texture_rect(focused, drect, false); }; } break; } }
void TextureButton::_notification(int p_what) { switch( p_what ) { case NOTIFICATION_DRAW: { RID canvas_item = get_canvas_item(); DrawMode draw_mode = get_draw_mode(); // if (normal.is_null()) // break; Ref<Texture> texdraw; switch (draw_mode) { case DRAW_NORMAL: { if (normal.is_valid()) texdraw=normal; } break; case DRAW_PRESSED: { if (pressed.is_null()) { if (hover.is_null()) { if (normal.is_valid()) texdraw=normal; } else texdraw=hover; } else texdraw=pressed; } break; case DRAW_HOVER: { if (hover.is_null()) { if (pressed.is_valid() && is_pressed()) texdraw=pressed; else if (normal.is_valid()) texdraw=normal; } else texdraw=hover; } break; case DRAW_DISABLED: { if (disabled.is_null()) { if (normal.is_valid()) texdraw=normal; } else texdraw=disabled; } break; } if (texdraw.is_valid()) { Rect2 drect(Point2(),texdraw->get_size()*scale); draw_texture_rect(texdraw,drect,false,modulate); } if (has_focus() && focused.is_valid()) { Rect2 drect(Point2(),focused->get_size()*scale); draw_texture_rect(focused,drect,false,modulate); }; } break; } }