applicat.cpp Spostata gestione evento E_FONT

config.cpp     Aggiunti metodi per convertire i colori
controls.cpp   Gestito meglio il font dell'interfaccia
window.cpp     Aggiunto metodo per cambiare il colore dello sfondo


git-svn-id: svn://10.65.10.50/trunk@3248 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1996-07-26 15:41:29 +00:00
parent e4884eb6f9
commit 4f621ab513
8 changed files with 133 additions and 78 deletions

View File

@ -178,16 +178,6 @@ long XVT_CALLCONV1 TApplication::task_eh(WINDOW win, EVENT *ep)
backdrop_eh(win, ep);
break;
#endif
case E_FONT:
{
XVT_FNTID new_font = ep->v.font.font_id;
char font_ser_desc[512];
TConfig font(CONFIG_USER, "Font");
xvt_font_serialize(new_font, font_ser_desc, sizeof(font_ser_desc));
font.set("FontDesc", font_ser_desc);
}
break;
default:
break;
}
@ -215,54 +205,67 @@ long TApplication::handler(WINDOW win, EVENT* ep)
else
stop_run();
break;
case E_COMMAND:
switch(ep->v.cmd.tag)
{
case M_FILE_QUIT:
case E_COMMAND:
switch(ep->v.cmd.tag)
{
case M_FILE_QUIT:
if (can_close())
stop_run();
break;
case M_FILE_PG_SETUP:
printer().set();
break;
case M_FILE_PRINT:
print();
break;
case M_FILE_NEW:
set_firm();
break;
case M_FILE_REVERT:
if (config())
on_config_change();
break;
case (M_FILE+11):
about();
break;
default:
if (ep->v.cmd.tag >= BAR_ITEM(1))
{
if(!menu(ep->v.cmd.tag))
stop_run();
}
break;
}
break;
case E_CLOSE:
if (can_close())
stop_run();
break;
case M_FILE_PG_SETUP:
printer().set();
case E_FONT:
{
XVT_FNTID new_font = ep->v.font.font_id;
char font_ser_desc[512];
TConfig font(CONFIG_USER, "Font");
xvt_font_serialize(new_font, font_ser_desc, sizeof(font_ser_desc));
font.set("FontDesc", font_ser_desc);
font.set_paragraph("Colors"); // Forza la scrittura del paragrafo
xvt_load_default_font();
}
break;
case M_FILE_PRINT:
print();
break;
case M_FILE_NEW:
set_firm();
break;
case M_FILE_REVERT:
if (config())
on_config_change();
break;
case (M_FILE+11):
about();
case E_QUIT:
if (ep->v.query)
{
if (can_close())
xvt_app_allow_quit();
}
else
stop_run();
break;
default:
if (ep->v.cmd.tag >= BAR_ITEM(1))
{
if(!menu(ep->v.cmd.tag))
stop_run();
}
break;
}
break;
case E_CLOSE:
if (can_close())
stop_run();
break;
case E_QUIT:
if (ep->v.query)
{
if (can_close())
xvt_app_allow_quit();
}
else
stop_run();
break;
default:
break;
}
return 0L;
}

View File

@ -130,7 +130,7 @@ public:
TObject* get();
// @cmember Ritorna l'oggetto e la relativa chiave
THash_object* get_hashobj();
// @cmember Azzera il numero di righe e colonne della tabella hash
// @cmember Azzera il numero di riga e colonna corrente della tabella hash
void restart()
{ _row = 0; _col = 0; }

View File

@ -337,6 +337,30 @@ HIDDEN void RGB_COLOR(COLOR c, int& r, int& g, int& b)
b = int(c) & 0xFF;
}
COLOR RGB2COLOR(unsigned char red, unsigned char green, unsigned char blue)
{
COLOR def = MAKE_COLOR(red, green, blue);
// Se nel colore non compare l'indice cerca di calcolarlo
const byte color_index = byte(def >> 12);
if (color_index < 0x1 || color_index > 0xF)
{
const COLOR native_color[11] = { COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_CYAN,
COLOR_MAGENTA, COLOR_YELLOW, COLOR_BLACK, COLOR_DKGRAY,
COLOR_GRAY, COLOR_LTGRAY, COLOR_WHITE };
for (int c = 0; c < 11; c++)
{
if (def == (native_color[c] & 0x00FFFFFF)) // Confronta solo la terna R,G,B
{
def = native_color[c];
break;
}
}
}
return def;
}
// @doc EXTERNAL
// @mfunc Ritorna il valore del colore settato nella variabile nella
@ -358,36 +382,18 @@ COLOR TConfig::get_color(
if (*c)
{
TToken_string s(c, ',');
const int r = s.get_int();
const int g = s.get_int();
const int b = s.get_int();
def = MAKE_COLOR(r, g, b);
const byte r = (byte)s.get_int();
const byte g = (byte)s.get_int();
const byte b = (byte)s.get_int();
def = RGB2COLOR(r, g, b);
}
else
{
int r, g, b; RGB_COLOR(def, r, g, b);
TString16 d; d << r << ',' << g << ',' << b;
TString16 d; d.format("%d,%d,%d", r, g, b);
set(var, d, section, TRUE, index);
}
// Se nel colore non compare l'indice cerca di calcolarlo
const byte color_index = byte(def >> 12);
if (color_index < 0x1 || color_index > 0xF)
{
const COLOR native_color[11] = { COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_CYAN,
COLOR_MAGENTA, COLOR_YELLOW, COLOR_BLACK, COLOR_DKGRAY,
COLOR_GRAY, COLOR_LTGRAY, COLOR_WHITE };
for (int c = 0; c < 11; c++)
{
if (def == (native_color[c] & 0x00FFFFFF)) // Confronta solo la terna R,G,B
{
def = native_color[c];
break;
}
}
}
return def;
}

