Patch level : 10.0

Files correlati     : tutti
Ricompilazione Demo : [ ]
Commento            :
Coretta gestione Copia/Incolla in finestre di ricerca


git-svn-id: svn://10.65.10.50/trunk@17473 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2008-10-24 15:45:54 +00:00
parent 0238fb2229
commit 73eb9c8753
12 changed files with 68 additions and 88 deletions

View File

@ -135,8 +135,7 @@ long TApplication::task_eh(WINDOW win, EVENT *ep)
// Setta la caption della task window // Setta la caption della task window
TString cap; TString cap;
cap << _application->get_module_name() << " - " << dongle().reseller(); cap << _application->get_module_name() << " - " << dongle().reseller();
TTemp_window tw(win); xvt_vobj_set_title(win, cap);
tw.set_caption(cap);
// Carica colori e font // Carica colori e font
customize_controls(TRUE); customize_controls(TRUE);
@ -144,7 +143,7 @@ long TApplication::task_eh(WINDOW win, EVENT *ep)
xvtil_create_statbar(); xvtil_create_statbar();
xvtil_statbar_set(""); xvtil_statbar_set("");
do_events(); // strateggicca non scancellare do_events(); // strateggica non scancellare
} }
break; break;
case E_UPDATE: case E_UPDATE:
@ -218,6 +217,19 @@ long TApplication::handler(WINDOW win, EVENT* ep)
dispatch_e_char(w, K_F1); dispatch_e_char(w, K_F1);
} }
break; break;
case M_EDIT_CUT:
case M_EDIT_COPY:
case M_EDIT_PASTE:
{
// I comandi della clipborad vanno ridiretti alla finestra col focus
WINDOW w = xvt_scr_get_focus_vobj();
if (w != NULL_WIN && w != win) // Evito ciclo infinito
{
dispatch_event(w, *ep, true);
break;
}
}
// fall down to normal processing
default: default:
if (ep->v.cmd.tag > MAX_MENU_TAG) if (ep->v.cmd.tag > MAX_MENU_TAG)
{ {

View File

@ -7,6 +7,7 @@ COLOR RGB2COLOR(unsigned char red, unsigned char green, unsigned char blue)
{ {
COLOR def = XVT_MAKE_COLOR(red, green, blue); COLOR def = XVT_MAKE_COLOR(red, green, blue);
/*
#ifndef DBG #ifndef DBG
// Se nel colore non compare l'indice cerca di calcolarlo // Se nel colore non compare l'indice cerca di calcolarlo
const unsigned char color_index = (unsigned char)(def >> 12); const unsigned char color_index = (unsigned char)(def >> 12);
@ -27,6 +28,7 @@ COLOR RGB2COLOR(unsigned char red, unsigned char green, unsigned char blue)
} }
} }
#endif #endif
*/
return def; return def;
} }
@ -61,9 +63,10 @@ COLOR grayed_color(COLOR col)
return XVT_MAKE_COLOR(k, k, k); return XVT_MAKE_COLOR(k, k, k);
} }
/*
unsigned int color_distance(COLOR col1, COLOR col2) unsigned int color_distance(COLOR col1, COLOR col2)
{ {
if ((col1 & 0x00FFFFFF) == (col2 & 0x00FFFFFF)) if (same_color(col1, col2))
return 0; return 0;
const int r1 = XVT_COLOR_GET_RED(col1); const int r1 = XVT_COLOR_GET_RED(col1);
@ -77,6 +80,7 @@ unsigned int color_distance(COLOR col1, COLOR col2)
const int b = abs(b1-b2); const int b = abs(b1-b2);
return (r > g && r > b) ? r : (g > b ? g : b); return (r > g && r > b) ? r : (g > b ? g : b);
} }
*/
class TColor_row_mask : public TMask class TColor_row_mask : public TMask
{ {

View File

@ -13,7 +13,8 @@ COLOR RGB2COLOR(unsigned char red, unsigned char green, unsigned char blue);
COLOR choose_color(COLOR col = COLOR_BLACK, WINDOW win = NULL_WIN); COLOR choose_color(COLOR col = COLOR_BLACK, WINDOW win = NULL_WIN);
COLOR blend_colors(COLOR col1, COLOR col2, double perc = 0.5); COLOR blend_colors(COLOR col1, COLOR col2, double perc = 0.5);
COLOR grayed_color(COLOR col); COLOR grayed_color(COLOR col);
unsigned int color_distance(COLOR col1, COLOR col2); inline bool same_color(COLOR col1, COLOR col2) { return (col1 & 0x00FFFFFF) == (col2 & 0x00FFFFFF); }
// unsigned int color_distance(COLOR col1, COLOR col2);
extern COLOR MASK_BACK_COLOR; extern COLOR MASK_BACK_COLOR;
extern COLOR MASK_LIGHT_COLOR; extern COLOR MASK_LIGHT_COLOR;

View File

@ -722,18 +722,11 @@ TConfig::TConfig(int which_config, const char* paragraph)
break; break;
case CONFIG_GUI: case CONFIG_GUI:
{ {
const TFilename ini = CGetCampoIni(); TFilename gui = "gui.ini";
TFilename gui = ini.path(); gui.add("gui.ini"); if (gui.custom_path())
bool ok = gui.exist();
if (!ok)
{ {
gui = "gui.ini"; _file = gui; // I colori sono qui ...
ok = gui.custom_path(); break; // ... scavalca utente
}
if (ok) // I colori sono qui, scavalca utente
{
_file = gui;
break;
} }
} }
case CONFIG_USER: case CONFIG_USER:

View File

@ -37,21 +37,20 @@ XVT_IMAGE TImage::set(
bool TImage::build_filename(TFilename& file) bool TImage::build_filename(TFilename& file)
{ {
const char * const exts[] = {"gif", "png", "bmp", "jpg", NULL};
bool ok = false; bool ok = false;
if (file.ext()[0] != '\0') if (file.ext()[0] != '\0')
ok = file.custom_path(); ok = file.custom_path();
if (!ok) if (!ok)
{ {
const char* const exts[] = { "png", "gif", "jpg", "jpeg", "bmp", "tif", "tiff", NULL};
for (int i = 0; !ok && exts[i]; i++) for (int i = 0; !ok && exts[i]; i++)
{ {
file.ext(exts[i]); file.ext(exts[i]);
ok = file.custom_path(); ok = file.custom_path();
if (!ok) if (!ok)
{ {
TFilename res(file); TFilename res(file.name());
res.insert("res/"); res.insert("res/");
ok = res.exist(); ok = res.exist();
if (ok) if (ok)
@ -182,29 +181,7 @@ void TImage::draw(WINDOW w, const RCT& dst) const
// Certified 100% // Certified 100%
void TImage::draw(WINDOW w, const RCT& dst, const RCT& src) const void TImage::draw(WINDOW w, const RCT& dst, const RCT& src) const
{ {
xvt_dwin_draw_image(w, _image, (RCT*)&dst, (RCT*)&src); xvt_dwin_draw_image(w, _image, &dst, &src);
}
// Certified 99%
// @doc EXTERNAL
// @mfunc Fa corrispondere la palette della finestra a quella dell'immagine
void TImage::set_palette(
WINDOW w) const // @parm Finestra a cui settare la palette
{
XVT_PALETTE wp = xvt_vobj_get_palet(w);
if (wp != NULL)
{
XVT_PALETTE p = xvt_palet_create(XVT_PALETTE_USER, 0L);
const int ncolors = xvt_palet_get_ncolors(wp);
COLOR* color = new COLOR[ncolors];
xvt_palet_get_colors(wp, color, ncolors);
xvt_palet_add_colors(p, color, ncolors);
delete color;
xvt_palet_add_colors_from_image(p, _image);
xvt_vobj_set_palet(w, p);
xvt_palet_destroy(wp);
}
} }
// Certified 100% // Certified 100%
@ -233,7 +210,7 @@ void TImage::convert_to_default_colors()
// @comm Legge nell'immagine i colori CYAN e DARK_CYAN e li setta a seconda del colore // @comm Legge nell'immagine i colori CYAN e DARK_CYAN e li setta a seconda del colore
// della finestra per fare in modo di rendere trasparenti tali colori. // della finestra per fare in modo di rendere trasparenti tali colori.
{ {
if (MASK_BACK_COLOR != COLOR_DKCYAN) if (!same_color(MASK_BACK_COLOR, COLOR_DKCYAN))
{ {
if (xvt_image_get_format(_image) == XVT_IMAGE_CL8) if (xvt_image_get_format(_image) == XVT_IMAGE_CL8)
@ -276,14 +253,14 @@ void TImage::convert_transparent_color(COLOR transparent)
if (_image == NULL) if (_image == NULL)
return; // Null image return; // Null image
const COLOR trans = get_pixel(0,0) & 0x00FFFFFF; const COLOR trans = get_pixel(0,0);
if (trans == (transparent & 0x00FFFFFF)) if (same_color(trans, transparent))
return; // Nothing to do return; // Nothing to do
if (xvt_image_get_format(_image) == XVT_IMAGE_CL8) if (xvt_image_get_format(_image) == XVT_IMAGE_CL8)
{ {
for (int index = xvt_image_get_ncolors(_image)-1; index >=0; index--) for (int index = xvt_image_get_ncolors(_image)-1; index >=0; index--)
if (trans == (xvt_image_get_clut(_image, index) & 0x00FFFFFF)) if (same_color(trans, xvt_image_get_clut(_image, index)))
{ {
xvt_image_set_clut(_image, index, transparent); xvt_image_set_clut(_image, index, transparent);
// break; don't break: replace all colors equal to upper left in the palette // break; don't break: replace all colors equal to upper left in the palette
@ -295,7 +272,7 @@ void TImage::convert_transparent_color(COLOR transparent)
for (short y = 0; y < dy; y++) for (short x = 0; x < dx; x++) for (short y = 0; y < dy; y++) for (short x = 0; x < dx; x++)
{ {
const COLOR c = get_pixel(x, y); const COLOR c = get_pixel(x, y);
if ((c & 0x00FFFFFF) == trans) if (same_color(c, trans))
set_pixel(x, y, transparent); set_pixel(x, y, transparent);
} }
} }
@ -327,14 +304,14 @@ void TImage::fade_to_gray(bool use_btn_colors)
if (_image == NULL) if (_image == NULL)
return; // Null image return; // Null image
const COLOR trans = get_pixel(0,0) & 0x00FFFFFF; const COLOR trans = get_pixel(0,0);
btncolor2btngray(trans, use_btn_colors); // Reset color conversion btncolor2btngray(trans, use_btn_colors); // Reset color conversion
if (xvt_image_get_format(_image) == XVT_IMAGE_CL8) if (xvt_image_get_format(_image) == XVT_IMAGE_CL8)
{ {
for (int index = xvt_image_get_ncolors(_image)-1; index >=0; index--) for (int index = xvt_image_get_ncolors(_image)-1; index >=0; index--)
{ {
COLOR pixie = xvt_image_get_clut(_image, index) & 0x00FFFFFF; const COLOR pixie = xvt_image_get_clut(_image, index);
if (pixie != trans) if (!same_color(pixie, trans))
xvt_image_set_clut(_image, index, btncolor2btngray(pixie, use_btn_colors)); xvt_image_set_clut(_image, index, btncolor2btngray(pixie, use_btn_colors));
} }
} }
@ -343,8 +320,8 @@ void TImage::fade_to_gray(bool use_btn_colors)
short dx, dy; xvt_image_get_dimensions(_image, &dx, &dy); short dx, dy; xvt_image_get_dimensions(_image, &dx, &dy);
for (short y = 0; y < dy; y++) for (short x = 0; x < dx; x++) for (short y = 0; y < dy; y++) for (short x = 0; x < dx; x++)
{ {
COLOR pixie = get_pixel(x, y) & 0x00FFFFFF; const COLOR pixie = get_pixel(x, y);
if (pixie != trans) if (!same_color(pixie, trans))
set_pixel(x, y, btncolor2btngray(pixie, use_btn_colors)); set_pixel(x, y, btncolor2btngray(pixie, use_btn_colors));
} }
} }

View File

@ -36,8 +36,6 @@ class TImage : public TObject
// @access Public Member // @access Public Member
public: public:
// @cmember Fa corrispondere la palette della finestra a quella dell'immagine
void set_palette(WINDOW w) const;
// @cmember Permette di settare la posizione della figura // @cmember Permette di settare la posizione della figura
void set_pos(int x, int y); void set_pos(int x, int y);

View File

@ -3431,7 +3431,7 @@ void TEdit_field::set_background()
switch (status) switch (status)
{ {
case 1: case 1:
if (color_distance(NORMAL_BACK_COLOR, REQUIRED_BACK_COLOR) != 0) if (!same_color(NORMAL_BACK_COLOR, REQUIRED_BACK_COLOR))
c = REQUIRED_BACK_COLOR; c = REQUIRED_BACK_COLOR;
break; break;
case 2: case 2:

View File

@ -302,7 +302,7 @@ static void set_num_attr(TXmlItem& item, const char* attr, long num, short def =
static void set_col_attr(TXmlItem& item, const char* attr, COLOR col, COLOR def = COLOR_BLACK) static void set_col_attr(TXmlItem& item, const char* attr, COLOR col, COLOR def = COLOR_BLACK)
{ {
if (color_distance(col, def) != 0) if (!same_color(col, def))
{ {
TString8 str; TString8 str;
str.format("#%06X", col & 0xFFFFFF); str.format("#%06X", col & 0xFFFFFF);

View File

@ -1299,7 +1299,7 @@ void TSheet::on_idle()
{ {
if (_select_row >= 0) if (_select_row >= 0)
{ {
const short focus_id = low_get_focus_id(win()); const short focus_id = low_get_focus_id(curr_win());
_sheet->select(_select_row); _sheet->select(_select_row);
if (focus_id == _sheet->id()) if (focus_id == _sheet->id())
_sheet->set_focus_rec(-1); _sheet->set_focus_rec(-1);

View File

@ -1,8 +1,8 @@
#include <xvt.h> #include <xvt.h>
#include <statbar.h> #include <statbar.h>
#include <date.h>
#include <diction.h> #include <diction.h>
#include <dongle.h>
#include <utility.h> #include <utility.h>
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -591,15 +591,16 @@ long daytime()
bool is_power_station() bool is_power_station()
{ {
const char* ranger[] = { "ANTARES", "ARCHIMEDE", "BATMOBILE", "KIRK", bool ok = false;
if (dongle().hardware() != _dongle_network)
{
const char* const ranger[] = { "ANTARES", "ARCHIMEDE", "BATMOBILE", "KIRK",
"MOBILE", "PICARD", "SPOCK", "SULU", "UHURA", NULL }; "MOBILE", "PICARD", "SPOCK", "SULU", "UHURA", NULL };
const TString& hostname = get_hostname(); const TString& hostname = get_hostname();
for (int i = 0; ranger[i]; i++) for (int i = 0; ranger[i] && !ok; i++)
{ ok = hostname.compare(ranger[i], -1, true) == 0;
if (hostname.compare(ranger[i], -1, true) == 0)
return true;
} }
return false; return ok;
} }
bool expand_sys_vars(TString& str) bool expand_sys_vars(TString& str)

View File

@ -2371,8 +2371,6 @@ void TViswin::close_print ()
} }
const TImage* i = (TImage*)_images.objptr(0); const TImage* i = (TImage*)_images.objptr(0);
if (i != NULL) i->set_palette(win());
set_scroll_max (MAXLEN - 1, _txt.lines () <= _textrows ? _txt.lines () : _txt.lines () - _textrows); set_scroll_max (MAXLEN - 1, _txt.lines () <= _textrows ? _txt.lines () : _txt.lines () - _textrows);
force_update (); force_update ();

View File

@ -143,13 +143,9 @@ HIDDEN bool remove_menu_item(MENU_ITEM* menu, MENU_TAG id, bool ismbar)
HIDDEN void set_menu_item(MENU_ITEM& m, TToken_string& tt) HIDDEN void set_menu_item(MENU_ITEM& m, TToken_string& tt)
{ {
MENU_TAG tag = tt.get_int(0); MENU_TAG tag = tt.get_int(0);
TString flag = tt.items() <= 2 ? "": tt.get(2); const char* txt = tt.get();
char* text = NULL; char* text = (txt && *txt) ? xvt_str_duplicate(txt) : NULL;
if (strlen(tt.get(1)) > 0) const TString4 flag = tt.get();
{
text = (char*)xvt_mem_alloc(strlen(tt.get(1)) + 1);
strcpy(text, tt.get(1));
}
m.tag = tag; m.tag = tag;
m.text = text; m.text = text;