aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gtk/PlatGTK.cxx251
-rw-r--r--gtk/ScintillaGTK.cxx126
-rw-r--r--include/Platform.h196
-rw-r--r--include/Scintilla.h2
-rw-r--r--src/CallTip.cxx10
-rw-r--r--src/Document.cxx4
-rw-r--r--src/DocumentAccessor.cxx2
-rw-r--r--src/Editor.cxx56
-rw-r--r--src/Indicator.h2
-rw-r--r--src/LexHTML.cxx197
-rw-r--r--src/LineMarker.cxx8
-rw-r--r--src/LineMarker.h4
-rw-r--r--src/ScintillaBase.cxx2
-rw-r--r--src/Style.cxx8
-rw-r--r--src/Style.h2
-rw-r--r--src/ViewStyle.cxx23
-rw-r--r--src/WindowAccessor.cxx2
-rw-r--r--win32/ExternalLexer.cxx5
-rw-r--r--win32/PlatWin.cxx266
-rw-r--r--win32/ScintillaWin.cxx146
20 files changed, 756 insertions, 556 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index 47e32118c..c028a52a1 100644
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -8,6 +8,7 @@
#include <stdlib.h>
#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
#include "Platform.h"
@@ -20,58 +21,50 @@
#define FAST_WAY
#endif
-Point Point::FromLong(long lpoint) {
- return Point(
- Platform::LowShortFromLong(lpoint),
- Platform::HighShortFromLong(lpoint));
-}
+#ifdef _MSC_VER
+// Ignore unreferenced local functions in GTK+ headers
+#pragma warning(disable: 4505)
+#endif
-static GdkColor ColourfromRGB(unsigned int red, unsigned int green, unsigned int blue) {
- GdkColor co;
- co.red = red * (65535 / 255);
- co.green = green * (65535 / 255);
- co.blue = blue * (65535 / 255);
- // the pixel value indicates the index in the colourmap of the colour.
- // it is simply a combination of the RGB values we set earlier
- co.pixel = (gulong)(red * 65536 + green * 256 + blue);
- return co;
+static GdkFont *PFont(Font &f) {
+ return reinterpret_cast<GdkFont *>(f.GetID());
}
-Colour::Colour(long lcol) {
- unsigned int red = lcol & 0xff;
- unsigned int green = (lcol >> 8) & 0xff;
- unsigned int blue = lcol >> 16;
- co = ColourfromRGB(red, green, blue);
+static GdkDrawable *PDrawable(SurfaceID id) {
+ return reinterpret_cast<GdkDrawable *>(id);
}
-Colour::Colour(unsigned int red, unsigned int green, unsigned int blue) {
- co = ColourfromRGB(red, green, blue);
+static GdkGC *PGC(void *gc) {
+ return reinterpret_cast<GdkGC *>(gc);
}
-bool Colour::operator==(const Colour &other) const {
- return
- co.red == other.co.red &&
- co.green == other.co.green &&
- co.blue == other.co.blue;
+static GtkWidget *PWidget(WindowID id) {
+ return reinterpret_cast<GtkWidget *>(id);
}
-unsigned int Colour::GetRed() {
- return co.red;
+static GtkWidget *PWidget(Window &w) {
+ return PWidget(w.GetID());
}
-unsigned int Colour::GetGreen() {
- return co.green;
+static GtkItemFactory *PMenu(MenuID id) {
+ return reinterpret_cast<GtkItemFactory *>(id);
}
-unsigned int Colour::GetBlue() {
- return co.blue;
+Point Point::FromLong(long lpoint) {
+ return Point(
+ Platform::LowShortFromLong(lpoint),
+ Platform::HighShortFromLong(lpoint));
}
-long Colour::AsLong() const {
- unsigned int red = co.red * 255 / 65535;
- unsigned int green = co.green * 255 / 65535;
- unsigned int blue = co.blue * 255 / 65535;
- return (red + green*256 + blue*65536);
+static GdkColor ColourfromRGB(unsigned int red, unsigned int green, unsigned int blue) {
+ GdkColor co;
+ co.red = red * (65535 / 255);
+ co.green = green * (65535 / 255);
+ co.blue = blue * (65535 / 255);
+ // the pixel value indicates the index in the colourmap of the colour.
+ // it is simply a combination of the RGB values we set earlier
+ co.pixel = (gulong)(red * 65536 + green * 256 + blue);
+ return co;
}
Palette::Palette() {
@@ -87,7 +80,7 @@ Palette::~Palette() {
void Palette::Release() {
used = 0;
- delete []allocatedPalette;
+ delete [](reinterpret_cast<GdkColor *>(allocatedPalette));
allocatedPalette = 0;
allocatedLen = 0;
}
@@ -104,7 +97,7 @@ void Palette::WantFind(ColourPair &cp, bool want) {
if (used < numEntries) {
entries[used].desired = cp.desired;
- entries[used].allocated = cp.desired;
+ entries[used].allocated.Set(cp.desired.AsLong());
used++;
}
} else {
@@ -114,31 +107,33 @@ void Palette::WantFind(ColourPair &cp, bool want) {
return ;
}
}
- cp.allocated = cp.desired;
+ cp.allocated.Set(cp.desired.AsLong());
}
}
void Palette::Allocate(Window &w) {
if (allocatedPalette) {
- gdk_colormap_free_colors(gtk_widget_get_colormap(w.GetID()),
- allocatedPalette, allocatedLen);
- delete []allocatedPalette;
+ gdk_colormap_free_colors(gtk_widget_get_colormap(PWidget(w)),
+ reinterpret_cast<GdkColor *>(allocatedPalette),
+ allocatedLen);
+ delete [](reinterpret_cast<GdkColor *>(allocatedPalette));
allocatedPalette = 0;
allocatedLen = 0;
}
- allocatedPalette = new GdkColor[used];
+ GdkColor *paletteNew = new GdkColor[used];
+ allocatedPalette = paletteNew;
gboolean *successPalette = new gboolean[used];
- if (allocatedPalette) {
+ if (paletteNew) {
allocatedLen = used;
int iPal = 0;
for (iPal = 0; iPal < used; iPal++) {
- allocatedPalette[iPal] = entries[iPal].desired.co;
+ paletteNew[iPal].pixel = entries[iPal].desired.AsLong();
}
- gdk_colormap_alloc_colors(gtk_widget_get_colormap(w.GetID()),
- allocatedPalette, allocatedLen, FALSE, TRUE,
+ gdk_colormap_alloc_colors(gtk_widget_get_colormap(PWidget(w)),
+ paletteNew, allocatedLen, FALSE, TRUE,
successPalette);
for (iPal = 0; iPal < used; iPal++) {
- entries[iPal].allocated.co = allocatedPalette[iPal];
+ entries[iPal].allocated.Set(paletteNew[iPal].pixel);
}
}
delete []successPalette;
@@ -231,7 +226,7 @@ void Font::Create(const char *faceName, int characterSet,
void Font::Release() {
if (id)
- gdk_font_unref(id);
+ gdk_font_unref(PFont(*this));
id = 0;
}
@@ -246,11 +241,11 @@ void Surface::Release() {
drawable = 0;
if (createdGC) {
createdGC = false;
- gdk_gc_unref(gc);
+ gdk_gc_unref(PGC(gc));
}
gc = 0;
if (ppixmap)
- gdk_pixmap_unref(ppixmap);
+ gdk_pixmap_unref(PDrawable(ppixmap));
ppixmap = 0;
x = 0;
y = 0;
@@ -267,7 +262,8 @@ void Surface::Init() {
inited = true;
}
-void Surface::Init(GdkDrawable *drawable_) {
+void Surface::Init(SurfaceID sid) {
+ GdkDrawable *drawable_ = PDrawable(sid);
Release();
drawable = drawable_;
gc = gdk_gc_new(drawable_);
@@ -280,18 +276,21 @@ void Surface::Init(GdkDrawable *drawable_) {
void Surface::InitPixMap(int width, int height, Surface *surface_) {
Release();
if (height > 0 && width > 0)
- ppixmap = gdk_pixmap_new(surface_->drawable, width, height, -1);
+ ppixmap = gdk_pixmap_new(PDrawable(surface_->drawable), width, height, -1);
drawable = ppixmap;
- gc = gdk_gc_new(surface_->drawable);
+ gc = gdk_gc_new(PDrawable(surface_->drawable));
//gdk_gc_set_line_attributes(gc, 1,
// GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_BEVEL);
createdGC = true;
inited = true;
}
-void Surface::PenColour(Colour fore) {
- if (gc)
- gdk_gc_set_foreground(gc, &fore.co);
+void Surface::PenColour(ColourAllocated fore) {
+ if (gc) {
+ GdkColor co;
+ co.pixel = fore.AsLong();
+ gdk_gc_set_foreground(PGC(gc), &co);
+ }
}
int Surface::LogPixelsY() {
@@ -309,15 +308,15 @@ void Surface::MoveTo(int x_, int y_) {
}
void Surface::LineTo(int x_, int y_) {
- gdk_draw_line(drawable, gc,
+ gdk_draw_line(PDrawable(drawable), PGC(gc),
x, y,
x_, y_);
x = x_;
y = y_;
}
-void Surface::Polygon(Point *pts, int npts, Colour fore,
- Colour back) {
+void Surface::Polygon(Point *pts, int npts, ColourAllocated fore,
+ ColourAllocated back) {
GdkPoint gpts[20];
if (npts < static_cast<int>((sizeof(gpts) / sizeof(gpts[0])))) {
for (int i = 0;i < npts;i++) {
@@ -325,32 +324,32 @@ void Surface::Polygon(Point *pts, int npts, Colour fore,
gpts[i].y = pts[i].y;
}
PenColour(back);
- gdk_draw_polygon(drawable, gc, 1, gpts, npts);
+ gdk_draw_polygon(PDrawable(drawable), PGC(gc), 1, gpts, npts);
PenColour(fore);
- gdk_draw_polygon(drawable, gc, 0, gpts, npts);
+ gdk_draw_polygon(PDrawable(drawable), PGC(gc), 0, gpts, npts);
}
}
-void Surface::RectangleDraw(PRectangle rc, Colour fore, Colour back) {
+void Surface::RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
if (gc && drawable) {
PenColour(back);
- gdk_draw_rectangle(drawable, gc, 1,
+ gdk_draw_rectangle(PDrawable(drawable), PGC(gc), 1,
rc.left + 1, rc.top + 1,
rc.right - rc.left - 2, rc.bottom - rc.top - 2);
PenColour(fore);
// The subtraction of 1 off the width and height here shouldn't be needed but
// otherwise a different rectangle is drawn than would be done if the fill parameter == 1
- gdk_draw_rectangle(drawable, gc, 0,
+ gdk_draw_rectangle(PDrawable(drawable), PGC(gc), 0,
rc.left, rc.top,
rc.right - rc.left - 1, rc.bottom - rc.top - 1);
}
}
-void Surface::FillRectangle(PRectangle rc, Colour back) {
+void Surface::FillRectangle(PRectangle rc, ColourAllocated back) {
PenColour(back);
if (drawable) {
- gdk_draw_rectangle(drawable, gc, 1,
+ gdk_draw_rectangle(PDrawable(drawable), PGC(gc), 1,
rc.left, rc.top,
rc.right - rc.left, rc.bottom - rc.top);
}
@@ -366,9 +365,9 @@ void Surface::FillRectangle(PRectangle rc, Surface &surfacePattern) {
int widthx = (xTile + widthPat > rc.right) ? rc.right - xTile : widthPat;
for (int yTile = rc.top; yTile < rc.bottom; yTile += heightPat) {
int heighty = (yTile + heightPat > rc.bottom) ? rc.bottom - yTile : heightPat;
- gdk_draw_pixmap(drawable,
- gc,
- surfacePattern.drawable,
+ gdk_draw_pixmap(PDrawable(drawable),
+ PGC(gc),
+ PDrawable(surfacePattern.drawable),
0, 0,
xTile, yTile,
widthx, heighty);
@@ -377,11 +376,11 @@ void Surface::FillRectangle(PRectangle rc, Surface &surfacePattern) {
} else {
// Something is wrong so try to show anyway
// Shows up black because colour not allocated
- FillRectangle(rc, Colour(0xff, 0, 0));
+ FillRectangle(rc, ColourAllocated(0));
}
}
-void Surface::RoundedRectangle(PRectangle rc, Colour fore, Colour back) {
+void Surface::RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
if (((rc.right - rc.left) > 4) && ((rc.bottom - rc.top) > 4)) {
// Approximate a round rect with some cut off corners
Point pts[] = {
@@ -400,16 +399,16 @@ void Surface::RoundedRectangle(PRectangle rc, Colour fore, Colour back) {
}
}
-void Surface::Ellipse(PRectangle rc, Colour fore, Colour back) {
+void Surface::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
PenColour(back);
- gdk_draw_arc(drawable, gc, 1,
+ gdk_draw_arc(PDrawable(drawable), PGC(gc), 1,
rc.left + 1, rc.top + 1,
rc.right - rc.left - 2, rc.bottom - rc.top - 2,
0, 32767);
// The subtraction of 1 here is similar to the case for RectangleDraw
PenColour(fore);
- gdk_draw_arc(drawable, gc, 0,
+ gdk_draw_arc(PDrawable(drawable), PGC(gc), 0,
rc.left, rc.top,
rc.right - rc.left - 1, rc.bottom - rc.top - 1,
0, 32767);
@@ -417,9 +416,9 @@ void Surface::Ellipse(PRectangle rc, Colour fore, Colour back) {
void Surface::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
if (surfaceSource.drawable) {
- gdk_draw_pixmap(drawable,
- gc,
- surfaceSource.drawable,
+ gdk_draw_pixmap(PDrawable(drawable),
+ PGC(gc),
+ PDrawable(surfaceSource.drawable),
from.x, from.y,
rc.left, rc.top,
rc.right - rc.left, rc.bottom - rc.top);
@@ -427,27 +426,27 @@ void Surface::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
}
void Surface::DrawText(PRectangle rc, Font &font_, int ybase, const char *s, int len,
- Colour fore, Colour back) {
+ ColourAllocated fore, ColourAllocated back) {
FillRectangle(rc, back);
PenColour(fore);
if (gc && drawable)
- gdk_draw_text(drawable, font_.id, gc, rc.left, ybase, s, len);
+ gdk_draw_text(PDrawable(drawable), PFont(font_), PGC(gc), rc.left, ybase, s, len);
}
// On GTK+, exactly same as DrawText
void Surface::DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len,
- Colour fore, Colour back) {
+ ColourAllocated fore, ColourAllocated back) {
FillRectangle(rc, back);
PenColour(fore);
if (gc && drawable)
- gdk_draw_text(drawable, font_.id, gc, rc.left, ybase, s, len);
+ gdk_draw_text(PDrawable(drawable), PFont(font_), PGC(gc), rc.left, ybase, s, len);
}
void Surface::MeasureWidths(Font &font_, const char *s, int len, int *positions) {
int totalWidth = 0;
for (int i = 0;i < len;i++) {
if (font_.id) {
- int width = gdk_char_width(font_.id, s[i]);
+ int width = gdk_char_width(PFont(font_), s[i]);
totalWidth += width;
} else {
totalWidth++;
@@ -458,14 +457,14 @@ void Surface::MeasureWidths(Font &font_, const char *s, int len, int *positions)
int Surface::WidthText(Font &font_, const char *s, int len) {
if (font_.id)
- return gdk_text_width(font_.id, s, len);
+ return gdk_text_width(PFont(font_), s, len);
else
return 1;
}
int Surface::WidthChar(Font &font_, char ch) {
if (font_.id)
- return gdk_char_width(font_.id, ch);
+ return gdk_char_width(PFont(font_), ch);
else
return 1;
}
@@ -489,7 +488,7 @@ int Surface::Ascent(Font &font_) {
if (!font_.id)
return 1;
#ifdef FAST_WAY
- return font_.id->ascent;
+ return PFont(font_)->ascent;
#else
gint lbearing;
gint rbearing;
@@ -507,7 +506,7 @@ int Surface::Descent(Font &font_) {
if (!font_.id)
return 1;
#ifdef FAST_WAY
- return font_.id->descent;
+ return PFont(font_)->descent;
#else
gint lbearing;
gint rbearing;
@@ -535,7 +534,7 @@ int Surface::Height(Font &font_) {
int Surface::AverageCharWidth(Font &font_) {
if (font_.id)
- return gdk_char_width(font_.id, 'n');
+ return gdk_char_width(PFont(font_), 'n');
else
return 1;
}
@@ -548,7 +547,7 @@ int Surface::SetPalette(Palette *, bool) {
void Surface::SetClip(PRectangle rc) {
GdkRectangle area = {rc.left, rc.top,
rc.right - rc.left, rc.bottom - rc.top};
- gdk_gc_set_clip_rectangle(gc, &area);
+ gdk_gc_set_clip_rectangle(PGC(gc), &area);
}
void Surface::FlushCachedState() {}
@@ -569,11 +568,11 @@ PRectangle Window::GetPosition() {
// Before any size allocated pretend its 1000 wide so not scrolled
PRectangle rc(0, 0, 1000, 1000);
if (id) {
- rc.left = id->allocation.x;
- rc.top = id->allocation.y;
- if (id->allocation.width > 20) {
- rc.right = rc.left + id->allocation.width;
- rc.bottom = rc.top + id->allocation.height;
+ rc.left = PWidget(id)->allocation.x;
+ rc.top = PWidget(id)->allocation.y;
+ if (PWidget(id)->allocation.width > 20) {
+ rc.right = rc.left + PWidget(id)->allocation.width;
+ rc.bottom = rc.top + PWidget(id)->allocation.height;
}
}
return rc;
@@ -587,7 +586,7 @@ void Window::SetPosition(PRectangle rc) {
alloc.y = rc.top;
alloc.width = rc.Width();
alloc.height = rc.Height();
- gtk_widget_size_allocate(id, &alloc);
+ gtk_widget_size_allocate(PWidget(id), &alloc);
#else
gtk_widget_set_uposition(id, rc.left, rc.top);
gtk_widget_set_usize(id, rc.right - rc.left, rc.bottom - rc.top);
@@ -597,9 +596,9 @@ void Window::SetPosition(PRectangle rc) {
void Window::SetPositionRelative(PRectangle rc, Window relativeTo) {
int ox = 0;
int oy = 0;
- gdk_window_get_origin(relativeTo.id->window, &ox, &oy);
+ gdk_window_get_origin(PWidget(relativeTo.id)->window, &ox, &oy);
- gtk_widget_set_uposition(id, rc.left + ox, rc.top + oy);
+ gtk_widget_set_uposition(PWidget(id), rc.left + ox, rc.top + oy);
#if 0
GtkAllocation alloc;
alloc.x = rc.left + ox;
@@ -608,7 +607,7 @@ void Window::SetPositionRelative(PRectangle rc, Window relativeTo) {
alloc.height = rc.bottom - rc.top;
gtk_widget_size_allocate(id, &alloc);
#endif
- gtk_widget_set_usize(id, rc.right - rc.left, rc.bottom - rc.top);
+ gtk_widget_set_usize(PWidget(id), rc.right - rc.left, rc.bottom - rc.top);
}
PRectangle Window::GetClientPosition() {
@@ -618,18 +617,18 @@ PRectangle Window::GetClientPosition() {
void Window::Show(bool show) {
if (show)
- gtk_widget_show(id);
+ gtk_widget_show(PWidget(id));
}
void Window::InvalidateAll() {
if (id) {
- gtk_widget_queue_draw(id);
+ gtk_widget_queue_draw(PWidget(id));
}
}
void Window::InvalidateRectangle(PRectangle rc) {
if (id) {
- gtk_widget_queue_draw_area(id,
+ gtk_widget_queue_draw_area(PWidget(id),
rc.left, rc.top,
rc.right - rc.left, rc.bottom - rc.top);
}
@@ -662,7 +661,7 @@ void Window::SetCursor(Cursor curs) {
break;
}
- gdk_window_set_cursor(id->window, gdkCurs);
+ gdk_window_set_cursor(PWidget(id)->window, gdkCurs);
gdk_cursor_destroy(gdkCurs);
}
@@ -694,7 +693,7 @@ static gboolean ButtonPress(GtkWidget *, GdkEventButton* ev, gpointer p) {
void ListBox::Create(Window &, int) {
id = gtk_window_new(GTK_WINDOW_POPUP);
- GtkWidget* frame = gtk_frame_new(NULL);
+ GtkWidget *frame = gtk_frame_new(NULL);
gtk_widget_show (frame);
gtk_container_add(GTK_CONTAINER(GetID()), frame);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_OUT);
@@ -704,33 +703,33 @@ void ListBox::Create(Window &, int) {
gtk_container_set_border_width(GTK_CONTAINER(scroller), 0);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroller),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_container_add(GTK_CONTAINER(frame), scroller);
- gtk_widget_show(scroller);
+ gtk_container_add(GTK_CONTAINER(frame), PWidget(scroller));
+ gtk_widget_show(PWidget(scroller));
list = gtk_clist_new(1);
- gtk_widget_show(list);
- gtk_container_add(GTK_CONTAINER(scroller), list);
- gtk_clist_set_column_auto_resize(GTK_CLIST(list), 0, TRUE);
- gtk_clist_set_selection_mode(GTK_CLIST(list), GTK_SELECTION_BROWSE);
- gtk_signal_connect(GTK_OBJECT(list), "select_row",
+ gtk_widget_show(PWidget(list));
+ gtk_container_add(GTK_CONTAINER(PWidget(scroller)), PWidget(list));
+ gtk_clist_set_column_auto_resize(GTK_CLIST(PWidget(list)), 0, TRUE);
+ gtk_clist_set_selection_mode(GTK_CLIST(PWidget(list)), GTK_SELECTION_BROWSE);
+ gtk_signal_connect(GTK_OBJECT(PWidget(list)), "select_row",
GTK_SIGNAL_FUNC(SelectionAC), &current);
- gtk_signal_connect(GTK_OBJECT(list), "button_press_event",
+ gtk_signal_connect(GTK_OBJECT(PWidget(list)), "button_press_event",
GTK_SIGNAL_FUNC(ButtonPress), this);
- gtk_clist_set_shadow_type(GTK_CLIST(list), GTK_SHADOW_NONE);
+ gtk_clist_set_shadow_type(GTK_CLIST(PWidget(list)), GTK_SHADOW_NONE);
- gtk_widget_realize(id);
+ gtk_widget_realize(PWidget(id));
}
void ListBox::SetFont(Font &scint_font) {
GtkStyle* style;
- style = gtk_widget_get_style(GTK_WIDGET(list));
- if (!gdk_font_equal(style->font, scint_font.GetID())) {
+ style = gtk_widget_get_style(GTK_WIDGET(PWidget(list)));
+ if (!gdk_font_equal(style->font, PFont(scint_font))) {
style = gtk_style_copy(style);
gdk_font_unref(style->font);
- style->font = scint_font.GetID();
+ style->font = PFont(scint_font);
gdk_font_ref(style->font);
- gtk_widget_set_style(GTK_WIDGET(list), style);
+ gtk_widget_set_style(GTK_WIDGET(PWidget(list)), style);
gtk_style_unref(style);
}
}
@@ -757,9 +756,9 @@ PRectangle ListBox::GetDesiredRect() {
// First calculate height of the clist for our desired visible row count otherwise it tries to expand to the total # of rows
height = (rows * GTK_CLIST(list)->row_height
+ rows + 1
- + 2 * (list->style->klass->ythickness
- + GTK_CONTAINER(list)->border_width));
- gtk_widget_set_usize(GTK_WIDGET(list), -1, height);
+ + 2 * (PWidget(list)->style->klass->ythickness
+ + GTK_CONTAINER(PWidget(list))->border_width));
+ gtk_widget_set_usize(GTK_WIDGET(PWidget(list)), -1, height);
// Get the size of the scroller because we set usize on the window
gtk_widget_size_request(GTK_WIDGET(scroller), &req);
@@ -845,15 +844,15 @@ void Menu::Destroy() {
}
void Menu::Show(Point pt, Window &) {
- gtk_item_factory_popup(id, pt.x - 4, pt.y, 3, 0);
+ gtk_item_factory_popup(PMenu(id), pt.x - 4, pt.y, 3, 0);
}
-Colour Platform::Chrome() {
- return Colour(0xe0, 0xe0, 0xe0);
+ColourDesired Platform::Chrome() {
+ return ColourDesired(0xe0, 0xe0, 0xe0);
}
-Colour Platform::ChromeHighlight() {
- return Colour(0xff, 0xff, 0xff);
+ColourDesired Platform::ChromeHighlight() {
+ return ColourDesired(0xff, 0xff, 0xff);
}
const char *Platform::DefaultFont() {
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx
index 89aed40bf..b9668d9bf 100644
--- a/gtk/ScintillaGTK.cxx
+++ b/gtk/ScintillaGTK.cxx
@@ -9,7 +9,11 @@
#include <ctype.h>
#include <time.h>
+#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
+
#include "Platform.h"
+
#if PLAT_GTK_WIN32
#include "Windows.h"
#endif
@@ -42,6 +46,8 @@
#ifdef _MSC_VER
// Constant conditional expressions are because of GTK+ headers
#pragma warning(disable: 4127)
+// Ignore unreferenced local functions in GTK+ headers
+#pragma warning(disable: 4505)
#endif
class ScintillaGTK : public ScintillaBase {
@@ -198,6 +204,10 @@ enum {
TARGET_COMPOUND_TEXT
};
+static GtkWidget *PWidget(Window &w) {
+ return reinterpret_cast<GtkWidget *>(w.GetID());
+}
+
static ScintillaGTK *ScintillaFromWidget(GtkWidget *widget) {
ScintillaObject *scio = reinterpret_cast<ScintillaObject *>(widget);
return reinterpret_cast<ScintillaGTK *>(scio->pscin);
@@ -315,8 +325,8 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) {
gdk_im_begin(ic, widget->window);
}
}
- gtk_widget_realize(scrollbarv.GetID());
- gtk_widget_realize(scrollbarh.GetID());
+ gtk_widget_realize(PWidget(scrollbarv));
+ gtk_widget_realize(PWidget(scrollbarh));
}
void ScintillaGTK::Realize(GtkWidget *widget) {
@@ -329,8 +339,8 @@ void ScintillaGTK::UnRealizeThis(GtkWidget *widget) {
gtk_widget_unmap(widget);
}
GTK_WIDGET_UNSET_FLAGS(widget, GTK_REALIZED);
- gtk_widget_unrealize(scrollbarv.GetID());
- gtk_widget_unrealize(scrollbarh.GetID());
+ gtk_widget_unrealize(PWidget(scrollbarv));
+ gtk_widget_unrealize(PWidget(scrollbarh));
if (ic) {
gdk_ic_destroy(ic);
ic = NULL;
@@ -362,12 +372,12 @@ static void MapWidget(GtkWidget *widget) {
void ScintillaGTK::MapThis() {
//Platform::DebugPrintf("ScintillaGTK::map this\n");
- GTK_WIDGET_SET_FLAGS(wMain.GetID(), GTK_MAPPED);
- MapWidget(scrollbarh.GetID());
- MapWidget(scrollbarv.GetID());
+ GTK_WIDGET_SET_FLAGS(PWidget(wMain), GTK_MAPPED);
+ MapWidget(PWidget(scrollbarh));
+ MapWidget(PWidget(scrollbarv));
scrollbarv.SetCursor(Window::cursorReverseArrow);
scrollbarh.SetCursor(Window::cursorReverseArrow);
- gdk_window_show(wMain.GetID()->window);
+ gdk_window_show(PWidget(wMain)->window);
}
void ScintillaGTK::Map(GtkWidget *widget) {
@@ -377,10 +387,10 @@ void ScintillaGTK::Map(GtkWidget *widget) {
void ScintillaGTK::UnMapThis() {
//Platform::DebugPrintf("ScintillaGTK::unmap this\n");
- GTK_WIDGET_UNSET_FLAGS(wMain.GetID(), GTK_MAPPED);
- gdk_window_hide(wMain.GetID()->window);
- gtk_widget_unmap(scrollbarh.GetID());
- gtk_widget_unmap(scrollbarv.GetID());
+ GTK_WIDGET_UNSET_FLAGS(PWidget(wMain), GTK_MAPPED);
+ gdk_window_hide(PWidget(wMain)->window);
+ gtk_widget_unmap(PWidget(scrollbarh));
+ gtk_widget_unmap(PWidget(scrollbarv));
}
void ScintillaGTK::UnMap(GtkWidget *widget) {
@@ -426,8 +436,8 @@ void ScintillaGTK::SizeRequest(GtkWidget *widget, GtkRequisition *requisition) {
requisition->height = 2000;
ScintillaGTK *sciThis = ScintillaFromWidget(widget);
GtkRequisition child_requisition;
- gtk_widget_size_request(sciThis->scrollbarh.GetID(), &child_requisition);
- gtk_widget_size_request(sciThis->scrollbarv.GetID(), &child_requisition);
+ gtk_widget_size_request(PWidget(sciThis->scrollbarh), &child_requisition);
+ gtk_widget_size_request(PWidget(sciThis->scrollbarv), &child_requisition);
}
void ScintillaGTK::SizeAllocate(GtkWidget *widget, GtkAllocation *allocation) {
@@ -460,9 +470,9 @@ void ScintillaGTK::Initialise() {
parentClass = reinterpret_cast<GtkWidgetClass *>(
gtk_type_class(gtk_container_get_type()));
- GTK_WIDGET_SET_FLAGS(wMain.GetID(), GTK_CAN_FOCUS);
- GTK_WIDGET_SET_FLAGS(GTK_WIDGET(wMain.GetID()), GTK_SENSITIVE);
- gtk_widget_set_events(wMain.GetID(),
+ GTK_WIDGET_SET_FLAGS(PWidget(wMain), GTK_CAN_FOCUS);
+ GTK_WIDGET_SET_FLAGS(GTK_WIDGET(PWidget(wMain)), GTK_SENSITIVE);
+ gtk_widget_set_events(PWidget(wMain),
GDK_EXPOSURE_MASK
| GDK_STRUCTURE_MASK
| GDK_KEY_PRESS_MASK
@@ -476,21 +486,21 @@ void ScintillaGTK::Initialise() {
adjustmentv = gtk_adjustment_new(0.0, 0.0, 201.0, 1.0, 20.0, 20.0);
scrollbarv = gtk_vscrollbar_new(GTK_ADJUSTMENT(adjustmentv));
- GTK_WIDGET_UNSET_FLAGS(scrollbarv.GetID(), GTK_CAN_FOCUS);
+ GTK_WIDGET_UNSET_FLAGS(PWidget(scrollbarv), GTK_CAN_FOCUS);
gtk_signal_connect(GTK_OBJECT(adjustmentv), "value_changed",
GTK_SIGNAL_FUNC(ScrollSignal), this);
- gtk_widget_set_parent(scrollbarv.GetID(), wMain.GetID());
- gtk_widget_show(scrollbarv.GetID());
+ gtk_widget_set_parent(PWidget(scrollbarv), PWidget(wMain));
+ gtk_widget_show(PWidget(scrollbarv));
adjustmenth = gtk_adjustment_new(0.0, 0.0, 101.0, 1.0, 20.0, 20.0);
scrollbarh = gtk_hscrollbar_new(GTK_ADJUSTMENT(adjustmenth));
- GTK_WIDGET_UNSET_FLAGS(scrollbarh.GetID(), GTK_CAN_FOCUS);
+ GTK_WIDGET_UNSET_FLAGS(PWidget(scrollbarh), GTK_CAN_FOCUS);
gtk_signal_connect(GTK_OBJECT(adjustmenth), "value_changed",
GTK_SIGNAL_FUNC(ScrollHSignal), this);
- gtk_widget_set_parent(scrollbarh.GetID(), wMain.GetID());
- gtk_widget_show(scrollbarh.GetID());
+ gtk_widget_set_parent(PWidget(scrollbarh), PWidget(wMain));
+ gtk_widget_show(PWidget(scrollbarh));
- gtk_widget_grab_focus(wMain.GetID());
+ gtk_widget_grab_focus(PWidget(wMain));
static const GtkTargetEntry targets[] = {
{ "STRING", 0, TARGET_STRING },
@@ -500,16 +510,16 @@ void ScintillaGTK::Initialise() {
};
static const gint n_targets = sizeof(targets) / sizeof(targets[0]);
- gtk_selection_add_targets(GTK_WIDGET(wMain.GetID()), GDK_SELECTION_PRIMARY,
+ gtk_selection_add_targets(GTK_WIDGET(PWidget(wMain)), GDK_SELECTION_PRIMARY,
targets, n_targets);
if (!clipboard_atom)
clipboard_atom = gdk_atom_intern("CLIPBOARD", FALSE);
- gtk_selection_add_targets(GTK_WIDGET(wMain.GetID()), clipboard_atom,
+ gtk_selection_add_targets(GTK_WIDGET(PWidget(wMain)), clipboard_atom,
targets, n_targets);
- gtk_drag_dest_set(GTK_WIDGET(wMain.GetID()),
+ gtk_drag_dest_set(GTK_WIDGET(PWidget(wMain)),
GTK_DEST_DEFAULT_ALL, targets, n_targets,
static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE));
@@ -530,7 +540,7 @@ void ScintillaGTK::StartDrag() {
};
static const gint n_targets = sizeof(targets) / sizeof(targets[0]);
GtkTargetList *tl = gtk_target_list_new(targets, n_targets);
- gtk_drag_begin(GTK_WIDGET(wMain.GetID()),
+ gtk_drag_begin(GTK_WIDGET(PWidget(wMain)),
tl,
static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE),
evbtn.button,
@@ -541,7 +551,7 @@ sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
switch (iMessage) {
case SCI_GRABFOCUS:
- gtk_widget_grab_focus(wMain.GetID());
+ gtk_widget_grab_focus(PWidget(wMain));
break;
case SCI_GETDIRECTFUNCTION:
@@ -575,9 +585,9 @@ void ScintillaGTK::SetTicking(bool on) {
void ScintillaGTK::SetMouseCapture(bool on) {
if (mouseDownCaptures) {
if (on) {
- gtk_grab_add(GTK_WIDGET(wMain.GetID()));
+ gtk_grab_add(GTK_WIDGET(PWidget(wMain)));
} else {
- gtk_grab_remove(GTK_WIDGET(wMain.GetID()));
+ gtk_grab_remove(GTK_WIDGET(PWidget(wMain)));
}
}
capturedMouse = on;
@@ -595,7 +605,7 @@ void ScintillaGTK::FullPaint() {
// rcPaint.left, rcPaint.top, rcPaint.right, rcPaint.bottom);
paintingAllText = true;
Surface sw;
- sw.Init((wMain.GetID())->window);
+ sw.Init((PWidget(wMain))->window);
Paint(&sw, rcPaint);
sw.Release();
paintState = notPainting;
@@ -623,7 +633,7 @@ void ScintillaGTK::SyncPaint(PRectangle rc) {
//Platform::DebugPrintf("ScintillaGTK::SyncPaint %0d,%0d %0d,%0d\n",
// rcPaint.left, rcPaint.top, rcPaint.right, rcPaint.bottom);
Surface sw;
- sw.Init((wMain.GetID())->window);
+ sw.Init((PWidget(wMain))->window);
Paint(&sw, rc);
sw.Release();
if (paintState == paintAbandoned) {
@@ -638,7 +648,7 @@ void ScintillaGTK::ScrollText(int linesToMove) {
int diff = vs.lineHeight * -linesToMove;
//Platform::DebugPrintf("ScintillaGTK::ScrollText %d %d %0d,%0d %0d,%0d\n", linesToMove, diff,
// rc.left, rc.top, rc.right, rc.bottom);
- WindowID wi = wMain.GetID();
+ GtkWidget *wi = PWidget(wMain);
GdkGC *gc = gdk_gc_new(wi->window);
GdkEvent* event;
@@ -718,16 +728,16 @@ void ScintillaGTK::ReconfigureScrollBars() {
void ScintillaGTK::NotifyChange() {
gtk_signal_emit(GTK_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL],
- Platform::LongFromTwoShorts(ctrlID, SCEN_CHANGE), wMain.GetID());
+ Platform::LongFromTwoShorts(ctrlID, SCEN_CHANGE), PWidget(wMain));
}
void ScintillaGTK::NotifyFocus(bool focus) {
gtk_signal_emit(GTK_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL],
- Platform::LongFromTwoShorts(ctrlID, focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), wMain.GetID());
+ Platform::LongFromTwoShorts(ctrlID, focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), PWidget(wMain));
}
void ScintillaGTK::NotifyParent(SCNotification scn) {
- scn.nmhdr.hwndFrom = wMain.GetID();
+ scn.nmhdr.hwndFrom = PWidget(wMain);
scn.nmhdr.idFrom = ctrlID;
gtk_signal_emit(GTK_OBJECT(sci), scintilla_signals[NOTIFY_SIGNAL],
ctrlID, &scn);
@@ -765,7 +775,7 @@ int ScintillaGTK::KeyDefault(int key, int modifiers) {
void ScintillaGTK::Copy() {
if (currentPos != anchor) {
CopySelectionRange(&copyText);
- gtk_selection_owner_set(GTK_WIDGET(wMain.GetID()),
+ gtk_selection_owner_set(GTK_WIDGET(PWidget(wMain)),
clipboard_atom,
GDK_CURRENT_TIME);
#if PLAT_GTK_WIN32
@@ -779,7 +789,7 @@ void ScintillaGTK::Copy() {
}
void ScintillaGTK::Paste() {
- gtk_selection_convert(GTK_WIDGET(wMain.GetID()),
+ gtk_selection_convert(GTK_WIDGET(PWidget(wMain)),
clipboard_atom,
gdk_atom_intern("STRING", FALSE), GDK_CURRENT_TIME);
}
@@ -787,11 +797,11 @@ void ScintillaGTK::Paste() {
void ScintillaGTK::CreateCallTipWindow(PRectangle rc) {
ct.wCallTip = gtk_window_new(GTK_WINDOW_POPUP);
ct.wDraw = gtk_drawing_area_new();
- gtk_container_add(GTK_CONTAINER(ct.wCallTip.GetID()), ct.wDraw.GetID());
- gtk_signal_connect(GTK_OBJECT(ct.wDraw.GetID()), "expose_event",
+ gtk_container_add(GTK_CONTAINER(PWidget(ct.wCallTip)), PWidget(ct.wDraw));
+ gtk_signal_connect(GTK_OBJECT(PWidget(ct.wDraw)), "expose_event",
GtkSignalFunc(ScintillaGTK::ExposeCT), &ct);
- gtk_widget_set_events(ct.wDraw.GetID(), GDK_EXPOSURE_MASK);
- gtk_drawing_area_size(GTK_DRAWING_AREA(ct.wDraw.GetID()),
+ gtk_widget_set_events(PWidget(ct.wDraw), GDK_EXPOSURE_MASK);
+ gtk_drawing_area_size(GTK_DRAWING_AREA(PWidget(ct.wDraw)),
rc.Width(), rc.Height());
ct.wDraw.Show();
}
@@ -809,7 +819,7 @@ void ScintillaGTK::AddToPopUp(const char *label, int cmd, bool enabled) {
&itemEntry, this, 1);
if (cmd) {
GtkWidget *item = gtk_item_factory_get_widget_by_action(
- popup.GetID(), cmd);
+ reinterpret_cast<GtkItemFactory *>(popup.GetID()), cmd);
if (item)
gtk_widget_set_sensitive(item, enabled);
}
@@ -817,7 +827,7 @@ void ScintillaGTK::AddToPopUp(const char *label, int cmd, bool enabled) {
bool ScintillaGTK::OwnPrimarySelection() {
return (gdk_selection_owner_get(GDK_SELECTION_PRIMARY)
- == GTK_WIDGET(wMain.GetID())->window);
+ == GTK_WIDGET(PWidget(wMain))->window);
}
void ScintillaGTK::ClaimSelection() {
@@ -825,7 +835,7 @@ void ScintillaGTK::ClaimSelection() {
// Whenever the user selects some text, we become the primary selection
if (currentPos != anchor) {
primarySelection = true;
- gtk_selection_owner_set(GTK_WIDGET(wMain.GetID()),
+ gtk_selection_owner_set(GTK_WIDGET(PWidget(wMain)),
GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME);
primary.Set(0, 0);
} else if (OwnPrimarySelection()) {
@@ -1007,8 +1017,8 @@ void ScintillaGTK::Resize(int width, int height) {
DropGraphics();
// Not always needed, but some themes can have different sizes of scrollbars
- scrollBarWidth = GTK_WIDGET(scrollbarv.GetID())->requisition.width;
- scrollBarHeight = GTK_WIDGET(scrollbarh.GetID())->requisition.height;
+ scrollBarWidth = GTK_WIDGET(PWidget(scrollbarv))->requisition.width;
+ scrollBarHeight = GTK_WIDGET(PWidget(scrollbarh))->requisition.height;
// These allocations should never produce negative sizes as they would wrap around to huge
// unsigned numbers inside GTK+ causing warnings.
@@ -1027,13 +1037,13 @@ void ScintillaGTK::Resize(int width, int height) {
alloc.width = 0;
alloc.height = 0;
}
- gtk_widget_size_allocate(GTK_WIDGET(scrollbarh.GetID()), &alloc);
+ gtk_widget_size_allocate(GTK_WIDGET(PWidget(scrollbarh)), &alloc);
alloc.x = width - scrollBarWidth;
alloc.y = 0;
alloc.width = scrollBarWidth;
alloc.height = Platform::Maximum(1, height - scrollBarHeight) + 1;
- gtk_widget_size_allocate(GTK_WIDGET(scrollbarv.GetID()), &alloc);
+ gtk_widget_size_allocate(GTK_WIDGET(PWidget(scrollbarv)), &alloc);
SetScrollBars();
}
@@ -1058,7 +1068,7 @@ gint ScintillaGTK::PressThis(GdkEventButton *event) {
bool ctrl = event->state & GDK_CONTROL_MASK;
- gtk_widget_grab_focus(wMain.GetID());
+ gtk_widget_grab_focus(PWidget(wMain));
if (event->button == 1) {
//ButtonDown(pt, event->time,
// event->state & GDK_SHIFT_MASK,
@@ -1077,14 +1087,14 @@ gint ScintillaGTK::PressThis(GdkEventButton *event) {
CopySelectionRange(&primary);
SetSelection(pos, pos);
- gtk_selection_convert(GTK_WIDGET(wMain.GetID()), GDK_SELECTION_PRIMARY,
+ gtk_selection_convert(GTK_WIDGET(PWidget(wMain)), GDK_SELECTION_PRIMARY,
gdk_atom_intern("STRING", FALSE), event->time);
} else if (event->button == 3 && displayPopupMenu) {
// PopUp menu
// Convert to screen
int ox = 0;
int oy = 0;
- gdk_window_get_origin(wMain.GetID()->window, &ox, &oy);
+ gdk_window_get_origin(PWidget(wMain)->window, &ox, &oy);
ContextMenu(Point(pt.x + ox, pt.y + oy));
} else if (event->button == 4) {
// Wheel scrolling up (only xwin gtk does it this way)
@@ -1124,7 +1134,7 @@ gint ScintillaGTK::MouseRelease(GtkWidget *widget, GdkEventButton *event) {
pt.y = int(event->y);
//Platform::DebugPrintf("Up %x %x %d %d %d\n",
// sciThis,event->window,event->time, pt.x, pt.y);
- if (event->window != sciThis->wMain.GetID()->window)
+ if (event->window != PWidget(sciThis->wMain)->window)
// If mouse released on scroll bar then the position is relative to the
// scrollbar, not the drawing window so just repeat the most recent point.
pt = sciThis->ptMouseLast;
@@ -1348,9 +1358,9 @@ void ScintillaGTK::Draw(GtkWidget *widget, GdkRectangle *area) {
//Platform::DebugPrintf("Draw %p %0d,%0d %0d,%0d\n", widget, area->x, area->y, area->width, area->height);
PRectangle rcPaint(area->x, area->y, area->x + area->width, area->y + area->height);
sciThis->SyncPaint(rcPaint);
- if (GTK_WIDGET_DRAWABLE(sciThis->wMain.GetID())) {
- DrawChild(sciThis->scrollbarh.GetID(), area);
- DrawChild(sciThis->scrollbarv.GetID(), area);
+ if (GTK_WIDGET_DRAWABLE(PWidget(sciThis->wMain))) {
+ DrawChild(PWidget(sciThis->scrollbarh), area);
+ DrawChild(PWidget(sciThis->scrollbarv), area);
}
}
@@ -1376,7 +1386,7 @@ gint ScintillaGTK::Expose(GtkWidget *, GdkEventExpose *ose, ScintillaGTK *sciThi
PRectangle rcText = sciThis->GetTextRectangle();
sciThis->paintingAllText = sciThis->rcPaint.Contains(rcText);
Surface surfaceWindow;
- surfaceWindow.Init((sciThis->wMain.GetID())->window);
+ surfaceWindow.Init((PWidget(sciThis->wMain))->window);
sciThis->Paint(&surfaceWindow, sciThis->rcPaint);
surfaceWindow.Release();
if (sciThis->paintState == paintAbandoned) {
diff --git a/include/Platform.h b/include/Platform.h
index 6d37799e7..eeb72c1ce 100644
--- a/include/Platform.h
+++ b/include/Platform.h
@@ -39,57 +39,14 @@
#endif
-// Include the main header for each platform
-
-#if PLAT_GTK
-#ifdef _MSC_VER
-#pragma warning(disable: 4505 4514 4710 4800)
-#endif
-#include <gtk/gtk.h>
-#include <gdk/gdkkeysyms.h>
-#endif
-
-#if PLAT_WIN
-#define _WIN32_WINNT 0x0400 // Otherwise some required stuff gets ifdef'd out
-// Vassili Bourdo: shut up annoying Visual C++ warnings:
-#ifdef _MSC_VER
-#pragma warning(disable: 4244 4309 4710 4800)
-#endif
-#include <windows.h>
-#include <commctrl.h>
-#include <richedit.h>
-#endif
-
-#if PLAT_WX
-#include <wx/wx.h>
-#endif
-
// Underlying the implementation of the platform classes are platform specific types.
// Sometimes these need to be passed around by client code so they are defined here
-#if PLAT_GTK
-typedef GdkColor ColourID;
-typedef GdkFont* FontID;
-typedef GdkDrawable* SurfaceID;
-typedef GtkWidget* WindowID;
-typedef GtkItemFactory* MenuID;
-#endif
-
-#if PLAT_WIN
-typedef COLORREF ColourID;
-typedef HFONT FontID;
-typedef HDC SurfaceID;
-typedef HWND WindowID;
-typedef HMENU MenuID;
-#endif
-
-#if PLAT_WX
-typedef wxColour ColourID;
-typedef wxFont* FontID;
-typedef wxDC* SurfaceID;
-typedef wxWindow* WindowID;
-typedef wxMenu* MenuID;
-#endif
+typedef void* FontID;
+typedef void* SurfaceID;
+typedef void* WindowID;
+typedef void* MenuID;
+typedef void* PaletteID;
/**
* A geometric point class.
@@ -146,27 +103,61 @@ public:
int Height() { return bottom - top; }
};
-#if PLAT_WX
-wxRect wxRectFromPRectangle(PRectangle prc);
-PRectangle PRectangleFromwxRect(wxRect rc);
-#endif
-
/**
* A colour class.
*/
-class Colour {
- ColourID co;
+class ColourDesired {
+ long co;
public:
- Colour(long lcol=0);
- Colour(unsigned int red, unsigned int green, unsigned int blue);
- bool operator==(const Colour &other) const;
- long AsLong() const;
- unsigned int GetRed();
- unsigned int GetGreen();
- unsigned int GetBlue();
+ ColourDesired(long lcol=0) {
+ co = lcol;
+ }
+
+ ColourDesired(unsigned int red, unsigned int green, unsigned int blue) {
+ co = red | (green << 8) | (blue << 16);
+ }
+
+ bool operator==(const ColourDesired &other) const {
+ return co == other.co;
+ }
+
+ void Set(long lcol) {
+ co = lcol;
+ }
+
+ long AsLong() const {
+ return co;
+ }
+
+ unsigned int GetRed() {
+ return co & 0xff;
+ }
+
+ unsigned int GetGreen() {
+ return (co >> 8) & 0xff;
+ }
+
+ unsigned int GetBlue() {
+ return (co >> 16) & 0xff;
+ }
+};
- friend class Surface;
- friend class Palette;
+class ColourAllocated {
+ long coAllocated;
+
+public:
+
+ ColourAllocated(long lcol=0) {
+ coAllocated = lcol;
+ }
+
+ void Set(long lcol) {
+ coAllocated = lcol;
+ }
+
+ long AsLong() const {
+ return coAllocated;
+ }
};
/**
@@ -176,12 +167,12 @@ public:
* construction time with a palette management object.
*/
struct ColourPair {
- Colour desired;
- Colour allocated;
+ ColourDesired desired;
+ ColourAllocated allocated;
- ColourPair(Colour desired_=Colour(0,0,0)) {
+ ColourPair(ColourDesired desired_=ColourDesired(0,0,0)) {
desired = desired_;
- allocated = desired;
+ allocated.Set(desired.AsLong());
}
};
@@ -195,10 +186,10 @@ class Palette {
enum {numEntries = 100};
ColourPair entries[numEntries];
#if PLAT_GTK
- GdkColor *allocatedPalette;
+ void *allocatedPalette; // GdkColor *
int allocatedLen;
#elif PLAT_WIN
- HPALETTE hpal;
+ void *hpal;
#elif PLAT_WX
// wxPalette* pal; // **** Is this needed?
#endif
@@ -254,29 +245,29 @@ class Surface {
private:
bool unicodeMode;
#if PLAT_GTK
- GdkDrawable *drawable;
- GdkGC *gc;
- GdkPixmap *ppixmap;
+ void *drawable; // GdkDrawable *drawable;
+ void *gc; // GdkGC *gc;
+ void *ppixmap; // GdkPixmap *ppixmap;
int x;
int y;
bool inited;
bool createdGC;
#elif PLAT_WIN
- HDC hdc;
+ void *hdc; // HDC
bool hdcOwned;
- HPEN pen;
- HPEN penOld;
- HBRUSH brush;
- HBRUSH brushOld;
- HFONT font;
- HFONT fontOld;
- HBITMAP bitmap;
- HBITMAP bitmapOld;
- HPALETTE paletteOld;
+ void *pen; // HPEN
+ void *penOld; // HPEN
+ void *brush; // HBRUSH
+ void *brushOld; // HBRUSH
+ void *font; // HFONT
+ void *fontOld; // HFONT
+ void *bitmap; // HBITMAP
+ void *bitmapOld; // HBITMAP
+ void *paletteOld; // HPALETTE
#elif PLAT_WX
- wxDC* hdc;
+ void *hdc; // wxDC*
bool hdcOwned;
- wxBitmap* bitmap;
+ void *bitmap; // wxBitmap*
int x;
int y;
#endif
@@ -285,7 +276,7 @@ private:
Surface(const Surface &) {}
Surface &operator=(const Surface &) { return *this; }
#if PLAT_WIN || PLAT_WX
- void BrushColor(Colour back);
+ void BrushColor(ColourAllocated back);
void SetFont(Font &font_);
#endif
public:
@@ -293,26 +284,26 @@ public:
~Surface();
void Init();
- void Init(SurfaceID hdc_);
+ void Init(SurfaceID sid);
void InitPixMap(int width, int height, Surface *surface_);
void Release();
bool Initialised();
- void PenColour(Colour fore);
+ void PenColour(ColourAllocated fore);
int LogPixelsY();
int DeviceHeightFont(int points);
void MoveTo(int x_, int y_);
void LineTo(int x_, int y_);
- void Polygon(Point *pts, int npts, Colour fore, Colour back);
- void RectangleDraw(PRectangle rc, Colour fore, Colour back);
- void FillRectangle(PRectangle rc, Colour back);
+ void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back);
+ void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back);
+ void FillRectangle(PRectangle rc, ColourAllocated back);
void FillRectangle(PRectangle rc, Surface &surfacePattern);
- void RoundedRectangle(PRectangle rc, Colour fore, Colour back);
- void Ellipse(PRectangle rc, Colour fore, Colour back);
+ void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back);
+ void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back);
void Copy(PRectangle rc, Point from, Surface &surfaceSource);
- void DrawText(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back);
- void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back);
+ void DrawText(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back);
+ void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back);
void MeasureWidths(Font &font_, const char *s, int len, int *positions);
int WidthText(Font &font_, const char *s, int len);
int WidthChar(Font &font_, char ch);
@@ -368,11 +359,6 @@ public:
enum Cursor { cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow };
void SetCursor(Cursor curs);
void SetTitle(const char *s);
-#if PLAT_WIN
- LRESULT SendMessage(UINT msg, WPARAM wParam=0, LPARAM lParam=0);
- int GetDlgCtrlID();
- HINSTANCE GetInstance();
-#endif
};
/**
@@ -440,8 +426,8 @@ public:
// but gcc warns about this
Platform() {}
~Platform() {}
- static Colour Chrome();
- static Colour ChromeHighlight();
+ static ColourDesired Chrome();
+ static ColourDesired ChromeHighlight();
static const char *DefaultFont();
static int DefaultFontSize();
static unsigned int DoubleClickTime();
@@ -449,6 +435,7 @@ public:
static bool IsKeyDown(int key);
static long SendScintilla(
WindowID w, unsigned int msg, unsigned long wParam=0, long lParam=0);
+ static bool IsDBCSLeadByte(int codePage, char ch);
// These are utility functions not really tied to a platform
static int Minimum(int a, int b);
@@ -475,4 +462,9 @@ public:
#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Platform::Assert(#c, __FILE__, __LINE__))
#endif
+// Shut up annoying Visual C++ warnings:
+#ifdef _MSC_VER
+#pragma warning(disable: 4244 4309 4514 4710 4800)
+#endif
+
#endif
diff --git a/include/Scintilla.h b/include/Scintilla.h
index e49bd959e..beeda1ab6 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -13,7 +13,7 @@
#if PLAT_WIN
#ifdef STATIC_BUILD
-void Scintilla_RegisterClasses(HINSTANCE hInstance);
+void Scintilla_RegisterClasses(void *hInstance);
#endif
#endif
diff --git a/src/CallTip.cxx b/src/CallTip.cxx
index 3422de696..006e2cb51 100644
--- a/src/CallTip.cxx
+++ b/src/CallTip.cxx
@@ -21,11 +21,11 @@ CallTip::CallTip() {
startHighlight = 0;
endHighlight = 0;
- colourBG.desired = Colour(0xff, 0xff, 0xff);
- colourUnSel.desired = Colour(0x80, 0x80, 0x80);
- colourSel.desired = Colour(0, 0, 0x80);
- colourShade.desired = Colour(0, 0, 0);
- colourLight.desired = Colour(0xc0, 0xc0, 0xc0);
+ colourBG.desired = ColourDesired(0xff, 0xff, 0xff);
+ colourUnSel.desired = ColourDesired(0x80, 0x80, 0x80);
+ colourSel.desired = ColourDesired(0, 0, 0x80);
+ colourShade.desired = ColourDesired(0, 0, 0);
+ colourLight.desired = ColourDesired(0xc0, 0xc0, 0xc0);
}
CallTip::~CallTip() {
diff --git a/src/Document.cxx b/src/Document.cxx
index 7ffb651ba..213a72d6a 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -230,7 +230,7 @@ bool Document::IsDBCS(int pos) {
while (startLine > 0 && cb.CharAt(startLine) != '\r' && cb.CharAt(startLine) != '\n')
startLine--;
while (startLine <= pos) {
- if (IsDBCSLeadByteEx(dbcsCodePage, cb.CharAt(startLine))) {
+ if (Platform::IsDBCSLeadByte(dbcsCodePage, cb.CharAt(startLine))) {
startLine++;
if (startLine >= pos)
return true;
@@ -322,7 +322,7 @@ int Document::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) {
while (startLine < pos) {
if (atLeadByte)
atLeadByte = false;
- else if (IsDBCSLeadByteEx(dbcsCodePage, cb.CharAt(startLine)))
+ else if (Platform::IsDBCSLeadByte(dbcsCodePage, cb.CharAt(startLine)))
atLeadByte = true;
else
atLeadByte = false;
diff --git a/src/DocumentAccessor.cxx b/src/DocumentAccessor.cxx
index c187f2a44..e8930c23d 100644
--- a/src/DocumentAccessor.cxx
+++ b/src/DocumentAccessor.cxx
@@ -30,7 +30,7 @@ bool DocumentAccessor::InternalIsLeadByte(char ch) {
// same so none is considered a lead byte.
return false;
else
- return IsDBCSLeadByteEx(codePage, ch);
+ return Platform::IsDBCSLeadByte(codePage, ch);
}
#else
// PLAT_GTK or PLAT_WX
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 15ba91b20..941c05971 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -997,7 +997,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
// display itself. These are checked in order with the earlier taking precedence. When
// multiple markers cause background override, the color for the highest numbered one is used.
bool overrideBackground = false;
- Colour background = Colour(0, 0, 0);
+ ColourAllocated background;
if (caret.active && vsDraw.showCaretLineBackground && ll.containsCaret) {
overrideBackground = true;
background = vsDraw.caretLineBackground.allocated;
@@ -1046,8 +1046,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis
((ll.selStart != ll.selEnd) && ((iDoc + 1 == ll.selStart) || (iDoc + 1 == ll.selEnd))) ||
(i == (ll.edgeColumn - 1))) {
int styleMain = ll.styles[i];
- Colour textBack = vsDraw.styles[styleMain].back.allocated;
- Colour textFore = vsDraw.styles[styleMain].fore.allocated;
+ ColourAllocated textBack = vsDraw.styles[styleMain].back.allocated;
+ ColourAllocated textFore = vsDraw.styles[styleMain].fore.allocated;
Font &textFont = vsDraw.styles[styleMain].font;
bool inSelection = (iDoc >= ll.selStart) && (iDoc < ll.selEnd) && (ll.selStart != ll.selEnd);
if (inSelection) {
@@ -1239,7 +1239,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
// way between the chrome colour and the chrome highlight colour making a nice transition
// between the window chrome and the content area. And it works in low colour depths.
PRectangle rcPattern(0, 0, 8, 8);
- if (vs.selbarlight.desired == Colour(0xff, 0xff, 0xff)) {
+ if (vs.selbarlight.desired == ColourDesired(0xff, 0xff, 0xff)) {
pixmapSelPattern.FillRectangle(rcPattern, vs.selbar.allocated);
pixmapSelPattern.PenColour(vs.selbarlight.allocated);
for (int stripe = 0; stripe < 8; stripe++) {
@@ -1494,18 +1494,18 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
// Space (3 space characters) between line numbers and text when printing.
#define lineNumberPrintSpace " "
-Colour InvertedLight(Colour orig) {
+ColourDesired InvertedLight(ColourDesired orig) {
unsigned int r = orig.GetRed();
unsigned int g = orig.GetGreen();
unsigned int b = orig.GetBlue();
unsigned int l = (r + g + b) / 3; // There is a better calculation for this that matches human eye
unsigned int il = 0xff - l;
if (l == 0)
- return Colour(0xff, 0xff, 0xff);
+ return ColourDesired(0xff, 0xff, 0xff);
r = r * il / l;
g = g * il / l;
b = b * il / l;
- return Colour(Platform::Minimum(r, 0xff), Platform::Minimum(g, 0xff), Platform::Minimum(b, 0xff));
+ return ColourDesired(Platform::Minimum(r, 0xff), Platform::Minimum(g, 0xff), Platform::Minimum(b, 0xff));
}
// This is mostly copied from the Paint method but with some things omitted
@@ -1549,18 +1549,18 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) {
vsPrint.styles[sty].fore.desired = InvertedLight(vsPrint.styles[sty].fore.desired);
vsPrint.styles[sty].back.desired = InvertedLight(vsPrint.styles[sty].back.desired);
} else if (printColourMode == SC_PRINT_BLACKONWHITE) {
- vsPrint.styles[sty].fore.desired = Colour(0, 0, 0);
- vsPrint.styles[sty].back.desired = Colour(0xff, 0xff, 0xff);
+ vsPrint.styles[sty].fore.desired = ColourDesired(0, 0, 0);
+ vsPrint.styles[sty].back.desired = ColourDesired(0xff, 0xff, 0xff);
} else if (printColourMode == SC_PRINT_COLOURONWHITE) {
- vsPrint.styles[sty].back.desired = Colour(0xff, 0xff, 0xff);
+ vsPrint.styles[sty].back.desired = ColourDesired(0xff, 0xff, 0xff);
} else if (printColourMode == SC_PRINT_COLOURONWHITEDEFAULTBG) {
if (sty <= STYLE_DEFAULT) {
- vsPrint.styles[sty].back.desired = Colour(0xff, 0xff, 0xff);
+ vsPrint.styles[sty].back.desired = ColourDesired(0xff, 0xff, 0xff);
}
}
}
// White background for the line numbers
- vsPrint.styles[STYLE_LINENUMBER].back.desired = Colour(0xff, 0xff, 0xff);
+ vsPrint.styles[STYLE_LINENUMBER].back.desired = ColourDesired(0xff, 0xff, 0xff);
vsPrint.Refresh(*surfaceMeasure);
// Ensure colours are set up
@@ -3529,11 +3529,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETTEXT:
{
if (lParam == 0)
- return FALSE;
+ return 0;
pdoc->DeleteChars(0, pdoc->Length());
SetEmptySelection(0);
pdoc->InsertString(0, reinterpret_cast<char *>(lParam));
- return TRUE;
+ return 1;
}
case SCI_GETTEXTLENGTH:
@@ -3565,7 +3565,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_CANUNDO:
- return pdoc->CanUndo() ? TRUE : FALSE;
+ return pdoc->CanUndo() ? 1 : 0;
case SCI_EMPTYUNDOBUFFER:
pdoc->DeleteUndoHistory();
@@ -3699,7 +3699,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_LINESCROLL:
ScrollTo(topLine + lParam);
HorizontalScrollTo(xOffset + wParam * vs.spaceWidth);
- return TRUE;
+ return 1;
case SCI_SETXOFFSET:
xOffset = wParam;
@@ -3715,7 +3715,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETREADONLY:
pdoc->SetReadOnly(wParam);
- return TRUE;
+ return 1;
case SCI_GETREADONLY:
return pdoc->IsReadOnly();
@@ -3934,7 +3934,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
}
case SCI_CANREDO:
- return pdoc->CanRedo() ? TRUE : FALSE;
+ return pdoc->CanRedo() ? 1 : 0;
case SCI_MARKERLINEFROMHANDLE:
return pdoc->LineFromHandle(wParam);
@@ -4128,13 +4128,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_MARKERSETFORE:
if (wParam <= MARKER_MAX)
- vs.markers[wParam].fore.desired = Colour(lParam);
+ vs.markers[wParam].fore.desired = ColourDesired(lParam);
InvalidateStyleData();
RedrawSelMargin();
break;
case SCI_MARKERSETBACK:
if (wParam <= MARKER_MAX)
- vs.markers[wParam].back.desired = Colour(lParam);
+ vs.markers[wParam].back.desired = ColourDesired(lParam);
InvalidateStyleData();
RedrawSelMargin();
break;
@@ -4230,13 +4230,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_STYLESETFORE:
if (wParam <= STYLE_MAX) {
- vs.styles[wParam].fore.desired = Colour(lParam);
+ vs.styles[wParam].fore.desired = ColourDesired(lParam);
InvalidateStyleRedraw();
}
break;
case SCI_STYLESETBACK:
if (wParam <= STYLE_MAX) {
- vs.styles[wParam].back.desired = Colour(lParam);
+ vs.styles[wParam].back.desired = ColourDesired(lParam);
InvalidateStyleRedraw();
}
break;
@@ -4418,18 +4418,18 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SETSELFORE:
vs.selforeset = wParam;
- vs.selforeground.desired = Colour(lParam);
+ vs.selforeground.desired = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
case SCI_SETSELBACK:
vs.selbackset = wParam;
- vs.selbackground.desired = Colour(lParam);
+ vs.selbackground.desired = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
case SCI_SETCARETFORE:
- vs.caretcolour.desired = Colour(wParam);
+ vs.caretcolour.desired = ColourDesired(wParam);
InvalidateStyleRedraw();
break;
@@ -4475,7 +4475,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_INDICSETFORE:
if (wParam <= INDIC_MAX) {
- vs.indicators[wParam].fore.desired = Colour(lParam);
+ vs.indicators[wParam].fore.desired = ColourDesired(lParam);
InvalidateStyleRedraw();
}
break;
@@ -4584,7 +4584,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.edgecolour.desired.AsLong();
case SCI_SETEDGECOLOUR:
- vs.edgecolour.desired = Colour(wParam);
+ vs.edgecolour.desired = ColourDesired(wParam);
InvalidateStyleRedraw();
break;
@@ -4629,7 +4629,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_GETOVERTYPE:
- return inOverstrike ? TRUE : FALSE;
+ return inOverstrike ? 1 : 0;
case SCI_SETFOCUS:
SetFocusState(wParam);
diff --git a/src/Indicator.h b/src/Indicator.h
index a19b46b5e..56e9420bc 100644
--- a/src/Indicator.h
+++ b/src/Indicator.h
@@ -14,7 +14,7 @@ class Indicator {
public:
int style;
ColourPair fore;
- Indicator() : style(INDIC_PLAIN), fore(Colour(0,0,0)) {
+ Indicator() : style(INDIC_PLAIN), fore(ColourDesired(0,0,0)) {
}
void Draw(Surface *surface, PRectangle &rc);
};
diff --git a/src/LexHTML.cxx b/src/LexHTML.cxx
index 3a03096f8..551e7015a 100644
--- a/src/LexHTML.cxx
+++ b/src/LexHTML.cxx
@@ -15,6 +15,7 @@
#include "PropSet.h"
#include "Accessor.h"
+#include "StyleContext.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
@@ -26,6 +27,14 @@
enum { eScriptNone = 0, eScriptJS, eScriptVBS, eScriptPython, eScriptPHP, eScriptXML, eScriptSGML, eScriptSGMLblock };
enum { eHtml = 0, eNonHtmlScript, eNonHtmlPreProc, eNonHtmlScriptPreProc };
+inline bool IsAWordChar(const int ch) {
+ return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
+}
+
+inline bool IsAWordStart(const int ch) {
+ return (ch < 0x80) && (isalnum(ch) || ch == '_');
+}
+
static int segIsScriptingIndicator(Accessor &styler, unsigned int start, unsigned int end, int prevValue) {
char s[30 + 1];
unsigned int i = 0;
@@ -1541,5 +1550,193 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
}
}
+static bool isASPScript(int state) {
+ return
+ (state >= SCE_HJA_START && state <= SCE_HJA_REGEX) ||
+ (state >= SCE_HBA_START && state <= SCE_HBA_STRINGEOL) ||
+ (state >= SCE_HPA_DEFAULT && state <= SCE_HPA_IDENTIFIER);
+}
+
+static void ColouriseHBAPiece(StyleContext &sc, WordList *keywordlists[]) {
+ WordList &keywordsVBS = *keywordlists[2];
+ if (sc.state == SCE_HBA_WORD) {
+ if (!IsAWordChar(sc.ch)) {
+ char s[100];
+ sc.GetCurrentLowered(s, sizeof(s));
+ if (keywordsVBS.InList(s)) {
+ if (strcmp(s, "rem") == 0) {
+ sc.ChangeState(SCE_HBA_COMMENTLINE);
+ if (sc.atLineEnd) {
+ sc.SetState(SCE_HBA_DEFAULT);
+ }
+ } else {
+ sc.SetState(SCE_HBA_DEFAULT);
+ }
+ } else {
+ sc.ChangeState(SCE_HBA_IDENTIFIER);
+ sc.SetState(SCE_HBA_DEFAULT);
+ }
+ }
+ } else if (sc.state == SCE_HBA_NUMBER) {
+ if (!IsAWordChar(sc.ch)) {
+ sc.SetState(SCE_HBA_DEFAULT);
+ }
+ } else if (sc.state == SCE_HBA_STRING) {
+ if (sc.ch == '\"') {
+ sc.ForwardSetState(SCE_HBA_DEFAULT);
+ } else if (sc.ch == '\r' || sc.ch == '\n') {
+ sc.ChangeState(SCE_HBA_STRINGEOL);
+ sc.ForwardSetState(SCE_HBA_DEFAULT);
+ }
+ } else if (sc.state == SCE_HBA_COMMENTLINE) {
+ if (sc.ch == '\r' || sc.ch == '\n') {
+ sc.SetState(SCE_HBA_DEFAULT);
+ }
+ }
+
+ if (sc.state == SCE_HBA_DEFAULT) {
+ if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
+ sc.SetState(SCE_HBA_NUMBER);
+ } else if (IsAWordStart(sc.ch)) {
+ sc.SetState(SCE_HBA_WORD);
+ } else if (sc.ch == '\'') {
+ sc.SetState(SCE_HBA_COMMENTLINE);
+ } else if (sc.ch == '\"') {
+ sc.SetState(SCE_HBA_STRING);
+ }
+ }
+}
+
+static void ColouriseASPPiece(StyleContext &sc, WordList *keywordlists[]) {
+ // Possibly exit current state to either SCE_H_DEFAULT or SCE_HBA_DEFAULT
+ if ((sc.state == SCE_H_ASPAT || isASPScript(sc.state)) && sc.Match('%', '>')) {
+ sc.SetState(SCE_H_ASP);
+ sc.Forward();
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ }
+
+ // Handle some ASP script
+ if (sc.state >= SCE_HBA_START && sc.state <= SCE_HBA_STRINGEOL) {
+ ColouriseHBAPiece(sc, keywordlists);
+ }
+
+ // Enter new sc.state
+ if (sc.state == SCE_H_DEFAULT) {
+ if (sc.Match('<', '%')) {
+ sc.SetState(SCE_H_ASP);
+ sc.Forward();
+ sc.Forward();
+ if (sc.ch == '@') {
+ sc.ForwardSetState(SCE_H_ASPAT);
+ } else {
+ if (sc.ch == '=') {
+ sc.Forward();
+ }
+ sc.SetState(SCE_HBA_DEFAULT);
+ }
+ }
+ }
+}
+
+static void ColouriseASPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+ Accessor &styler) {
+ // Lexer for HTML requires more lexical states (7 bits worth) than most lexers
+ StyleContext sc(startPos, length, initStyle, styler, 0x7f);
+ for (; sc.More(); sc.Forward()) {
+ ColouriseASPPiece(sc, keywordlists);
+ }
+ sc.Complete();
+}
+
+static void ColourisePHPPiece(StyleContext &sc, WordList *[]) {
+ // Possibly exit current state to either SCE_H_DEFAULT or SCE_HBA_DEFAULT
+ if (sc.state >= SCE_HPHP_DEFAULT && sc.state <= SCE_HPHP_OPERATOR) {
+ if (!isPHPStringState(sc.state) &&
+ (sc.state != SCE_HPHP_COMMENT) &&
+ (sc.Match('?', '>'))) {
+ sc.SetState(SCE_H_QUESTION);
+ sc.Forward();
+ sc.ForwardSetState(SCE_H_DEFAULT);
+ }
+ }
+
+ // Handle some PHP script
+ if (sc.state == SCE_HPHP_WORD) {
+ if (!IsAWordStart(sc.ch)) {
+ sc.SetState(SCE_HPHP_DEFAULT);
+ }
+ } else if (sc.state == SCE_HPHP_COMMENTLINE) {
+ if (sc.ch == '\r' || sc.ch == '\n') {
+ sc.SetState(SCE_HPHP_DEFAULT);
+ }
+ } else if (sc.state == SCE_HPHP_COMMENT) {
+ if (sc.Match('*', '/')) {
+ sc.Forward();
+ sc.Forward();
+ sc.SetState(SCE_HPHP_DEFAULT);
+ }
+ } else if (sc.state == SCE_HPHP_HSTRING) {
+ if (sc.ch == '\"') {
+ sc.ForwardSetState(SCE_HPHP_DEFAULT);
+ }
+ } else if (sc.state == SCE_HPHP_SIMPLESTRING) {
+ if (sc.ch == '\'') {
+ sc.ForwardSetState(SCE_HPHP_DEFAULT);
+ }
+ } else if (sc.state == SCE_HPHP_VARIABLE) {
+ if (!IsAWordStart(sc.ch)) {
+ sc.SetState(SCE_HPHP_DEFAULT);
+ }
+ } else if (sc.state == SCE_HPHP_OPERATOR) {
+ sc.SetState(SCE_HPHP_DEFAULT);
+ }
+
+ // Enter new sc.state
+ if (sc.state == SCE_H_DEFAULT) {
+ if (sc.Match("<?php")) {
+ sc.SetState(SCE_H_QUESTION);
+ sc.Forward();
+ sc.Forward();
+ sc.Forward();
+ sc.Forward();
+ sc.Forward();
+ sc.SetState(SCE_HPHP_DEFAULT);
+ }
+ }
+ if (sc.state == SCE_HPHP_DEFAULT) {
+ if (IsAWordStart(sc.ch)) {
+ sc.SetState(SCE_HPHP_WORD);
+ } else if (sc.ch == '#') {
+ sc.SetState(SCE_HPHP_COMMENTLINE);
+ } else if (sc.Match("<!--")) {
+ sc.SetState(SCE_HPHP_COMMENTLINE);
+ } else if (sc.Match('/', '/')) {
+ sc.SetState(SCE_HPHP_COMMENTLINE);
+ } else if (sc.Match('/', '*')) {
+ sc.SetState(SCE_HPHP_COMMENT);
+ } else if (sc.ch == '\"') {
+ sc.SetState(SCE_HPHP_HSTRING);
+ } else if (sc.ch == '\'') {
+ sc.SetState(SCE_HPHP_SIMPLESTRING);
+ } else if (sc.ch == '$') {
+ sc.SetState(SCE_HPHP_VARIABLE);
+ } else if (isoperator(static_cast<char>(sc.ch))) {
+ sc.SetState(SCE_HPHP_OPERATOR);
+ }
+ }
+}
+
+static void ColourisePHPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+ Accessor &styler) {
+ // Lexer for HTML requires more lexical states (7 bits worth) than most lexers
+ StyleContext sc(startPos, length, initStyle, styler, 0x7f);
+ for (; sc.More(); sc.Forward()) {
+ ColourisePHPPiece(sc, keywordlists);
+ }
+ sc.Complete();
+}
+
LexerModule lmHTML(SCLEX_HTML, ColouriseHyperTextDoc, "hypertext");
LexerModule lmXML(SCLEX_XML, ColouriseHyperTextDoc, "xml");
+LexerModule lmASP(SCLEX_ASP, ColouriseASPDoc, "asp");
+LexerModule lmPHP(SCLEX_PHP, ColourisePHPDoc, "php");
diff --git a/src/LineMarker.cxx b/src/LineMarker.cxx
index e4b8b3299..1b8975d9c 100644
--- a/src/LineMarker.cxx
+++ b/src/LineMarker.cxx
@@ -10,7 +10,7 @@
#include "Scintilla.h"
#include "LineMarker.h"
-static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, Colour fore, Colour back) {
+static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore, ColourAllocated back) {
PRectangle rc;
rc.left = centreX - armSize;
rc.top = centreY - armSize;
@@ -19,7 +19,7 @@ static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, Col
surface->RectangleDraw(rc, back, fore);
}
-static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, Colour fore, Colour back) {
+static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore, ColourAllocated back) {
PRectangle rcCircle;
rcCircle.left = centreX - armSize;
rcCircle.top = centreY - armSize;
@@ -28,14 +28,14 @@ static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize,
surface->Ellipse(rcCircle, back, fore);
}
-static void DrawPlus(Surface *surface, int centreX, int centreY, int armSize, Colour fore) {
+static void DrawPlus(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore) {
PRectangle rcV(centreX, centreY - armSize + 2, centreX + 1, centreY + armSize - 2 + 1);
surface->FillRectangle(rcV, fore);
PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1);
surface->FillRectangle(rcH, fore);
}
-static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, Colour fore) {
+static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, ColourAllocated fore) {
PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1);
surface->FillRectangle(rcH, fore);
}
diff --git a/src/LineMarker.h b/src/LineMarker.h
index b9dd15d06..7897aa775 100644
--- a/src/LineMarker.h
+++ b/src/LineMarker.h
@@ -17,8 +17,8 @@ public:
ColourPair back;
LineMarker() {
markType = SC_MARK_CIRCLE;
- fore = Colour(0,0,0);
- back = Colour(0xff,0xff,0xff);
+ fore = ColourDesired(0,0,0);
+ back = ColourDesired(0xff,0xff,0xff);
}
void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter);
};
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index f938a1f4d..4863dbcb7 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -517,7 +517,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
break;
case SCI_CALLTIPSETBACK:
- ct.colourBG = Colour(wParam);
+ ct.colourBG = ColourDesired(wParam);
InvalidateStyleRedraw();
break;
diff --git a/src/Style.cxx b/src/Style.cxx
index 4a3526791..5989dae80 100644
--- a/src/Style.cxx
+++ b/src/Style.cxx
@@ -14,13 +14,13 @@
Style::Style() {
aliasOfDefaultFont = true;
- Clear(Colour(0, 0, 0), Colour(0xff, 0xff, 0xff),
+ Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
Platform::DefaultFontSize(), 0, SC_CHARSET_DEFAULT,
false, false, false, false, caseMixed, true);
}
Style::Style(const Style &source) {
- Clear(Colour(0, 0, 0), Colour(0xff, 0xff, 0xff),
+ Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
0, 0, 0,
false, false, false, false, caseMixed, true);
fore.desired = source.fore.desired;
@@ -46,7 +46,7 @@ Style::~Style() {
Style &Style::operator=(const Style &source) {
if (this == &source)
return * this;
- Clear(Colour(0, 0, 0), Colour(0xff, 0xff, 0xff),
+ Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
0, 0, SC_CHARSET_DEFAULT,
false, false, false, false, caseMixed, true);
fore.desired = source.fore.desired;
@@ -62,7 +62,7 @@ Style &Style::operator=(const Style &source) {
return *this;
}
-void Style::Clear(Colour fore_, Colour back_, int size_,
+void Style::Clear(ColourDesired fore_, ColourDesired back_, int size_,
const char *fontName_, int characterSet_,
bool bold_, bool italic_, bool eolFilled_,
bool underline_, ecaseForced caseForce_, bool visible_) {
diff --git a/src/Style.h b/src/Style.h
index 3600886b3..17d32ac33 100644
--- a/src/Style.h
+++ b/src/Style.h
@@ -39,7 +39,7 @@ public:
Style(const Style &source);
~Style();
Style &operator=(const Style &source);
- void Clear(Colour fore_, Colour back_,
+ void Clear(ColourDesired fore_, ColourDesired back_,
int size_,
const char *fontName_, int characterSet_,
bool bold_, bool italic_, bool eolFilled_,
diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx
index 4db7e2508..40615da65 100644
--- a/src/ViewStyle.cxx
+++ b/src/ViewStyle.cxx
@@ -103,11 +103,11 @@ void ViewStyle::Init() {
ResetDefaultStyle();
indicators[0].style = INDIC_SQUIGGLE;
- indicators[0].fore = Colour(0, 0x7f, 0);
+ indicators[0].fore = ColourDesired(0, 0x7f, 0);
indicators[1].style = INDIC_TT;
- indicators[1].fore = Colour(0, 0, 0xff);
+ indicators[1].fore = ColourDesired(0, 0, 0xff);
indicators[2].style = INDIC_PLAIN;
- indicators[2].fore = Colour(0xff, 0, 0);
+ indicators[2].fore = ColourDesired(0xff, 0, 0);
lineHeight = 1;
maxAscent = 1;
@@ -116,18 +116,18 @@ void ViewStyle::Init() {
spaceWidth = 8;
selforeset = false;
- selforeground.desired = Colour(0xff, 0, 0);
+ selforeground.desired = ColourDesired(0xff, 0, 0);
selbackset = true;
- selbackground.desired = Colour(0xc0, 0xc0, 0xc0);
- selbackground2.desired = Colour(0xb0, 0xb0, 0xb0);
+ selbackground.desired = ColourDesired(0xc0, 0xc0, 0xc0);
+ selbackground2.desired = ColourDesired(0xb0, 0xb0, 0xb0);
selbar.desired = Platform::Chrome();
selbarlight.desired = Platform::ChromeHighlight();
- styles[STYLE_LINENUMBER].fore.desired = Colour(0, 0, 0);
+ styles[STYLE_LINENUMBER].fore.desired = ColourDesired(0, 0, 0);
styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
- caretcolour.desired = Colour(0, 0, 0);
+ caretcolour.desired = ColourDesired(0, 0, 0);
showCaretLineBackground = false;
- caretLineBackground.desired = Colour(0xff, 0xff, 0);
- edgecolour.desired = Colour(0xc0, 0xc0, 0xc0);
+ caretLineBackground.desired = ColourDesired(0xff, 0xff, 0);
+ edgecolour.desired = ColourDesired(0xc0, 0xc0, 0xc0);
edgeState = EDGE_NONE;
caretWidth = 1;
@@ -215,7 +215,8 @@ void ViewStyle::Refresh(Surface &surface) {
}
void ViewStyle::ResetDefaultStyle() {
- styles[STYLE_DEFAULT].Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
+ styles[STYLE_DEFAULT].Clear(ColourDesired(0,0,0),
+ ColourDesired(0xff,0xff,0xff),
Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
SC_CHARSET_DEFAULT,
false, false, false, false, Style::caseMixed, true);
diff --git a/src/WindowAccessor.cxx b/src/WindowAccessor.cxx
index db2f938f3..cd419572c 100644
--- a/src/WindowAccessor.cxx
+++ b/src/WindowAccessor.cxx
@@ -27,7 +27,7 @@ bool WindowAccessor::InternalIsLeadByte(char ch) {
// same so none is considered a lead byte.
return false;
else
- return IsDBCSLeadByteEx(codePage, ch);
+ return Platform::IsDBCSLeadByte(codePage, ch);
}
#else
// PLAT_GTK or PLAT_WX
diff --git a/win32/ExternalLexer.cxx b/win32/ExternalLexer.cxx
index 77c235940..015f9b6af 100644
--- a/win32/ExternalLexer.cxx
+++ b/win32/ExternalLexer.cxx
@@ -9,8 +9,11 @@
#include <stdio.h>
#include <ctype.h>
-#include "SciLexer.h"
+#define _WIN32_WINNT 0x0400
+#include <windows.h>
+
#include "Platform.h"
+#include "SciLexer.h"
#include "PropSet.h"
#include "Accessor.h"
#include "DocumentAccessor.h"
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index b9164c757..6a6c38029 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -11,6 +11,12 @@
#include <stdarg.h>
#include <stdio.h>
+#define _WIN32_WINNT 0x0400
+#include <windows.h>
+#undef DrawText
+#include <commctrl.h>
+#include <richedit.h>
+
#include "Platform.h"
#include "PlatformRes.h"
#include "UniConversion.h"
@@ -24,34 +30,6 @@ static RECT RectFromPRectangle(PRectangle prc) {
return rc;
}
-Colour::Colour(long lcol) {
- co = lcol;
-}
-
-Colour::Colour(unsigned int red, unsigned int green, unsigned int blue) {
- co = RGB(red, green, blue);
-}
-
-bool Colour::operator==(const Colour &other) const {
- return co == other.co;
-}
-
-long Colour::AsLong() const {
- return co;
-}
-
-unsigned int Colour::GetRed() {
- return co & 0xff;
-}
-
-unsigned int Colour::GetGreen() {
- return (co >> 8) & 0xff;
-}
-
-unsigned int Colour::GetBlue() {
- return (co >> 16) & 0xff;
-}
-
Palette::Palette() {
used = 0;
allowRealization = false;
@@ -83,7 +61,7 @@ void Palette::WantFind(ColourPair &cp, bool want) {
if (used < numEntries) {
entries[used].desired = cp.desired;
- entries[used].allocated = cp.desired;
+ entries[used].allocated.Set(cp.desired.AsLong());
used++;
}
} else {
@@ -93,7 +71,7 @@ void Palette::WantFind(ColourPair &cp, bool want) {
return;
}
}
- cp.allocated = cp.desired;
+ cp.allocated.Set(cp.desired.AsLong());
}
}
@@ -108,12 +86,12 @@ void Palette::Allocate(Window &) {
logpal->palVersion = 0x300;
logpal->palNumEntries = static_cast<WORD>(used);
for (int iPal=0;iPal<used;iPal++) {
- Colour desired = entries[iPal].desired;
+ ColourDesired desired = entries[iPal].desired;
logpal->palPalEntry[iPal].peRed = static_cast<BYTE>(desired.GetRed());
logpal->palPalEntry[iPal].peGreen = static_cast<BYTE>(desired.GetGreen());
logpal->palPalEntry[iPal].peBlue = static_cast<BYTE>(desired.GetBlue());
- entries[iPal].allocated =
- PALETTERGB(desired.GetRed(), desired.GetGreen(), desired.GetBlue());
+ entries[iPal].allocated.Set(
+ PALETTERGB(desired.GetRed(), desired.GetGreen(), desired.GetBlue()));
// PC_NOCOLLAPSE means exact colours allocated even when in background this means other windows
// are less likely to get their colours and also flashes more when switching windows
logpal->palPalEntry[iPal].peFlags = PC_NOCOLLAPSE;
@@ -273,36 +251,37 @@ Surface::~Surface() {
void Surface::Release() {
if (penOld) {
- ::SelectObject(hdc, penOld);
+ ::SelectObject(reinterpret_cast<HDC>(hdc), penOld);
::DeleteObject(pen);
penOld = 0;
}
pen = 0;
if (brushOld) {
- ::SelectObject(hdc, brushOld);
+ ::SelectObject(reinterpret_cast<HDC>(hdc), brushOld);
::DeleteObject(brush);
brushOld = 0;
}
brush = 0;
if (fontOld) {
// Fonts are not deleted as they are owned by a Font object
- ::SelectObject(hdc, fontOld);
+ ::SelectObject(reinterpret_cast<HDC>(hdc), fontOld);
fontOld = 0;
}
font =0;
if (bitmapOld) {
- ::SelectObject(hdc, bitmapOld);
+ ::SelectObject(reinterpret_cast<HDC>(hdc), bitmapOld);
::DeleteObject(bitmap);
bitmapOld = 0;
}
bitmap = 0;
if (paletteOld) {
// Fonts are not deleted as they are owned by a Palette object
- ::SelectPalette(hdc, paletteOld, TRUE);
+ ::SelectPalette(reinterpret_cast<HDC>(hdc),
+ reinterpret_cast<HPALETTE>(paletteOld), TRUE);
paletteOld = 0;
}
if (hdcOwned) {
- ::DeleteDC(hdc);
+ ::DeleteDC(reinterpret_cast<HDC>(hdc));
hdc = 0;
hdcOwned = false;
}
@@ -316,61 +295,61 @@ void Surface::Init() {
Release();
hdc = ::CreateCompatibleDC(NULL);
hdcOwned = true;
- ::SetTextAlign(hdc, TA_BASELINE);
+ ::SetTextAlign(reinterpret_cast<HDC>(hdc), TA_BASELINE);
}
void Surface::Init(SurfaceID sid) {
Release();
hdc = sid;
- ::SetTextAlign(hdc, TA_BASELINE);
+ ::SetTextAlign(reinterpret_cast<HDC>(hdc), TA_BASELINE);
}
void Surface::InitPixMap(int width, int height, Surface *surface_) {
Release();
- hdc = ::CreateCompatibleDC(surface_->hdc);
+ hdc = ::CreateCompatibleDC(reinterpret_cast<HDC>(surface_->hdc));
hdcOwned = true;
- bitmap = ::CreateCompatibleBitmap(surface_->hdc, width, height);
- bitmapOld = static_cast<HBITMAP>(::SelectObject(hdc, bitmap));
- ::SetTextAlign(hdc, TA_BASELINE);
+ bitmap = ::CreateCompatibleBitmap(reinterpret_cast<HDC>(surface_->hdc), width, height);
+ bitmapOld = static_cast<HBITMAP>(::SelectObject(reinterpret_cast<HDC>(hdc), bitmap));
+ ::SetTextAlign(reinterpret_cast<HDC>(hdc), TA_BASELINE);
}
-void Surface::PenColour(Colour fore) {
+void Surface::PenColour(ColourAllocated fore) {
if (pen) {
- ::SelectObject(hdc, penOld);
+ ::SelectObject(reinterpret_cast<HDC>(hdc), penOld);
::DeleteObject(pen);
pen = 0;
penOld = 0;
}
pen = ::CreatePen(0,1,fore.AsLong());
- penOld = static_cast<HPEN>(::SelectObject(hdc, pen));
+ penOld = static_cast<HPEN>(::SelectObject(reinterpret_cast<HDC>(hdc), pen));
}
-void Surface::BrushColor(Colour back) {
+void Surface::BrushColor(ColourAllocated back) {
if (brush) {
- ::SelectObject(hdc, brushOld);
+ ::SelectObject(reinterpret_cast<HDC>(hdc), brushOld);
::DeleteObject(brush);
brush = 0;
brushOld = 0;
}
// Only ever want pure, non-dithered brushes
- Colour colourNearest = ::GetNearestColor(hdc, back.AsLong());
+ ColourAllocated colourNearest = ::GetNearestColor(reinterpret_cast<HDC>(hdc), back.AsLong());
brush = ::CreateSolidBrush(colourNearest.AsLong());
- brushOld = static_cast<HBRUSH>(::SelectObject(hdc, brush));
+ brushOld = static_cast<HBRUSH>(::SelectObject(reinterpret_cast<HDC>(hdc), brush));
}
void Surface::SetFont(Font &font_) {
if (font_.GetID() != font) {
if (fontOld) {
- ::SelectObject(hdc, font_.GetID());
+ ::SelectObject(reinterpret_cast<HDC>(hdc), font_.GetID());
} else {
- fontOld = static_cast<HFONT>(::SelectObject(hdc, font_.GetID()));
+ fontOld = static_cast<HFONT>(::SelectObject(reinterpret_cast<HDC>(hdc), font_.GetID()));
}
font = font_.GetID();
}
}
int Surface::LogPixelsY() {
- return ::GetDeviceCaps(hdc, LOGPIXELSY);
+ return ::GetDeviceCaps(reinterpret_cast<HDC>(hdc), LOGPIXELSY);
}
int Surface::DeviceHeightFont(int points) {
@@ -378,93 +357,96 @@ int Surface::DeviceHeightFont(int points) {
}
void Surface::MoveTo(int x_, int y_) {
- ::MoveToEx(hdc, x_, y_, 0);
+ ::MoveToEx(reinterpret_cast<HDC>(hdc), x_, y_, 0);
}
void Surface::LineTo(int x_, int y_) {
- ::LineTo(hdc, x_, y_);
+ ::LineTo(reinterpret_cast<HDC>(hdc), x_, y_);
}
-void Surface::Polygon(Point *pts, int npts, Colour fore, Colour back) {
+void Surface::Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back) {
PenColour(fore);
BrushColor(back);
- ::Polygon(hdc, reinterpret_cast<POINT *>(pts), npts);
+ ::Polygon(reinterpret_cast<HDC>(hdc), reinterpret_cast<POINT *>(pts), npts);
}
-void Surface::RectangleDraw(PRectangle rc, Colour fore, Colour back) {
+void Surface::RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
PenColour(fore);
BrushColor(back);
- ::Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom);
+ ::Rectangle(reinterpret_cast<HDC>(hdc), rc.left, rc.top, rc.right, rc.bottom);
}
-void Surface::FillRectangle(PRectangle rc, Colour back) {
+void Surface::FillRectangle(PRectangle rc, ColourAllocated back) {
// Using ExtTextOut rather than a FillRect ensures that no dithering occurs.
// There is no need to allocate a brush either.
RECT rcw = RectFromPRectangle(rc);
- ::SetBkColor(hdc, back.AsLong());
- ::ExtTextOut(hdc, rc.left, rc.top, ETO_OPAQUE, &rcw, "", 0, NULL);
+ ::SetBkColor(reinterpret_cast<HDC>(hdc), back.AsLong());
+ ::ExtTextOut(reinterpret_cast<HDC>(hdc), rc.left, rc.top, ETO_OPAQUE, &rcw, "", 0, NULL);
}
void Surface::FillRectangle(PRectangle rc, Surface &surfacePattern) {
HBRUSH br;
if (surfacePattern.bitmap)
- br = ::CreatePatternBrush(surfacePattern.bitmap);
+ br = ::CreatePatternBrush(reinterpret_cast<HBITMAP>(surfacePattern.bitmap));
else // Something is wrong so display in red
br = ::CreateSolidBrush(RGB(0xff, 0, 0));
RECT rcw = RectFromPRectangle(rc);
- ::FillRect(hdc, &rcw, br);
+ ::FillRect(reinterpret_cast<HDC>(hdc), &rcw, br);
::DeleteObject(br);
}
-void Surface::RoundedRectangle(PRectangle rc, Colour fore, Colour back) {
+void Surface::RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
PenColour(fore);
BrushColor(back);
- ::RoundRect(hdc,
+ ::RoundRect(reinterpret_cast<HDC>(hdc),
rc.left + 1, rc.top,
rc.right - 1, rc.bottom,
8, 8 );
}
-void Surface::Ellipse(PRectangle rc, Colour fore, Colour back) {
+void Surface::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) {
PenColour(fore);
BrushColor(back);
- ::Ellipse(hdc, rc.left, rc.top, rc.right, rc.bottom);
+ ::Ellipse(reinterpret_cast<HDC>(hdc), rc.left, rc.top, rc.right, rc.bottom);
}
void Surface::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
- ::BitBlt(hdc, rc.left, rc.top, rc.Width(), rc.Height(),
- surfaceSource.hdc, from.x, from.y, SRCCOPY);
+ ::BitBlt(reinterpret_cast<HDC>(hdc),
+ rc.left, rc.top, rc.Width(), rc.Height(),
+ reinterpret_cast<HDC>(surfaceSource.hdc), from.x, from.y, SRCCOPY);
}
#define MAX_US_LEN 5000
-void Surface::DrawText(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back) {
+void Surface::DrawText(PRectangle rc, Font &font_, int ybase, const char *s, int len,
+ ColourAllocated fore, ColourAllocated back) {
SetFont(font_);
- ::SetTextColor(hdc, fore.AsLong());
- ::SetBkColor(hdc, back.AsLong());
+ ::SetTextColor(reinterpret_cast<HDC>(hdc), fore.AsLong());
+ ::SetBkColor(reinterpret_cast<HDC>(hdc), back.AsLong());
RECT rcw = RectFromPRectangle(rc);
if (unicodeMode) {
wchar_t tbuf[MAX_US_LEN];
int tlen = UCS2FromUTF8(s, len, tbuf, sizeof(tbuf)/sizeof(wchar_t));
tbuf[tlen] = L'\0';
- ::ExtTextOutW(hdc, rc.left, ybase, ETO_OPAQUE, &rcw, tbuf, tlen, NULL);
+ ::ExtTextOutW(reinterpret_cast<HDC>(hdc), rc.left, ybase, ETO_OPAQUE, &rcw, tbuf, tlen, NULL);
} else {
- ::ExtTextOut(hdc, rc.left, ybase, ETO_OPAQUE, &rcw, s, len, NULL);
+ ::ExtTextOut(reinterpret_cast<HDC>(hdc), rc.left, ybase, ETO_OPAQUE, &rcw, s, len, NULL);
}
}
-void Surface::DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, Colour fore, Colour back) {
+void Surface::DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len,
+ ColourAllocated fore, ColourAllocated back) {
SetFont(font_);
- ::SetTextColor(hdc, fore.AsLong());
- ::SetBkColor(hdc, back.AsLong());
+ ::SetTextColor(reinterpret_cast<HDC>(hdc), fore.AsLong());
+ ::SetBkColor(reinterpret_cast<HDC>(hdc), back.AsLong());
RECT rcw = RectFromPRectangle(rc);
if (unicodeMode) {
wchar_t tbuf[MAX_US_LEN];
int tlen = UCS2FromUTF8(s, len, tbuf, sizeof(tbuf)/sizeof(wchar_t));
tbuf[tlen] = L'\0';
- ::ExtTextOutW(hdc, rc.left, ybase, ETO_OPAQUE | ETO_CLIPPED, &rcw, tbuf, tlen, NULL);
+ ::ExtTextOutW(reinterpret_cast<HDC>(hdc), rc.left, ybase, ETO_OPAQUE | ETO_CLIPPED, &rcw, tbuf, tlen, NULL);
} else {
- ::ExtTextOut(hdc, rc.left, ybase, ETO_OPAQUE | ETO_CLIPPED, &rcw, s, len, NULL);
+ ::ExtTextOut(reinterpret_cast<HDC>(hdc), rc.left, ybase, ETO_OPAQUE | ETO_CLIPPED, &rcw, s, len, NULL);
}
}
@@ -475,9 +457,9 @@ int Surface::WidthText(Font &font_, const char *s, int len) {
wchar_t tbuf[MAX_US_LEN];
int tlen = UCS2FromUTF8(s, len, tbuf, sizeof(tbuf)/sizeof(wchar_t));
tbuf[tlen] = L'\0';
- ::GetTextExtentPoint32W(hdc, tbuf, tlen, &sz);
+ ::GetTextExtentPoint32W(reinterpret_cast<HDC>(hdc), tbuf, tlen, &sz);
} else {
- ::GetTextExtentPoint32(hdc, s, len, &sz);
+ ::GetTextExtentPoint32(reinterpret_cast<HDC>(hdc), s, len, &sz);
}
return sz.cx;
}
@@ -492,12 +474,12 @@ void Surface::MeasureWidths(Font &font_, const char *s, int len, int *positions)
tbuf[tlen] = L'\0';
int poses[MAX_US_LEN];
fit = tlen;
- if (!::GetTextExtentExPointW(hdc, tbuf, tlen, 30000, &fit, poses, &sz)) {
+ if (!::GetTextExtentExPointW(reinterpret_cast<HDC>(hdc), tbuf, tlen, 30000, &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
for (int widthSS=0; widthSS < tlen; widthSS++) {
- ::GetTextExtentPoint32W(hdc, tbuf, widthSS+1, &sz);
+ ::GetTextExtentPoint32W(reinterpret_cast<HDC>(hdc), tbuf, widthSS+1, &sz);
poses[widthSS] = sz.cx;
}
}
@@ -520,7 +502,7 @@ void Surface::MeasureWidths(Font &font_, const char *s, int len, int *positions)
}
positions[i] = sz.cx;
} else {
- if (!::GetTextExtentExPoint(hdc, s, len, 30000, &fit, positions, &sz)) {
+ if (!::GetTextExtentExPoint(reinterpret_cast<HDC>(hdc), s, len, 30000, &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));
@@ -536,67 +518,70 @@ void Surface::MeasureWidths(Font &font_, const char *s, int len, int *positions)
int Surface::WidthChar(Font &font_, char ch) {
SetFont(font_);
SIZE sz;
- ::GetTextExtentPoint32(hdc, &ch, 1, &sz);
+ ::GetTextExtentPoint32(reinterpret_cast<HDC>(hdc), &ch, 1, &sz);
return sz.cx;
}
int Surface::Ascent(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
- ::GetTextMetrics(hdc, &tm);
+ ::GetTextMetrics(reinterpret_cast<HDC>(hdc), &tm);
return tm.tmAscent;
}
int Surface::Descent(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
- ::GetTextMetrics(hdc, &tm);
+ ::GetTextMetrics(reinterpret_cast<HDC>(hdc), &tm);
return tm.tmDescent;
}
int Surface::InternalLeading(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
- ::GetTextMetrics(hdc, &tm);
+ ::GetTextMetrics(reinterpret_cast<HDC>(hdc), &tm);
return tm.tmInternalLeading;
}
int Surface::ExternalLeading(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
- ::GetTextMetrics(hdc, &tm);
+ ::GetTextMetrics(reinterpret_cast<HDC>(hdc), &tm);
return tm.tmExternalLeading;
}
int Surface::Height(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
- ::GetTextMetrics(hdc, &tm);
+ ::GetTextMetrics(reinterpret_cast<HDC>(hdc), &tm);
return tm.tmHeight;
}
int Surface::AverageCharWidth(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
- ::GetTextMetrics(hdc, &tm);
+ ::GetTextMetrics(reinterpret_cast<HDC>(hdc), &tm);
return tm.tmAveCharWidth;
}
int Surface::SetPalette(Palette *pal, bool inBackGround) {
if (paletteOld) {
- ::SelectPalette(hdc,paletteOld,TRUE);
+ ::SelectPalette(reinterpret_cast<HDC>(hdc),
+ reinterpret_cast<HPALETTE>(paletteOld),TRUE);
}
paletteOld = 0;
int changes = 0;
if (pal->allowRealization) {
- paletteOld = ::SelectPalette(hdc, pal->hpal, inBackGround);
- changes = ::RealizePalette(hdc);
+ paletteOld = ::SelectPalette(
+ reinterpret_cast<HDC>(hdc),
+ reinterpret_cast<HPALETTE>(pal->hpal), inBackGround);
+ changes = ::RealizePalette(reinterpret_cast<HDC>(hdc));
}
return changes;
}
void Surface::SetClip(PRectangle rc) {
- ::IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
+ ::IntersectClipRect(reinterpret_cast<HDC>(hdc), rc.left, rc.top, rc.right, rc.bottom);
}
void Surface::FlushCachedState() {
@@ -610,7 +595,7 @@ Window::~Window() {
void Window::Destroy() {
if (id)
- ::DestroyWindow(id);
+ ::DestroyWindow(reinterpret_cast<HWND>(id));
id = 0;
}
@@ -620,12 +605,13 @@ bool Window::HasFocus() {
PRectangle Window::GetPosition() {
RECT rc;
- ::GetWindowRect(id, &rc);
+ ::GetWindowRect(reinterpret_cast<HWND>(id), &rc);
return PRectangle(rc.left, rc.top, rc.right, rc.bottom);
}
void Window::SetPosition(PRectangle rc) {
- ::SetWindowPos(id, 0, rc.left, rc.top, rc.Width(), rc.Height(), 0);
+ ::SetWindowPos(reinterpret_cast<HWND>(id),
+ 0, rc.left, rc.top, rc.Width(), rc.Height(), 0);
}
void Window::SetPositionRelative(PRectangle rc, Window) {
@@ -634,28 +620,32 @@ void Window::SetPositionRelative(PRectangle rc, Window) {
PRectangle Window::GetClientPosition() {
RECT rc;
- ::GetClientRect(id, &rc);
+ ::GetClientRect(reinterpret_cast<HWND>(id), &rc);
return PRectangle(rc.left, rc.top, rc.right, rc.bottom);
}
void Window::Show(bool show) {
if (show)
- ::ShowWindow(id, SW_SHOWNORMAL);
+ ::ShowWindow(reinterpret_cast<HWND>(id), SW_SHOWNORMAL);
else
- ::ShowWindow(id, SW_HIDE);
+ ::ShowWindow(reinterpret_cast<HWND>(id), SW_HIDE);
}
void Window::InvalidateAll() {
- ::InvalidateRect(id, NULL, FALSE);
+ ::InvalidateRect(reinterpret_cast<HWND>(id), NULL, FALSE);
}
void Window::InvalidateRectangle(PRectangle rc) {
RECT rcw = RectFromPRectangle(rc);
- ::InvalidateRect(id, &rcw, FALSE);
+ ::InvalidateRect(reinterpret_cast<HWND>(id), &rcw, FALSE);
+}
+
+static LRESULT Window_SendMessage(Window *w, UINT msg, WPARAM wParam=0, LPARAM lParam=0) {
+ return ::SendMessage(reinterpret_cast<HWND>(w->GetID()), msg, wParam, lParam);
}
void Window::SetFont(Font &font) {
- SendMessage(WM_SETFONT,
+ Window_SendMessage(this, WM_SETFONT,
reinterpret_cast<WPARAM>(font.GetID()), 0);
}
@@ -695,23 +685,7 @@ void Window::SetCursor(Cursor curs) {
}
void Window::SetTitle(const char *s) {
- ::SetWindowText(id, s);
-}
-
-LRESULT Window::SendMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
- if (id)
- return ::SendMessage(id, msg, wParam, lParam);
- else
- return 0;
-}
-
-int Window::GetDlgCtrlID() {
- return ::GetDlgCtrlID(id);
-}
-
-HINSTANCE Window::GetInstance() {
- return reinterpret_cast<HINSTANCE>(
- ::GetWindowLong(id,GWL_HINSTANCE));
+ ::SetWindowText(reinterpret_cast<HWND>(id), s);
}
ListBox::ListBox() : desiredVisibleRows(5), maxItemCharacters(0), aveCharWidth(8) {
@@ -721,11 +695,15 @@ ListBox::~ListBox() {
}
void ListBox::Create(Window &parent, int ctrlID) {
+ HINSTANCE hinstanceParent = reinterpret_cast<HINSTANCE>(
+ ::GetWindowLong(reinterpret_cast<HWND>(parent.GetID()),GWL_HINSTANCE));
id = ::CreateWindowEx(
WS_EX_WINDOWEDGE, "listbox", "",
WS_CHILD | WS_THICKFRAME | WS_VSCROLL | LBS_NOTIFY,
- 100,100, 150,80, parent.GetID(), reinterpret_cast<HMENU>(ctrlID),
- parent.GetInstance(), 0);
+ 100,100, 150,80, reinterpret_cast<HWND>(parent.GetID()),
+ reinterpret_cast<HMENU>(ctrlID),
+ hinstanceParent,
+ 0);
}
void ListBox::SetFont(Font &font) {
@@ -742,7 +720,7 @@ void ListBox::SetVisibleRows(int rows) {
PRectangle ListBox::GetDesiredRect() {
PRectangle rcDesired = GetPosition();
- int itemHeight = SendMessage(LB_GETITEMHEIGHT, 0);
+ int itemHeight = Window_SendMessage(this, LB_GETITEMHEIGHT, 0);
int rows = Length();
if ((rows == 0) || (rows > desiredVisibleRows))
rows = desiredVisibleRows;
@@ -758,40 +736,40 @@ PRectangle ListBox::GetDesiredRect() {
}
void ListBox::Clear() {
- SendMessage(LB_RESETCONTENT);
+ Window_SendMessage(this, LB_RESETCONTENT);
maxItemCharacters = 0;
}
void ListBox::Append(char *s) {
- SendMessage(LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(s));
+ Window_SendMessage(this, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(s));
size_t len = strlen(s);
if (maxItemCharacters < len)
maxItemCharacters = len;
}
int ListBox::Length() {
- return SendMessage(LB_GETCOUNT);
+ return Window_SendMessage(this, LB_GETCOUNT);
}
void ListBox::Select(int n) {
- SendMessage(LB_SETCURSEL, n);
+ Window_SendMessage(this, LB_SETCURSEL, n);
}
int ListBox::GetSelection() {
- return SendMessage(LB_GETCURSEL);
+ return Window_SendMessage(this, LB_GETCURSEL);
}
int ListBox::Find(const char *prefix) {
- return SendMessage(LB_FINDSTRING, static_cast<WPARAM>(-1),
- reinterpret_cast<LPARAM>(prefix));
+ return Window_SendMessage(this, LB_FINDSTRING, static_cast<WPARAM>(-1),
+ reinterpret_cast<LPARAM>(prefix));
}
void ListBox::GetValue(int n, char *value, int len) {
- int lenText = SendMessage(LB_GETTEXTLEN, n);
+ int lenText = Window_SendMessage(this, LB_GETTEXTLEN, n);
if ((len > 0) && (lenText > 0)){
char *text = new char[len+1];
if (text) {
- SendMessage(LB_GETTEXT, n, reinterpret_cast<LPARAM>(text));
+ Window_SendMessage(this, LB_GETTEXT, n, reinterpret_cast<LPARAM>(text));
strncpy(value, text, len);
value[len-1] = '\0';
delete []text;
@@ -817,20 +795,22 @@ void Menu::CreatePopUp() {
void Menu::Destroy() {
if (id)
- ::DestroyMenu(id);
+ ::DestroyMenu(reinterpret_cast<HMENU>(id));
id = 0;
}
void Menu::Show(Point pt, Window &w) {
- ::TrackPopupMenu(id, 0, pt.x - 4, pt.y, 0, w.GetID(), NULL);
+ ::TrackPopupMenu(reinterpret_cast<HMENU>(id),
+ 0, pt.x - 4, pt.y, 0,
+ reinterpret_cast<HWND>(w.GetID()), NULL);
Destroy();
}
-Colour Platform::Chrome() {
+ColourDesired Platform::Chrome() {
return ::GetSysColor(COLOR_3DFACE);
}
-Colour Platform::ChromeHighlight() {
+ColourDesired Platform::ChromeHighlight() {
return ::GetSysColor(COLOR_3DHIGHLIGHT);
}
@@ -855,7 +835,11 @@ bool Platform::IsKeyDown(int key) {
}
long Platform::SendScintilla(WindowID w, unsigned int msg, unsigned long wParam, long lParam) {
- return ::SendMessage(w, msg, wParam, lParam);
+ return ::SendMessage(reinterpret_cast<HWND>(w), msg, wParam, lParam);
+}
+
+bool Platform::IsDBCSLeadByte(int codePage, char ch) {
+ return ::IsDBCSLeadByteEx(codePage, ch);
}
// These are utility functions not really tied to a platform
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 90cb275a5..d2b399be5 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -11,6 +11,11 @@
#include <ctype.h>
#include <assert.h>
+#define _WIN32_WINNT 0x0400
+#include <windows.h>
+#include <commctrl.h>
+#include <richedit.h>
+
#include "Platform.h"
#include "Scintilla.h"
@@ -159,6 +164,7 @@ class ScintillaWin :
virtual void Initialise();
virtual void Finalise();
+ HWND MainHWND();
static sptr_t DirectFunction(
ScintillaWin *sci, UINT iMessage, uptr_t wParam, sptr_t lParam);
@@ -280,10 +286,14 @@ void ScintillaWin::Initialise() {
void ScintillaWin::Finalise() {
ScintillaBase::Finalise();
SetTicking(false);
- RevokeDragDrop(wMain.GetID());
+ RevokeDragDrop(MainHWND());
OleUninitialize();
}
+HWND ScintillaWin::MainHWND() {
+ return reinterpret_cast<HWND>(wMain.GetID());
+}
+
void ScintillaWin::StartDrag() {
DWORD dwEffect = 0;
dropWentOutside = true;
@@ -370,7 +380,7 @@ LRESULT ScintillaWin::WndPaint(unsigned long wParam) {
pps = reinterpret_cast<PAINTSTRUCT*>(wParam);
} else {
pps = &ps;
- BeginPaint(wMain.GetID(), pps);
+ ::BeginPaint(MainHWND(), pps);
}
Surface surfaceWindow;
surfaceWindow.Init(pps->hdc);
@@ -386,7 +396,7 @@ LRESULT ScintillaWin::WndPaint(unsigned long wParam) {
Paint(&surfaceWindow, rcPaint);
surfaceWindow.Release();
if(!IsOcxCtrl)
- EndPaint(wMain.GetID(), pps);
+ ::EndPaint(MainHWND(), pps);
if (paintState == paintAbandoned) {
// Painting area was insufficient to cover new styling or brace highlight positions
FullPaint();
@@ -418,7 +428,7 @@ sptr_t ScintillaWin::HandleComposition(uptr_t wParam, sptr_t lParam) {
return 0;
#else
if ((lParam & GCS_RESULTSTR) && (IsNT())) {
- HIMC hIMC = ::ImmGetContext(wMain.GetID());
+ HIMC hIMC = ::ImmGetContext(MainHWND());
if (hIMC) {
const int maxLenInputIME = 200;
wchar_t wcs[maxLenInputIME];
@@ -439,11 +449,11 @@ sptr_t ScintillaWin::HandleComposition(uptr_t wParam, sptr_t lParam) {
AddChar(dbcsval[i]);
}
}
- ::ImmReleaseContext(wMain.GetID(), hIMC);
+ ::ImmReleaseContext(MainHWND(), hIMC);
}
return 0;
} else {
- return ::DefWindowProc(wMain.GetID(), WM_IME_COMPOSITION, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), WM_IME_COMPOSITION, wParam, lParam);
}
#endif
}
@@ -483,10 +493,10 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
switch (iMessage) {
case WM_CREATE:
- ctrlID = wMain.GetDlgCtrlID();
+ ctrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(wMain.GetID()));
// Get Intellimouse scroll line parameters
GetIntelliMouseParameters();
- RegisterDragDrop(wMain.GetID(), reinterpret_cast<IDropTarget *>(&dt));
+ ::RegisterDragDrop(MainHWND(), reinterpret_cast<IDropTarget *>(&dt));
break;
case WM_COMMAND:
@@ -497,7 +507,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
AutoCompleteCompleted();
} else {
if (cmd != LBN_SETFOCUS)
- SetFocus(wMain.GetID());
+ ::SetFocus(MainHWND());
}
}
Command(LoWord(wParam));
@@ -529,7 +539,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
// i.e. if datazoomed out only class structures are visible, when datazooming in the control
// structures appear, then eventually the individual statements...)
if (wParam & MK_SHIFT) {
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
}
// Either SCROLL or ZOOM. We handle the wheel steppings calculation
@@ -562,7 +572,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
break;
case WM_GETMINMAXINFO:
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_LBUTTONDOWN:
//Platform::DebugPrintf("Buttdown %d %x %x %x %x %x\n",iMessage, wParam, lParam,
@@ -571,7 +581,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
// Platform::IsKeyDown(VK_MENU));
ButtonDown(Point::FromLong(lParam), GetTickCount(),
wParam & MK_SHIFT, wParam & MK_CONTROL, Platform::IsKeyDown(VK_MENU));
- SetFocus(wMain.GetID());
+ SetFocus(MainHWND());
break;
case WM_MOUSEMOVE:
@@ -590,7 +600,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
// Display regular (drag) cursor over selection
POINT pt;
::GetCursorPos(&pt);
- ::ScreenToClient(wMain.GetID(), &pt);
+ ::ScreenToClient(MainHWND(), &pt);
if (PointInSelMargin(Point(pt.x, pt.y))) {
DisplayCursor(Window::cursorReverseArrow);
} else if (PointInSelection(Point(pt.x, pt.y))) {
@@ -601,7 +611,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
}
return TRUE;
} else
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_CHAR:
if (!iscntrl(wParam&0xff) || !lastKeyDownConsumed) {
@@ -623,16 +633,16 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
Platform::IsKeyDown(VK_MENU),
&lastKeyDownConsumed);
if (!ret && !lastKeyDownConsumed)
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
break;
}
case WM_IME_KEYDOWN:
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_KEYUP:
//Platform::DebugPrintf("S keyup %d %x %x\n",iMessage, wParam, lParam);
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_SETTINGCHANGE:
//Platform::DebugPrintf("Setting Changed\n");
@@ -660,7 +670,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
break;
case WM_PALETTECHANGED:
- if (wParam != reinterpret_cast<unsigned int>(wMain.GetID())) {
+ if (wParam != reinterpret_cast<unsigned int>(MainHWND())) {
//Platform::DebugPrintf("** Palette Changed\n");
RealizeWindowPalette(true);
}
@@ -673,11 +683,11 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case WM_IME_STARTCOMPOSITION: // dbcs
ImeStartComposition();
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_IME_ENDCOMPOSITION: // dbcs
ImeEndComposition();
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_IME_COMPOSITION:
return HandleComposition(wParam, lParam);
@@ -695,21 +705,21 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
// Caused by keyboard so display menu near caret
pt = LocationFromPosition(currentPos);
POINT spt = {pt.x, pt.y};
- ::ClientToScreen(wMain.GetID(), &spt);
+ ::ClientToScreen(MainHWND(), &spt);
pt = Point(spt.x, spt.y);
}
ContextMenu(pt);
return 0;
}
#endif
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_INPUTLANGCHANGE:
//::SetThreadLocale(LOWORD(lParam));
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_INPUTLANGCHANGEREQUEST:
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_ERASEBKGND:
return 1; // Avoid any background erasure as whole window painted.
@@ -732,7 +742,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
case WM_SYSCOMMAND:
case WM_WINDOWPOSCHANGING:
case WM_WINDOWPOSCHANGED:
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case EM_LINEFROMCHAR:
if (static_cast<int>(wParam) < 0)
@@ -772,7 +782,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
return reinterpret_cast<sptr_t>(this);
case SCI_GRABFOCUS:
- ::SetFocus(wMain.GetID());
+ ::SetFocus(MainHWND());
break;
default:
@@ -782,16 +792,16 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
}
sptr_t ScintillaWin::DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
- return ::DefWindowProc(wMain.GetID(), iMessage, wParam, lParam);
+ return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
}
void ScintillaWin::SetTicking(bool on) {
if (timer.ticking != on) {
timer.ticking = on;
if (timer.ticking) {
- timer.tickerID = ::SetTimer(wMain.GetID(), 1, timer.tickSize, NULL);
+ timer.tickerID = ::SetTimer(MainHWND(), 1, timer.tickSize, NULL);
} else {
- ::KillTimer(wMain.GetID(), timer.tickerID);
+ ::KillTimer(MainHWND(), timer.tickerID);
timer.tickerID = 0;
}
}
@@ -801,7 +811,7 @@ void ScintillaWin::SetTicking(bool on) {
void ScintillaWin::SetMouseCapture(bool on) {
if (mouseDownCaptures) {
if (on) {
- ::SetCapture(wMain.GetID());
+ ::SetCapture(MainHWND());
} else {
::ReleaseCapture();
}
@@ -812,22 +822,22 @@ void ScintillaWin::SetMouseCapture(bool on) {
bool ScintillaWin::HaveMouseCapture() {
// Cannot just see if GetCapture is this window as the scroll bar also sets capture for the window
return capturedMouse;
- //return capturedMouse && (::GetCapture() == wMain.GetID());
+ //return capturedMouse && (::GetCapture() == MainHWND());
}
void ScintillaWin::ScrollText(int linesToMove) {
//Platform::DebugPrintf("ScintillaWin::ScrollText %d\n", linesToMove);
- ::ScrollWindow(wMain.GetID(), 0,
+ ::ScrollWindow(MainHWND(), 0,
vs.lineHeight * linesToMove, 0, 0);
- ::UpdateWindow(wMain.GetID());
+ ::UpdateWindow(MainHWND());
}
void ScintillaWin::SetVerticalScrollPos() {
- ::SetScrollPos(wMain.GetID(), SB_VERT, topLine, TRUE);
+ ::SetScrollPos(MainHWND(), SB_VERT, topLine, TRUE);
}
void ScintillaWin::SetHorizontalScrollPos() {
- ::SetScrollPos(wMain.GetID(), SB_HORZ, xOffset, TRUE);
+ ::SetScrollPos(MainHWND(), SB_HORZ, xOffset, TRUE);
}
bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) {
@@ -836,7 +846,7 @@ bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) {
sizeof(sci),0,0,0,0,0,0
};
sci.fMask = SIF_PAGE | SIF_RANGE;
- ::GetScrollInfo(wMain.GetID(), SB_VERT, &sci);
+ ::GetScrollInfo(MainHWND(), SB_VERT, &sci);
if ((sci.nMin != 0) || (sci.nMax != pdoc->LinesTotal()) ||
(sci.nPage != static_cast<unsigned int>(pdoc->LinesTotal() - MaxScrollPos() + 1)) ||
(sci.nPos != 0)) {
@@ -848,7 +858,7 @@ bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) {
sci.nPage = nPage;
sci.nPos = 0;
sci.nTrackPos = 1;
- ::SetScrollInfo(wMain.GetID(), SB_VERT, &sci, TRUE);
+ ::SetScrollInfo(MainHWND(), SB_VERT, &sci, TRUE);
modified = true;
}
int horizStart = 0;
@@ -856,9 +866,9 @@ bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) {
int horizEndPreferred = 2000;
if (!horizontalScrollBarVisible)
horizEndPreferred = 0;
- if (!::GetScrollRange(wMain.GetID(), SB_HORZ, &horizStart, &horizEnd) ||
+ if (!::GetScrollRange(MainHWND(), SB_HORZ, &horizStart, &horizEnd) ||
horizStart != 0 || horizEnd != horizEndPreferred) {
- ::SetScrollRange(wMain.GetID(), SB_HORZ, 0, horizEndPreferred, TRUE);
+ ::SetScrollRange(MainHWND(), SB_HORZ, 0, horizEndPreferred, TRUE);
//Platform::DebugPrintf("Horiz Scroll info changed\n");
modified = true;
}
@@ -866,29 +876,30 @@ bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) {
}
void ScintillaWin::NotifyChange() {
- ::SendMessage(::GetParent(wMain.GetID()), WM_COMMAND,
- MAKELONG(wMain.GetDlgCtrlID(), SCEN_CHANGE),
- reinterpret_cast<LPARAM>(wMain.GetID()));
+ ::SendMessage(::GetParent(MainHWND()), WM_COMMAND,
+ MAKELONG(ctrlID, SCEN_CHANGE),
+ reinterpret_cast<LPARAM>(MainHWND()));
}
void ScintillaWin::NotifyFocus(bool focus) {
- ::SendMessage(::GetParent(wMain.GetID()), WM_COMMAND,
- MAKELONG(wMain.GetDlgCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS),
- reinterpret_cast<LPARAM>(wMain.GetID()));
+ ::SendMessage(::GetParent(MainHWND()), WM_COMMAND,
+ MAKELONG(ctrlID, focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS),
+ reinterpret_cast<LPARAM>(MainHWND()));
}
void ScintillaWin::NotifyParent(SCNotification scn) {
- scn.nmhdr.hwndFrom = wMain.GetID();
+ scn.nmhdr.hwndFrom = MainHWND();
scn.nmhdr.idFrom = ctrlID;
- ::SendMessage(::GetParent(wMain.GetID()), WM_NOTIFY,
- wMain.GetDlgCtrlID(), reinterpret_cast<LPARAM>(&scn));
+ ::SendMessage(::GetParent(MainHWND()), WM_NOTIFY,
+ ctrlID, reinterpret_cast<LPARAM>(&scn));
}
void ScintillaWin::NotifyDoubleClick(Point pt, bool shift) {
//Platform::DebugPrintf("ScintillaWin Double click 0\n");
ScintillaBase::NotifyDoubleClick(pt, shift);
// Send myself a WM_LBUTTONDBLCLK, so the container can handle it too.
- wMain.SendMessage(WM_LBUTTONDBLCLK,
+ ::SendMessage(MainHWND(),
+ WM_LBUTTONDBLCLK,
shift ? MK_SHIFT : 0,
MAKELPARAM(pt.x, pt.y));
}
@@ -896,7 +907,7 @@ void ScintillaWin::NotifyDoubleClick(Point pt, bool shift) {
void ScintillaWin::Copy() {
//Platform::DebugPrintf("Copy\n");
if (currentPos != anchor) {
- ::OpenClipboard(wMain.GetID());
+ ::OpenClipboard(MainHWND());
::EmptyClipboard();
CopySelTextToClipboard();
if (selType == selRectangle) {
@@ -920,7 +931,7 @@ void ScintillaWin::Paste() {
pdoc->BeginUndoAction();
int selStart = SelectionStart();
ClearSelection();
- ::OpenClipboard(wMain.GetID());
+ ::OpenClipboard(MainHWND());
bool isRectangular = ::IsClipboardFormatAvailable(cfColumnSelect);
HGLOBAL hmemUSelection = 0;
if (IsUnicodeMode()) {
@@ -977,19 +988,22 @@ void ScintillaWin::CreateCallTipWindow(PRectangle) {
#ifdef TOTAL_CONTROL
ct.wCallTip = ::CreateWindow(callClassName, "ACallTip",
WS_VISIBLE | WS_CHILD, 100, 100, 150, 20,
- wMain.GetID(), reinterpret_cast<HMENU>(idCallTip), wMain.GetInstance(), &ct);
+ MainHWND(), reinterpret_cast<HMENU>(idCallTip),
+ reinterpret_cast<HINSTANCE>(::GetWindowLong(MainHWND(),GWL_HINSTANCE)),
+ &ct);
ct.wDraw = ct.wCallTip;
#endif
}
void ScintillaWin::AddToPopUp(const char *label, int cmd, bool enabled) {
#ifdef TOTAL_CONTROL
+ HMENU hmenuPopup = reinterpret_cast<HMENU>(popup.GetID());
if (!label[0])
- ::AppendMenu(popup.GetID(), MF_SEPARATOR, 0, "");
+ ::AppendMenu(hmenuPopup, MF_SEPARATOR, 0, "");
else if (enabled)
- ::AppendMenu(popup.GetID(), MF_STRING, cmd, label);
+ ::AppendMenu(hmenuPopup, MF_STRING, cmd, label);
else
- ::AppendMenu(popup.GetID(), MF_STRING | MF_DISABLED | MF_GRAYED, cmd, label);
+ ::AppendMenu(hmenuPopup, MF_STRING | MF_DISABLED | MF_GRAYED, cmd, label);
#endif
}
@@ -1310,7 +1324,7 @@ void ScintillaWin::ImeStartComposition() {
#ifndef __DMC__
if (caret.active) {
// Move IME Window to current caret position
- HIMC hIMC = ::ImmGetContext(wMain.GetID());
+ HIMC hIMC = ::ImmGetContext(MainHWND());
Point pos = LocationFromPosition(currentPos);
COMPOSITIONFORM CompForm;
CompForm.dwStyle = CFS_POINT;
@@ -1342,7 +1356,7 @@ void ScintillaWin::ImeStartComposition() {
::ImmSetCompositionFont(hIMC, &lf);
}
- ::ImmReleaseContext(wMain.GetID(), hIMC);
+ ::ImmReleaseContext(MainHWND(), hIMC);
// Caret is displayed in IME window. So, caret in Scintilla is useless.
DropCaret();
}
@@ -1418,7 +1432,7 @@ void ScintillaWin::ScrollMessage(WPARAM wParam) {
sci.cbSize = sizeof(sci);
sci.fMask = SIF_ALL;
- ::GetScrollInfo(wMain.GetID(), SB_VERT, &sci);
+ ::GetScrollInfo(MainHWND(), SB_VERT, &sci);
//Platform::DebugPrintf("ScrollInfo %d mask=%x min=%d max=%d page=%d pos=%d track=%d\n", b,sci.fMask,
//sci.nMin, sci.nMax, sci.nPage, sci.nPos, sci.nTrackPos);
@@ -1478,13 +1492,13 @@ void ScintillaWin::HorizontalScrollMessage(WPARAM wParam) {
void ScintillaWin::RealizeWindowPalette(bool inBackGround) {
RefreshStyleData();
Surface surfaceWindow;
- HDC hdc = ::GetDC(wMain.GetID());
+ HDC hdc = ::GetDC(MainHWND());
surfaceWindow.Init(hdc);
int changes = surfaceWindow.SetPalette(&palette, inBackGround);
if (changes > 0)
Redraw();
surfaceWindow.Release();
- ::ReleaseDC(wMain.GetID(), hdc);
+ ::ReleaseDC(MainHWND(), hdc);
}
/**
@@ -1495,13 +1509,13 @@ void ScintillaWin::FullPaint() {
paintState = painting;
rcPaint = GetTextRectangle();
paintingAllText = true;
- HDC hdc = ::GetDC(wMain.GetID());
+ HDC hdc = ::GetDC(MainHWND());
Surface surfaceWindow;
surfaceWindow.Init(hdc);
surfaceWindow.SetUnicodeMode(IsUnicodeMode());
Paint(&surfaceWindow, rcPaint);
surfaceWindow.Release();
- ::ReleaseDC(wMain.GetID(), hdc);
+ ::ReleaseDC(MainHWND(), hdc);
paintState = notPainting;
}
@@ -1577,7 +1591,7 @@ STDMETHODIMP ScintillaWin::DragOver(DWORD grfKeyState, POINTL pt, PDWORD pdwEffe
*pdwEffect = DROPEFFECT_COPY;
// Update the cursor.
POINT rpt = {pt.x, pt.y};
- ::ScreenToClient(wMain.GetID(), &rpt);
+ ::ScreenToClient(MainHWND(), &rpt);
SetDragPosition(PositionFromLocation(Point(rpt.x, rpt.y)));
return S_OK;
@@ -1643,7 +1657,7 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState,
HRESULT hrRectangular = pIDataSource->QueryGetData(&fmtr);
POINT rpt = {pt.x, pt.y};
- ::ScreenToClient(wMain.GetID(), &rpt);
+ ::ScreenToClient(MainHWND(), &rpt);
int movePos = PositionFromLocation(Point(rpt.x, rpt.y));
DropAt(movePos, data, *pdwEffect == DROPEFFECT_MOVE, hrRectangular == S_OK);
@@ -1846,8 +1860,8 @@ sptr_t PASCAL ScintillaWin::SWndProc(
}
// This function is externally visible so it can be called from container when building statically
-void Scintilla_RegisterClasses(HINSTANCE hInstance) {
- ScintillaWin::Register(hInstance);
+void Scintilla_RegisterClasses(void *hInstance) {
+ ScintillaWin::Register(reinterpret_cast<HINSTANCE>(hInstance));
}
#ifndef STATIC_BUILD