aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gtk/PlatGTK.cxx15
-rw-r--r--include/Platform.h14
-rw-r--r--src/ScintillaBase.cxx6
-rw-r--r--src/ScintillaBase.h13
4 files changed, 41 insertions, 7 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index 3e2d10f99..47e32118c 100644
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -670,7 +670,8 @@ void Window::SetTitle(const char *s) {
gtk_window_set_title(GTK_WINDOW(id), s);
}
-ListBox::ListBox() : list(0), current(0), desiredVisibleRows(5), maxItemCharacters(0) {}
+ListBox::ListBox() : list(0), current(0), desiredVisibleRows(5), maxItemCharacters(0),
+ doubleClickAction(NULL), doubleClickActionData(NULL) {}
ListBox::~ListBox() {}
@@ -680,6 +681,16 @@ static void SelectionAC(GtkWidget *, gint row, gint,
*pi = row;
}
+static gboolean ButtonPress(GtkWidget *, GdkEventButton* ev, gpointer p) {
+ ListBox* lb = reinterpret_cast<ListBox*>(p);
+ if (ev->type == GDK_2BUTTON_PRESS && lb->doubleClickAction != NULL) {
+ lb->doubleClickAction(lb->doubleClickActionData);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
void ListBox::Create(Window &, int) {
id = gtk_window_new(GTK_WINDOW_POPUP);
@@ -703,6 +714,8 @@ void ListBox::Create(Window &, int) {
gtk_clist_set_selection_mode(GTK_CLIST(list), GTK_SELECTION_BROWSE);
gtk_signal_connect(GTK_OBJECT(list), "select_row",
GTK_SIGNAL_FUNC(SelectionAC), &current);
+ gtk_signal_connect(GTK_OBJECT(list), "button_press_event",
+ GTK_SIGNAL_FUNC(ButtonPress), this);
gtk_clist_set_shadow_type(GTK_CLIST(list), GTK_SHADOW_NONE);
gtk_widget_realize(id);
diff --git a/include/Platform.h b/include/Platform.h
index 74de63174..6d37799e7 100644
--- a/include/Platform.h
+++ b/include/Platform.h
@@ -333,6 +333,11 @@ public:
};
/**
+ * A simple callback action passing one piece of untyped user data.
+ */
+typedef void (*CallBackAction)(void*);
+
+/**
* Class to hide the details of window manipulation.
* Does not own the window which will normally have a longer life than this object.
*/
@@ -373,7 +378,9 @@ public:
/**
* Listbox management.
*/
+
class ListBox : public Window {
+private:
#if PLAT_GTK
WindowID list;
WindowID scroller;
@@ -383,6 +390,9 @@ class ListBox : public Window {
unsigned int maxItemCharacters;
unsigned int aveCharWidth;
public:
+ CallBackAction doubleClickAction;
+ void *doubleClickActionData;
+public:
ListBox();
virtual ~ListBox();
void Create(Window &parent, int ctrlID);
@@ -398,6 +408,10 @@ public:
int Find(const char *prefix);
void GetValue(int n, char *value, int len);
void Sort();
+ void SetDoubleClickAction(CallBackAction action, void *data) {
+ doubleClickAction = action;
+ doubleClickActionData = data;
+ }
};
/**
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx
index 75a8ffffa..f938a1f4d 100644
--- a/src/ScintillaBase.cxx
+++ b/src/ScintillaBase.cxx
@@ -173,6 +173,11 @@ int ScintillaBase::KeyCommand(unsigned int iMessage) {
return Editor::KeyCommand(iMessage);
}
+void ScintillaBase::AutoCompleteDoubleClick(void* p) {
+ ScintillaBase* sci = reinterpret_cast<ScintillaBase*>(p);
+ sci->AutoCompleteCompleted();
+}
+
void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
//Platform::DebugPrintf("AutoComplete %s\n", list);
ct.CallTipCancel();
@@ -222,6 +227,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
ac.lb.SetPositionRelative(rcac, wMain);
ac.lb.SetFont(vs.styles[STYLE_DEFAULT].font);
ac.lb.SetAverageCharWidth(vs.styles[STYLE_DEFAULT].aveCharWidth);
+ ac.lb.SetDoubleClickAction(AutoCompleteDoubleClick, this);
ac.SetList(list);
diff --git a/src/ScintillaBase.h b/src/ScintillaBase.h
index ca4695355..375cc9a74 100644
--- a/src/ScintillaBase.h
+++ b/src/ScintillaBase.h
@@ -20,7 +20,7 @@ protected:
enum {
idCallTip=1,
idAutoComplete=2,
-
+
idcmdUndo=10,
idcmdRedo=11,
idcmdCut=12,
@@ -38,7 +38,7 @@ protected:
int listType; ///< 0 is an autocomplete list
SString userListSelected; ///< Receives listbox selected string
-
+
#ifdef SCI_LEXER
int lexLanguage;
LexerModule *lexCurrent;
@@ -56,24 +56,25 @@ protected:
virtual void Finalise() = 0;
virtual void RefreshColourPalette(Palette &pal, bool want);
-
+
virtual void AddCharUTF(char *s, unsigned int len);
void Command(int cmdId);
virtual void CancelModes();
virtual int KeyCommand(unsigned int iMessage);
-
+
void AutoCompleteStart(int lenEntered, const char *list);
void AutoCompleteCancel();
void AutoCompleteMove(int delta);
void AutoCompleteChanged(char ch=0);
void AutoCompleteCompleted(char fillUp='\0');
void AutoCompleteMoveToCurrentWord();
+ static void AutoCompleteDoubleClick(void* p);
virtual void CreateCallTipWindow(PRectangle rc) = 0;
-
+
virtual void AddToPopUp(const char *label, int cmd=0, bool enabled=true) = 0;
void ContextMenu(Point pt);
-
+
virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
virtual void NotifyStyleToNeeded(int endStyleNeeded);