Progress of the configuration menu, and some enhancements

This commit is contained in:
Nemh 2015-05-31 14:17:43 +02:00
parent fc254b0784
commit c9c0fb8b56
8 changed files with 38 additions and 43 deletions

View File

@ -161,8 +161,8 @@ SourceFile=:tex\disp.src
SourceFile=:tex\libText.c
SourceFile=:tex\math.c
SourceFile=:print.cpp
SourceFile=:draw.cpp
SourceFile=:config.c
SourceFile=:coeff.cpp
HeaderFile=:defs.h
HeaderFile=:prototypes.h
HeaderFile=:setjmp.h

View File

@ -66,7 +66,7 @@ int AddIn_main(int isAppli, unsigned short OptionNum)
unsigned char *expr;
char fkey = NULL;
fkey = *(get_tex_flag_address());
//fkey = *(get_tex_flag_address());
initialize_tuamath();
// initialize failed ?

View File

@ -1,14 +1,6 @@
#include <stdlib.h>
#include <fxlib.h>
#ifdef __cplusplus
extern "C"{
#endif
#include "defs.h"
#ifdef __cplusplus
}
#endif
#include "config.h"
#include "console.h"
@ -17,21 +9,15 @@ extern "C"{
#define menu_free_item(item) if(item) free(item->str)
// Draws a menu in a popup-style window.
#ifdef __cplusplus
extern "C"{
#endif
extern char* get_tex_flag_address();
#ifdef __cplusplus
}
#endif
extern int* get_tex_flag_address();
int test;
void draw_menu(Menu* menu)
{
int x, y, i, key;
int longest = 0, tmp;
int border = 1, margin = 2, check_box_width = 10, item_height = 7, letter_width = 4;
int border = 1, margin = 2, check_box_width = 15, item_height = 7, letter_width = 4;// inter_line = 1;
int cursor_y = 0;
DISPBOX box;
@ -44,7 +30,7 @@ void draw_menu(Menu* menu)
box.left = (WIDTH/2) - (longest/2) - margin - border;
box.right = box.left + longest + 2*margin + 2*border;
box.bottom = (HEIGHT/2) + (menu->items_number * item_height)/2 + margin + border;
box.bottom = (HEIGHT/2) + (menu->items_number * item_height)/2 /*+ margin*/ + border;
box.top = HEIGHT - box.bottom;
Bdisp_AreaClr_VRAM(&box);
@ -58,16 +44,16 @@ void draw_menu(Menu* menu)
PrintMini(box.left + border + margin, box.top + margin + item_height*i, (unsigned char*)menu->items[i]->str, MINI_OVER);
if(menu->items[i]->type == CHECK_BOX) {
if((menu->items[i]->action.value)) {
if(*(menu->items[i]->action.value)) PrintMini(box.right - border - margin - check_box_width , box.top + margin + item_height*i, (unsigned char*)"[v]", MINI_OVER);
else PrintMini(box.right - border - margin - check_box_width , box.top + margin + item_height*i, (unsigned char*)"[x]", MINI_OVER);
if(*(menu->items[i]->action.value)) PrintMini(box.right - border - margin - (check_box_width/2) , box.top + margin + item_height*i, (unsigned char*)"[x]", MINI_OVER);
else PrintMini(box.right - border - margin - (check_box_width/2) , box.top + margin + item_height*i, (unsigned char*)"[ ]", MINI_OVER);
}
}
}
PrintMini(box.left + border + margin, box.top + margin + item_height*cursor_y, (unsigned char*)menu->items[cursor_y]->str, MINI_REV);
if(menu->items[cursor_y]->type == CHECK_BOX) {
if((menu->items[cursor_y]->action.value)) {
if(*(menu->items[cursor_y]->action.value)) PrintMini(box.right - border - margin - check_box_width , box.top + margin + item_height*cursor_y, (unsigned char*)"[v]", MINI_OVER);
else PrintMini(box.right - border - margin - check_box_width , box.top + margin + item_height*cursor_y, (unsigned char*)"[x]", MINI_OVER);
if(*(menu->items[cursor_y]->action.value)) PrintMini(box.right - border - margin - (check_box_width/2) , box.top + margin + item_height*cursor_y, (unsigned char*)"[x]", MINI_OVER);
else PrintMini(box.right - border - margin - (check_box_width/2) , box.top + margin + item_height*cursor_y, (unsigned char*)"[ ]", MINI_OVER);
}
}
GetKey(&key);
@ -86,39 +72,44 @@ void draw_menu(Menu* menu)
else if(menu->items[cursor_y]->type == FUNCTION_CALL) {
if(menu->items[cursor_y]->action.function != NULL) {
(*(menu->items[cursor_y]->action.function))(); //Calling the function
break;
}
}
}
}
GetKey(&key);
}
void menu_setup()
{
int number = 3;
int number = 2;
Menu menu;
menu.items = malloc(sizeof(Menu_Item*) * number);
menu.items[0] = menu_create_item("Test string", CHECK_BOX, &test);
menu.items[1] = menu_create_item("Test -- waza(bi)", FUNCTION_CALL, menu_test);
menu.items[2] = menu_create_item("Tex flag", CHECK_BOX, get_tex_flag_address());
if(menu.items[0] && menu.items[1]&& menu.items[2]) menu.items_number = number;
menu.items[0] = menu_create_item("About", FUNCTION_CALL, menu_about);
menu.items[1] = menu_create_item("Tex flag", CHECK_BOX, get_tex_flag_address());
if(menu.items[0] && menu.items[1]) menu.items_number = number;
else {
menu_free_item(menu.items[0]);
menu_free_item(menu.items[1]);
menu_free_item(menu.items[2]);
}
draw_menu(&menu);
menu_free_item(menu.items[0]);
menu_free_item(menu.items[1]);
free(menu.items);
}
void menu_test()
void menu_about()
{
int key;
PopUpWin(4);
PopUpWin(5);
PrintMini(12, 6, (unsigned char*)"Eigenmath symbolic maths", MINI_OVER);
PrintMini(51, 13, (unsigned char*)"engine", MINI_OVER);
PrintMini(12, 20, (unsigned char*)"Ported by Mike.", MINI_OVER);
PrintMini(12, 27, (unsigned char*)"Enhanced by Nemh and the", MINI_OVER);
PrintMini(38, 34, (unsigned char*)"PC community.", MINI_OVER);
PrintMini(40, 41, (unsigned char*)"Early build", MINI_OVER);
GetKey(&key);
return;
}

