Patch level : 2.1 nopatch

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :

Risistemate stampe


git-svn-id: svn://10.65.10.50/trunk@11882 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2004-03-17 17:15:44 +00:00
parent e8785e9eb2
commit d2cbf07a3d
3 changed files with 46 additions and 11 deletions

View File

@ -442,7 +442,7 @@ wxDC& TDC::GetDC(bool bPaint)
if (_dirty < 0 || FontChanged()) if (_dirty < 0 || FontChanged())
{ {
_dc->SetFont(_font.Font(_dc)); _dc->SetFont(_font.Font(_dc, (WINDOW)_owner));
_real_font = _font; _real_font = _font;
int height, desc, lead; int height, desc, lead;
@ -1713,7 +1713,7 @@ BOOLEAN xvt_dm_post_font_sel(WINDOW win, XVT_FNTID font_id, PRINT_RCD *precp, un
{ {
TFontId& font = *(TFontId*)font_id; TFontId& font = *(TFontId*)font_id;
wxFontData data; wxFontData data;
data.SetInitialFont(font.Font(NULL)); data.SetInitialFont(font.Font(NULL, win));
data.EnableEffects(FALSE); data.EnableEffects(FALSE);
wxFontDialog dlg(_task_win, &data); wxFontDialog dlg(_task_win, &data);
BOOLEAN ok = dlg.ShowModal() == wxID_OK; BOOLEAN ok = dlg.ShowModal() == wxID_OK;
@ -1987,14 +1987,14 @@ bool TFontId::Underline() const
} }
wxFont& TFontId::Font(wxDC* dc) const wxFont& TFontId::Font(wxDC* dc, WINDOW win) const
{ {
int nSize = PointSize(); int nSize = PointSize();
if (m_win == _print_win) if (win == _print_win)
{ {
static wxDC* lastDC = NULL; static wxDC* lastDC = NULL;
static double dPrintScale = 1.0; static double dPrintScale = 1.0;
/*
if (dc != lastDC) if (dc != lastDC)
{ {
const wxSize ppi = dc->GetPPI(); const wxSize ppi = dc->GetPPI();
@ -2010,9 +2010,10 @@ wxFont& TFontId::Font(wxDC* dc) const
const int nFontSize = int(12.0 * nScale); // First guess for PointSize const int nFontSize = int(12.0 * nScale); // First guess for PointSize
if (nFontSize == nBestSize) if (nFontSize == nBestSize)
break; break;
wxFont courier(nFontSize, wxMODERN, wxNORMAL, wxNORMAL); //wxFont courier(nFontSize, wxTELETYPE, wxNORMAL, wxNORMAL);
wxFont courier(nFontSize, Family(), wxNORMAL, wxNORMAL);
dc->SetFont(courier); dc->SetFont(courier);
int tw; dc->GetTextExtent("0123456789", &tw, NULL); int tw; dc->GetTextExtent("MMMMMMMMMM", &tw, NULL);
if (tw != nLastTextWidth) if (tw != nLastTextWidth)
nLastTextWidth = tw; // Happens with Generic/Text Only nLastTextWidth = tw; // Happens with Generic/Text Only
else else
@ -2035,7 +2036,35 @@ wxFont& TFontId::Font(wxDC* dc) const
dPrintScale = nBestSize / 12.0; dPrintScale = nBestSize / 12.0;
lastDC = dc; lastDC = dc;
} }
nSize = int(nSize * dPrintScale); */
if (dc != lastDC)
{
const wxSize ppi = dc->GetPPI();
const int nTarget = ppi.x;
const int cpi = 120 / nSize;
wxString str = "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM";
str.Truncate(cpi);
int nMin = 1, nMax = nSize*8;
while (nMin < nMax)
{
const int nFontSize = (nMin+nMax)/2;
wxFont courier(nFontSize, Family(), wxNORMAL, wxNORMAL, FALSE, FaceName());
dc->SetFont(courier);
int tw; dc->GetTextExtent(str, &tw, NULL);
if (tw == nTarget)
break;
if (tw > nTarget)
nMax = nFontSize-1;
else
nMin = nFontSize+1;
}
dPrintScale = double((nMin+nMax)/2) / double(nSize);
lastDC = dc;
}
nSize = int(nSize * dPrintScale + 0.5);
} }
const int nWeight = (m_wMask & XVT_FS_BOLD) ? wxBOLD : wxNORMAL; const int nWeight = (m_wMask & XVT_FS_BOLD) ? wxBOLD : wxNORMAL;
@ -2509,7 +2538,7 @@ void xvt_font_get_metrics(XVT_FNTID font_id, int *leadingp, int *ascentp, int *d
CAST_DC(win, dc); CAST_DC(win, dc);
const wxString str = "Mq"; const wxString str = "Mq";
int height, desc, lead; int height, desc, lead;
dc.GetTextExtent(str, NULL, &height, &desc, &lead, &font.Font(&dc)); dc.GetTextExtent(str, NULL, &height, &desc, &lead, &font.Font(&dc, win));
if (leadingp) if (leadingp)
*leadingp = lead; *leadingp = lead;
if (ascentp) if (ascentp)

View File

@ -31,7 +31,7 @@ public:
int Family() const; int Family() const;
void Copy(const wxFont& rFont); void Copy(const wxFont& rFont);
wxFont& Font(wxDC* dc) const; wxFont& Font(wxDC* dc, WINDOW w) const;
TFontId& operator=(const TFontId& f) { Copy(f); return *this; } TFontId& operator=(const TFontId& f) { Copy(f); return *this; }
bool operator==(const TFontId& f) const { return IsEqual(f); } bool operator==(const TFontId& f) const { return IsEqual(f); }
@ -69,7 +69,7 @@ public:
int GetFontDelta() const { return _deltaf; } int GetFontDelta() const { return _deltaf; }
virtual wxDC& GetDC(bool bPaint = false); virtual wxDC& GetDC(bool bPaint = false);
void KillDC(); virtual void KillDC();
TDC(wxWindow* owner); TDC(wxWindow* owner);
virtual ~TDC(); virtual ~TDC();
}; };
@ -78,6 +78,7 @@ class TPrintDC : public TDC
{ {
public: public:
virtual wxDC& GetDC(bool); virtual wxDC& GetDC(bool);
virtual void KillDC();
TPrintDC(wxWindow* owner); TPrintDC(wxWindow* owner);
virtual ~TPrintDC(); virtual ~TPrintDC();
}; };

View File

@ -203,6 +203,11 @@ wxDC& TPrintDC::GetDC(bool)
return TDC::GetDC(false); return TDC::GetDC(false);
} }
void TPrintDC::KillDC()
{
_dc = NULL; // _dc is owned by wxPrintout
}
TPrintDC::TPrintDC(wxWindow* owner) : TDC(owner) TPrintDC::TPrintDC(wxWindow* owner) : TDC(owner)
{ } { }