diff options
Diffstat (limited to 'gtk/ScintillaGTK.cxx')
-rw-r--r-- | gtk/ScintillaGTK.cxx | 522 |
1 files changed, 7 insertions, 515 deletions
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index b53b46691..a0f55fd2b 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -56,9 +56,7 @@ #include "gtk/gtksignal.h" #include "gtk/gtkmarshal.h" -#if GLIB_MAJOR_VERSION >= 2 #include "scintilla-marshal.h" -#endif #ifdef SCI_LEXER #include <glib.h> @@ -66,15 +64,7 @@ #include "ExternalLexer.h" #endif -#define INTERNATIONAL_INPUT - -#if !PLAT_GTK_WIN32 || GTK_MAJOR_VERSION >= 2 -#define USE_CONVERTER -#endif - -#ifdef USE_CONVERTER #include "Converter.h" -#endif #ifdef _MSC_VER // Constant conditional expressions are because of GTK+ headers @@ -87,11 +77,7 @@ #define USE_GTK_CLIPBOARD #endif -#if GLIB_MAJOR_VERSION < 2 -#define OBJECT_CLASS GtkObjectClass -#else #define OBJECT_CLASS GObjectClass -#endif #ifdef SCI_NAMESPACE using namespace Scintilla; @@ -135,17 +121,9 @@ class ScintillaGTK : public ScintillaBase { CLIPFORMAT cfColumnSelect; #endif -#ifdef INTERNATIONAL_INPUT -#if GTK_MAJOR_VERSION < 2 - // Input context used for supporting internationalized key entry - GdkIC *ic; - GdkICAttr *ic_attr; -#else Window wPreedit; Window wPreeditDraw; GtkIMContext *im_context; -#endif -#endif // Wheel mouse support unsigned int linesPerScroll; @@ -245,36 +223,25 @@ private: gint PressThis(GdkEventButton *event); static gint Press(GtkWidget *widget, GdkEventButton *event); static gint MouseRelease(GtkWidget *widget, GdkEventButton *event); -#if PLAT_GTK_WIN32 || (GTK_MAJOR_VERSION >= 2) static gint ScrollEvent(GtkWidget *widget, GdkEventScroll *event); -#endif static gint Motion(GtkWidget *widget, GdkEventMotion *event); gboolean KeyThis(GdkEventKey *event); static gboolean KeyPress(GtkWidget *widget, GdkEventKey *event); static gboolean KeyRelease(GtkWidget *widget, GdkEventKey *event); -#if GTK_MAJOR_VERSION >= 2 gboolean ExposePreeditThis(GtkWidget *widget, GdkEventExpose *ose); static gboolean ExposePreedit(GtkWidget *widget, GdkEventExpose *ose, ScintillaGTK *sciThis); void CommitThis(char *str); static void Commit(GtkIMContext *context, char *str, ScintillaGTK *sciThis); void PreeditChangedThis(); static void PreeditChanged(GtkIMContext *context, ScintillaGTK *sciThis); -#endif static gint StyleSetText(GtkWidget *widget, GtkStyle *previous, void*); static gint RealizeText(GtkWidget *widget, void*); -#if GLIB_MAJOR_VERSION < 2 - static void Destroy(GtkObject *object); -#else static void Destroy(GObject *object); -#endif static void SelectionReceived(GtkWidget *widget, GtkSelectionData *selection_data, guint time); static void SelectionGet(GtkWidget *widget, GtkSelectionData *selection_data, guint info, guint time); static gint SelectionClear(GtkWidget *widget, GdkEventSelection *selection_event); -#if GTK_MAJOR_VERSION < 2 - static gint SelectionNotify(GtkWidget *widget, GdkEventSelection *selection_event); -#endif static void DragBegin(GtkWidget *widget, GdkDragContext *context); gboolean DragMotionThis(GdkDragContext *context, gint x, gint y, guint dragtime); static gboolean DragMotion(GtkWidget *widget, GdkDragContext *context, @@ -309,9 +276,6 @@ enum { }; static gint scintilla_signals[LAST_SIGNAL] = { 0 }; -#if GLIB_MAJOR_VERSION < 2 -static GtkWidgetClass *parent_class = NULL; -#endif enum { TARGET_STRING, @@ -354,14 +318,7 @@ ScintillaGTK::ScintillaGTK(_ScintillaObject *sci_) : scrollBarWidth(30), scrollBarHeight(30), capturedMouse(false), dragWasDropped(false), lastKey(0), rectangularSelectionModifier(SCMOD_CTRL), parentClass(0), -#ifdef INTERNATIONAL_INPUT -#if GTK_MAJOR_VERSION < 2 - ic(NULL), - ic_attr(NULL), -#else im_context(NULL), -#endif -#endif lastWheelMouseDirection(0), wheelMouseIntensity(0), rgnUpdate(0) { @@ -420,65 +377,6 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) { gdk_window_show(widget->window); gdk_cursor_destroy(cursor); widget->style = gtk_style_attach(widget->style, widget->window); -#ifdef INTERNATIONAL_INPUT -#if GTK_MAJOR_VERSION < 2 - if (gdk_im_ready() && (ic_attr = gdk_ic_attr_new()) != NULL) { - gint width, height; - GdkColormap *colormap; - GdkEventMask mask; - GdkICAttr *attr = ic_attr; - GdkICAttributesType attrmask = GDK_IC_ALL_REQ; - GdkIMStyle style; - GdkIMStyle supported_style = (GdkIMStyle) (GDK_IM_PREEDIT_NONE | - GDK_IM_PREEDIT_NOTHING | - GDK_IM_PREEDIT_POSITION | - GDK_IM_STATUS_NONE | - GDK_IM_STATUS_NOTHING); - - if (widget->style && widget->style->font->type != GDK_FONT_FONTSET) - supported_style = (GdkIMStyle) ((int) supported_style & ~GDK_IM_PREEDIT_POSITION); - - attr->style = style = gdk_im_decide_style(supported_style); - attr->client_window = widget->window; - - if ((colormap = gtk_widget_get_colormap (widget)) != gtk_widget_get_default_colormap ()) { - attrmask = (GdkICAttributesType) ((int) attrmask | GDK_IC_PREEDIT_COLORMAP); - attr->preedit_colormap = colormap; - } - - switch (style & GDK_IM_PREEDIT_MASK) { - case GDK_IM_PREEDIT_POSITION: - if (widget->style && widget->style->font->type != GDK_FONT_FONTSET) { - g_warning("over-the-spot style requires fontset"); - break; - } - - attrmask = (GdkICAttributesType) ((int) attrmask | GDK_IC_PREEDIT_POSITION_REQ); - gdk_window_get_size(widget->window, &width, &height); - attr->spot_location.x = 0; - attr->spot_location.y = height; - attr->preedit_area.x = 0; - attr->preedit_area.y = 0; - attr->preedit_area.width = width; - attr->preedit_area.height = height; - attr->preedit_fontset = widget->style->font; - - break; - } - ic = gdk_ic_new(attr, attrmask); - - if (ic == NULL) { - g_warning("Can't create input context."); - } else { - mask = gdk_window_get_events(widget->window); - mask = (GdkEventMask) ((int) mask | gdk_ic_get_events(ic)); - gdk_window_set_events(widget->window, mask); - - if (GTK_WIDGET_HAS_FOCUS(widget)) - gdk_im_begin(ic, widget->window); - } - } -#else wPreedit = gtk_window_new(GTK_WINDOW_POPUP); wPreeditDraw = gtk_drawing_area_new(); GtkWidget *predrw = PWidget(wPreeditDraw); // No code inside the G_OBJECT macro @@ -495,20 +393,11 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) { g_signal_connect(G_OBJECT(im_context), "preedit_changed", G_CALLBACK(PreeditChanged), this); gtk_im_context_set_client_window(im_context, widget->window); -#endif -#endif GtkWidget *widtxt = PWidget(wText); // // No code inside the G_OBJECT macro -#if GLIB_MAJOR_VERSION < 2 - gtk_signal_connect_after(GTK_OBJECT(widtxt), "style_set", - GtkSignalFunc(ScintillaGTK::StyleSetText), NULL); - gtk_signal_connect_after(GTK_OBJECT(widtxt), "realize", - GtkSignalFunc(ScintillaGTK::RealizeText), NULL); -#else g_signal_connect_after(G_OBJECT(widtxt), "style_set", G_CALLBACK(ScintillaGTK::StyleSetText), NULL); g_signal_connect_after(G_OBJECT(widtxt), "realize", G_CALLBACK(ScintillaGTK::RealizeText), NULL); -#endif gtk_widget_realize(widtxt); gtk_widget_realize(PWidget(scrollbarv)); gtk_widget_realize(PWidget(scrollbarh)); @@ -528,23 +417,10 @@ void ScintillaGTK::UnRealizeThis(GtkWidget *widget) { gtk_widget_unrealize(PWidget(wText)); gtk_widget_unrealize(PWidget(scrollbarv)); gtk_widget_unrealize(PWidget(scrollbarh)); -#ifdef INTERNATIONAL_INPUT -#if GTK_MAJOR_VERSION < 2 - if (ic) { - gdk_ic_destroy(ic); - ic = NULL; - } - if (ic_attr) { - gdk_ic_attr_destroy(ic_attr); - ic_attr = NULL; - } -#else gtk_widget_unrealize(PWidget(wPreedit)); gtk_widget_unrealize(PWidget(wPreeditDraw)); g_object_unref(im_context); im_context = NULL; -#endif -#endif if (GTK_WIDGET_CLASS(parentClass)->unrealize) GTK_WIDGET_CLASS(parentClass)->unrealize(widget); @@ -626,18 +502,6 @@ void ScintillaGTK::MainForAll(GtkContainer *container, gboolean include_internal } } -#ifdef INTERNATIONAL_INPUT -#if GTK_MAJOR_VERSION < 2 -gint ScintillaGTK::CursorMoved(GtkWidget *widget, int xoffset, int yoffset, ScintillaGTK *sciThis) { - if (GTK_WIDGET_HAS_FOCUS(widget) && gdk_im_ready() && sciThis->ic && - (gdk_ic_get_style(sciThis->ic) & GDK_IM_PREEDIT_POSITION)) { - sciThis->ic_attr->spot_location.x = xoffset; - sciThis->ic_attr->spot_location.y = yoffset; - gdk_ic_set_attr(sciThis->ic, sciThis->ic_attr, GDK_IC_SPOT_LOCATION); - } - return FALSE; -} -#else gint ScintillaGTK::CursorMoved(GtkWidget *, int xoffset, int yoffset, ScintillaGTK *sciThis) { GdkRectangle area; area.x = xoffset; @@ -647,22 +511,11 @@ gint ScintillaGTK::CursorMoved(GtkWidget *, int xoffset, int yoffset, ScintillaG gtk_im_context_set_cursor_location(sciThis->im_context, &area); return FALSE; } -#endif -#else -gint ScintillaGTK::CursorMoved(GtkWidget *, int, int, ScintillaGTK *) { - return FALSE; -} -#endif gint ScintillaGTK::FocusInThis(GtkWidget *widget) { try { GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS); SetFocusState(true); -#ifdef INTERNATIONAL_INPUT -#if GTK_MAJOR_VERSION < 2 - if (ic) - gdk_im_begin(ic, widget->window); -#else if (im_context != NULL) { gchar *str = NULL; gint cursor_pos; @@ -678,8 +531,6 @@ gint ScintillaGTK::FocusInThis(GtkWidget *widget) { g_free(str); gtk_im_context_focus_in(im_context); } -#endif -#endif } catch (...) { errorStatus = SC_STATUS_FAILURE; @@ -697,16 +548,10 @@ gint ScintillaGTK::FocusOutThis(GtkWidget *widget) { GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS); SetFocusState(false); -#ifdef INTERNATIONAL_INPUT -#if GTK_MAJOR_VERSION < 2 - gdk_im_end(); -#else if (PWidget(wPreedit) != NULL) gtk_widget_hide(PWidget(wPreedit)); if (im_context != NULL) gtk_im_context_focus_out(im_context); -#endif -#endif } catch (...) { errorStatus = SC_STATUS_FAILURE; @@ -741,19 +586,6 @@ void ScintillaGTK::SizeAllocate(GtkWidget *widget, GtkAllocation *allocation) { sciThis->Resize(allocation->width, allocation->height); -#ifdef INTERNATIONAL_INPUT -#if GTK_MAJOR_VERSION < 2 - if (sciThis->ic && (gdk_ic_get_style(sciThis->ic) & GDK_IM_PREEDIT_POSITION)) { - gint width, height; - - gdk_window_get_size(widget->window, &width, &height); - sciThis->ic_attr->preedit_area.width = width; - sciThis->ic_attr->preedit_area.height = height; - - gdk_ic_set_attr(sciThis->ic, sciThis->ic_attr, GDK_IC_PREEDIT_AREA); - } -#endif -#endif } catch (...) { sciThis->errorStatus = SC_STATUS_FAILURE; } @@ -782,43 +614,26 @@ void ScintillaGTK::Initialise() { gtk_widget_set_parent(PWidget(wText), PWidget(wMain)); GtkWidget *widtxt = PWidget(wText); // No code inside the G_OBJECT macro gtk_widget_show(widtxt); -#if GLIB_MAJOR_VERSION < 2 - gtk_signal_connect(GTK_OBJECT(widtxt), "expose_event", - GtkSignalFunc(ScintillaGTK::ExposeText), this); -#else g_signal_connect(G_OBJECT(widtxt), "expose_event", G_CALLBACK(ScintillaGTK::ExposeText), this); -#endif gtk_widget_set_events(widtxt, GDK_EXPOSURE_MASK); -#if GTK_MAJOR_VERSION >= 2 // Avoid background drawing flash gtk_widget_set_double_buffered(widtxt, FALSE); -#endif gtk_drawing_area_size(GTK_DRAWING_AREA(widtxt), 100,100); 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(PWidget(scrollbarv), GTK_CAN_FOCUS); -#if GLIB_MAJOR_VERSION < 2 - gtk_signal_connect(adjustmentv, "value_changed", - GtkSignalFunc(ScrollSignal), this); -#else g_signal_connect(G_OBJECT(adjustmentv), "value_changed", G_CALLBACK(ScrollSignal), this); -#endif 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(PWidget(scrollbarh), GTK_CAN_FOCUS); -#if GLIB_MAJOR_VERSION < 2 - gtk_signal_connect(adjustmenth, "value_changed", - GtkSignalFunc(ScrollHSignal), this); -#else g_signal_connect(G_OBJECT(adjustmenth), "value_changed", G_CALLBACK(ScrollHSignal), this); -#endif gtk_widget_set_parent(PWidget(scrollbarh), PWidget(wMain)); gtk_widget_show(PWidget(scrollbarh)); @@ -836,7 +651,6 @@ void ScintillaGTK::Initialise() { GTK_DEST_DEFAULT_ALL, clipboardPasteTargets, nClipboardPasteTargets, static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE)); -#if GLIB_MAJOR_VERSION >= 2 // Set caret period based on GTK settings gboolean blinkOn = false; if (g_object_class_find_property(G_OBJECT_GET_CLASS( @@ -854,7 +668,6 @@ void ScintillaGTK::Initialise() { } else { caret.period = 0; } -#endif SetTicking(true); } @@ -872,12 +685,8 @@ void ScintillaGTK::DisplayCursor(Window::Cursor c) { } bool ScintillaGTK::DragThreshold(Point ptStart, Point ptNow) { -#if GTK_MAJOR_VERSION < 2 - return Editor::DragThreshold(ptStart, ptNow); -#else return gtk_drag_check_threshold(GTK_WIDGET(PWidget(wMain)), ptStart.x, ptStart.y, ptNow.x, ptNow.y); -#endif } void ScintillaGTK::StartDrag() { @@ -891,7 +700,6 @@ void ScintillaGTK::StartDrag() { reinterpret_cast<GdkEvent *>(&evbtn)); } -#ifdef USE_CONVERTER static char *ConvertText(int *lenResult, char *s, size_t len, const char *charSetDest, const char *charSetSource, bool transliterations) { // s is not const because of different versions of iconv disagreeing about const @@ -924,7 +732,6 @@ fprintf(stderr, "Can not iconv %s %s\n", charSetDest, charSetSource); } return destForm; } -#endif // Returns the target converted to UTF8. // Return the length in bytes. @@ -936,7 +743,6 @@ int ScintillaGTK::TargetAsUTF8(char *text) { } } else { // Need to convert -#ifdef USE_CONVERTER const char *charSetBuffer = CharacterSetID(); if (*charSetBuffer) { //~ fprintf(stderr, "AsUTF8 %s %d %0d-%0d\n", charSetBuffer, targetLength, targetStart, targetEnd); @@ -957,10 +763,6 @@ int ScintillaGTK::TargetAsUTF8(char *text) { pdoc->GetCharRange(text, targetStart, targetLength); } } -#else - // Fail - return 0; -#endif } //~ fprintf(stderr, "Length = %d bytes\n", targetLength); return targetLength; @@ -977,14 +779,11 @@ int ScintillaGTK::EncodedFromUTF8(char *utf8, char *encoded) { return inputLength; } else { // Need to convert -#ifdef USE_CONVERTER const char *charSetBuffer = CharacterSetID(); if (*charSetBuffer) { -//~ fprintf(stderr, "Encode %s %d\n", charSetBuffer, inputLength); int outLength = 0; char *tmpEncoded = ConvertText(&outLength, utf8, inputLength, charSetBuffer, "UTF-8", true); if (tmpEncoded) { -//~ fprintf(stderr, " \"%s\"\n", tmpEncoded); if (encoded) { memcpy(encoded, tmpEncoded, outLength); } @@ -997,7 +796,6 @@ int ScintillaGTK::EncodedFromUTF8(char *utf8, char *encoded) { } return inputLength; } -#endif } // Fail return 0; @@ -1123,25 +921,7 @@ bool ScintillaGTK::PaintContains(PRectangle rc) { // Redraw all of text area. This paint will not be abandoned. void ScintillaGTK::FullPaint() { -#if GTK_MAJOR_VERSION < 2 - paintState = painting; - rcPaint = GetClientRectangle(); - //Platform::DebugPrintf("ScintillaGTK::FullPaint %0d,%0d %0d,%0d\n", - // rcPaint.left, rcPaint.top, rcPaint.right, rcPaint.bottom); - paintingAllText = true; - if ((PWidget(wText))->window) { - Surface *sw = Surface::Allocate(); - if (sw) { - sw->Init(PWidget(wText)->window, PWidget(wText)); - Paint(sw, rcPaint); - sw->Release(); - delete sw; - } - } - paintState = notPainting; -#else wText.InvalidateAll(); -#endif } PRectangle ScintillaGTK::GetClientRectangle() { @@ -1186,50 +966,8 @@ void ScintillaGTK::ScrollText(int linesToMove) { // rc.left, rc.top, rc.right, rc.bottom); GtkWidget *wi = PWidget(wText); -#if GTK_MAJOR_VERSION < 2 - PRectangle rc = GetClientRectangle(); - GdkGC *gc = gdk_gc_new(wi->window); - - // Set up gc so we get GraphicsExposures from gdk_draw_pixmap - // which calls XCopyArea - gdk_gc_set_exposures(gc, TRUE); - - // Redraw exposed bit : scrolling upwards - if (diff > 0) { - gdk_draw_pixmap(wi->window, - gc, wi->window, - 0, diff, - 0, 0, - rc.Width()-1, rc.Height() - diff); - SyncPaint(PRectangle(0, rc.Height() - diff, - rc.Width(), rc.Height()+1)); - - // Redraw exposed bit : scrolling downwards - } else { - gdk_draw_pixmap(wi->window, - gc, wi->window, - 0, 0, - 0, -diff, - rc.Width()-1, rc.Height() + diff); - SyncPaint(PRectangle(0, 0, rc.Width(), -diff)); - } - - // Look for any graphics expose - GdkEvent* event; - while ((event = gdk_event_get_graphics_expose(wi->window)) != NULL) { - gtk_widget_event(wi, event); - if (event->expose.count == 0) { - gdk_event_free(event); - break; - } - gdk_event_free(event); - } - - gdk_gc_unref(gc); -#else gdk_window_scroll(wi->window, 0, -diff); gdk_window_process_updates(wi->window, FALSE); -#endif } void ScintillaGTK::SetVerticalScrollPos() { @@ -1283,37 +1021,21 @@ void ScintillaGTK::ReconfigureScrollBars() { } void ScintillaGTK::NotifyChange() { -#if GLIB_MAJOR_VERSION < 2 - gtk_signal_emit(GTK_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL], - Platform::LongFromTwoShorts(GetCtrlID(), SCEN_CHANGE), PWidget(wMain)); -#else g_signal_emit(G_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL], 0, Platform::LongFromTwoShorts(GetCtrlID(), SCEN_CHANGE), PWidget(wMain)); -#endif } void ScintillaGTK::NotifyFocus(bool focus) { -#if GLIB_MAJOR_VERSION < 2 - gtk_signal_emit(GTK_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL], - Platform::LongFromTwoShorts - (GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), PWidget(wMain)); -#else g_signal_emit(G_OBJECT(sci), scintilla_signals[COMMAND_SIGNAL], 0, Platform::LongFromTwoShorts (GetCtrlID(), focus ? SCEN_SETFOCUS : SCEN_KILLFOCUS), PWidget(wMain)); -#endif } void ScintillaGTK::NotifyParent(SCNotification scn) { scn.nmhdr.hwndFrom = PWidget(wMain); scn.nmhdr.idFrom = GetCtrlID(); -#if GLIB_MAJOR_VERSION < 2 - gtk_signal_emit(GTK_OBJECT(sci), scintilla_signals[NOTIFY_SIGNAL], - GetCtrlID(), &scn); -#else g_signal_emit(G_OBJECT(sci), scintilla_signals[NOTIFY_SIGNAL], 0, GetCtrlID(), &scn); -#endif } void ScintillaGTK::NotifyKey(int key, int modifiers) { @@ -1398,9 +1120,6 @@ CaseFolder *ScintillaGTK::CaseFolderForEncoding() { } std::string ScintillaGTK::CaseMapString(const std::string &s, int caseMapping) { -#if GTK_MAJOR_VERSION < 2 - return Editor::CaseMapString(s, caseMapping); -#else if (s.size() == 0) return std::string(); @@ -1444,7 +1163,6 @@ std::string ScintillaGTK::CaseMapString(const std::string &s, int caseMapping) { delete []needsFree1; delete []needsFree2; return ret; -#endif } int ScintillaGTK::KeyDefault(int key, int modifiers) { @@ -1512,17 +1230,10 @@ void ScintillaGTK::CreateCallTipWindow(PRectangle rc) { ct.wDraw = gtk_drawing_area_new(); GtkWidget *widcdrw = PWidget(ct.wDraw); // // No code inside the G_OBJECT macro gtk_container_add(GTK_CONTAINER(PWidget(ct.wCallTip)), widcdrw); -#if GLIB_MAJOR_VERSION < 2 - gtk_signal_connect(GTK_OBJECT(widcdrw), "expose_event", - GtkSignalFunc(ScintillaGTK::ExposeCT), &ct); - gtk_signal_connect(GTK_OBJECT(widcdrw), "button_press_event", - GtkSignalFunc(ScintillaGTK::PressCT), static_cast<void *>(this)); -#else g_signal_connect(G_OBJECT(widcdrw), "expose_event", G_CALLBACK(ScintillaGTK::ExposeCT), &ct); g_signal_connect(G_OBJECT(widcdrw), "button_press_event", G_CALLBACK(ScintillaGTK::PressCT), static_cast<void *>(this)); -#endif gtk_widget_set_events(widcdrw, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK); } @@ -1544,9 +1255,7 @@ void ScintillaGTK::AddToPopUp(const char *label, int cmd, bool enabled) { menuSig, cmd, const_cast<gchar *>(label[0] ? "<Item>" : "<Separator>"), -#if GTK_MAJOR_VERSION >= 2 NULL -#endif }; gtk_item_factory_create_item(GTK_ITEM_FACTORY(popup.GetID()), &itemEntry, this, 1); @@ -1623,16 +1332,13 @@ void ScintillaGTK::GetGtkSelectionText(GtkSelectionData *selectionData, Selectio } else { // UTF-8 dest = Document::TransformLineEnds(&len, data, len, pdoc->eolMode); selText.Set(dest, len, SC_CP_UTF8, 0, isRectangular, false); -#ifdef USE_CONVERTER const char *charSetBuffer = CharacterSetID(); if (!IsUnicodeMode() && *charSetBuffer) { -//fprintf(stderr, "Convert to locale %s\n", CharacterSetID()); - // Convert to locale - dest = ConvertText(&len, selText.s, selText.len, charSetBuffer, "UTF-8", true); - selText.Set(dest, len, pdoc->dbcsCodePage, - vs.styles[STYLE_DEFAULT].characterSet, selText.rectangular, false); + // Convert to locale + dest = ConvertText(&len, selText.s, selText.len, charSetBuffer, "UTF-8", true); + selText.Set(dest, len, pdoc->dbcsCodePage, + vs.styles[STYLE_DEFAULT].characterSet, selText.rectangular, false); } -#endif } } @@ -1710,7 +1416,6 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se } #endif -#if GTK_MAJOR_VERSION >= 2 // Convert text to utf8 if it isn't already SelectionText *converted = 0; if ((text->codePage != SC_CP_UTF8) && (info == TARGET_UTF8_STRING)) { @@ -1747,64 +1452,6 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se } delete converted; -#else /* Gtk 1 */ - char *selBuffer = text->s; - - char *tmputf = 0; - if ((info == TARGET_UTF8_STRING) || (info == TARGET_STRING)) { - int len = strlen(selBuffer); -#ifdef USE_CONVERTER - // Possible character set conversion - const char *charSetBuffer = ::CharacterSetID(text->characterSet); - if (info == TARGET_UTF8_STRING) { - //fprintf(stderr, "Copy to clipboard as UTF-8\n"); - if (text->codePage != SC_CP_UTF8) { - // Convert to UTF-8 - //fprintf(stderr, "Convert to UTF-8 from %s\n", charSetBuffer); - tmputf = ConvertText(&len, selBuffer, len, "UTF-8", charSetBuffer, false); - selBuffer = tmputf; - } - } else if (info == TARGET_STRING) { - if (text->codePage == SC_CP_UTF8) { - //fprintf(stderr, "Convert to locale %s\n", charSetBuffer); - // Convert to locale - tmputf = ConvertText(&len, selBuffer, len, charSetBuffer, "UTF-8", true); - selBuffer = tmputf; - } - } -#endif - - // Here is a somewhat evil kludge. - // As I can not work out how to store data on the clipboard in multiple formats - // and need some way to mark the clipping as being stream or rectangular, - // the terminating \0 is included in the length for rectangular clippings. - // All other tested aplications behave benignly by ignoring the \0. - // The #if is here because on Windows cfColumnSelect clip entry is used - // instead as standard indicator of rectangularness (so no need to kludge) -#if PLAT_GTK_WIN32 == 0 - if (text->rectangular) - len++; -#endif - gtk_selection_data_set(selection_data, - (info == TARGET_STRING) ? - static_cast<GdkAtom>(GDK_SELECTION_TYPE_STRING) : atomUTF8, - 8, reinterpret_cast<unsigned char *>(selBuffer), - len); - } else if ((info == TARGET_TEXT) || (info == TARGET_COMPOUND_TEXT)) { - guchar *text; - GdkAtom encoding; - gint format; - gint new_length; - - gdk_string_to_compound_text(reinterpret_cast<char *>(selBuffer), - &encoding, &format, &text, &new_length); - gtk_selection_data_set(selection_data, encoding, format, text, new_length); - gdk_free_compound_text(text); - } - - delete []tmputf; -#endif /* Gtk >= 2 */ - #if PLAT_GTK_WIN32 delete newline_normalized; #endif @@ -1996,11 +1643,7 @@ gint ScintillaGTK::PressThis(GdkEventButton *event) { } catch (...) { errorStatus = SC_STATUS_FAILURE; } -#if GTK_MAJOR_VERSION >= 2 return TRUE; -#else - return FALSE; -#endif } gint ScintillaGTK::Press(GtkWidget *widget, GdkEventButton *event) { @@ -2036,7 +1679,6 @@ gint ScintillaGTK::MouseRelease(GtkWidget *widget, GdkEventButton *event) { // win32gtk and GTK >= 2 use SCROLL_* events instead of passing the // button4/5/6/7 events to the GTK app -#if PLAT_GTK_WIN32 || (GTK_MAJOR_VERSION >= 2) gint ScintillaGTK::ScrollEvent(GtkWidget *widget, GdkEventScroll *event) { ScintillaGTK *sciThis = ScintillaFromWidget(widget); @@ -2113,7 +1755,6 @@ gint ScintillaGTK::ScrollEvent(GtkWidget *widget, } return FALSE; } -#endif gint ScintillaGTK::Motion(GtkWidget *widget, GdkEventMotion *event) { ScintillaGTK *sciThis = ScintillaFromWidget(widget); @@ -2218,11 +1859,9 @@ gboolean ScintillaGTK::KeyThis(GdkEventKey *event) { try { //fprintf(stderr, "SC-key: %d %x [%s]\n", // event->keyval, event->state, (event->length > 0) ? event->string : "empty"); -#if GTK_MAJOR_VERSION >= 2 if (gtk_im_context_filter_keypress(im_context, event)) { return 1; } -#endif if (!event->keyval) { return true; } @@ -2239,10 +1878,6 @@ gboolean ScintillaGTK::KeyThis(GdkEventKey *event) { // This will have to change for Unicode else if (key >= 0xFE00) key = KeyTranslate(key); -#if GTK_MAJOR_VERSION < 2 - else if (!IsUnicodeMode() && (key >= 0x100) && (key < 0x1000)) - key &= 0xff; -#endif bool consumed = false; bool added = KeyDown(key, shift, ctrl, alt, &consumed) != 0; @@ -2272,7 +1907,6 @@ gboolean ScintillaGTK::KeyRelease(GtkWidget *, GdkEventKey * /*event*/) { return FALSE; } -#if GTK_MAJOR_VERSION >= 2 gboolean ScintillaGTK::ExposePreeditThis(GtkWidget *widget, GdkEventExpose *ose) { try { gchar *str; @@ -2388,7 +2022,6 @@ void ScintillaGTK::PreeditChangedThis() { void ScintillaGTK::PreeditChanged(GtkIMContext *, ScintillaGTK *sciThis) { sciThis->PreeditChangedThis(); } -#endif gint ScintillaGTK::StyleSetText(GtkWidget *widget, GtkStyle *, void*) { if (widget->window != NULL) @@ -2402,12 +2035,7 @@ gint ScintillaGTK::RealizeText(GtkWidget *widget, void*) { return FALSE; } -#if GLIB_MAJOR_VERSION < 2 -void ScintillaGTK::Destroy(GtkObject *object) -#else -void ScintillaGTK::Destroy(GObject *object) -#endif -{ +void ScintillaGTK::Destroy(GObject *object) { try { ScintillaObject *scio = reinterpret_cast<ScintillaObject *>(object); // This avoids a double destruction @@ -2417,13 +2045,6 @@ void ScintillaGTK::Destroy(GObject *object) //Platform::DebugPrintf("Destroying %x %x\n", sciThis, object); sciThis->Finalise(); -#if GLIB_MAJOR_VERSION < 2 - if (GTK_OBJECT_CLASS(parent_class)->destroy) - (* GTK_OBJECT_CLASS(parent_class)->destroy)(object); -#else - // IS ANYTHING NEEDED ? -#endif - delete sciThis; scio->pscin = 0; } catch (...) { @@ -2451,13 +2072,11 @@ void ScintillaGTK::Draw(GtkWidget *widget, GdkRectangle *area) { DrawChild(PWidget(sciThis->scrollbarv), area); } -#ifdef INTERNATIONAL_INPUT Point pt = sciThis->PointMainCaret(); pt.y += sciThis->vs.lineHeight - 2; if (pt.x < 0) pt.x = 0; if (pt.y < 0) pt.y = 0; CursorMoved(widget, pt.x, pt.y, sciThis); -#endif } catch (...) { sciThis->errorStatus = SC_STATUS_FAILURE; } @@ -2473,9 +2092,7 @@ gint ScintillaGTK::ExposeTextThis(GtkWidget * /*widget*/, GdkEventExpose *ose) { rcPaint.bottom = ose->area.y + ose->area.height; PLATFORM_ASSERT(rgnUpdate == NULL); -#if GTK_MAJOR_VERSION >= 2 rgnUpdate = gdk_region_copy(ose->region); -#endif PRectangle rcClient = GetClientRectangle(); paintingAllText = rcPaint.Contains(rcClient); Surface *surfaceWindow = Surface::Allocate(); @@ -2518,51 +2135,11 @@ gint ScintillaGTK::Expose(GtkWidget *, GdkEventExpose *ose) { //fprintf(stderr, "Expose %0d,%0d %0d,%0d\n", //ose->area.x, ose->area.y, ose->area.width, ose->area.height); -#if GTK_MAJOR_VERSION < 2 - - paintState = painting; - - rcPaint.left = ose->area.x; - rcPaint.top = ose->area.y; - rcPaint.right = ose->area.x + ose->area.width; - rcPaint.bottom = ose->area.y + ose->area.height; - - PRectangle rcClient = GetClientRectangle(); - paintingAllText = rcPaint.Contains(rcClient); - Surface *surfaceWindow = Surface::Allocate(); - if (surfaceWindow) { - surfaceWindow->Init(PWidget(wMain)->window, PWidget(wMain)); - - // Fill the corner between the scrollbars - if (verticalScrollBarVisible) { - if (horizontalScrollBarVisible && (wrapState == eWrapNone)) { - PRectangle rcCorner = wMain.GetClientPosition(); - rcCorner.left = rcCorner.right - scrollBarWidth + 1; - rcCorner.top = rcCorner.bottom - scrollBarHeight + 1; - //fprintf(stderr, "Corner %0d,%0d %0d,%0d\n", - //rcCorner.left, rcCorner.top, rcCorner.right, rcCorner.bottom); - surfaceWindow->FillRectangle(rcCorner, - vs.styles[STYLE_LINENUMBER].back.allocated); - } - } - - //Paint(surfaceWindow, rcPaint); - surfaceWindow->Release(); - delete surfaceWindow; - } - if (paintState == paintAbandoned) { - // Painting area was insufficient to cover new styling or brace highlight positions - FullPaint(); - } - paintState = notPainting; - -#else - // For GTK+ 2, the text is painted in ExposeText + // The text is painted in ExposeText gtk_container_propagate_expose( GTK_CONTAINER(PWidget(wMain)), PWidget(scrollbarh), ose); gtk_container_propagate_expose( GTK_CONTAINER(PWidget(wMain)), PWidget(scrollbarv), ose); -#endif } catch (...) { errorStatus = SC_STATUS_FAILURE; @@ -2621,13 +2198,6 @@ gint ScintillaGTK::SelectionClear(GtkWidget *widget, GdkEventSelection *selectio return gtk_selection_clear(widget, selection_event); } -#if GTK_MAJOR_VERSION < 2 -gint ScintillaGTK::SelectionNotify(GtkWidget *widget, GdkEventSelection *selection_event) { - //Platform::DebugPrintf("Selection notify\n"); - return gtk_selection_notify(widget, selection_event); -} -#endif - void ScintillaGTK::DragBegin(GtkWidget *, GdkDragContext *) { //Platform::DebugPrintf("DragBegin\n"); } @@ -2770,11 +2340,7 @@ gint ScintillaGTK::PressCT(GtkWidget *widget, GdkEventButton *event, ScintillaGT sciThis->CallTipClick(); } catch (...) { } -#if GTK_MAJOR_VERSION >= 2 return TRUE; -#else - return FALSE; -#endif } gint ScintillaGTK::ExposeCT(GtkWidget *widget, GdkEventExpose * /*ose*/, CallTip *ctip) { @@ -2810,32 +2376,6 @@ static void scintilla_init(ScintillaObject *sci); extern void Platform_Initialise(); extern void Platform_Finalise(); -#if GLIB_MAJOR_VERSION < 2 -GtkType scintilla_get_type() { - static GtkType scintilla_type = 0; - try { - - if (!scintilla_type) { - Platform_Initialise(); - static GtkTypeInfo scintilla_info = { - "Scintilla", - sizeof (ScintillaObject), - sizeof (ScintillaClass), - (GtkClassInitFunc) scintilla_class_init, - (GtkObjectInitFunc) scintilla_init, - (gpointer) NULL, - (gpointer) NULL, - 0 - }; - - scintilla_type = gtk_type_unique(gtk_container_get_type(), &scintilla_info); - } - - } catch (...) { - } - return scintilla_type; -} -#else GType scintilla_get_type() { static GType scintilla_type = 0; try { @@ -2865,12 +2405,9 @@ GType scintilla_get_type() { } return scintilla_type; } -#endif void ScintillaGTK::ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_class, GtkContainerClass *container_class) { -#if GLIB_MAJOR_VERSION >= 2 Platform_Initialise(); -#endif atomClipboard = gdk_atom_intern("CLIPBOARD", FALSE); atomUTF8 = gdk_atom_intern("UTF8_STRING", FALSE); atomString = GDK_SELECTION_TYPE_STRING; @@ -2881,23 +2418,14 @@ void ScintillaGTK::ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_ // of the signal handlers here (those that currently attached to wDraw // in Initialise() may require coordinate translation?) -#if GLIB_MAJOR_VERSION < 2 - object_class->destroy = Destroy; -#else object_class->finalize = Destroy; -#endif widget_class->size_request = SizeRequest; widget_class->size_allocate = SizeAllocate; widget_class->expose_event = ExposeMain; -#if GTK_MAJOR_VERSION < 2 - widget_class->draw = Draw; -#endif widget_class->motion_notify_event = Motion; widget_class->button_press_event = Press; widget_class->button_release_event = MouseRelease; -#if PLAT_GTK_WIN32 || (GTK_MAJOR_VERSION >= 2) widget_class->scroll_event = ScrollEvent; -#endif widget_class->key_press_event = KeyPress; widget_class->key_release_event = KeyRelease; widget_class->focus_in_event = FocusIn; @@ -2905,9 +2433,6 @@ void ScintillaGTK::ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_ widget_class->selection_received = SelectionReceived; widget_class->selection_get = SelectionGet; widget_class->selection_clear_event = SelectionClear; -#if GTK_MAJOR_VERSION < 2 - widget_class->selection_notify_event = SelectionNotify; -#endif widget_class->drag_data_received = DragDataReceived; widget_class->drag_motion = DragMotion; @@ -2924,14 +2449,8 @@ void ScintillaGTK::ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_ container_class->forall = MainForAll; } -#if GLIB_MAJOR_VERSION < 2 -#define GTK_CLASS_TYPE(c) (c->type) -#define SIG_MARSHAL gtk_marshal_NONE__INT_POINTER -#define MARSHAL_ARGUMENTS GTK_TYPE_INT, GTK_TYPE_POINTER -#else #define SIG_MARSHAL scintilla_marshal_NONE__INT_POINTER #define MARSHAL_ARGUMENTS G_TYPE_INT, G_TYPE_POINTER -#endif static void scintilla_class_init(ScintillaClass *klass) { try { @@ -2939,29 +2458,6 @@ static void scintilla_class_init(ScintillaClass *klass) { GtkWidgetClass *widget_class = (GtkWidgetClass*) klass; GtkContainerClass *container_class = (GtkContainerClass*) klass; -#if GLIB_MAJOR_VERSION < 2 - parent_class = (GtkWidgetClass*) gtk_type_class(gtk_container_get_type()); - - scintilla_signals[COMMAND_SIGNAL] = gtk_signal_new( - "command", - GTK_RUN_LAST, - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET(ScintillaClass, command), - SIG_MARSHAL, - GTK_TYPE_NONE, - 2, MARSHAL_ARGUMENTS); - - scintilla_signals[NOTIFY_SIGNAL] = gtk_signal_new( - SCINTILLA_NOTIFY, - GTK_RUN_LAST, - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET(ScintillaClass, notify), - SIG_MARSHAL, - GTK_TYPE_NONE, - 2, MARSHAL_ARGUMENTS); - gtk_object_class_add_signals(object_class, - reinterpret_cast<unsigned int *>(scintilla_signals), LAST_SIGNAL); -#else GSignalFlags sigflags = GSignalFlags(G_SIGNAL_ACTION | G_SIGNAL_RUN_LAST); scintilla_signals[COMMAND_SIGNAL] = g_signal_new( "command", @@ -2984,7 +2480,7 @@ static void scintilla_class_init(ScintillaClass *klass) { SIG_MARSHAL, G_TYPE_NONE, 2, MARSHAL_ARGUMENTS); -#endif + klass->command = NULL; klass->notify = NULL; @@ -3002,11 +2498,7 @@ static void scintilla_init(ScintillaObject *sci) { } GtkWidget* scintilla_new() { -#if GLIB_MAJOR_VERSION < 2 - return GTK_WIDGET(gtk_type_new(scintilla_get_type())); -#else return GTK_WIDGET(g_object_new(scintilla_get_type(), NULL)); -#endif } void scintilla_set_id(ScintillaObject *sci, uptr_t id) { |