aboutsummaryrefslogtreecommitdiffhomepage
path: root/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'gtk')
-rw-r--r--gtk/PlatGTK.cxx251
-rw-r--r--gtk/ScintillaGTK.cxx126
2 files changed, 193 insertions, 184 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) {