Rhino C++ API  9.0
Public Types | Public Member Functions | Protected Member Functions | List of all members
CRhinoUserInterfaceGrid Class Reference

#include <rhinoSdkUserInterfaceObject.h>

Inheritance diagram for CRhinoUserInterfaceGrid:
CRhinoUserInterfaceControl CRhinoUserInterfaceObject

Public Types

enum  ColumnSizing : int { ColumnSizing::Fixed = 0, ColumnSizing::Auto = 1, ColumnSizing::Flexible = 2 }
 

Public Member Functions

 CRhinoUserInterfaceGrid ()
 
 CRhinoUserInterfaceGrid (int columnCount)
 
virtual ~CRhinoUserInterfaceGrid ()
 
void AddChild (std::shared_ptr< CRhinoUserInterfaceControl > child)
 
void AddEmptyCell ()
 
std::shared_ptr< CRhinoUserInterfaceLabelAddHeading (const wchar_t *text)
 
std::shared_ptr< CRhinoUserInterfaceLabelAddLabel (const wchar_t *text)
 
bool BackgroundClaimsMouse () const
 
ON_Color BackgroundColor () const
 
ON_Color BorderColor () const
 
float BorderThickness () const
 
std::shared_ptr< CRhinoUserInterfaceControlCell (int row, int column) const
 
std::shared_ptr< CRhinoUserInterfaceControlChild (int index) const
 
int ChildColumnSpan (int index) const
 
int ChildCount () const
 
int ColumnCount () const
 
double ColumnMinimumWidth (int column) const
 
float ColumnSpacing () const
 
double ColumnWidth (int column) const
 
ON_4fRect ComputedRect (const CRhinoDisplayPipeline *pipeline, bool logicalPixels) const override
 
float ComputedRowHeight (int row) const
 
ON_2fSize ComputeSize () const override
 
float CornerRadius () const
 
void Draw (CRhinoDisplayPipeline &dp) override
 
void EnableRowSeparatorBelowRow (int row, bool on)
 
void EnableRowSeparators (bool on)
 
void GetColumnContentAlignment (int column, ControlHorizontalAlignment &h, ControlVerticalAlignment &v) const
 
ColumnSizing GetColumnSizing (int column) const
 
void InsertChild (std::shared_ptr< CRhinoUserInterfaceControl > child, int index)
 
bool IsMouseOver (const CRhinoMouseEventArgs &mouse) override
 
void OnMouseDoubleClick (const CRhinoMouseEventArgs &mouse) override
 
void OnMouseDown (const CRhinoMouseEventArgs &mouse) override
 
void OnMouseEnter (const CRhinoMouseEventArgs &mouse) override
 
void OnMouseLeave (const CRhinoMouseEventArgs &mouse) override
 
void OnMouseMove (const CRhinoMouseEventArgs &mouse) override
 
void OnMouseUp (const CRhinoMouseEventArgs &mouse) override
 
void OnMouseWheel (const CRhinoMouseEventArgs &mouse, int delta) override
 
void OnTrackpadScroll (const CRhinoMouseEventArgs &mouse, float horizontal, float vertical) override
 
ON_4fRect Padding () const
 
void RemoveAllChildren ()
 
std::shared_ptr< CRhinoUserInterfaceControlRemoveChild (int index)
 
int RowCount () const
 
float RowHeight () const
 
bool RowSeparatorBelowRow (int row) const
 
ON_Color RowSeparatorColor () const
 
bool RowSeparatorsEnabled () const
 
float RowSpacing () const
 
void SetBackgroundClaimsMouse (bool on)
 
void SetBackgroundColor (const ON_Color &color)
 
void SetBorderColor (const ON_Color &color)
 
void SetBorderThickness (float thicknessLP)
 
void SetChildColumnSpan (int index, int span)
 
void SetColumnAutoWidth (int column)
 
void SetColumnContentAlignment (int column, ControlHorizontalAlignment h, ControlVerticalAlignment v)
 
void SetColumnCount (int count)
 
void SetColumnFixedWidth (int column, float widthLP)
 
void SetColumnFlexibleWidth (int column, double weight)
 
