-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_tests.c
118 lines (94 loc) · 3.93 KB
/
main_tests.c
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// =================================================================================== //
// This program is free software: you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation, either version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <https://www.gnu.org/licenses/>5. //
// //
// Copyright: Luiz Gustavo Pfitscher e Feldmann, 2020 //
// =================================================================================== //
#include "boxcanvas.h"
#include "terminaldialogbox.h"
#include <stdio.h>
void demo_Boxes()
{
BoxCanvas canvas;
BoxCanvas_Create(&canvas, 0, 0, 0, 0); // o width or height means "fullscreen"
canvas.FillStyle = CONSOLE_STYLE_TEXT_WHITE;
canvas.BackgroundStyle = CONSOLE_STYLE_BACKGROUND_GREY;
BoxCanvas_Box(&canvas, 10, 10, 10, 10, BOX_STYLE_STRONG);
BoxCanvas_Box(&canvas, 25, 10, 10, 10, BOX_STYLE_WEAK);
BoxCanvas_Box(&canvas, 40, 10, 10, 10, BOX_STYLE_SHADOW);
BoxCanvas_Box(&canvas, 10, 25, 50, 10, BOX_STYLE_STRONG | BOX_STYLE_SHADOW);
BoxCanvas_Box(&canvas, 10, 25, 25, 8, BOX_STYLE_WEAK);
BoxCanvas_Box(&canvas, 30, 27, 10, 4, BOX_STYLE_SHADOW | BOX_STYLE_FILL);
BoxCanvas_Render(&canvas);
fflush(stdin);
getc(stdin);
Terminal_SetStyle(CONSOLE_STYLE_TEXT_WHITE, CONSOLE_STYLE_BACKGROUND_BLACK);
}
void demo_Msg()
{
int opt = ShowMessageBox("TITLE HERE", "This is the text inside the message box.", 3, (char *[]){"OPTION 0", "OPTION 1", "OPTION 2"}, DIALOG_BOX_STYLE_RED);
Terminal_SetStyle(CONSOLE_STYLE_TEXT_WHITE, CONSOLE_STYLE_BACKGROUND_BLACK);
Terminal_Clear();
Terminal_RestoreCursorSavedPosition();
printf("\nYou chose option %d\n", opt);
}
void demo_Explore()
{
char path[256] = "";
int result = ShowFileExplorer(path, "c", "Please pick a .c file", 1, DIALOG_BOX_STYLE_BLUE);
Terminal_SetStyle(CONSOLE_STYLE_TEXT_WHITE, CONSOLE_STYLE_BACKGROUND_BLACK);
Terminal_Clear();
Terminal_RestoreCursorSavedPosition();
if (!result)
printf("\nYou did not pick a file!\n");
else
printf("\nPath: %s\n", path);
}
void demo_Slider()
{
float def = 5.0;
float min = 1.0;
float max = 10.0;
float step = 0.5;
float val = ShowSliderBox("TITLE HERE", "Use arrows to move slider below", min, def, max, step, DIALOG_BOX_STYLE_GREY);
Terminal_Clear();
Terminal_RestoreCursorSavedPosition();
printf("\nThe value is %f\n", val);
}
int main(int argc, char** argv)
{
printf("1 - demo boxes\n");
printf("2 - demo message box\n");
printf("3 - demo file explorer\n");
printf("4 - demo slider bar\n");
printf("\n>> ");
fflush(stdin);
char opt = getc(stdin);
Terminal_SaveCursorPosition();
switch (opt)
{
case '1':
demo_Boxes();
break;
case '2':
demo_Msg();
break;
case '3':
demo_Explore();
break;
case '4':
demo_Slider();
break;
default: break;
}
}