网格 (Grid)

网格组件可以在网格视图中显示组件集。

用法

创建网格组件

开发者可以通过 gui_grid_create() 创建网格组件, 按照创建的顺序用控件填充网格。

设置网格样式

开发者可以使用 gui_grid_style() 进行设置样式,总共有以下两种样式。

/** @brief  Support two style. */
typedef enum
{
    GRID_CLASSIC,         //!< Evenly layout vertically and horizontally.
    GRID_SCALE,           //!< Scale by slide.
} T_GUI_GRID_STYLE;

示例

经典样式

#include <gui_obj.h>
#include <gui_grid.h>
#include "gui_magic_img.h"
#include "root_image_hongkong/ui_resource.h"

void page_tb_grid(void *parent)
{
   void *array[] = {CLOCK_BIN, EMAIL_BIN, SPORT_BIN, SLEEP_BIN, MAP_BIN};
   gui_grid_t *grid = gui_grid_create(parent, 0, 0, 2, 3, 210, 100);
   gui_grid_style(grid, GRID_CLASSIC);
   for (size_t i = 0; i < 5; i++)
   {
      gui_img_creat_from_mem(grid, "1", array[i], 0, 0, 0, 0);
   }
}


API

Enums

enum T_GUI_GRID_STYLE

Support two style.

Values:

enumerator GRID_CLASSIC

Evenly layout vertically and horizontally.

enumerator GRID_SCALE

Scale by slide.

Functions

gui_grid_t *gui_grid_create(void *parent, int16_t x, int16_t y, int16_t row, int16_t col, uint16_t gap_col, uint16_t gap_row)

Create a grid widget.

参数:
  • parent – The father widget the grid is nested in.

  • x – The X-axis coordinate.

  • y – The Y-axis coordinate.

  • row – Number of rows.

  • col – Number of columns.

  • gap_col – Gap between two columns.

  • gap_row – Gap between two rows.

返回:

Return the grid widget pointer.

void gui_grid_style(gui_grid_t *grid, T_GUI_GRID_STYLE style)

Configure the grid style.

参数:
  • grid – The grid widget pointer.

  • style – The grid style (GRID_CLASSIC or GRID_SCALE).

struct gui_grid_t

Public Members

gui_obj_t base
int16_t row
int16_t col
uint16_t gap_col
uint16_t gap_row
uint16_t gap_col_scale
uint16_t gap_row_scale
float scale
int yold
int start_x
int start_y
int id_offset
int row_count
bool row_count_flag
bool col_count_flag
T_GUI_GRID_STYLE style
int col_count
int change_threshold