gfx::Point ImageView::ComputeImageOrigin(const gfx::Size& image_size) const { gfx::Insets insets = GetInsets(); int x; // In order to properly handle alignment of images in RTL locales, we need // to flip the meaning of trailing and leading. For example, if the // horizontal alignment is set to trailing, then we'll use left alignment for // the image instead of right alignment if the UI layout is RTL. Alignment actual_horiz_alignment = horiz_alignment_; if(base::i18n::IsRTL() && (horiz_alignment_!=CENTER)) { actual_horiz_alignment = (horiz_alignment_==LEADING) ? TRAILING : LEADING; } switch(actual_horiz_alignment) { case LEADING: x = insets.left(); break; case TRAILING: x = width() - insets.right() - image_size.width(); break; case CENTER: x = (width() - image_size.width()) / 2; break; default: NOTREACHED(); x = 0; break; } int y; switch(vert_alignment_) { case LEADING: y = insets.top(); break; case TRAILING: y = height() - insets.bottom() - image_size.height(); break; case CENTER: y = (height() - image_size.height()) / 2; break; default: NOTREACHED(); y = 0; break; } return gfx::Point(x, y); }
void OnSize(int type, const gfx::Size& sz) { SetWindowPos(scrollbar_, 0, 0, 0, sz.width(), sz.height(), SWP_DEFERERASE|SWP_NOACTIVATE|SWP_NOCOPYBITS| SWP_NOOWNERZORDER|SWP_NOSENDCHANGING|SWP_NOZORDER); }
void GetDefaultWindowMask(const gfx::Size& size, gfx::Path* window_mask) { // Redefine the window visible region for the new size. window_mask->moveTo(0, 3); window_mask->lineTo(1, 2); window_mask->lineTo(1, 1); window_mask->lineTo(2, 1); window_mask->lineTo(3, 0); window_mask->lineTo(SkIntToScalar(size.width()-3), 0); window_mask->lineTo(SkIntToScalar(size.width()-2), 1); window_mask->lineTo(SkIntToScalar(size.width()-1), 1); window_mask->lineTo(SkIntToScalar(size.width()-1), 2); window_mask->lineTo(SkIntToScalar(size.width()), 3); window_mask->lineTo(SkIntToScalar(size.width()), SkIntToScalar(size.height()-3)); window_mask->lineTo(SkIntToScalar(size.width()-1), SkIntToScalar(size.height()-3)); window_mask->lineTo(SkIntToScalar(size.width()-1), SkIntToScalar(size.height()-1)); window_mask->lineTo(SkIntToScalar(size.width()-3), SkIntToScalar(size.height()-2)); window_mask->lineTo(SkIntToScalar(size.width()-3), SkIntToScalar(size.height())); window_mask->lineTo(3, SkIntToScalar(size.height())); window_mask->lineTo(2, SkIntToScalar(size.height()-2)); window_mask->lineTo(1, SkIntToScalar(size.height()-1)); window_mask->lineTo(1, SkIntToScalar(size.height()-3)); window_mask->lineTo(0, SkIntToScalar(size.height()-3)); window_mask->close(); }
virtual void SetSize(const gfx::Size& size) { X; fprintf(stderr, "SetSize %d %d\n", size.width(), size.height()); bounds_.set_size(size); }