#include "ui_comp_input_pwd.h"
#include "ui_cont.h"
#include "data_config.h"
#include "ui_spinbox.h"

lv_obj_t *win_pwd;      // 窗体
lv_obj_t *pwd_spinbox;     // 参数设置控件

void ui_comp_input_pwd_create(void)
{
    win_pwd = lv_win_create(ui_get_cont(), NULL); // 创建窗体对象
    lv_obj_set_size(win_pwd, 300, 180);                  // 设置窗体的大小
    lv_obj_set_style_local_text_font(win_pwd, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, &GBhzk22);
    lv_obj_set_style_local_bg_opa(win_pwd, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_100);      // LV_OPA_0);/设置背景透明
    lv_obj_set_style_local_border_opa(win_pwd, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_100);  // 设置边框透明
    lv_obj_set_style_local_bg_color(win_pwd, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_CYAN); // 设置颜色
    lv_win_set_title(win_pwd, "密码输入");                                                       // 设置窗体的标题
    lv_win_set_btn_width(win_pwd, 30);                                                           // 设置控制按钮的大小
    // lv_obj_set_pos(win_pwd,85,15);//设置坐标
    lv_obj_align(win_pwd, NULL, LV_ALIGN_CENTER, 0, 0);

    // 往窗体页面中添加一个长文本的标签子对象
    lv_obj_t *label1 = lv_label_create(win_pwd, NULL);
    lv_obj_set_style_local_text_font(label1, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, &GBhzk22); //&style_hzk28);&style_roboto_22//设置样式
    lv_label_set_text(label1, Password_dis[0][0]);                                          // 请输入密码
    lv_obj_align(label1, NULL, LV_ALIGN_IN_TOP_LEFT, 20, 10);

    // 创建spinbox对象,数字设置
    pwd_spinbox = lv_spinbox_create(win_pwd, NULL);
    lv_obj_set_size(pwd_spinbox, 90, 40);                          // 设置大小
    lv_obj_align(pwd_spinbox, NULL, LV_ALIGN_IN_TOP_LEFT, 80, 60); //(pwd_spinbox,NULL,LV_ALIGN_CENTER,0,0);//与屏幕居中对齐     //左对齐 LV_ALIGN_IN_TOP_LEFT
    lv_spinbox_set_step(pwd_spinbox, 1);                           // 设置step步值为10   Cutrpos
    lv_spinbox_set_range(pwd_spinbox, 0, 9999);                    // 设置数值范围[-1000,1000]
    lv_spinbox_set_padding_left(pwd_spinbox, 6);                   // 设置空格间隙
    lv_spinbox_set_digit_format(pwd_spinbox, 4, 0);                // 设置显示格式,数值总共4位,小数点在第3位
    lv_spinbox_set_value(pwd_spinbox, 0);                          // 设置起始值为0
    // lv_obj_set_event_cb(pwd_spinbox, event_handler_cb);
    // DisEdit.Cutrpos = 0;
}


int ui_comp_input_pwd_get_value(void)
{
    return lv_spinbox_get_value(pwd_spinbox);
}

/**
 * @brief 
 * @param  type             操作类型（上下左右按键）
 * @return int 
 * @date 2025-12-31
 */
int ui_comp_input_set_spinbox(SpinboxSetOperate type)
{
    ui_spinbox_set_operate(pwd_spinbox, type);
}