当前位置: 首页>>代码示例>>C++>>正文


C++ View::GetPreferredSize方法代码示例

本文整理汇总了C++中View::GetPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:C++ View::GetPreferredSize方法的具体用法?C++ View::GetPreferredSize怎么用?C++ View::GetPreferredSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在View的用法示例。


在下文中一共展示了View::GetPreferredSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetPreferredSize

 gfx::Size BoxLayout::GetPreferredSize(View* host)
 {
     gfx::Rect bounds;
     int position = 0;
     for(int i=0; i<host->GetChildViewCount(); ++i)
     {
         View* child = host->GetChildViewAt(i);
         if(child->IsVisible())
         {
             gfx::Size size(child->GetPreferredSize());
             if(orientation_ == kHorizontal)
             {
                 gfx::Rect child_bounds(position, 0, size.width(), size.height());
                 bounds = bounds.Union(child_bounds);
                 position += size.width();
             }
             else
             {
                 gfx::Rect child_bounds(0, position, size.width(), size.height());
                 bounds = bounds.Union(child_bounds);
                 position += size.height();
             }
             position += between_child_spacing_;
         }
     }
     gfx::Insets insets(host->GetInsets());
     return gfx::Size(
         bounds.width()+insets.width()+2*inside_border_horizontal_spacing_,
         bounds.height()+insets.height()+2*inside_border_vertical_spacing_);
 }
开发者ID:Strongc,项目名称:Chrome_Library,代码行数:30,代码来源:box_layout.cpp

示例2: GetPreferredSize

 gfx::Size SingleSplitView::GetPreferredSize()
 {
     int width = 0;
     int height = 0;
     for(int i=0; i<2&&i<GetChildViewCount(); ++i)
     {
         View* view = GetChildViewAt(i);
         gfx::Size pref = view->GetPreferredSize();
         if(is_horizontal_)
         {
             width += pref.width();
             height = std::max(height, pref.height());
         }
         else
         {
             width = std::max(width, pref.width());
             height += pref.height();
         }
     }
     if(is_horizontal_)
     {
         width += kDividerSize;
     }
     else
     {
         height += kDividerSize;
     }
     return gfx::Size(width, height);
 }
开发者ID:Strongc,项目名称:Chrome_Library,代码行数:29,代码来源:single_split_view.cpp

示例3: Layout

 void BoxLayout::Layout(View* host)
 {
     gfx::Rect childArea(gfx::Rect(host->size()));
     childArea.Inset(host->GetInsets());
     childArea.Inset(inside_border_horizontal_spacing_,
         inside_border_vertical_spacing_);
     int x = childArea.x();
     int y = childArea.y();
     for(int i=0; i<host->GetChildViewCount(); ++i)
     {
         View* child = host->GetChildViewAt(i);
         if(child->IsVisible())
         {
             gfx::Rect bounds(x, y, childArea.width(), childArea.height());
             gfx::Size size(child->GetPreferredSize());
             if(orientation_ == kHorizontal)
             {
                 bounds.set_width(size.width());
                 x += size.width() + between_child_spacing_;
             }
             else
             {
                 bounds.set_height(size.height());
                 y += size.height() + between_child_spacing_;
             }
             // Clamp child view bounds to |childArea|.
             child->SetBounds(bounds.Intersect(childArea));
         }
     }
 }
开发者ID:Strongc,项目名称:Chrome_Library,代码行数:30,代码来源:box_layout.cpp

示例4: Size

 virtual gfx::Size GetPreferredSize(View* host)
 {
     // First, query the preferred sizes to determine a good width.
     int width = 0;
     for(int i=0; i<host->child_count(); ++i)
     {
         View* page = host->child_at(i);
         width = std::max(width, page->GetPreferredSize().width());
     }
     // After we know the width, decide on the height.
     return gfx::Size(width, GetPreferredHeightForWidth(host, width));
 }
开发者ID:leer168,项目名称:x-framework,代码行数:12,代码来源:native_tabbed_pane_win.cpp


注:本文中的View::GetPreferredSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。