void SetColumnMinimumWidth (int column, double minimumLP)
 
void SetColumnSpacing (float spacingLP)
 
void SetCornerRadius (float radiusLP)
 
void SetPadding (float left, float top, float right, float bottom)
 
void SetPadding (float paddingLP)
 
void SetRowHeight (float heightLP)
 
void SetRowSeparatorColor (const ON_Color &color)
 
void SetRowSpacing (float spacingLP)
 
- Public Member Functions inherited from CRhinoUserInterfaceControl
 CRhinoUserInterfaceControl ()
 
virtual ~CRhinoUserInterfaceControl ()
 
void GetAlignment (ControlHorizontalAlignment &h, ControlVerticalAlignment &v) const
 
void GetTextAlignment (ControlHorizontalAlignment &h, ControlVerticalAlignment &v) const
 
const ON_wStringImageSVG () const
 
ON_2fPoint Location () const
 
void SetAlignment (ControlHorizontalAlignment h, ControlVerticalAlignment v)
 
void SetImageSVG (const wchar_t *svg)
 
void SetLocation (float x, float y)
 
void SetLocation (ON_2fPoint location)
 
void SetLocation (ON_2fPoint location, ControlHorizontalAlignment hAlign, ControlVerticalAlignment vAlign)
 
void SetSize (const ON_2fSize &size)
 
void SetSize (float width, float height)
 
void SetText (const wchar_t *text)
 
void SetTextAlignment (ControlHorizontalAlignment h, ControlVerticalAlignment v)
 
void SetTextColor (const ON_Color &color)
 
void SetTextHeight (float height)
 
void SetTrackingPoint (const ON_3dPoint &pt)
 
ON_2fSize Size () const
 
const ON_wStringText () const
 
ON_Color TextColor () const
 
float TextHeight () const
 
ON_3dPoint TrackingPoint () const
 
- Public Member Functions inherited from CRhinoUserInterfaceObject
 CRhinoUserInterfaceObject ()
 
virtual ~CRhinoUserInterfaceObject ()
 
void Animate (CRhinoAnimatingDouble &value, double target, double duration, AnimationStyle style, CRhinoDoc *doc)
 
void BindToActiveViewport (bool on)
 
void BindToViewport (unsigned int viewport_sn)
 
virtual double CameraDepth (const ON_Plane &cameraPlane) const
 
int DisplayOrder () const
 
ON_UUID DocumentGroupId () const
 
unsigned int DocumentRuntimeSerialNumber () const
 
bool GetData (const wchar_t *key, bool &value) const
 
bool GetData (const wchar_t *key, double &value) const
 
bool GetData (const wchar_t *key, int &value) const
 
bool GetData (const wchar_t *key, ON_UUID &value) const
 
bool GetData (const wchar_t *key, ON_wString &value) const
 
bool HasMouseCapture () const
 
bool IsBoundToActiveViewport () const
 
unsigned int IsBoundToViewport () const
 
virtual void OnMouseClick (const CRhinoMouseEventArgs &mouse)
 
virtual CRhinoCommand::result OnRunCommand (const CRhinoCommandContext &context, const CRhinoMouseEventArgs &mouse)
 
CRhinoUserInterfaceObjectParent ()
 
const CRhinoUserInterfaceObjectParent () const
 
bool ReceivesMouseWheelEvents () const
 
bool ReceivesTrackpadScrollEvents () const
 
bool RegisterForAllDocuments ()
 
void RunCommand (const CRhinoMouseEventArgs &mouse)
 
unsigned int RuntimeSerialNumber () const
 
void SetCursor (HCURSOR cursor)
 
void SetData (const wchar_t *key, bool value)
 
void SetData (const wchar_t *key, const wchar_t *value)
 
void SetData (const wchar_t *key, double value)
 
void SetData (const wchar_t *key, int value)
 
void SetData (const wchar_t *key, ON_UUID value)
 
void SetDisplayOrder (int order)
 
void SetReceivesMouseWheelEvents (bool enable)
 
void SetReceivesTrackpadScrollEvents (bool enable)
 
void SetTooltip (const wchar_t *tooltip)
 
