EU1KY AA
textbox.h
Go to the documentation of this file.
1 #ifndef _TEXTBOX_H_
2 #define _TEXTBOX_H_
3 
4 #include <stdint.h>
5 #include "font.h"
6 
7 typedef enum
8 {
9  TEXTBOX_TYPE_TEXT = 0, //Visible item with text
10  TEXTBOX_TYPE_BMP, //Visible item with bitmap. User MUST provide correct bmp, bmpsize, width and height parameters. Only 8BPP bitmaps are supported!
11  TEXTBOX_TYPE_HITRECT, //Invisible hit rectangle
13 
14 #pragma pack(push,1)
15 typedef struct
16 {
17  uint8_t type : 3; //TEXTBOX_TYPE_t
18  uint8_t border : 1; //Set to 1 to draw border
19  uint8_t cbparam : 1; //Set to 1 to use callback with parameter
20  uint8_t center : 1; //Set to 1 to center text in the box with predefined width and height
21  uint8_t nowait; //Set to nonzero to bypass waiting for touch release and to return 0 from hit test func
22  uint16_t x0; //Origin x
23  uint16_t y0; //Origin y
24  union
25  {
26  const char* text; //Text of the box for TEXTBOX_TYPE_TEXT type
27  uint8_t *bmp; //Pointer to 8BPP bitmap file placed in memory, for TEXTBOX_TYPE_BMP type
28  };
29  union
30  {
31  uint32_t font; //Font of the box for TEXTBOX_TYPE_TEXT type
32  uint32_t bmpsize; //Bitmap data size in bytes for TEXTBOX_TYPE_BMP type
33  };
34  uint32_t fgcolor; //Foreground color for TEXTBOX_TYPE_TEXT type
35  uint32_t bgcolor; //Background color for TEXTBOX_TYPE_TEXT type
36  void (*cb)(void); //Callback function to be called when textbox is tapped
37  // uint16_t val; // Callback value WK
38  uint16_t width; //Filled automatically for TEXTBOX_TYPE_TEXT type
39  uint16_t height; //Filled automatically for TEXTBOX_TYPE_TEXT type
40  void *next; //Filled automatically in TEXTBOX_Append
41 } TEXTBOX_t;
42 #pragma pack(pop)
43 
44 typedef struct
45 {
48 
50 uint32_t TEXTBOX_Append(TEXTBOX_CTX_t* ctx, TEXTBOX_t* hbox);
52 void TEXTBOX_Clear(TEXTBOX_CTX_t *ctx, uint32_t idx);
53 void TEXTBOX_SetText(TEXTBOX_CTX_t *ctx, uint32_t idx, const char *txt);
54 uint32_t TEXTBOX_HitTest(TEXTBOX_CTX_t *ctx);
55 TEXTBOX_t* TEXTBOX_Find(TEXTBOX_CTX_t *ctx, uint32_t idx);
56 
57 #endif //_TEXTBOX_H_
uint16_t y0
Definition: textbox.h:23
Definition: textbox.h:15
uint32_t TEXTBOX_Append(TEXTBOX_CTX_t *ctx, TEXTBOX_t *hbox)
Definition: textbox.c:45
uint32_t bmpsize
Definition: textbox.h:32
uint8_t * bmp
Definition: textbox.h:27
void TEXTBOX_InitContext(TEXTBOX_CTX_t *ctx)
Definition: textbox.c:15
uint32_t fgcolor
Definition: textbox.h:34
Definition: textbox.h:11
Definition: textbox.h:44
TEXTBOX_TYPE_t
Definition: textbox.h:7
Definition: textbox.h:9
uint32_t font
Definition: textbox.h:31
void TEXTBOX_DrawContext(TEXTBOX_CTX_t *ctx)
Definition: textbox.c:108
Definition: textbox.h:10
uint16_t x0
Definition: textbox.h:22
uint16_t height
Definition: textbox.h:39
void TEXTBOX_SetText(TEXTBOX_CTX_t *ctx, uint32_t idx, const char *txt)
Definition: textbox.c:86
void TEXTBOX_Clear(TEXTBOX_CTX_t *ctx, uint32_t idx)
Definition: textbox.c:74
uint16_t width
Definition: textbox.h:38
const char * text
Definition: textbox.h:26
uint32_t TEXTBOX_HitTest(TEXTBOX_CTX_t *ctx)
Definition: textbox.c:160
TEXTBOX_t * TEXTBOX_Find(TEXTBOX_CTX_t *ctx, uint32_t idx)
Definition: textbox.c:22
void * next
Definition: textbox.h:40
uint32_t bgcolor
Definition: textbox.h:35
void(Delete(void))
Definition: mainwnd.c:360
TEXTBOX_t * start
Definition: textbox.h:46
uint8_t nowait
Definition: textbox.h:21