diff options
author | nyamatongwe <unknown> | 2003-02-05 09:05:48 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2003-02-05 09:05:48 +0000 |
commit | 631c2f4856068c096714f6ec750b35f0dfd3bdd2 (patch) | |
tree | 05aee0b8730ba1e29e71ec82a3d22fa42e7f386b | |
parent | d176be2a32cc0e8fc0310200c475ddfd0565108a (diff) | |
download | scintilla-mirror-631c2f4856068c096714f6ec750b35f0dfd3bdd2.tar.gz |
Moved IsNT to PlatWin and cached the result.
Change maximum number of pixels when measuring text on NT to be 1000000
rather than 30000 possible on Windows.
Increased size of Unicode buffers to 10000 elements to handle longer
paragraphs of text.
-rw-r--r-- | win32/PlatWin.cxx | 17 | ||||
-rw-r--r-- | win32/ScintillaWin.cxx | 14 |
2 files changed, 19 insertions, 12 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 9943471bd..e0a6840bd 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -42,6 +42,11 @@ static void SetWindowPointer(HWND hWnd, void *ptr) { static CRITICAL_SECTION crPlatformLock; static HINSTANCE hinstPlatformRes = 0; +static bool onNT = false; + +bool IsNT() { + return onNT; +} Point Point::FromLong(long lpoint) { return Point(static_cast<short>(LOWORD(lpoint)), static_cast<short>(HIWORD(lpoint))); @@ -276,6 +281,7 @@ class SurfaceImpl : public Surface { HBITMAP bitmap; HBITMAP bitmapOld; HPALETTE paletteOld; + int maxWidthMeasure; void BrushColor(ColourAllocated back); void SetFont(Font &font_); @@ -334,6 +340,8 @@ SurfaceImpl::SurfaceImpl() : font(0), fontOld(0), bitmap(0), bitmapOld(0), paletteOld(0) { + // Windows 9x has only a 16 bit coordinate system so break after 30000 pixels + maxWidthMeasure = IsNT() ? 1000000 : 30000; } SurfaceImpl::~SurfaceImpl() { @@ -507,7 +515,7 @@ void SurfaceImpl::Copy(PRectangle rc, Point from, Surface &surfaceSource) { static_cast<SurfaceImpl &>(surfaceSource).hdc, from.x, from.y, SRCCOPY); } -#define MAX_US_LEN 5000 +#define MAX_US_LEN 10000 void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back) { @@ -591,7 +599,7 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi tbuf[tlen] = L'\0'; int poses[MAX_US_LEN]; fit = tlen; - if (!::GetTextExtentExPointW(hdc, tbuf, tlen, 30000, &fit, poses, &sz)) { + if (!::GetTextExtentExPointW(hdc, tbuf, tlen, maxWidthMeasure, &fit, poses, &sz)) { // Likely to have failed because on Windows 9x where function not available // So measure the character widths by measuring each initial substring // Turns a linear operation into a qudratic but seems fast enough on test files @@ -624,7 +632,7 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi positions[i++] = lastPos; } } else { - if (!::GetTextExtentExPoint(hdc, s, len, 30000, &fit, positions, &sz)) { + if (!::GetTextExtentExPoint(hdc, s, len, maxWidthMeasure, &fit, positions, &sz)) { // Eeek - a NULL DC or other foolishness could cause this. // The least we can do is set the positions to zero! memset(positions, 0, len * sizeof(*positions)); @@ -1370,6 +1378,9 @@ int Platform::Clamp(int val, int minVal, int maxVal) { } void Platform_Initialise(void *hInstance) { + OSVERSIONINFO osv = {sizeof(OSVERSIONINFO),0,0,0,0,""}; + ::GetVersionEx(&osv); + onNT = osv.dwPlatformId == VER_PLATFORM_WIN32_NT; ::InitializeCriticalSection(&crPlatformLock); hinstPlatformRes = reinterpret_cast<HINSTANCE>(hInstance); ListBoxX_Register(); diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 983a5906f..6f0204362 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -87,6 +87,11 @@ #define MK_ALT 32 #endif +// Functions imported from PlatWin +extern bool IsNT(); +extern void Platform_Initialise(void *hInstance); +extern void Platform_Finalise(); + /** TOTAL_CONTROL ifdef surrounds code that will only work when ScintillaWin * is derived from ScintillaBase (all features) rather than directly from Editor * (lightweight editor). @@ -407,12 +412,6 @@ LRESULT ScintillaWin::WndPaint(uptr_t wParam) { return 0l; } -static BOOL IsNT() { - OSVERSIONINFO osv = {sizeof(OSVERSIONINFO),0,0,0,0,""}; - ::GetVersionEx(&osv); - return osv.dwPlatformId == VER_PLATFORM_WIN32_NT; -} - sptr_t ScintillaWin::HandleComposition(uptr_t wParam, sptr_t lParam) { #ifdef __DMC__ // Digital Mars compiler does not include Imm library @@ -1980,9 +1979,6 @@ sptr_t PASCAL ScintillaWin::SWndProc( } } -extern void Platform_Initialise(void *hInstance); -extern void Platform_Finalise(); - // This function is externally visible so it can be called from container when building statically. // Must be called once only. bool Scintilla_RegisterClasses(void *hInstance) { |