diff options
author | nyamatongwe <unknown> | 2011-08-10 23:56:59 +1000 |
---|---|---|
committer | nyamatongwe <unknown> | 2011-08-10 23:56:59 +1000 |
commit | 8bf7c53bd47fa32dd162d9db1063545537b1bb5f (patch) | |
tree | c401b75620e16fa591de3aca73465f7c5d471653 /src | |
parent | 305b3107ba2abd43e3ed635916c3cad52dc605fe (diff) | |
download | scintilla-mirror-8bf7c53bd47fa32dd162d9db1063545537b1bb5f.tar.gz |
Implement 'technology' concept which will allow GDI and Direct2D/DirectWrite
to run at the same time for different windows and operations.
Diffstat (limited to 'src')
-rw-r--r-- | src/AutoComplete.cxx | 4 | ||||
-rw-r--r-- | src/AutoComplete.h | 2 | ||||
-rw-r--r-- | src/CallTip.cxx | 8 | ||||
-rw-r--r-- | src/CallTip.h | 2 | ||||
-rw-r--r-- | src/Editor.cxx | 76 | ||||
-rw-r--r-- | src/Editor.h | 8 | ||||
-rw-r--r-- | src/ScintillaBase.cxx | 3 | ||||
-rw-r--r-- | src/ViewStyle.cxx | 10 | ||||
-rw-r--r-- | src/ViewStyle.h | 3 |
9 files changed, 80 insertions, 36 deletions
diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx index f6a291fe9..2752ef0c9 100644 --- a/src/AutoComplete.cxx +++ b/src/AutoComplete.cxx @@ -50,11 +50,11 @@ bool AutoComplete::Active() const { void AutoComplete::Start(Window &parent, int ctrlID, int position, Point location, int startLen_, - int lineHeight, bool unicodeMode) { + int lineHeight, bool unicodeMode, int technology) { if (active) { Cancel(); } - lb->Create(parent, ctrlID, location, lineHeight, unicodeMode); + lb->Create(parent, ctrlID, location, lineHeight, unicodeMode, technology); lb->Clear(); active = true; startLen = startLen_; diff --git a/src/AutoComplete.h b/src/AutoComplete.h index f48cb0551..aefab120a 100644 --- a/src/AutoComplete.h +++ b/src/AutoComplete.h @@ -40,7 +40,7 @@ public: /// Display the auto completion list positioned to be near a character position void Start(Window &parent, int ctrlID, int position, Point location, - int startLen_, int lineHeight, bool unicodeMode); + int startLen_, int lineHeight, bool unicodeMode, int technology); /// The stop chars are characters which, when typed, cause the auto completion list to disappear void SetStopChars(const char *stopChars_); diff --git a/src/CallTip.cxx b/src/CallTip.cxx index 6fd11730d..0e1e80cc1 100644 --- a/src/CallTip.cxx +++ b/src/CallTip.cxx @@ -255,14 +255,15 @@ void CallTip::MouseClick(Point pt) { PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn, const char *faceName, int size, - int codePage_, int characterSet, Window &wParent) { + int codePage_, int characterSet, + int technology, Window &wParent) { clickPlace = 0; delete []val; val = 0; val = new char[strlen(defn) + 1]; strcpy(val, defn); codePage = codePage_; - Surface *surfaceMeasure = Surface::Allocate(); + Surface *surfaceMeasure = Surface::Allocate(technology); if (!surfaceMeasure) return PRectangle(); surfaceMeasure->Init(wParent.GetID()); @@ -273,7 +274,8 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn, inCallTipMode = true; posStartCallTip = pos; int deviceHeight = surfaceMeasure->DeviceHeightFont(size); - font.Create(faceName, characterSet, deviceHeight / SC_FONT_SIZE_MULTIPLIER, SC_WEIGHT_NORMAL, false); + FontParameters fp(faceName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, SC_WEIGHT_NORMAL, false, 0, technology, characterSet); + font.Create(fp); // Look for multiple lines in the text // Only support \n here - simply means container must avoid \r! int numLines = 1; diff --git a/src/CallTip.h b/src/CallTip.h index a9ba82eb8..e437f3309 100644 --- a/src/CallTip.h +++ b/src/CallTip.h @@ -62,7 +62,7 @@ public: /// Setup the calltip and return a rectangle of the area required. PRectangle CallTipStart(int pos, Point pt, const char *defn, const char *faceName, int size, int codePage_, - int characterSet, Window &wParent); + int characterSet, int technology, Window &wParent); void CallTipCancel(); diff --git a/src/Editor.cxx b/src/Editor.cxx index f5649ce11..74698a13d 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -102,7 +102,8 @@ Editor::Editor() { ctrlID = 0; stylesValid = false; - + technology = SC_TECHNOLOGY_DEFAULT; + printMagnification = 0; printColourMode = SC_PRINT_NORMAL; printWrapState = eWrapWord; @@ -168,11 +169,11 @@ Editor::Editor() { additionalCaretsVisible = true; virtualSpaceOptions = SCVS_NONE; - pixmapLine = Surface::Allocate(); - pixmapSelMargin = Surface::Allocate(); - pixmapSelPattern = Surface::Allocate(); - pixmapIndentGuide = Surface::Allocate(); - pixmapIndentGuideHighlight = Surface::Allocate(); + pixmapLine = 0; + pixmapSelMargin = 0; + pixmapSelPattern = 0; + pixmapIndentGuide = 0; + pixmapIndentGuideHighlight = 0; targetStart = 0; targetEnd = 0; @@ -226,12 +227,7 @@ Editor::~Editor() { pdoc->RemoveWatcher(this, 0); pdoc->Release(); pdoc = 0; - DropGraphics(); - delete pixmapLine; - delete pixmapSelMargin; - delete pixmapSelPattern; - delete pixmapIndentGuide; - delete pixmapIndentGuideHighlight; + DropGraphics(true); } void Editor::Finalise() { @@ -239,17 +235,50 @@ void Editor::Finalise() { CancelModes(); } -void Editor::DropGraphics() { - pixmapLine->Release(); - pixmapSelMargin->Release(); - pixmapSelPattern->Release(); - pixmapIndentGuide->Release(); - pixmapIndentGuideHighlight->Release(); +void Editor::DropGraphics(bool freeObjects) { + if (freeObjects) { + delete pixmapLine; + pixmapLine = 0; + delete pixmapSelMargin; + pixmapSelMargin = 0; + delete pixmapSelPattern; + pixmapSelPattern = 0; + delete pixmapIndentGuide; + pixmapIndentGuide = 0; + delete pixmapIndentGuideHighlight; + pixmapIndentGuideHighlight = 0; + } else { + if (pixmapLine) + pixmapLine->Release(); + if (pixmapSelMargin) + pixmapSelMargin->Release(); + if (pixmapSelPattern) + pixmapSelPattern->Release(); + if (pixmapIndentGuide) + pixmapIndentGuide->Release(); + if (pixmapIndentGuideHighlight) + pixmapIndentGuideHighlight->Release(); + } +} + +void Editor::AllocateGraphics() { + if (!pixmapLine) + pixmapLine = Surface::Allocate(technology); + if (!pixmapSelMargin) + pixmapSelMargin = Surface::Allocate(technology); + if (!pixmapSelPattern) + pixmapSelPattern = Surface::Allocate(technology); + if (!pixmapIndentGuide) + pixmapIndentGuide = Surface::Allocate(technology); + if (!pixmapIndentGuideHighlight) + pixmapIndentGuideHighlight = Surface::Allocate(technology); } void Editor::InvalidateStyleData() { stylesValid = false; - DropGraphics(); + vs.technology = technology; + DropGraphics(false); + AllocateGraphics(); palette.Release(); llc.Invalidate(LineLayout::llInvalid); posCache.Clear(); @@ -3926,7 +3955,7 @@ void Editor::SetScrollBars() { } void Editor::ChangeSize() { - DropGraphics(); + DropGraphics(false); SetScrollBars(); if (wrapState != eWrapNone) { PRectangle rcTextArea = GetClientRectangle(); @@ -9218,6 +9247,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETIDENTIFIER: return GetCtrlID(); + case SCI_SETTECHNOLOGY: + // No action by default + break; + + case SCI_GETTECHNOLOGY: + return technology; + default: return DefWndProc(iMessage, wParam, lParam); } diff --git a/src/Editor.h b/src/Editor.h index f1a500b74..7a30fdf3f 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -131,6 +131,7 @@ protected: // ScintillaBase subclass needs access to much of Editor * When a style attribute is changed, this cache is flushed. */ bool stylesValid; ViewStyle vs; + int technology; Point sizeRGBAImage; Palette palette; @@ -279,7 +280,8 @@ protected: // ScintillaBase subclass needs access to much of Editor void InvalidateStyleRedraw(); virtual void RefreshColourPalette(Palette &pal, bool want); void RefreshStyleData(); - void DropGraphics(); + void DropGraphics(bool freeObjects); + void AllocateGraphics(); virtual PRectangle GetClientRectangle(); PRectangle GetTextRectangle(); @@ -574,7 +576,7 @@ private: public: AutoSurface(Editor *ed) : surf(0) { if (ed->wMain.GetID()) { - surf = Surface::Allocate(); + surf = Surface::Allocate(ed->technology); if (surf) { surf->Init(ed->wMain.GetID()); surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage()); @@ -584,7 +586,7 @@ public: } AutoSurface(SurfaceID sid, Editor *ed) : surf(0) { if (ed->wMain.GetID()) { - surf = Surface::Allocate(); + surf = Surface::Allocate(ed->technology); if (surf) { surf->Init(sid, ed->wMain.GetID()); surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage()); diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index da6b03e0d..247f34c4e 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -222,7 +222,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) { } } ac.Start(wMain, idAutoComplete, sel.MainCaret(), PointMainCaret(), - lenEntered, vs.lineHeight, IsUnicodeMode()); + lenEntered, vs.lineHeight, IsUnicodeMode(), technology); PRectangle rcClient = GetClientRectangle(); Point pt = LocationFromPosition(sel.MainCaret() - lenEntered); @@ -419,6 +419,7 @@ void ScintillaBase::CallTipShow(Point pt, const char *defn) { vs.styles[ctStyle].sizeZoomed, CodePage(), vs.styles[ctStyle].characterSet, + vs.technology, wMain); // If the call-tip window would be out of the client // space, adjust so it displays above the text. diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx index b722f8d02..08164f648 100644 --- a/src/ViewStyle.cxx +++ b/src/ViewStyle.cxx @@ -86,14 +86,15 @@ FontRealised::~FontRealised() { frNext = 0; } -void FontRealised::Realise(Surface &surface, int zoomLevel) { +void FontRealised::Realise(Surface &surface, int zoomLevel, int technology) { PLATFORM_ASSERT(fontName); sizeZoomed = size + zoomLevel * SC_FONT_SIZE_MULTIPLIER; if (sizeZoomed <= 2 * SC_FONT_SIZE_MULTIPLIER) // Hangs if sizeZoomed <= 1 sizeZoomed = 2 * SC_FONT_SIZE_MULTIPLIER; float deviceHeight = surface.DeviceHeightFont(sizeZoomed); - font.Create(fontName, characterSet, deviceHeight / SC_FONT_SIZE_MULTIPLIER, weight, italic, extraFontFlag); + FontParameters fp(fontName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, weight, italic, extraFontFlag, technology, characterSet); + font.Create(fp); ascent = surface.Ascent(font); descent = surface.Descent(font); @@ -102,7 +103,7 @@ void FontRealised::Realise(Surface &surface, int zoomLevel) { aveCharWidth = surface.AverageCharWidth(font); spaceWidth = surface.WidthChar(font, ' '); if (frNext) { - frNext->Realise(surface, zoomLevel); + frNext->Realise(surface, zoomLevel, technology); } } @@ -239,6 +240,7 @@ void ViewStyle::Init(size_t stylesSize_) { indicators[2].under = false; indicators[2].fore = ColourDesired(0xff, 0, 0); + technology = SC_TECHNOLOGY_DEFAULT; lineHeight = 1; maxAscent = 1; maxDescent = 1; @@ -388,7 +390,7 @@ void ViewStyle::Refresh(Surface &surface) { CreateFont(styles[j]); } - frFirst->Realise(surface, zoomLevel); + frFirst->Realise(surface, zoomLevel, technology); for (unsigned int k=0; k<stylesSize; k++) { FontRealised *fr = frFirst->Find(styles[k]); diff --git a/src/ViewStyle.h b/src/ViewStyle.h index b038a9b54..b15b9163c 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -48,7 +48,7 @@ public: FontRealised *frNext; FontRealised(const FontSpecification &fs); virtual ~FontRealised(); - void Realise(Surface &surface, int zoomLevel); + void Realise(Surface &surface, int zoomLevel, int technology); FontRealised *Find(const FontSpecification &fs); void FindMaxAscentDescent(unsigned int &maxAscent, unsigned int &maxDescent); }; @@ -67,6 +67,7 @@ public: Style *styles; LineMarker markers[MARKER_MAX + 1]; Indicator indicators[INDIC_MAX + 1]; + int technology; int lineHeight; unsigned int maxAscent; unsigned int maxDescent; |