OHOS::UICanvas

    Graphic

    Description:

    Defines a canvas, which is used to draw multiple types of 2D graphs.

    Since:

    1.0

    Version:

    1.0

    Public Member Function Name

    Description

    ()

     

    A constructor used to create a UICanvas instance.

    ()

    virtual 

    A destructor used to delete the UICanvas instance.

    () const override

    UIViewType 

    Obtains the view type.

    Clear ()

    void 

    Clears the entire canvas.

    (const Point &startPoint)

    void 

    Sets the coordinates of the start point for drawing a line. For example, if startPoint is set to {50, 50}, the line is drawn from this set of coordinates on the canvas.

    () const

    const Point

    Obtains the coordinates of the start point of a line.

    (const Point &endPoint, const &paint)

    void 

    Draws a straight line.

    DrawLine (const &startPoint, const Point &endPoint, const &paint)

    void 

    Draws a straight line from the coordinates of the start point.

    DrawCurve (const &control1, const Point &control2, const &endPoint, const Paint &paint)

    void 

    Draws a cubic Bezier curve.

    (const Point &startPoint, const &control1, const Point &control2, const &endPoint, const Paint &paint)

    void 

    Draws a cubic Bezier curve from the start point coordinates.

    (const Point &startPoint, int16_t height, int16_t width, const &paint)

    void 

    Draws a rectangle.

    DrawCircle (const &center, uint16_t radius, const Paint &paint)

    void 

    Draws a circle.

    (const Point &center, uint16_t radius, int16_t startAngle, int16_t endAngle, const &paint)

    void 

    Draws a sector.

    DrawArc (const &center, uint16_t radius, int16_t startAngle, int16_t endAngle, const Paint &paint)

    void 

    Draws an arc.

    (const Point &startPoint, const char image, const &paint)

    void 

    Draws an image.

    DrawLabel (const &startPoint, const char text, uint16_t maxWidth, const FontStyle &fontStyle, const &paint)

    void 

    Draws text.

    OnDraw (const &invalidatedArea) override

    virtual void 

    Called when a view is drawn.

    UIView ()

     

    A default constructor used to create an instance.

    UIView (const char id)

     

    A constructor used to create an instance.

    ~UIView ()

    virtual 

    A destructor used to delete the instance.

    OnPreDraw (const &invalidatedArea)

    virtual bool 

    Called before a view is drawn. This function is used to check whether the parent view of this view needs to be redrawn so as to optimize the drawing process.

    OnPostDraw (const &invalidatedArea)

    virtual void 

    Called after a view is drawn.

    ReMeasure ()

    virtual void 

    Remeasures the view size.

    ()

    void 

    Refreshes the invalidated area of the view.

    InvalidateRect (const &invalidatedArea)

    void 

    Refreshes a view in a specified invalidated area.

    OnLongPressEvent (const &event)

    virtual bool 

    Called when the view is long pressed.

    OnDragStartEvent (const &event)

    virtual bool 

    Called when the view starts to drag.

    OnDragEvent (const &event)

    virtual bool 

    Called when the view is being dragged.

    OnDragEndEvent (const &event)

    virtual bool 

    Called when the view stops dragging.

    OnClickEvent (const &event)

    virtual void 

    Called when the view is clicked.

    OnPressEvent (const &event)

    virtual void 

    OnReleaseEvent (const &event)

    virtual void 

    Called when the view is released.

    OnCancelEvent (const &event)

    virtual void 

    Called when a click event on the view is canceled.

    SetOnDragListener ( onDragListener)

    void 

    Sets a drag event listener for the view.

    GetOnDragListener ()

    Obtains the drag event listener for the view.

    SetOnClickListener ( onClickListener)

    void 

    Sets a click event listener for the view.

    GetOnClickListener ()

    Obtains the click event listener for the view.

    SetOnLongPressListener ( onLongPressListener)

    void 

    Sets a long-press event listener for the view.

    GetOnLongPressListener ()

    Obtains the long-press event listener for the view.

    SetOnTouchListener ( onTouchListener)

    void 

    Sets a touch event listener for the view.

    GetTouchListener ()

    Obtains the touch event listener for the view.

    GetTargetView (const &point, UIView **last)

    virtual void 

    Obtains the top-level view based on specified coordinates.

    (UIView parent)

    void 

    Sets the parent view for the view.

    () const

    UIView  

    Obtains the parent view of the view.

    (UIView sibling)

    void 

    Sets the next sibling view for the view.

    () const

    UIView  

    Obtains the next sibling view of the view.

    (bool visible)

    virtual void 

    Sets whether the view is visible.

    IsVisible () const

    bool 

    Checks whether the view is visible.

    (bool touch)

    void 

    Sets whether the view is touchable.

    IsTouchable () const

    bool 

    Checks whether the view is touchable.

    (bool draggable)

    void 

    Sets whether the view is draggable.

    IsDraggable () const

    bool 

    Checks whether the view is draggable.

    (bool dragParentInstead)

    void 

    Sets whether to transfer the drag event to the parent view for processing when the view is being dragged.

    IsDragParentInstead () const

    bool 

    Obtains whether the view transfers a drag event to the parent view for processing.

    () const

    Rect 

    Obtains the absolute rectangle area of the view. When the view has deformation such as rotation, the rectangle area is the intersection set of the absolute rectangle area and deformation matrix.

    () const

    Rect 

    Obtains the visible absolute rectangle area of the view.

    () const

    Rect 

    Obtains the valid absolute rectangle area of the view. The valid area refers to the area where the view can be displayed. Generally, the valid area is the same as the visible view area, but they may be different in the grid layout.

    () const

    Rect 

    Obtains the absolute rectangle area of the view.

    ()

    virtual Rect 

    Obtains the content of the absolute rectangle area of the view. This area excludes padding.

    () const

    Rect 

    Obtains the rectangular area of the view relative to the parent view, that is, the rectangular area relative to the coordinates of the parent view.

    (int16_t x, int16_t y, int16_t width, int16_t height)

    void 

    Adjusts the size of the visible area. This operation may affect the final display size.

    SetWidth (int16_t width)

    virtual void 

    Sets the width for the view.

    ()

    virtual int16_t 

    Obtains the width for the view.

    SetHeight (int16_t height)

    virtual void 

    Sets the height for the view.

    ()

    virtual int16_t 

    Obtains the height for the view.

    Resize (int16_t width, int16_t height)

    virtual void 

    Adjusts the size of the view.

    (int16_t x)

    virtual void 

    GetX () const

    int16_t 

    Obtains the x-coordinate for the view.

    (int16_t y)

    virtual void 

    Sets the y-coordinate for the view.

    GetY () const

    int16_t 

    Obtains the y-coordinate for the view.

    (int16_t x, int16_t y)

    virtual void 

    Sets the position for the view.

    SetPosition (int16_t x, int16_t y, int16_t width, int16_t height)

    virtual void 

    Adjusts the position and size of the view.

    () const

    bool 

    Checks whether the view is a container view.

    SetIntercept (bool isIntercept)

    void 

    Sets whether to intercept the drag event. If intercepted, the view does not transfer the drag event to the parent view after local processing.

    (const TransformMap &transMap)

    void 

    Sets the affine transformation matrix.

    ()

    TransformMap

    Obtains an affine transformation matrix.

    (const char id) const

    virtual UIView  

    Obtains the child view of a specified ID.

    (const char id)

    void 

    Sets the view ID.

    GetViewId () const

    const char  

    Obtains the view ID.

    (int16_t index)

    void 

    Sets the view index.

    () const

    int16_t 

    Obtains the view index.

    LayoutChildren (bool neeInvalidate=false)

    virtual void 

    Lays out all child views according to the preset arrangement mode.

    (int16_t xOffSet=0, int16_t yOffset=0)

    void 

    Lays out the view in the center of the parent view.

    LayoutLeftOfParent (int16_t offset=0)

    void 

    Lays out the view on the left of the parent view.

    (int16_t offset=0)

    void 

    Lays out the view on the right of the parent view.

    LayoutTopOfParent (int16_t offset=0)

    void 

    Lays out the view on the top of the parent view.

    (int16_t offset=0)

    void 

    Lays out the view on the bottom of the parent view.

    AlignLeftToSibling (const char id, int16_t offset=0)

    void 

    Aligns the view with the left of a sibling view.

    (const char id, int16_t offset=0)

    void 

    Aligns the view with the right of a sibling view.

    AlignTopToSibling (const char id, int16_t offset=0)

    void 

    Aligns the view with the top of a sibling view.

    (const char id, int16_t offset=0)

    void 

    Aligns the view with the bottom of a sibling view.

    AlignHorCenterToSibling (const char id, int16_t offset=0)

    void 

    Aligns the view with the center of a sibling view in the x-axis.

    (const char id, int16_t offset=0)

    void 

    Aligns the view with the center of a sibling view in the y-axis.

    LayoutLeftToSibling (const char id, int16_t offset=0)

    void 

    Lays out the view on the left of a sibling view.

    (const char id, int16_t offset=0)

    void 

    Lays out the view on the right of a sibling view.

    LayoutTopToSibling (const char id, int16_t offset=0)

    void 

    Lays out the view on the above of a sibling view.

    (const char id, int16_t offset=0)

    void 

    Lays out the view on the below of a sibling view.

    SetStyle ( &style)

    virtual void 

    Sets the view style.

    SetStyle (uint8_t key, int64_t value)

    virtual void 

    Sets a style.

    (uint8_t key) const

    virtual int64_t 

    Obtains the value of a style.

    GetStyleConst () const

    const & 

    Obtains the view style. This function applies to scenarios where the style does not need to be modified, which saves memory.

    operator new (size_t size)

    void  

    Overrides the new function.

    (void *p)

    void