diff options
author | nyamatongwe <devnull@localhost> | 2000-09-22 11:19:36 +0000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2000-09-22 11:19:36 +0000 |
commit | 80abe6e55f1925c4be355d827351b2c0d8afc3c1 (patch) | |
tree | 02bf721d4bde545e627a6fac3e0e065fbba0a458 | |
parent | 2399b9f209b208a56dd844f31c911a4e049885f8 (diff) | |
download | scintilla-mirror-80abe6e55f1925c4be355d827351b2c0d8afc3c1.tar.gz |
An hasFocus flag was added to separate logical focus from environment
determined focus. hasFocus determines whether the caret is displayed.
-rw-r--r-- | gtk/ScintillaGTK.cxx | 13 | ||||
-rw-r--r-- | src/Editor.cxx | 23 | ||||
-rw-r--r-- | src/Editor.h | 4 | ||||
-rw-r--r-- | win32/ScintillaWin.cxx | 8 |
4 files changed, 32 insertions, 16 deletions
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index a8644e81f..83ba91798 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -260,13 +260,11 @@ gint ScintillaGTK::CursorMoved(GtkWidget *widget, int xoffset, int yoffset, Scin gint ScintillaGTK::FocusIn(GtkWidget *widget, GdkEventFocus * /*event*/, ScintillaGTK *sciThis) { //Platform::DebugPrintf("ScintillaGTK::focus in %x\n", sciThis); GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS); - sciThis->NotifyFocus(true); - sciThis->ShowCaretAtCurrentPosition(); - sciThis->InvalidateCaret(); + sciThis->SetFocusState(true); #ifdef USE_XIM - if (sciThis->ic) - gdk_im_begin (sciThis->ic, widget->window); + if (sciThis->ic) + gdk_im_begin(sciThis->ic, widget->window); #endif return FALSE; @@ -275,11 +273,10 @@ gint ScintillaGTK::FocusIn(GtkWidget *widget, GdkEventFocus * /*event*/, Scintil gint ScintillaGTK::FocusOut(GtkWidget *widget, GdkEventFocus * /*event*/, ScintillaGTK *sciThis) { //Platform::DebugPrintf("ScintillaGTK::focus out %x\n", sciThis); GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS); - sciThis->NotifyFocus(false); - sciThis->DropCaret(); + sciThis->SetFocusState(false); #ifdef USE_XIM - gdk_im_end (); + gdk_im_end(); #endif return FALSE; diff --git a/src/Editor.cxx b/src/Editor.cxx index 698bb65d2..5bfe8fb25 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -41,6 +41,7 @@ Editor::Editor() { printMagnification = 0; printColourMode = SC_PRINT_NORMAL; + hasFocus = false; hideSelection = false; inOverstrike = false; @@ -608,7 +609,7 @@ void Editor::EnsureCaretVisible(bool useMargin) { } void Editor::ShowCaretAtCurrentPosition() { - if (!wMain.HasFocus()) { + if (!hasFocus) { caret.active = false; caret.on = false; return ; @@ -1096,7 +1097,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { } surfaceWindow->SetPalette(&palette, true); - pixmapLine.SetPalette(&palette, !wMain.HasFocus()); + pixmapLine.SetPalette(&palette, !hasFocus); //Platform::DebugPrintf("Paint: (%3d,%3d) ... (%3d,%3d)\n", // rcArea.left, rcArea.top, rcArea.right, rcArea.bottom); @@ -2811,6 +2812,17 @@ void Editor::Tick() { } } +void Editor::SetFocusState(bool focusState) { + hasFocus = focusState; + NotifyFocus(hasFocus); + if (hasFocus) { + ShowCaretAtCurrentPosition(); + InvalidateCaret(); + } else { + DropCaret(); + } +} + static bool IsIn(int a, int minimum, int maximum) { return (a >= minimum) && (a <= maximum); } @@ -4265,6 +4277,13 @@ long Editor::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) { case SCI_GETOVERTYPE: return inOverstrike ? TRUE : FALSE; + case SCI_SETFOCUS: + SetFocusState(wParam); + break; + + case SCI_GETFOCUS: + return hasFocus; + #ifdef MACRO_SUPPORT case SCI_STARTRECORD: recordingMacro = 1; diff --git a/src/Editor.h b/src/Editor.h index 83967cfd6..38d7ad913 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -61,7 +61,8 @@ protected: // ScintillaBase subclass needs access to much of Editor Palette palette; int printMagnification; int printColourMode; - + + bool hasFocus; bool hideSelection; bool inOverstrike; @@ -285,6 +286,7 @@ protected: // ScintillaBase subclass needs access to much of Editor virtual void SetTicking(bool on) = 0; virtual void SetMouseCapture(bool on) = 0; virtual bool HaveMouseCapture() = 0; + void SetFocusState(bool focusState); void CheckForChangeOutsidePaint(Range r); int BraceMatch(int position, int maxReStyle); diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index dfb53a825..b3b40660b 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -388,7 +388,7 @@ LRESULT ScintillaWin::WndProc(unsigned int iMessage, unsigned long wParam, long // 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(wMain.GetID(), iMessage, wParam, lParam); } // Either SCROLL or ZOOM. We handle the wheel steppings calculation @@ -501,14 +501,12 @@ LRESULT ScintillaWin::WndProc(unsigned int iMessage, unsigned long wParam, long return DLGC_HASSETSEL | DLGC_WANTALLKEYS; case WM_KILLFOCUS: - NotifyFocus(false); - DropCaret(); + SetFocusState(false); //RealizeWindowPalette(true); break; case WM_SETFOCUS: - NotifyFocus(true); - ShowCaretAtCurrentPosition(); + SetFocusState(true); RealizeWindowPalette(false); break; |