Patch level : 2.1 nopatch
Files correlati : ba0 Ricompilazione Demo : [ ] Commento : Corretta gestione logo mancante git-svn-id: svn://10.65.10.50/trunk@11993 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
91133719be
commit
a8287fd608
109
ba/ba0100.cpp
109
ba/ba0100.cpp
@ -81,8 +81,6 @@ protected:
|
||||
static bool tree_handler(TMask_field& f, KEY k);
|
||||
static bool explore_handler(TMask_field& f, KEY k);
|
||||
|
||||
void select_tree_current();
|
||||
|
||||
bool choose_colors();
|
||||
bool choose_editors();
|
||||
bool choose_study();
|
||||
@ -98,6 +96,7 @@ protected:
|
||||
bool test_network();
|
||||
|
||||
public:
|
||||
void select_tree_current();
|
||||
static bool tree_find_handler(TMask_field& f, KEY k);
|
||||
static bool tree_shrink_handler(TMask_field& f, KEY k);
|
||||
|
||||
@ -265,9 +264,7 @@ TPicture_mask::TPicture_mask(const char* name, int dx, int dy,
|
||||
_logo = new TImage(logo, maxx, maxy);
|
||||
if (can_be_transparent(*_logo))
|
||||
_logo->convert_transparent_color(MASK_BACK_COLOR);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TPicture_mask::~TPicture_mask()
|
||||
@ -282,12 +279,17 @@ TPicture_mask::~TPicture_mask()
|
||||
|
||||
class TExplorer_mask : public TMask
|
||||
{
|
||||
TMenu_tree _tree;
|
||||
|
||||
protected:
|
||||
virtual bool stop_run(KEY k);
|
||||
virtual bool on_key(KEY k);
|
||||
virtual void on_idle();
|
||||
|
||||
static bool explore_handler(TMask_field& f, KEY k);
|
||||
|
||||
public:
|
||||
TExplorer_mask();
|
||||
TExplorer_mask(TMenu& menu);
|
||||
};
|
||||
|
||||
bool TExplorer_mask::stop_run(KEY k)
|
||||
@ -297,6 +299,15 @@ bool TExplorer_mask::stop_run(KEY k)
|
||||
return TMask::stop_run(k);
|
||||
}
|
||||
|
||||
void TExplorer_mask::on_idle()
|
||||
{
|
||||
if (ADVANCED_GRAPHICS)
|
||||
{
|
||||
TWindowed_field& lf = (TWindowed_field&)field(DLG_LIST);
|
||||
lf.win().on_idle();
|
||||
}
|
||||
}
|
||||
|
||||
bool TExplorer_mask::on_key(KEY k)
|
||||
{
|
||||
if (k == K_F3 || k == K_F8)
|
||||
@ -307,9 +318,48 @@ bool TExplorer_mask::on_key(KEY k)
|
||||
return TMask::on_key(k);
|
||||
}
|
||||
|
||||
TExplorer_mask::TExplorer_mask()
|
||||
: TMask ("", 1, 0, 0, 0, 0)
|
||||
bool TExplorer_mask::explore_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
if (k == K_CTRL + K_SPACE)
|
||||
{
|
||||
TTree_field& tf = (TTree_field&)f;
|
||||
TMenu_tree& mt = *(TMenu_tree*)tf.tree();
|
||||
const TMenuitem& mi = mt.curr_item();
|
||||
|
||||
if (mi.perform() && mt.goto_firstson())
|
||||
{
|
||||
TMenulist_field& mf = (TMenulist_field&)f.mask().field(DLG_LIST);
|
||||
mf.set_menu(mt);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
TExplorer_mask::TExplorer_mask(TMenu& menu)
|
||||
: TMask ("", 1, 0, 0, 0, 0), _tree(menu)
|
||||
{
|
||||
const int margin = (columns()-80) / 2;
|
||||
const int tree_width = margin+21; // Usa la metà di sinistra
|
||||
|
||||
TTree_field& tree_fld = add_tree(DLG_TREE, 0, 0, 0, tree_width, -5);
|
||||
tree_fld.set_tree(&_tree);
|
||||
tree_fld.set_handler(explore_handler);
|
||||
tree_fld.hide_leaves(true);
|
||||
|
||||
TMenulist_field* mf = new TMenulist_field(this);
|
||||
mf->create(DLG_LIST, tree_width-margin+3, 0, -3, -5);
|
||||
mf->set_menu(_tree);
|
||||
add_field(mf);
|
||||
|
||||
TEdit_field& ef = add_string(DLG_USER, 0, PR("Cerca "), 11, -4, 50);
|
||||
ef.set_handler(app().tree_find_handler);
|
||||
|
||||
add_button(DLG_QUIT, 0, "", -12, -2, 18, 2);
|
||||
|
||||
TButton_field& mp = add_button(201, 0, PR("Menu Principale"), -22, -2, 18, 2);
|
||||
mp.set_handler(app().tree_shrink_handler);
|
||||
|
||||
first_focus(DLG_LIST);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -1374,23 +1424,6 @@ bool TMenu_application::tree_shrink_handler(TMask_field&f, KEY k)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TMenu_application::explore_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
if (k == K_CTRL + K_SPACE)
|
||||
{
|
||||
TTree_field& tf = (TTree_field&)f;
|
||||
TMenu_tree& mt = *(TMenu_tree*)tf.tree();
|
||||
const TMenuitem& mi = mt.curr_item();
|
||||
|
||||
if (mi.perform() && mt.goto_firstson())
|
||||
{
|
||||
TMenulist_field& mf = (TMenulist_field&)f.mask().field(DLG_LIST);
|
||||
mf.set_menu(mt);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TMenu_application::update_preferred()
|
||||
{
|
||||
MENU_ITEM* mm = xvt_menu_get_tree(TASK_WIN);
|
||||
@ -1683,33 +1716,9 @@ int TMenu_application::do_tree()
|
||||
int TMenu_application::do_explore()
|
||||
{
|
||||
CHECK(_mask == NULL, "Two masks are better than one?");
|
||||
TExplorer_mask mask;
|
||||
_mask = &mask;
|
||||
|
||||
const int margin = (mask.columns()-80) / 2;
|
||||
const int tree_width = margin+21; // Usa la metà di sinistra
|
||||
|
||||
_menu.jumpto_root();
|
||||
TMenu_tree tree(_menu);
|
||||
TTree_field& tree_fld = mask.add_tree(DLG_TREE, 0, 0, 0, tree_width, -5);
|
||||
tree_fld.set_tree(&tree);
|
||||
tree_fld.set_handler(explore_handler);
|
||||
tree_fld.hide_leaves(true);
|
||||
|
||||
TMenulist_field* mf = new TMenulist_field(&mask);
|
||||
mf->create(DLG_LIST, tree_width-margin+3, 0, -3, -5);
|
||||
mask.add_field(mf);
|
||||
mf->set_menu(tree);
|
||||
|
||||
TEdit_field& ef = mask.add_string(DLG_USER, 0, PR("Cerca "), 11, -4, 50);
|
||||
ef.set_handler(tree_find_handler);
|
||||
|
||||
mask.add_button(DLG_QUIT, 0, "", -12, -2, 18, 2);
|
||||
|
||||
TButton_field& mp = mask.add_button(201, 0, PR("Menu Principale"), -22, -2, 18, 2);
|
||||
mp.set_handler(tree_shrink_handler);
|
||||
|
||||
mask.first_focus(DLG_LIST);
|
||||
TExplorer_mask mask(_menu);
|
||||
_mask = &mask;
|
||||
|
||||
KEY key = mask.run();
|
||||
_mask = NULL;
|
||||
|
103
ba/ba0102.cpp
103
ba/ba0102.cpp
@ -1,5 +1,6 @@
|
||||
#include <controls.h>
|
||||
#include <mask.h>
|
||||
#include <statbar.h>
|
||||
#include <urldefid.h>
|
||||
#include <utility.h>
|
||||
|
||||
@ -321,7 +322,7 @@ protected:
|
||||
|
||||
public:
|
||||
void set_owner_info(WINDOW win, int max_side);
|
||||
TImage* image(const TString& filename);
|
||||
TImage* image(const char* filename);
|
||||
TMenulist_images() : TCache(17), _win(NULL_WIN), _max_side(0) { }
|
||||
};
|
||||
|
||||
@ -375,7 +376,6 @@ TObject* TMenulist_images::key2obj(const char* key)
|
||||
|
||||
if (strcmp(key,"logo") != 0)
|
||||
{
|
||||
RCT rct; xvt_vobj_get_client_rect(_win, &rct);
|
||||
const double ratiox = max_img / image.width();
|
||||
const double ratioy = max_img / image.height();
|
||||
const double ratio = min(ratiox, ratioy);
|
||||
@ -383,26 +383,12 @@ TObject* TMenulist_images::key2obj(const char* key)
|
||||
const int maxy = int(ratio * image.height());
|
||||
img = new TImage(image, maxx, maxy);
|
||||
|
||||
// const int radius = (maxx+maxy)/2;
|
||||
const double radius = min(maxx,maxy)/5.0;
|
||||
//Sfumatura costante sui lati sx e up
|
||||
const double radius = min(maxx,maxy)/6.0;
|
||||
for (int y = 0; y < maxy; y++)
|
||||
{
|
||||
for (int x = 0; x < maxx; x++)
|
||||
{
|
||||
/* Sfumatura a semicerchio
|
||||
const int r = fast_hypot(maxx-x, maxy-y);
|
||||
if (r > radius)
|
||||
{
|
||||
const double perc = 5*double(radius-r)/radius+1.0;
|
||||
if (perc >= 0.0)
|
||||
{
|
||||
COLOR col = img->get_pixel(x, y);
|
||||
COLOR bri = blend_colors(col, NORMAL_BACK_COLOR, perc);
|
||||
img->set_pixel(x, y, bri);
|
||||
}
|
||||
else
|
||||
img->set_pixel(x, y, NORMAL_BACK_COLOR);*/
|
||||
//Sfumatura costante sui lati sx e up
|
||||
if (x <= radius || y <= radius)
|
||||
{
|
||||
double perc = 1.0;
|
||||
@ -426,7 +412,6 @@ TObject* TMenulist_images::key2obj(const char* key)
|
||||
}
|
||||
else //caso particolare del logo
|
||||
{
|
||||
RCT rct; xvt_vobj_get_client_rect(_win, &rct);
|
||||
const double ratio = max_lgo / image.width();
|
||||
const int maxx = int(ratio * image.width());
|
||||
const int maxy = int(ratio * image.height());
|
||||
@ -436,10 +421,12 @@ TObject* TMenulist_images::key2obj(const char* key)
|
||||
return img;
|
||||
}
|
||||
|
||||
TImage* TMenulist_images::image(const TString& filename)
|
||||
TImage* TMenulist_images::image(const char* name)
|
||||
{
|
||||
TObject* obj = objptr(filename);
|
||||
if (obj == NULL && filename != "ba00")
|
||||
TObject* obj = objptr(name);
|
||||
if (obj == NULL &&
|
||||
xvt_str_compare_ignoring_case(name, "ba00") != 0 &&
|
||||
xvt_str_compare_ignoring_case(name, "logo") != 0)
|
||||
obj = objptr("ba00");
|
||||
return (TImage*)obj;
|
||||
}
|
||||
@ -459,13 +446,17 @@ private:
|
||||
int _selected;
|
||||
TPointer_array _sorted;
|
||||
|
||||
clock_t _last_update;
|
||||
|
||||
protected:
|
||||
virtual void update();
|
||||
virtual void handler(WINDOW win, EVENT* ep);
|
||||
virtual bool on_key(KEY k);
|
||||
virtual void on_idle();
|
||||
|
||||
void synchronize_buddy_tree() const;
|
||||
void draw_item(int i);
|
||||
void draw_menu_caption(COLOR rgb);
|
||||
void click_on(int index);
|
||||
void select(int s, int direction);
|
||||
|
||||
@ -542,6 +533,37 @@ void TMenulist_window::draw_item(int i)
|
||||
xvt_dwin_draw_icon(win(), ix+4, iy+4, 10203); // Stop icon
|
||||
}
|
||||
|
||||
//scrive la voce di menu corrente a video
|
||||
void TMenulist_window::draw_menu_caption(COLOR rgb)
|
||||
{
|
||||
const char* caption = "";
|
||||
if (_sorted.items() > 1)
|
||||
{
|
||||
const TMenuitem& mi = (const TMenuitem&)_sorted[1];
|
||||
const TSubmenu& sm = mi.submenu();
|
||||
caption = sm.caption();
|
||||
}
|
||||
else
|
||||
{
|
||||
const TMenuitem& mi = (const TMenuitem&)_sorted[0];
|
||||
caption = mi.caption();
|
||||
}
|
||||
RCT rct; xvt_vobj_get_client_rect(win(), &rct);
|
||||
const int x = rct.left+2;
|
||||
int y = rct.bottom-CHARY;
|
||||
if (ADVANCED_GRAPHICS)
|
||||
{
|
||||
const TImage* logo = _images.image("logo");
|
||||
if (logo != NULL)
|
||||
y -= logo->height();
|
||||
}
|
||||
xvt_dwin_set_font(win(), xvt_default_font(true));
|
||||
set_color(rgb, NORMAL_BACK_COLOR);
|
||||
xvt_dwin_draw_text(win(), x, y, caption, -1);
|
||||
|
||||
statbar_set_title(TASK_WIN, caption);
|
||||
}
|
||||
|
||||
void TMenulist_window::update()
|
||||
{
|
||||
const bool db = _tree != NULL && ADVANCED_GRAPHICS;
|
||||
@ -571,28 +593,25 @@ void TMenulist_window::update()
|
||||
for (int i = 0; i < _sorted.items(); i++)
|
||||
draw_item(i);
|
||||
|
||||
//scrive la voce di menu corrente a video
|
||||
const char* caption = "";
|
||||
if (_sorted.items() > 1)
|
||||
{
|
||||
const TMenuitem& mi = (const TMenuitem&)_sorted[1];
|
||||
const TSubmenu& sm = mi.submenu();
|
||||
caption = sm.caption();
|
||||
}
|
||||
if (ADVANCED_GRAPHICS)
|
||||
_last_update = clock();
|
||||
else
|
||||
{
|
||||
const TMenuitem& mi = (const TMenuitem&)_sorted[0];
|
||||
caption = mi.caption();
|
||||
}
|
||||
draw_menu_caption(NORMAL_COLOR);
|
||||
}
|
||||
|
||||
RCT rct; xvt_vobj_get_client_rect(win(), &rct);
|
||||
const int x = rct.left;
|
||||
int y = rct.bottom-CHARY;
|
||||
if (logo != NULL)
|
||||
y -= logo->height();
|
||||
xvt_dwin_set_font(win(), xvt_default_font(true));
|
||||
set_color(NORMAL_COLOR, NORMAL_BACK_COLOR);
|
||||
xvt_dwin_draw_text(win(), x, y, caption, -1);
|
||||
void TMenulist_window::on_idle()
|
||||
{
|
||||
if (ADVANCED_GRAPHICS)
|
||||
{
|
||||
const clock_t max_clock = 3*CLOCKS_PER_SEC;
|
||||
const clock_t elapsed = clock() - _last_update;
|
||||
if (elapsed <= max_clock)
|
||||
{
|
||||
const double perc = double(elapsed) / double(max_clock);
|
||||
const COLOR rgb = blend_colors(NORMAL_COLOR, NORMAL_BACK_COLOR, perc);
|
||||
draw_menu_caption(rgb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TMenulist_window::click_on(int index)
|
||||
|
35
ba/ba8304.uml
Executable file
35
ba/ba8304.uml
Executable file
@ -0,0 +1,35 @@
|
||||
PAGE "Monitor" -1 -1 40 20
|
||||
|
||||
LIST 101 -3 13
|
||||
BEGIN
|
||||
PROMPT 0 0 ""
|
||||
END
|
||||
|
||||
STACK 102 -3 -3
|
||||
BEGIN
|
||||
PROMPT 0 14 ""
|
||||
END
|
||||
|
||||
BUTTON DLG_NEXTREC 10 2
|
||||
BEGIN
|
||||
PROMPT -13 -1 ""
|
||||
PICTURE 124
|
||||
MESSAGE EXIT,K_NEXT
|
||||
END
|
||||
|
||||
BUTTON DLG_QUIT 10 2
|
||||
BEGIN
|
||||
PROMPT -23 -1 ""
|
||||
END
|
||||
|
||||
BUTTON DLG_DELREC 10 2
|
||||
BEGIN
|
||||
PROMPT -33 -1 "Abort"
|
||||
MESSAGE EXIT,K_DEL
|
||||
END
|
||||
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
||||
|
Loading…
x
Reference in New Issue
Block a user