void SetVisible (bool visible)
 
bool UnregisterFromAllDocuments ()
 
bool Visible () const
 

Protected Member Functions

void ContinueAnimate (CRhinoDoc *doc) override
 
- Protected Member Functions inherited from CRhinoUserInterfaceObject
void SetMouseCapture (CRhinoDoc *doc)
 

Additional Inherited Members

- Protected Attributes inherited from CRhinoUserInterfaceControl
class CRhUserInterfaceControlPrivate * m_ui_control_private = nullptr
 
- Protected Attributes inherited from CRhinoUserInterfaceObject
class CRhUserInterfaceObjectPrivatem_private = nullptr
 

Detailed Description

Description: A control that arranges child controls in a grid of rows and columns. A grid shares ownership of the controls added to it: it holds a std::shared_ptr to each one, so a control lives for as long as the grid or anyone else is holding on to it.

Example, a two column grid with a fixed width label column: CRhinoUserInterfaceGrid* grid = new CRhinoUserInterfaceGrid(2); grid->SetColumnFixedWidth(0, 90); grid->SetColumnFlexibleWidth(1); grid->SetSize(260, 0); ///< 0 height means "as tall as the rows need" grid->AddLabel(L"Radius"); grid->AddChild(radiusSlider); ///< radiusSlider is a shared_ptr doc.AddUserInterfaceObject(grid, CommandId());

Member Enumeration Documentation

◆ ColumnSizing

Enumerator
Fixed 

Column is exactly the width passed to SetColumnFixedWidth.

Auto 

Column is as wide as the widest ComputeSize() of the controls in it.

Flexible 

Column shares the width the fixed and auto columns leave over, in proportion to the weight passed to SetColumnFlexibleWidth

Constructor & Destructor Documentation

◆ CRhinoUserInterfaceGrid() [1/2]

CRhinoUserInterfaceGrid::CRhinoUserInterfaceGrid ( )

◆ CRhinoUserInterfaceGrid() [2/2]

CRhinoUserInterfaceGrid::CRhinoUserInterfaceGrid ( int  columnCount)

◆ ~CRhinoUserInterfaceGrid()

virtual CRhinoUserInterfaceGrid::~CRhinoUserInterfaceGrid ( )
virtual

Member Function Documentation

◆ AddChild()

void CRhinoUserInterfaceGrid::AddChild ( std::shared_ptr< CRhinoUserInterfaceControl child)

Description: Append a control to the next cell. The grid keeps a reference to the control and removes it from the list of top level user interface objects if it was in that list.

◆ AddEmptyCell()

void CRhinoUserInterfaceGrid::AddEmptyCell ( )

Description: Append a cell with nothing in it. Use this to leave a hole in a row.

◆ AddHeading()

std::shared_ptr<CRhinoUserInterfaceLabel> CRhinoUserInterfaceGrid::AddHeading ( const wchar_t *  text)

Description: Append a label that spans every column, for a section heading. The heading starts a new row when the row being filled is partly full.

◆ AddLabel()

std::shared_ptr<CRhinoUserInterfaceLabel> CRhinoUserInterfaceGrid::AddLabel ( const wchar_t *  text)

Description: Append a label to the next cell. This is the same as adding a CRhinoUserInterfaceLabel, which is what most first column cells are. The label is returned so that its text alignment, color or height can be adjusted.

◆ BackgroundClaimsMouse()

bool CRhinoUserInterfaceGrid::BackgroundClaimsMouse ( ) const

◆ BackgroundColor()

ON_Color CRhinoUserInterfaceGrid::BackgroundColor ( ) const

◆ BorderColor()

ON_Color CRhinoUserInterfaceGrid::BorderColor ( ) const

◆ BorderThickness()

float CRhinoUserInterfaceGrid::BorderThickness ( ) const

◆ Cell()

std::shared_ptr<CRhinoUserInterfaceControl> CRhinoUserInterfaceGrid::Cell ( int  row,
int  column 
) const

◆ Child()

std::shared_ptr<CRhinoUserInterfaceControl> CRhinoUserInterfaceGrid::Child ( int  index) const

