Patch level : 4.0 451
Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione 3.1 650 git-svn-id: svn://10.65.10.50/trunk@14157 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
c52f052126
commit
5a8a42613e
@ -97,7 +97,6 @@ void advanced_draw_text_line(TWindow& win, const char* text, const RCT& r, char
|
||||
}
|
||||
else
|
||||
xvt_dwin_set_clip(w, (RCT*)&r);
|
||||
|
||||
|
||||
if (halign == 'J')
|
||||
advanced_draw_justified_text_line(win, text, x, y, dx);
|
||||
@ -108,11 +107,9 @@ void advanced_draw_text_line(TWindow& win, const char* text, const RCT& r, char
|
||||
xvt_dwin_set_clip(w, &orig);
|
||||
else
|
||||
xvt_dwin_set_clip(w, NULL);
|
||||
|
||||
}
|
||||
|
||||
bool finisce_per_punto(const TString& str)
|
||||
|
||||
{
|
||||
bool yes = false;
|
||||
const int len = str.len();
|
||||
@ -127,25 +124,18 @@ bool finisce_per_punto(const TString& str)
|
||||
void advanced_draw_paragraph(TWindow& win, const TString_array& para, const RCT& rct,
|
||||
char halign, char valign, int default_10row_height)
|
||||
{
|
||||
|
||||
int leading, ascent, descent;
|
||||
xvt_dwin_get_font_metrics(win.win(), &leading, &ascent, &descent);
|
||||
|
||||
int ky10 = (leading + ascent + descent) * 10;
|
||||
// Aggiusta l'altezza di una riga standard, se necessario
|
||||
if (ky10 < default_10row_height && ky10 > 80*default_10row_height/100)
|
||||
ky10 = default_10row_height;
|
||||
|
||||
const int rct_height = rct.bottom - rct.top;
|
||||
int rows = (rct_height * 11) / ky10; // Sto abbondante del 10% (*11/10) altrimenti risulta spesso 0
|
||||
|
||||
if (rows > 1 || para.items() >1) // Devo scrivere piu' righe?
|
||||
const int rows = para.items();
|
||||
if (rows > 1) // Devo scrivere piu' righe?
|
||||
{
|
||||
const int kx10 = xvt_dwin_get_text_width(win.win(), "MMMMMMMMMM", 10);
|
||||
const unsigned columns = (rct.right - rct.left) * 10 / kx10;
|
||||
int leading, ascent, descent;
|
||||
xvt_dwin_get_font_metrics(win.win(), &leading, &ascent, &descent);
|
||||
|
||||
int ky10 = (leading + ascent + descent) * 10;
|
||||
// Aggiusta l'altezza di una riga standard, se necessario
|
||||
if (ky10 < default_10row_height && ky10 > 80*default_10row_height/100)
|
||||
ky10 = default_10row_height;
|
||||
|
||||
if (para.items() < rows)
|
||||
rows = para.items();
|
||||
const int rct_height = rct.bottom - rct.top;
|
||||
|
||||
int ybase = rct.top;
|
||||
switch (valign)
|
||||
@ -157,17 +147,30 @@ void advanced_draw_paragraph(TWindow& win, const TString_array& para, const RCT&
|
||||
|
||||
for (int row = 0; row < rows; row++)
|
||||
{
|
||||
RCT rctline = rct;
|
||||
rctline.top = ybase + (ky10 * row) / 10;
|
||||
rctline.bottom = rctline.top + ky10 / 10;
|
||||
const char* line = para.row(row);
|
||||
if (halign == 'J' && (row == rows-1 || strlen(line) < columns/2))
|
||||
halign = 'L';
|
||||
advanced_draw_text_line(win, line, rctline, halign, 'T');
|
||||
const int top = ybase + (ky10 * row) / 10;
|
||||
if (top < rct.bottom)
|
||||
{
|
||||
const TString& line = para.row(row);
|
||||
if (!line.blank())
|
||||
{
|
||||
RCT rctline = rct;
|
||||
rctline.top = top;
|
||||
rctline.bottom = top + ky10 / 10;
|
||||
char ha = halign;
|
||||
if (ha == 'J' && (row == rows-1 || finisce_per_punto(line)))
|
||||
ha = 'L';
|
||||
advanced_draw_text_line(win, line, rctline, ha, 'T');
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (halign == 'J') halign = 'L';
|
||||
advanced_draw_text_line(win, para.row(0), rct, halign, valign);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
Loading…
x
Reference in New Issue
Block a user