-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlistbox.h
102 lines (89 loc) · 3.77 KB
/
listbox.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
========================================================================
- HEADER -
Module to implement a listBox integrated with LYNX.
@author : Velorek
@version : 1.0
Last modified: 26/12/2022
========================================================================
*/
#ifndef _LISTBOX_H_
#define _LISTBOX_H_
/*====================================================================*/
/* COMPILER DIRECTIVES AND INCLUDES */
/*====================================================================*/
#include <stdio.h>
#include "scbuf.h"
/*====================================================================*/
/* CONSTANTS */
/*====================================================================*/
//Scroll Control values.
#define SCROLL_ACTIVE 1
#define SCROLL_INACTIVE 0
#define CONTINUE_SCROLL -1
#define DOWN_SCROLL 1
#define UP_SCROLL 0
#define SELECT_ITEM 1
#define UNSELECT_ITEM 0
#define CIRCULAR_ACTIVE 1
#define CIRCULAR_INACTIVE 0
#define LOCKED 1
#define NOT_LOCKED 0
/*====================================================================*/
/* TYPEDEF STRUCTS DEFINITIONS */
/*====================================================================*/
typedef struct _listchoice {
unsigned index; // Item number
char *item; // Item string
struct _listchoice *next; // Pointer to next item
struct _listchoice *back; // Pointer to previous item
} LISTCHOICE;
typedef struct _scrolldata {
unsigned scrollActive; //To know whether scroll is active or not.
unsigned scrollLimit; //Last index for scroll.
unsigned listLength; //Total no. of items in the list
unsigned currentListIndex; //Pointer to new sublist of items when scrolling.
unsigned displayLimit; //No. of elements to be displayed.
unsigned selectorLimit; //how many items of string item can be displayed
unsigned scrollDirection; //To keep track of scrolling Direction.
unsigned wherex;
unsigned wherey;
unsigned selector; //Y++
unsigned backColor0; //0 unselected; 1 selected
unsigned foreColor0;
unsigned backColor1;
unsigned foreColor1;
unsigned displayMetrics; //to show metrics on screen/reuse code for text viewing
char *item;
int itemIndex; //-1 means ESC was pressed
LISTCHOICE *head; //store head of the list
} SCROLLDATA;
/*====================================================================*/
/* GLOBAL VARIABLES */
/*====================================================================*/
extern LISTCHOICE *listBox1; //Head pointer.
/*====================================================================*/
/* PROTOTYPES OF FUNCTIONS */
/*====================================================================*/
//DYNAMIC LINKED LIST FUNCTIONS
void removeList(LISTCHOICE ** head);
LISTCHOICE *addatend(LISTCHOICE * head, LISTCHOICE * newp);
LISTCHOICE *newitem(char *text);
//LISTBOX FUNCTIONS
//void addItems(LISTCHOICE ** listBox1);
char listBox(LISTCHOICE * selector, unsigned whereX, unsigned whereY,
SCROLLDATA * scrollData, unsigned bColor0,
unsigned fColor0, unsigned bColor1, unsigned fColor1,
unsigned displayLimit, unsigned locked);
void loadlist(LISTCHOICE * head, SCROLLDATA * scrollData, unsigned indexAt);
void printlist(LISTCHOICE * head, SCROLLDATA * scrollData,
unsigned displayLimit);
void gotoIndex(LISTCHOICE ** aux, SCROLLDATA * scrollData, unsigned indexAt);
int query_length(LISTCHOICE ** head);
int move_selector(LISTCHOICE ** head, SCROLLDATA * scrollData);
char selectorMenu(LISTCHOICE * aux, SCROLLDATA * scrollData);
void displayItem(LISTCHOICE * aux, SCROLLDATA * scrollData, int select);
/*====================================================================*/
/* FUNCTION PROTOTYPES */
/*====================================================================*/
#endif