View File

@ -27,7 +27,7 @@ typedef struct {
void draw_menu(Menu* menu);
void menu_setup();
void menu_test();
void menu_about();
Menu_Item* menu_create_item(const char* str, Menu_Item_Type type, void* other);
#ifdef __cplusplus

View File

@ -617,7 +617,7 @@ int Console_GetKey()
return CONSOLE_SUCCEEDED;
}
if (key == KEY_CTRL_INS) {
/*if (key == KEY_CTRL_INS) {
if (!Line[Current_Line].readonly) {
Edit_Line[0] = '\0';
Line[Current_Line].start_col = 0;
@ -626,7 +626,7 @@ int Console_GetKey()
Cursor.x = 0;
}
return Console_Init();
}
}*/
if (key == KEY_CTRL_SETUP) {
menu_setup();
@ -856,7 +856,7 @@ void Console_FMenu_Init()
// Does the file exists ?
// Todo : check the error codes...
if(!cfg) {
unsigned char conf_standard[] = {"F1 alge\nabs(\ndet(\nadj(\nunit(\nF2 trig\ncosh(\narccosh(\nsinh(\narcsinh(\ntanh(\narctanh(\nF3 cplx\narg(\nconj(\nimag(\nmag(\npolar(\nreal(\nrect(\nF4 calc\nd(\neval(\nintegral(\ntaylor(\nsum(\nsimplify(\nF5 poly\ncoeff(\nquotient(\ndeg(\nexpand(\nfactor(\nroots(\nnroots(\nF6 misc\nf(\ny\nsimplify("};
unsigned char conf_standard[] = {"F1 calc\nd(\nintegral(\ntaylor(\nsum(\nproduct(\nsimplify(\nfactor(\nF2 trig\ncosh(\narccosh(\nsinh(\narcsinh(\ntanh(\narctanh(\nF3 cplx\nmag(\narg(\nreal(\nimag(\nconj(\npolar(\nrect(\nF4 alge\nabs(\ndet(\nadj(\ncross(\ncurl(\ncontract(\nhilbert(\nF5 poly\nnroots(\ndeg(\ncoeff(\nquotient(\nhermite(\nlaguerre(\nlegendre(\nF6 arit\nmod(\ngcd(\nlcd(\nisprime(\nprime(\nfactor(\n"};
memory_createfile("\\\\fls0\\FMENU.cfg", strlen((char*)conf_standard)+1);
handle = memory_openfile("\\\\fls0\\FMENU.cfg", _OPENMODE_READWRITE);
memory_writefile(handle, conf_standard, strlen((char*)conf_standard)+1);

View File

@ -26,7 +26,7 @@ static double ymin, ymax;
#define YMAX 1000
typedef static struct {
typedef struct {
int x, y;
double t;
} DRAWBUF;

View File

@ -10,7 +10,9 @@
#define MAX_TEX_WIDTH 110
#define MAX_TEX_HEIGHT 50
static char tex_flag = 0;
//char* get_tex_flag_address();
int tex_flag = 1;
int out_index, out_length;
char *out_str;
@ -18,10 +20,12 @@ static int char_count, last_char;
char *power_str = "^";
char* get_tex_flag_address()
extern "C"{
int* get_tex_flag_address()
{
return &tex_flag;
}
}
void
print(U *p)
@ -32,7 +36,7 @@ print(U *p)
void
printline(U *p)
{
int old_tex_flag = *((int*)(get_tex_flag_address));
int old_tex_flag = tex_flag;
#ifdef TEX
int width, height, baseline;
char* edit_line = (char*)Console_GetEditLine();

View File

@ -748,7 +748,7 @@ void prime(void);
// primetab.cpp
// print.cpp
char* get_tex_flag_address();
//char* get_tex_flag_address();
void print(U *p);
void printline(U *p);
void print_subexpr(U *p);