Description: Control in a cell. The shared_ptr is empty for an empty cell or an out of range index.

◆ ChildColumnSpan()

int CRhinoUserInterfaceGrid::ChildColumnSpan ( int  index) const

◆ ChildCount()

int CRhinoUserInterfaceGrid::ChildCount ( ) const

Description: Number of cells that have been filled, including empty cells added with AddEmptyCell. This is not the same as ColumnCount() * RowCount().

◆ ColumnCount()

int CRhinoUserInterfaceGrid::ColumnCount ( ) const

Description: Number of columns in the grid. The default is 1. Changing the column count reflows the existing children.

◆ ColumnMinimumWidth()

double CRhinoUserInterfaceGrid::ColumnMinimumWidth ( int  column) const

◆ ColumnSpacing()

float CRhinoUserInterfaceGrid::ColumnSpacing ( ) const

◆ ColumnWidth()

double CRhinoUserInterfaceGrid::ColumnWidth ( int  column) const

Description: Width of a column in logical pixels as of the most recent layout. Returns 0 before the grid has been laid out.

◆ ComputedRect()

ON_4fRect CRhinoUserInterfaceGrid::ComputedRect ( const CRhinoDisplayPipeline pipeline,
bool  logicalPixels 
) const
overridevirtual

Description: Compute the location and size of this control in the coordinates of the thing that is drawing it. Parameters: pipeline - the display pipeline to compute location and size inside of. The same control can end up in different places in different pipelines, because of how it is aligned or because it is tracking a 3d point. Take the pipeline rather than the view it belongs to: a detail on a layout is drawn by its own nested pipeline whose view is the page view, so a view cannot say which of the two is being drawn. logicalPixels - should the rectangle be return in device or logical pixels

Reimplemented from CRhinoUserInterfaceControl.

◆ ComputedRowHeight()

float CRhinoUserInterfaceGrid::ComputedRowHeight ( int  row) const

Description: Height of a row in logical pixels as of the most recent layout. Returns 0 before the grid has been laid out.

◆ ComputeSize()

ON_2fSize CRhinoUserInterfaceGrid::ComputeSize ( ) const
overridevirtual

Description: Compute the size of this control in logical pixels.

Reimplemented from CRhinoUserInterfaceControl.

◆ ContinueAnimate()

void CRhinoUserInterfaceGrid::ContinueAnimate ( CRhinoDoc doc)
overrideprotectedvirtual

Reimplemented from CRhinoUserInterfaceObject.

◆ CornerRadius()

float CRhinoUserInterfaceGrid::CornerRadius ( ) const

◆ Draw()

void CRhinoUserInterfaceGrid::Draw ( CRhinoDisplayPipeline dp)
overridevirtual

Description: All user interface objects must implement a Draw function. This is where drawing using the input display pipeline is performed. The base class Draw function does nothing.

Reimplemented from CRhinoUserInterfaceObject.

◆ EnableRowSeparatorBelowRow()

void CRhinoUserInterfaceGrid::EnableRowSeparatorBelowRow ( int  row,
bool  on 
)

Description: Draw a horizontal line under one row, for a heading row that wants a rule under it when a line between every row would be too much. Off by default. EnableRowSeparators(true) draws them all whatever this is set to.

◆ EnableRowSeparators()

void CRhinoUserInterfaceGrid::EnableRowSeparators ( bool  on)

Description: Draw a horizontal line between every pair of rows. Off by default.

◆ GetColumnContentAlignment()

void CRhinoUserInterfaceGrid::GetColumnContentAlignment ( int  column,
ControlHorizontalAlignment h,
ControlVerticalAlignment v 
) const

◆ GetColumnSizing()

ColumnSizing CRhinoUserInterfaceGrid::GetColumnSizing ( int  column) const

◆ InsertChild()

void CRhinoUserInterfaceGrid::InsertChild ( std::shared_ptr< CRhinoUserInterfaceControl child,
int  index 
)

Description: Insert a control at a cell index, shifting the controls after it along.

◆ IsMouseOver()

bool CRhinoUserInterfaceGrid::IsMouseOver ( const CRhinoMouseEventArgs mouse)
overridevirtual

