Patch level : 10.0

Files correlati     : librerie
Ricompilazione Demo : [ ]
Commento            :
Corretta gestione toolbar basse (1 riga sola)


git-svn-id: svn://10.65.10.50/trunk@16481 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2008-04-08 12:55:06 +00:00
parent 0c732000c3
commit 72dde0c4d6
8 changed files with 352 additions and 54 deletions

View File

@ -11,7 +11,7 @@ BUTTON DLG_SAVEREC 10 2
BEGIN
PROMPT -24 -1 "Esporta"
MESSAGE EXIT,K_SAVE
PICTURE BMP_SAVEREC
PICTURE 151
END
BUTTON DLG_FIRSTREC 3

View File

@ -486,7 +486,7 @@ HIDDEN XI_BITMAP* get_background_bitmap()
}
WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy,
const char* caption, TWindow* msk/*, bool orecchie*/)
const char* caption, TWindow* msk)
{
if (parent == NULL_WIN)
parent = TASK_WIN;
@ -501,7 +501,8 @@ WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy,
RCT max_rct; xvt_vobj_get_client_rect(parent, &max_rct);
if (dy <= 0)
{
if (y < -1)
// Gestisce centrature e caso particolare di bottombar di una riga
if (y < -1 || (y == -1 && (dy == 0 || dy == 1)))
{
height = -top;
top += max_rct.bottom;
@ -518,8 +519,8 @@ WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy,
width -= left;
}
if (x < 0) left = (max_rct.right - width) / 2;
if (y < 0) top = (max_rct.bottom - height) / 2;
if (x < 0 && dx != 0) left = (max_rct.right - width) / 2;
if (y < 0 && dy != 0) top = (max_rct.bottom - height) / 2;
}
RCT r; xvt_rect_set(&r, left, top, left+width, top+height);
@ -566,34 +567,6 @@ WINDOW create_interface(WINDOW parent, short x, short y, short dx, short dy,
xi_fu_to_pu(itf, (XinPoint *) &r, 2);
xvt_vobj_move(win, &r);
}
/* OBSOLETE
// Aggiunge rettangolo di cornice per pagine con orecchie
if (!USE_NOTEBOOK && orecchie)
{
XI_RCT rct; xi_get_xi_rct(itf, &rct);
rct.top += Y_FU_MULTIPLE; // Lascia lo spazio per i Bottoni di cambio pagina
def = xi_add_rect_def(NULL, MASK_RECT_ID, &rct, XI_ATR_VISIBLE, 0, 0);
if (bmpback != NULL)
{
def->v.rect->back_color = 0;
def->v.rect->bitmap = bmpback;
}
XI_OBJ* obj = xi_create(itf, def);
CHECK(obj, "Can't create page rectangle");
// Fa coincidere esattamente il rettangolo con la finestra che lo contiene
RCT& rect = (RCT&) obj->v.rect->rct;
const int oldy = rect.top;
xvt_vobj_get_client_rect(win, &rect);
rect.top = oldy;
xi_dequeue();
xi_tree_free(def);
}
*/
return win;
}
@ -644,7 +617,7 @@ HIDDEN void xi_event_handler(XI_OBJ* itf, XI_EVENT* xiev)
XI_OBJ* b = button[i];
if (b->type == XIT_BTN && b->v.btn->drawable)
{
if (xvt_rect_intersect(NULL, (RCT *) &b->v.btn->rct, &xiev->v.xvte.v.update.rct))
if (xvt_rect_intersect(NULL, (RCT*)&b->v.btn->rct, &xiev->v.xvte.v.update.rct))
{
TPushbutton_control* p = (TPushbutton_control*)b->app_data;
p->update();
@ -656,7 +629,7 @@ HIDDEN void xi_event_handler(XI_OBJ* itf, XI_EVENT* xiev)
if (msk != NULL && msk->is_kind_of(CLASS_MASK))
{
const TMask& m = (const TMask&)*msk;
WINDOW win = m.win();
WINDOW win = m.page_win(0);
if ((WINDOW)xi_get_window(itf) == win)
{
if (m.number() == 0 && m.source_file().find("custom") > 0)

View File

@ -1152,8 +1152,6 @@ bool TMask::check_current_field() const
WINDOW TMask::create_book(bool single)
{
CHECK(_notebook == NULL_WIN, "One single notebook, please!");
WINDOW parent = win();
if (parent == NULL_WIN)
{
@ -1170,6 +1168,7 @@ WINDOW TMask::create_book(bool single)
}
else
{
CHECK(_notebook == NULL_WIN, "One single notebook, please!");
WIN_DEF wd; memset(&wd, 0, sizeof(wd));
wd.wtype = WC_NOTEBK;
xvt_vobj_get_client_rect(parent, &wd.rct);
@ -1197,8 +1196,10 @@ void TMask::insert_bar(WINDOW page)
if (_notebook == NULL_WIN && _single == NULL_WIN)
create_book(true); // In assenza di notebook crea un pane a pagina singola
RCT rct; xvt_vobj_get_outer_rect(page, &rct);
if (rct.top > 0) // BottomBar
RCT rct_win; xvt_vobj_get_outer_rect(parent, &rct_win);
RCT rct_bar; xvt_vobj_get_outer_rect(page, &rct_bar);
if (rct_bar.top > (rct_win.bottom-rct_win.top)/2) // BottomBar
{
CHECK(_toolwin == NULL_WIN, "One single bottom bar, please!");
_toolwin = page;

View File

@ -3078,7 +3078,7 @@ void TReport_select::parse_output(TScanner& scanner)
KEY TReport_select::run()
{
TFilename path;
TFilename path = field().get();
if (select_custom_file(path, "rep", _library))
{
path = path.name();

View File

@ -27,7 +27,7 @@ static bool is_numeric(const char* str)
}
while (*str)
{
if (strchr("0123456789.", *str) == NULL)
if (strchr("0123456789.,", *str) == NULL)
return false;
str++;
}
@ -766,21 +766,21 @@ bool list_custom_files(const char* ext, const char* classe, TString_array& files
{
TScanner scan(path);
stringona.cut(0);
for (int i = 0; i < 3 && scan.good(); i++) // Leggo solo le prime righe
for (int i = 0; i < 4 && scan.good(); i++) // Leggo solo le prime righe
stringona << scan.line();
get_xml_attr(stringona, "class", acqua);
if (classe && *classe)
ok = acqua == classe;
if (ok)
{
get_xml_child(stringona, "description", desc);
TToken_string* riga = new TToken_string;
riga->add(*row);
riga->add(acqua);
riga->add(desc);
riga->add(desc);
riga->add(path.find("custom") > 0 ? "X" : "");
files.add(riga);
}
}
@ -792,19 +792,21 @@ bool select_custom_file(TFilename& path, const char* ext, const char* classe)
{
TArray_sheet sheet(-1, -1, 78, 20, TR("Selezione"), HR("Nome@8|Classe|Descrizione@50|Custom"));
TString_array& files = sheet.rows_array();
TFilename first = path.name(); first.ext(""); // Riga su cui posizionarsi
bool ok = list_custom_files(ext, classe, files);
if (ok)
{
TFilename name;
FOR_EACH_ARRAY_ROW(files, i, row)
if (first.full()) // Cerco la prima riga da selezionare se possibile
{
name = row->get(0);
name.ext(ext);
name.custom_path();
if (name.find("custom") > 0)
row->add("X");
FOR_EACH_ARRAY_ROW(files, i, row)
{
if (first.compare(row->get(0), -1, true) == 0) // Ho trovato la selezione corrente
{
sheet.select(i);
break;
}
}
}
ok = sheet.run() == K_ENTER;
@ -1292,7 +1294,9 @@ const TVariant& TISAM_recordset::get_field(int logic, const char* fldname) const
const int open_bracket = name.find('[');
if (open_bracket > 0)
{
sscanf((const char*)name + open_bracket, "[%d,%d]", &from, &to);
TToken_string range(name.mid(open_bracket+1), ',');
from = range.get_int();
to = range.get_int();
name.cut(open_bracket);
}

83
include/relapbar.h Executable file
View File

@ -0,0 +1,83 @@
BUTTON DLG_NEWREC 2 2
BEGIN
PROMPT 1 1 "Nuovo"
MESSAGE EXIT,K_INS
PICTURE BMP_NEWREC
END
BUTTON DLG_SAVEREC 2 2
BEGIN
PROMPT 2 1 "Registra"
MESSAGE EXIT,K_SAVE
PICTURE BMP_SAVEREC
END
BUTTON DLG_DELREC 2 2
BEGIN
PROMPT 3 1 "Elimina"
MESSAGE EXIT,K_DEL
PICTURE BMP_DELREC
END
BUTTON DLG_FIRSTREC 2 2
BEGIN
PROMPT 4 1 "Primo"
MESSAGE EXIT,K_HOME
PICTURE 121
END
BUTTON DLG_PREVREC 2 2
BEGIN
PROMPT 5 1 "Precedente"
MESSAGE EXIT,K_PREV
PICTURE 122
END
BUTTON DLG_FINDREC 2 2
BEGIN
PROMPT 6 1 "Ricerca"
MESSAGE EXIT,K_F9
PICTURE 166
END
BUTTON DLG_NEXTREC 2 2
BEGIN
PROMPT 7 1 "Prossimo"
MESSAGE EXIT,K_NEXT
PICTURE 124
END
BUTTON DLG_LASTREC 2 2
BEGIN
PROMPT 8 1 "Ultimo"
MESSAGE EXIT,K_END
PICTURE 125
END
BUTTON DLG_INFO 2 2
BEGIN
PROMPT 9 1 "Informazioni"
MESSAGE EXIT,K_F2
PICTURE 162
END
BUTTON DLG_HELP 2 2
BEGIN
PROMPT 10 1 "Help"
MESSAGE EXIT,K_F1
PICTURE 163
END
BUTTON DLG_CANCEL 2 2
BEGIN
PROMPT 11 1 "Annulla"
MESSAGE EXIT,K_ESC
PICTURE 102
END
BUTTON DLG_QUIT 2 2
BEGIN
PROMPT 12 1 "Fine"
MESSAGE EXIT,K_QUIT
PICTURE BMP_QUIT
END

193
include/toolfld.cpp Executable file
View File

@ -0,0 +1,193 @@
#include <diction.h>
#include <mask.h>
#include <toolfld.h>
#include <statbar.h>
#include <urldefid.h>
///////////////////////////////////////////////////////////
// TTool_field
///////////////////////////////////////////////////////////
word TTool_field::class_id() const
{ return CLASS_TOOL_FIELD; }
bool TTool_field::is_kind_of(word cid) const
{ return cid == CLASS_TOOL_FIELD || TOperable_field::is_kind_of(cid); }
void TTool_field::create(WINDOW parent)
{
_parent = parent;
_cid = _ctl_data._dlg;
}
void TTool_field::enable(bool on)
{
TOperable_field::enable(on);
xvt_toolbar_enable_control(parent(), dlg(), on);
}
void TTool_field::show(bool on)
{
TOperable_field::show(on);
xvt_toolbar_show_control(parent(), dlg(), on);
}
TTool_field::TTool_field(TMask* mask) : TOperable_field(mask)
{ }
///////////////////////////////////////////////////////////
// TButton_tool
///////////////////////////////////////////////////////////
word TButton_tool::class_id() const
{ return CLASS_BUTTON_TOOL; }
bool TButton_tool::is_kind_of(word cid) const
{ return cid == CLASS_BUTTON_TOOL || TTool_field::is_kind_of(cid); }
void TButton_tool::parse_head(TScanner& scanner)
{
_ctl_data._width = scanner.integer();
if (_ctl_data._width <= 0) _ctl_data._width = 10;
_ctl_data._height = scanner.integer(); // Height
if (_ctl_data._height <= 0) _ctl_data._height = 1;
}
bool TButton_tool::parse_item(TScanner& scanner)
{
if (scanner.key() == "PI")
{
const short bmp = (short)scanner.integer();
if (_ctl_data._bmp_up == 0)
_ctl_data._bmp_up = bmp;
return bmp > 0;
}
return TTool_field::parse_item(scanner);
}
void TButton_tool::set_exit_key(KEY k)
{
switch (k)
{
case K_F1: _exit_key = M_HELP_CONTENTS; break;
case K_F2: _exit_key = M_FILE_ABOUT; break;
default: _exit_key = k; break;
}
}
void TButton_tool::create(WINDOW toolbar)
{
TTool_field::create(toolbar);
_exit_key = 0;
switch (dlg())
{
case DLG_OK:
if (_ctl_data._prompt.empty())
_ctl_data._prompt = TR("Conferma");
set_exit_key(K_ENTER);
if (_ctl_data._bmp_up <= 0)
_ctl_data._bmp_up = BMP_OK;
break;
case DLG_CANCEL:
if (_ctl_data._prompt.empty())
_ctl_data._prompt = TR("Annulla");
set_exit_key(K_ESC);
if (_ctl_data._bmp_up <= 0)
_ctl_data._bmp_up = BMP_CANCEL;
break;
case DLG_DELREC:
if (_ctl_data._prompt.empty())
_ctl_data._prompt = TR("Elimina");
set_exit_key(K_DEL);
if (_ctl_data._bmp_up <= 0)
_ctl_data._bmp_up = BMP_DELREC;
break;
case DLG_PRINT:
if (_ctl_data._prompt.empty())
_ctl_data._prompt = TR("Stampa");
set_exit_key(K_ENTER);
if (_ctl_data._bmp_up <= 0)
_ctl_data._bmp_up = BMP_PRINT;
break;
case DLG_QUIT:
if (_ctl_data._prompt.empty())
_ctl_data._prompt = TR("Fine");
set_exit_key(K_QUIT);
if (_ctl_data._bmp_up <= 0)
_ctl_data._bmp_up = BMP_QUIT;
break;
case DLG_SELECT:
if (_ctl_data._bmp_up <= 0)
_ctl_data._bmp_up = BMP_SELECT;
set_exit_key(K_ENTER);
break;
case DLG_HELP:
set_exit_key(K_F1);
break;
case DLG_INFO:
set_exit_key(K_F2);
break;
default:
break;
}
if (dlg() <= 0 || _ctl_data._bmp_up <= 0)
xvt_toolbar_add_control(toolbar, -1, TOOL_SEPARATOR, "", 0, _ctl_data._width, -1);
else
xvt_toolbar_add_control(toolbar, dlg(), TOOL_BUTTON, _ctl_data._prompt,
_ctl_data._bmp_up, _ctl_data._width, -1);
TToken_string* mess = message(0);
if (mess)
{
TToken_string msg(mess->get(0), ',');
const TFixed_string m = msg.get(0);
if (m == "EXIT")
set_exit_key(msg.get_int());
else
{
if (msg.get_int() == 0)
set_exit_key(atoi(m));
}
}
}
bool TButton_tool::on_key(KEY key)
{
bool ok = true;
if (key == K_SPACE)
{
const TMask& m = mask();
if (dlg() != DLG_CANCEL && dlg() != DLG_QUIT)
ok = m.focus_field().on_key(K_TAB);
if (ok)
{
if (xvt_vobj_get_attr(NULL_WIN, ATTR_SPEECH_MODE) & (1<<7))
{
TString str = prompt();
str.strip("~");
xvt_dm_post_speech(str, 7, TRUE);
}
if (_exit_key > M_FILE && _exit_key < FONT_MENU_TAG)
{
dispatch_e_menu(TASK_WIN, _exit_key);
ok = true;
}
else
{
ok = on_hit();
if (ok && _exit_key > 0 && !has_message())
mask().stop_run(_exit_key);
}
}
}
else
ok = TTool_field::on_key(key);
return ok;
}
TButton_tool::TButton_tool(TMask* mask) : TTool_field(mask), _exit_key(0)
{ }

44
include/toolfld.h Executable file
View File

@ -0,0 +1,44 @@
#ifndef __TOOLFLD_H
#define __TOOLFLD_H
#ifndef __MASKFLD_H
#include <maskfld.h>
#endif
class TTool_field : public TOperable_field
{
WINDOW _parent;
short _cid;
protected:
virtual void create(WINDOW parent);
public:
virtual word class_id() const;
virtual bool is_kind_of(word cid) const;
virtual WINDOW parent() const { return _parent; }
virtual short dlg() const { return _cid; }
virtual void enable(bool on);
virtual void show(bool on);
TTool_field(TMask* mask);
};
class TButton_tool : public TTool_field
{
KEY _exit_key;
protected:
virtual void parse_head(TScanner& scanner);
virtual bool parse_item(TScanner& scanner);
virtual void create(WINDOW parent);
virtual bool on_key(KEY key);
public:
virtual word class_id() const;
virtual bool is_kind_of(word cid) const;
void set_exit_key(KEY k);
KEY exit_key() const { return _exit_key; }
TButton_tool(TMask* mask);
};
#endif