View File

@ -143,4 +143,6 @@ public:
virtual ~TConfig();
};
COLOR RGB2COLOR(unsigned char red, unsigned char green, unsigned char blue);
#endif

View File

@ -84,6 +84,7 @@ public:
const TImage& image(short id) const { return (const TImage&)operator[](id); }
bool exist(short id) const { return objptr(id) != NULL; }
void reload();
TPicture_array() : TArray(128) {}
virtual ~TPicture_array() {}
@ -103,6 +104,19 @@ TImage& TPicture_array::add(short id)
return *i;
}
void TPicture_array::reload()
{
for (int id = last(); id >= 0; id--)
{
TImage* i = (TImage*)objptr(id);
if (i)
{
i->load(id);
i->convert_transparent_color();
}
}
}
///////////////////////////////////////////////////////////
// Utility functions
///////////////////////////////////////////////////////////
@ -152,6 +166,21 @@ XVT_FNTID xvt_default_font(bool bold)
return bold ? FAT_FONT : DEF_FONT;
}
XVT_FNTID xvt_load_default_font()
{
if (DEF_FONT)
{
xvt_font_destroy(DEF_FONT);
DEF_FONT = NULL;
}
if (FAT_FONT)
{
xvt_font_destroy(FAT_FONT);
FAT_FONT = NULL;
}
return xvt_default_font(FALSE);
}
static byte event_map[XIE_POST_NAVIGATION+1];
enum event_action { a_ignore, a_xvt, a_xvt_post, a_obj, a_child, a_update, a_select, a_post, a_debug };
@ -198,12 +227,12 @@ void customize_colors()
aga_set_pref(AGA_PREF_BTN_COLOR_DARK, BTN_DARK_COLOR);
if (_picture)
_picture->destroy();
_picture->reload();
}
void init_controls()
{
xi_set_font_id(xvt_default_font());
xi_set_font_id(xvt_load_default_font());
xi_set_pref(XI_PREF_CARET_WIDTH, 2);
@ -328,6 +357,7 @@ WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy,
def->v.itf->automatic_back_color = FALSE;
def->v.itf->back_color = MASK_BACK_COLOR;
def->v.itf->font_id = xvt_default_font(FALSE);
def->v.itf->tab_on_enter = TRUE;
def->v.itf->win = win;
@ -1354,6 +1384,7 @@ void TPushbutton_control::update()
else
{
RCT& r = _obj->v.btn->rct;
xvt_dwin_set_font(win, xvt_default_font());
int ascent, descent;
xvt_dwin_get_font_metrics(win, NULL, &ascent, &descent);

View File

@ -16,6 +16,7 @@ class TMask_field; // __MASKFLD_H
void init_controls();
void free_controls();
XVT_FNTID xvt_default_font(bool bold = FALSE);
XVT_FNTID xvt_load_default_font();
WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy,
const char* caption, TWindow* mask, bool tags);

View File

@ -1,4 +1,8 @@
#define STRICT
#define XI_INTERNAL
#include <xi.h>
#define XVT_INCL_NATIVE
#include <applicat.h>
#include <checks.h>
@ -10,7 +14,6 @@
#include <colors.h>
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_NT
#define STRICT
#include <windows.h>
#endif
@ -751,6 +754,14 @@ void TWindow::maximize() const
RCT r; xvt_rect_set(&r, 1,1,79,23);
xvt_vobj_move(win(),&r);
#endif
}
void TWindow::set_background_color(COLOR col)
{
XI_OBJ* itf = xi_get_itf(win());
itf->v.itf->back_color = col;
force_update();
}
// @doc EXTERNAL

View File

@ -259,7 +259,8 @@ public:
virtual bool stop_run(KEY key);
// @cmember Forza ridisegno della finestra
void force_update();
// @cmember Cambia il colore dello sfondo
void set_background_color(COLOR col);
// @cmember Mostra la finestra
virtual void open();
// @cmember Nasconde la finestra