Corretto disegno alberi
git-svn-id: svn://10.65.10.50/trunk@6158 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
35ed35349b
commit
c3401d2370
128
include/tree.cpp
128
include/tree.cpp
@ -800,74 +800,73 @@ struct TUpdate_info
|
||||
|
||||
const int TABX = 3;
|
||||
|
||||
bool TTree_window::callback_draw_node(TTree& node, void* jolly, word)
|
||||
bool TTree_window::callback_draw_node(TTree& node, void* jolly, word when)
|
||||
{
|
||||
TUpdate_info* ui = (TUpdate_info*)jolly;
|
||||
|
||||
if (ui->_y >= ui->_firsty && ui->_y < ui->_lasty)
|
||||
{
|
||||
node.curr_id(ui->_str);
|
||||
const bool is_selected = ui->_str == ui->_curr_info->_id;
|
||||
int text_len = 0;
|
||||
if (node.get_description(ui->_str))
|
||||
{
|
||||
text_len = ui->_str.len();
|
||||
if (is_selected)
|
||||
{
|
||||
ui->_win->set_color(FOCUS_COLOR, FOCUS_BACK_COLOR);
|
||||
ui->_win->set_opaque_text(TRUE);
|
||||
}
|
||||
ui->_win->stringat(int(ui->_x+2), int(ui->_y), ui->_str);
|
||||
if (is_selected)
|
||||
{
|
||||
ui->_win->set_color(NORMAL_COLOR, NORMAL_BACK_COLOR);
|
||||
ui->_win->set_opaque_text(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
const int ry = int(ui->_y - ui->_firsty);
|
||||
for (int by = ry-1; by >= 0; by--)
|
||||
{
|
||||
long rx = (*ui->_node_info)[by]._startx;
|
||||
if (rx < ui->_x)
|
||||
break;
|
||||
}
|
||||
|
||||
const PNT p = ui->_win->log2dev(ui->_x, ui->_y);
|
||||
const WINDOW win = ui->_win->win();
|
||||
ui->_win->set_pen(DISABLED_COLOR);
|
||||
|
||||
PNT q;
|
||||
q.h = p.h; q.v = p.v + CHARY/2;
|
||||
xvt_dwin_draw_set_pos(win, q);
|
||||
q.h -= TABX*CHARX - 3*CHARX/2;
|
||||
xvt_dwin_draw_line(win, q);
|
||||
q.v = (by+1)*CHARY;
|
||||
xvt_dwin_draw_line(win, q);
|
||||
|
||||
TImage* bmp = node.image();
|
||||
if (bmp)
|
||||
bmp->draw(win, p.h, p.v + (CHARY - bmp->height()) / 2);
|
||||
|
||||
TNode_info& ni = (*ui->_node_info)[ry];
|
||||
node.curr_id(ni._id);
|
||||
ni._startx = ui->_x;
|
||||
ni._endx = ui->_x + text_len + 2;
|
||||
ni._plusx = node.has_son() ? ui->_x - TABX + 1 : 0;
|
||||
ni._expanded = ni._plusx > 0 ? node.expanded() : FALSE;
|
||||
}
|
||||
ui->_y++;
|
||||
|
||||
if (node.expanded())
|
||||
if (when == SCAN_PRE_ORDER)
|
||||
{
|
||||
if (ui->_y >= ui->_firsty && ui->_y < ui->_lasty)
|
||||
{
|
||||
node.curr_id(ui->_str);
|
||||
const bool is_selected = ui->_str == ui->_curr_info->_id;
|
||||
int text_len = 0;
|
||||
if (node.get_description(ui->_str))
|
||||
{
|
||||
text_len = ui->_str.len();
|
||||
if (is_selected)
|
||||
{
|
||||
ui->_win->set_color(FOCUS_COLOR, FOCUS_BACK_COLOR);
|
||||
ui->_win->set_opaque_text(TRUE);
|
||||
}
|
||||
ui->_win->stringat(int(ui->_x+2), int(ui->_y), ui->_str);
|
||||
if (is_selected)
|
||||
{
|
||||
ui->_win->set_color(NORMAL_COLOR, NORMAL_BACK_COLOR);
|
||||
ui->_win->set_opaque_text(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
const int ry = int(ui->_y - ui->_firsty);
|
||||
for (int by = ry-1; by >= 0; by--)
|
||||
{
|
||||
long rx = (*ui->_node_info)[by]._startx;
|
||||
if (rx < ui->_x)
|
||||
break;
|
||||
}
|
||||
|
||||
const PNT p = ui->_win->log2dev(ui->_x, ui->_y);
|
||||
const WINDOW win = ui->_win->win();
|
||||
ui->_win->set_pen(DISABLED_COLOR);
|
||||
|
||||
PNT q;
|
||||
q.h = p.h; q.v = p.v + CHARY/2;
|
||||
xvt_dwin_draw_set_pos(win, q);
|
||||
q.h -= TABX*CHARX - 3*CHARX/2;
|
||||
xvt_dwin_draw_line(win, q);
|
||||
q.v = (by+1)*CHARY;
|
||||
xvt_dwin_draw_line(win, q);
|
||||
|
||||
TImage* bmp = node.image();
|
||||
if (bmp)
|
||||
bmp->draw(win, p.h, p.v + (CHARY - bmp->height()) / 2);
|
||||
|
||||
TNode_info& ni = (*ui->_node_info)[ry];
|
||||
node.curr_id(ni._id);
|
||||
ni._startx = ui->_x;
|
||||
ni._endx = ui->_x + text_len + 2;
|
||||
ni._plusx = node.has_son() ? ui->_x - TABX + 1 : 0;
|
||||
ni._expanded = ni._plusx > 0 ? node.expanded() : FALSE;
|
||||
}
|
||||
ui->_y++;
|
||||
|
||||
ui->_x += TABX;
|
||||
if (ui->_x > ui->_jolly)
|
||||
ui->_jolly = ui->_x;
|
||||
}
|
||||
else
|
||||
} else
|
||||
if (when == SCAN_IN_ORDER)
|
||||
{
|
||||
if (!node.has_rbrother())
|
||||
ui->_x -= TABX;
|
||||
ui->_x -= TABX;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@ -947,13 +946,16 @@ void TTree_window::update()
|
||||
}
|
||||
|
||||
_node_info.reset();
|
||||
_tree->scan_depth_first(callback_draw_node, &ui, SCAN_IGNORING_UNEXPANDED);
|
||||
|
||||
const word flags = SCAN_IGNORING_UNEXPANDED | SCAN_PRE_ORDER | SCAN_IN_ORDER;
|
||||
_tree->scan_depth_first(callback_draw_node, &ui, flags);
|
||||
while (ui._y < ui._lasty)
|
||||
{
|
||||
if (_tree->goto_father())
|
||||
{
|
||||
{
|
||||
ui._x -= TABX;
|
||||
if (_tree->goto_rbrother())
|
||||
_tree->scan_depth_first(callback_draw_node, &ui, SCAN_IGNORING_UNEXPANDED);
|
||||
_tree->scan_depth_first(callback_draw_node, &ui, flags);
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user