Patch level :2.1 28

Files correlati     :ba0.exe
Ricompilazione Demo : [ ]
Commento            :
risolto bug 0000108 (prima parte)
sostituire il logo Double One con OneRed (che dovra' essere inviato al piu' presto!) in tutte
le videate dei menu; inoltre il testo indicante il modulo dovra' riprendere il testo del menu'
corrente ed essere generato dal programma


git-svn-id: svn://10.65.10.50/trunk@11987 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
luca 2004-04-22 11:15:05 +00:00
parent ca4ca93059
commit f02c8b44f0
2 changed files with 81 additions and 25 deletions

View File

@ -152,8 +152,9 @@ void TPicture_mask::update()
int x = 1, y = 1, maxx = 640, maxy = 480; // Default values
RCT client; xvt_vobj_get_client_rect(win(), &client);
const bool tree_view = id2pos(DLG_TREE) >= 0;
if (id2pos(DLG_TREE) >= 0) // TreeView == 1
if (tree_view) // TreeView == 1
{
RCT rctree; field(DLG_TREE).get_rect(rctree);
@ -195,7 +196,10 @@ void TPicture_mask::update()
image.draw(win(), dst);
if (_logo != NULL)
_logo->draw(win(), x, y+maxy+1);
{
const int lx = tree_view ? dst.right-_logo->width()-1 : x;
_logo->draw(win(), lx, y+maxy+1);
}
}
}
@ -1305,13 +1309,18 @@ bool TMenu_application::tree_handler(TMask_field& f, KEY k)
const TMenuitem& mi = mt.curr_item();
mi.perform();
if (mi.is_submenu() && mt.expanded())
{
TMenu& menu = mt.curr_submenu().menu();
if (mi.is_submenu())
{
TPicture_mask& pm = (TPicture_mask&)f.mask();
pm.set_current(menu.current());
}
if (mt.expanded())
{
TMenu& menu = mt.curr_submenu().menu();
pm.set_current(menu.current());
}
pm.force_update();
}
}
return TRUE;
}

View File

@ -1,5 +1,4 @@
#include <math.h>
#include <controls.h>
#include <mask.h>
#include <urldefid.h>
#include <utility.h>
@ -315,14 +314,15 @@ bool can_be_transparent(const TImage& i)
class TMenulist_images : public TCache
{
WINDOW _win;
int _max_side;
protected:
TObject* key2obj(const char* key);
public:
void set_owner(WINDOW win) { _win = win; }
void set_owner_info(WINDOW win, int max_side);
TImage* image(const TString& filename);
TMenulist_images() : TCache(17), _win(NULL_WIN) { }
TMenulist_images() : TCache(17), _win(NULL_WIN), _max_side(0) { }
};
inline int fast_hypot(int x, int y)
@ -337,6 +337,13 @@ inline int fast_hypot(int x, int y)
return h;
}
void TMenulist_images::set_owner_info(WINDOW win, int max_side)
{
_win = win;
_max_side = max_side;
}
TObject* TMenulist_images::key2obj(const char* key)
{
TImage* img = NULL;
@ -363,8 +370,8 @@ TObject* TMenulist_images::key2obj(const char* key)
const int h = image.height();
RCT rct; xvt_vobj_get_client_rect(_win, &rct);
const double max_img = 2.0 * rct.bottom / 5.0;
const double max_lgo = rct.right - max_img;
const double max_img = (double)_max_side;
const double max_lgo = rct.right - _max_side;
if (strcmp(key,"logo") != 0)
{
@ -398,17 +405,26 @@ TObject* TMenulist_images::key2obj(const char* key)
//Sfumatura costante sui lati sx e up
if (x <= radius || y <= radius)
{
const double perc = min(x,y)/radius;
double perc = 1.0;
if (x <= radius && y <= radius)
{
const int r = fast_hypot(int(radius-x),int(radius-y));
if (r <= radius)
perc = 1.0-r/radius;
else
perc = 0;
}
else
perc = min(x,y)/radius;
COLOR col = img->get_pixel(x, y);
COLOR bri = blend_colors(col, NORMAL_BACK_COLOR, perc);
img->set_pixel(x, y, bri);
}
}
}
// const clock_t stop_timer = clock()-start_timer;
}
else
else //caso particolare del logo
{
RCT rct; xvt_vobj_get_client_rect(_win, &rct);
const double ratio = max_lgo / image.width();
@ -430,10 +446,10 @@ TImage* TMenulist_images::image(const TString& filename)
class TMenulist_window : public TField_window
{
enum { MENU_COLS = 4, MENU_ROWS = 5 };
private:
TMenu_tree* _tree;
size_t MENU_COLS, MENU_ROWS;
TMenu_tree* _tree;
TString _curr_node;
bool _can_go_back;
@ -476,12 +492,12 @@ void TMenulist_window::draw_item(int i)
const TMenuitem& item = (const TMenuitem&)_sorted[i];
if (i == _selected && item.enabled())
{
//testo nero su sfondo con colore del focus
//testo nero su sfondo con colore del focus se la voce e' selezionata
set_color(item.color(), FOCUS_BACK_COLOR);
}
else
{
set_color(item.color(), NORMAL_BACK_COLOR); //testo nero su sfondo trasparente
set_color(item.color(), NORMAL_BACK_COLOR); //testo nero su sfondo trasparente x voci non selezionate
}
const int row = i / MENU_COLS;
@ -511,7 +527,7 @@ void TMenulist_window::draw_item(int i)
TString str = item.caption();
if (i == 0 && _can_go_back)
str.insert("(..)\n");
str = "(..)";
TParagraph_string para(str, maxchars);
int y = iy + 32 + CHARY-2;
@ -554,6 +570,29 @@ 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();
}
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;
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::click_on(int index)
@ -798,10 +837,18 @@ void TMenulist_window::set_menu(TMenu_tree& tree)
}
TMenulist_window::TMenulist_window(int x, int y, int dx, int dy, WINDOW parent, TMenulist_field* owner)
: TField_window(x, y, dx, dy, parent, owner), _tree(NULL)
: TField_window(x, y, dx, dy, parent, owner), _tree(NULL), MENU_COLS(4), MENU_ROWS(5)
{
set_scroll_max(0, 0); // Get rid of that useless scrollbars
_images.set_owner(win());
RCT rct; xvt_vobj_get_client_rect(win(), &rct);
const size_t rh = 32 + 3 * CHARY;
const size_t mr = rct.bottom / rh;
if (mr > MENU_ROWS)
MENU_ROWS = mr;
int ms = rct.bottom - 3 * rh;
_images.set_owner_info(win(), ms);
}
TMenulist_window::~TMenulist_window()