Description: Return true if the input mouse is considered to be over this object

Reimplemented from CRhinoUserInterfaceObject.

◆ OnMouseDoubleClick()

void CRhinoUserInterfaceGrid::OnMouseDoubleClick ( const CRhinoMouseEventArgs mouse)
overridevirtual

Description: Called when a mouse double clicks on this UI element Parameters: mouse - mouse position, button and view

Reimplemented from CRhinoUserInterfaceObject.

◆ OnMouseDown()

void CRhinoUserInterfaceGrid::OnMouseDown ( const CRhinoMouseEventArgs mouse)
overridevirtual

Description: Called when a mouse button goes down over this UI element Parameters: mouse - mouse position, button and view

Reimplemented from CRhinoUserInterfaceObject.

◆ OnMouseEnter()

void CRhinoUserInterfaceGrid::OnMouseEnter ( const CRhinoMouseEventArgs mouse)
overridevirtual

Description: Called when first goes over this object (IsMouseOver returns true)

Reimplemented from CRhinoUserInterfaceObject.

◆ OnMouseLeave()

void CRhinoUserInterfaceGrid::OnMouseLeave ( const CRhinoMouseEventArgs mouse)
overridevirtual

Description: Called when mouse leaves this object (IsMouseOver returns false)

Reimplemented from CRhinoUserInterfaceObject.

◆ OnMouseMove()

void CRhinoUserInterfaceGrid::OnMouseMove ( const CRhinoMouseEventArgs mouse)
overridevirtual

Description: Called when a mouse moves over this UI element Parameters: mouse - mouse position, button and view

Reimplemented from CRhinoUserInterfaceObject.

◆ OnMouseUp()

void CRhinoUserInterfaceGrid::OnMouseUp ( const CRhinoMouseEventArgs mouse)
overridevirtual

Description: Called when a mouse button goes up over this UI element Parameters: mouse - mouse position, button and view

Reimplemented from CRhinoUserInterfaceObject.

◆ OnMouseWheel()

void CRhinoUserInterfaceGrid::OnMouseWheel ( const CRhinoMouseEventArgs mouse,
int  delta 
)
overridevirtual

Description: Called when a mouse wheel event occurs over this user interface object. The control needs to explicitly enable mouse wheel support (default off) in order to receive these events

Reimplemented from CRhinoUserInterfaceObject.

◆ OnTrackpadScroll()

void CRhinoUserInterfaceGrid::OnTrackpadScroll ( const CRhinoMouseEventArgs mouse,
float  horizontal,
float  vertical 
)
overridevirtual

Description: Called when a trackpad scroll event occurs and the mouse is over this user interface control. The control also needs to explicitly turn on track pad scroll support (default off) in order to receive these events.

Reimplemented from CRhinoUserInterfaceObject.

◆ Padding()

ON_4fRect CRhinoUserInterfaceGrid::Padding ( ) const

◆ RemoveAllChildren()

void CRhinoUserInterfaceGrid::RemoveAllChildren ( )

Description: Empty the grid. The controls in it are deleted unless something else is still holding a reference to them.

◆ RemoveChild()

std::shared_ptr<CRhinoUserInterfaceControl> CRhinoUserInterfaceGrid::RemoveChild ( int  index)

Description: Take a control out of the grid. The grid hands its reference back, so the control stays alive as long as the caller holds on to it. The shared_ptr is empty for an empty cell or an out of range index.

◆ RowCount()

int CRhinoUserInterfaceGrid::RowCount ( ) const

Description: Number of rows the current children occupy. This is computed from the child count, the column count and any column spans.

◆ RowHeight()

float CRhinoUserInterfaceGrid::RowHeight ( ) const

◆ RowSeparatorBelowRow()

bool CRhinoUserInterfaceGrid::RowSeparatorBelowRow ( int  row) const

◆ RowSeparatorColor()

ON_Color CRhinoUserInterfaceGrid::RowSeparatorColor ( ) const

◆ RowSeparatorsEnabled()

bool CRhinoUserInterfaceGrid::RowSeparatorsEnabled ( ) const

