2016-10-07 17:33:35 +02:00
|
|
|
/**
|
|
|
|
* @file lv_win.h
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LV_WIN_H
|
|
|
|
#define LV_WIN_H
|
|
|
|
|
2017-07-09 15:32:49 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2016-10-07 17:33:35 +02:00
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
|
|
|
#include "lv_conf.h"
|
|
|
|
#if USE_LV_WIN != 0
|
|
|
|
|
2017-01-02 10:48:21 +01:00
|
|
|
/*Testing of dependencies*/
|
2017-10-20 15:37:50 +02:00
|
|
|
#if USE_LV_BTN == 0
|
2017-01-02 10:48:21 +01:00
|
|
|
#error "lv_win: lv_btn is required. Enable it in lv_conf.h (USE_LV_BTN 1) "
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if USE_LV_LABEL == 0
|
|
|
|
#error "lv_win: lv_label is required. Enable it in lv_conf.h (USE_LV_LABEL 1) "
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if USE_LV_IMG == 0
|
|
|
|
#error "lv_win: lv_img is required. Enable it in lv_conf.h (USE_LV_IMG 1) "
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if USE_LV_PAGE == 0
|
|
|
|
#error "lv_win: lv_page is required. Enable it in lv_conf.h (USE_LV_PAGE 1) "
|
|
|
|
#endif
|
|
|
|
|
2016-10-07 17:33:35 +02:00
|
|
|
#include "../lv_obj/lv_obj.h"
|
2017-08-23 14:39:09 +02:00
|
|
|
#include "lv_cont.h"
|
2016-10-07 17:33:35 +02:00
|
|
|
#include "lv_btn.h"
|
|
|
|
#include "lv_label.h"
|
|
|
|
#include "lv_img.h"
|
|
|
|
#include "lv_page.h"
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
|
|
|
|
2017-01-14 23:54:16 +01:00
|
|
|
/*Data of window*/
|
|
|
|
typedef struct
|
|
|
|
{
|
2017-04-13 10:20:35 +02:00
|
|
|
/*Ext. of ancestor*/
|
2017-01-14 23:54:16 +01:00
|
|
|
/*New data for this type */
|
2017-04-21 09:15:39 +02:00
|
|
|
lv_obj_t * page; /*Pointer to a page which holds the content*/
|
|
|
|
lv_obj_t * header; /*Pointer to the header container of the window*/
|
|
|
|
lv_obj_t * title; /*Pointer to the title label of the window*/
|
|
|
|
lv_obj_t * btnh; /*Pointer to the control button holder container of the window*/
|
2017-04-13 16:12:03 +02:00
|
|
|
lv_style_t * style_header; /*Style of the header container*/
|
2017-04-13 13:34:57 +02:00
|
|
|
lv_style_t * style_cbtn_rel; /*Control button releases style*/
|
2017-04-21 09:15:39 +02:00
|
|
|
lv_style_t * style_cbtn_pr; /*Control button pressed style*/
|
|
|
|
cord_t cbtn_size; /*Size of the control buttons (square)*/
|
2017-01-14 23:54:16 +01:00
|
|
|
}lv_win_ext_t;
|
|
|
|
|
2016-10-07 17:33:35 +02:00
|
|
|
/**********************
|
|
|
|
* GLOBAL PROTOTYPES
|
|
|
|
**********************/
|
2017-01-13 23:27:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a window objects
|
|
|
|
* @param par pointer to an object, it will be the parent of the new window
|
2017-01-14 23:54:16 +01:00
|
|
|
* @param copy pointer to a window object, if not NULL then the new object will be copied from it
|
2017-01-13 23:27:49 +01:00
|
|
|
* @return pointer to the created window
|
|
|
|
*/
|
2016-10-07 17:33:35 +02:00
|
|
|
lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy);
|
2017-01-13 23:27:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Signal function of the window
|
|
|
|
* @param win pointer to a window object
|
|
|
|
* @param sign a signal type from lv_signal_t enum
|
|
|
|
* @param param pointer to a signal specific variable
|
|
|
|
* @return true: the object is still valid (not deleted), false: the object become invalid
|
|
|
|
*/
|
2016-10-07 17:33:35 +02:00
|
|
|
bool lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param);
|
|
|
|
|
2017-01-13 23:27:49 +01:00
|
|
|
/**
|
|
|
|
* Add control button to the header of the window
|
|
|
|
* @param win pointer to a window object
|
|
|
|
* @param img_path path of an image on the control button
|
|
|
|
* @param rel_action a function pointer to call when the button is released
|
|
|
|
* @return pointer to the created button object
|
|
|
|
*/
|
2017-04-28 16:12:35 +02:00
|
|
|
lv_obj_t * lv_win_add_cbtn(lv_obj_t * win, const char * img_path, lv_action_t rel_action);
|
2017-01-13 23:27:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A release action which can be assigned to a window control button to close it
|
|
|
|
* @param btn pointer to the released button
|
2017-10-09 15:21:26 +02:00
|
|
|
* @param indev_proc pointer to the caller input device
|
2017-04-21 09:15:39 +02:00
|
|
|
* @return always LV_ACTION_RES_INV because the button is deleted with the window
|
2017-01-13 23:27:49 +01:00
|
|
|
*/
|
2017-10-31 16:25:52 +01:00
|
|
|
lv_res_t lv_win_close_action(lv_obj_t * btn);
|
2017-01-13 23:27:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the title of a window
|
|
|
|
* @param win pointer to a window object
|
|
|
|
* @param title string of the new title
|
|
|
|
*/
|
2016-10-07 17:33:35 +02:00
|
|
|
void lv_win_set_title(lv_obj_t * win, const char * title);
|
|
|
|
|
2017-04-21 09:15:39 +02:00
|
|
|
/**
|
|
|
|
* Set the control button size of a window
|
|
|
|
* @param win pointer to a window object
|
|
|
|
* @return control button size
|
|
|
|
*/
|
|
|
|
void lv_win_set_cbtn_size(lv_obj_t * win, cord_t size);
|
|
|
|
|
|
|
|
/**
|
2017-05-12 16:09:37 +02:00
|
|
|
* Set the styles of the window control buttons in a given state
|
2017-04-21 09:15:39 +02:00
|
|
|
* @param win pointer to a window object
|
2017-05-12 16:09:37 +02:00
|
|
|
* @param rel pointer to the style in released state
|
2017-04-21 09:15:39 +02:00
|
|
|
* @param pr pointer to the style in pressed state
|
|
|
|
*/
|
2017-04-28 16:12:35 +02:00
|
|
|
void lv_win_set_styles_cbtn(lv_obj_t * win, lv_style_t * rel, lv_style_t * pr);
|
2017-04-21 09:15:39 +02:00
|
|
|
|
2017-01-13 23:27:49 +01:00
|
|
|
/**
|
|
|
|
* Get the title of a window
|
|
|
|
* @param win pointer to a window object
|
|
|
|
* @return title string of the window
|
|
|
|
*/
|
2016-12-15 10:31:30 +01:00
|
|
|
const char * lv_win_get_title(lv_obj_t * win);
|
2017-01-13 23:27:49 +01:00
|
|
|
|
2017-04-21 09:15:39 +02:00
|
|
|
/**
|
|
|
|
* Get the page of a window
|
|
|
|
* @param win pointer to a window object
|
|
|
|
* @return page pointer to the page object of the window
|
|
|
|
*/
|
2017-04-13 10:20:35 +02:00
|
|
|
lv_obj_t * lv_win_get_page(lv_obj_t * win);
|
|
|
|
|
2017-04-21 09:15:39 +02:00
|
|
|
/**
|
|
|
|
* Get the s window header
|
|
|
|
* @param win pointer to a window object
|
|
|
|
* @return pointer to the window header object (lv_rect)
|
|
|
|
*/
|
2017-04-13 13:34:57 +02:00
|
|
|
lv_obj_t * lv_win_get_header(lv_obj_t * win);
|
|
|
|
|
2017-04-21 09:15:39 +02:00
|
|
|
/**
|
|
|
|
* Get the control button size of a window
|
|
|
|
* @param win pointer to a window object
|
|
|
|
* @return control button size
|
|
|
|
*/
|
|
|
|
cord_t lv_win_get_cbtn_size(lv_obj_t * win);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get width of the content area (page scrollable) of the window
|
|
|
|
* @param win pointer to a window object
|
2017-05-12 16:09:37 +02:00
|
|
|
* @return the width of the content area
|
2017-04-21 09:15:39 +02:00
|
|
|
*/
|
2017-04-13 13:34:57 +02:00
|
|
|
cord_t lv_win_get_width(lv_obj_t * win);
|
|
|
|
|
2017-01-13 23:27:49 +01:00
|
|
|
/**
|
|
|
|
* Get the pointer of a widow from one of its control button.
|
|
|
|
* It is useful in the action of the control buttons where only button is known.
|
2017-05-12 16:09:37 +02:00
|
|
|
* @param ctrl_btn pointer to a control button of a window
|
|
|
|
* @return pointer to the window of 'ctrl_btn'
|
2017-01-13 23:27:49 +01:00
|
|
|
*/
|
2017-05-12 16:09:37 +02:00
|
|
|
lv_obj_t * lv_win_get_from_cbtn(lv_obj_t * ctrl_btn);
|
2017-01-13 23:27:49 +01:00
|
|
|
|
2016-10-07 17:33:35 +02:00
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
2016-12-16 07:41:34 +01:00
|
|
|
#endif /*USE_LV_WIN*/
|
2016-10-07 17:33:35 +02:00
|
|
|
|
2017-07-09 15:32:49 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
|
|
|
#endif
|
|
|
|
|
2016-12-16 07:41:34 +01:00
|
|
|
#endif /*LV_WIN_H*/
|