◆ RowSpacing()

float CRhinoUserInterfaceGrid::RowSpacing ( ) const

◆ SetBackgroundClaimsMouse()

void CRhinoUserInterfaceGrid::SetBackgroundClaimsMouse ( bool  on)

Description: Whether a click where the grid has no child control belongs to the grid or to whatever is behind it. The default is false, so clicks on the padding, on the gaps between cells and on empty cells go through to the viewport, which is what a heads up display over a model wants. Set it to true for a grid that should behave like a solid panel and swallow everything inside its rectangle.

◆ SetBackgroundColor()

void CRhinoUserInterfaceGrid::SetBackgroundColor ( const ON_Color color)

Description: Color the grid fills its rectangle with. The default is ON_UNSET_COLOR for both, which means draw no background at all.

◆ SetBorderColor()

void CRhinoUserInterfaceGrid::SetBorderColor ( const ON_Color color)

◆ SetBorderThickness()

void CRhinoUserInterfaceGrid::SetBorderThickness ( float  thicknessLP)

◆ SetChildColumnSpan()

void CRhinoUserInterfaceGrid::SetChildColumnSpan ( int  index,
int  span 
)

Description: Number of columns a cell occupies. The default is 1. Use this for a section heading or a control that runs the full width of the grid. A span is clamped to the number of columns left in the row.

◆ SetColumnAutoWidth()

void CRhinoUserInterfaceGrid::SetColumnAutoWidth ( int  column)

Description: Column is as wide as the widest control in it. Controls report their width from ComputeSize(), so a label column sized this way is exactly as wide as its longest description.

◆ SetColumnContentAlignment()

void CRhinoUserInterfaceGrid::SetColumnContentAlignment ( int  column,
ControlHorizontalAlignment  h,
ControlVerticalAlignment  v 
)

Description: How the controls in a column sit in their cells. The default is Stretch / Center, which makes a control fill the column width and center itself vertically in the row. Any horizontal setting other than Stretch gives the control the width it reports from ComputeSize().

◆ SetColumnCount()

void CRhinoUserInterfaceGrid::SetColumnCount ( int  count)

◆ SetColumnFixedWidth()

void CRhinoUserInterfaceGrid::SetColumnFixedWidth ( int  column,
float  widthLP 
)

Description: Column width in logical pixels, never resized.

◆ SetColumnFlexibleWidth()

void CRhinoUserInterfaceGrid::SetColumnFlexibleWidth ( int  column,
double  weight 
)

Description: Column shares the space the fixed and auto columns do not use. With one flexible column that column gets all of the remaining width; with more than one the remainder is divided in proportion to the weights.

◆ SetColumnMinimumWidth()

void CRhinoUserInterfaceGrid::SetColumnMinimumWidth ( int  column,
double  minimumLP 
)

Description: Width a column will never go below, in logical pixels. Useful for flexible columns in a grid that can be narrow. The default is 0.

◆ SetColumnSpacing()

void CRhinoUserInterfaceGrid::SetColumnSpacing ( float  spacingLP)

Description: Space between columns and between rows in logical pixels. The defaults are 6 and 2.

◆ SetCornerRadius()

void CRhinoUserInterfaceGrid::SetCornerRadius ( float  radiusLP)

◆ SetPadding() [1/2]

void CRhinoUserInterfaceGrid::SetPadding ( float  left,
float  top,
float  right,
float  bottom 
)

◆ SetPadding() [2/2]

void CRhinoUserInterfaceGrid::SetPadding ( float  paddingLP)

Description: Space between the edges of the grid and its cells in logical pixels. The default is 6 on all four sides.

◆ SetRowHeight()

void CRhinoUserInterfaceGrid::SetRowHeight ( float  heightLP)

Description: Height of every row in logical pixels. The default is 0 which means each row is as tall as the tallest control in it.

◆ SetRowSeparatorColor()

void CRhinoUserInterfaceGrid::SetRowSeparatorColor ( const ON_Color color)

◆ SetRowSpacing()

void CRhinoUserInterfaceGrid::SetRowSpacing ( float  spacingLP)