summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Fl.cxx25
-rw-r--r--src/Fl_Input.cxx2
-rw-r--r--src/Fl_Input_.cxx1
-rw-r--r--src/Fl_Screen_Driver.H5
-rw-r--r--src/Fl_Text_Display.cxx1
-rw-r--r--src/Fl_Text_Editor.cxx3
-rw-r--r--src/Fl_cocoa.mm13
-rw-r--r--src/Fl_compose.cxx35
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H6
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H2
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx10
11 files changed, 48 insertions, 55 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx
index 7d13c2619..db69fbd97 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -1885,31 +1885,6 @@ int Fl::dnd()
return Fl::screen_driver()->dnd();
}
-/**
- Resets marked text.
-
- In many languages, typing a character can involve multiple keystrokes. For
- example, the Ä can be composed of two dots (¨) on top of the
- character, followed by the letter A (on a Mac with U.S. keyboard, you'd
- type Alt-U, Shift-A. To inform the user that the dots may be followed by
- another character, the ¨ is underlined).
-
- Call this function if character composition needs to be aborted for some
- reason. One such example would be the text input widget losing focus.
- */
-void Fl::reset_marked_text() {
- Fl::screen_driver()->reset_marked_text();
-}
-
-/**
- Sets window coordinates and height of insertion point.
-
- \see Fl::compose(int& del) for a detailed description.
-*/
-void Fl::insertion_point_location(int x, int y, int height) {
- Fl::screen_driver()->insertion_point_location(x, y, height);
-}
-
int Fl::event_key(int k) {
return system_driver()->event_key(k);
}
diff --git a/src/Fl_Input.cxx b/src/Fl_Input.cxx
index 5fa16bfb0..880b7c676 100644
--- a/src/Fl_Input.cxx
+++ b/src/Fl_Input.cxx
@@ -469,7 +469,7 @@ int Fl_Input::handle(int event) {
case FL_UNFOCUS:
if (Fl::screen_driver()->has_marked_text() && Fl::compose_state) {
this->mark( this->position() );
- Fl::reset_marked_text();
+ fl_reset_spot();
}
break;
case FL_FOCUS:
diff --git a/src/Fl_Input_.cxx b/src/Fl_Input_.cxx
index 75bd51c4b..37edba106 100644
--- a/src/Fl_Input_.cxx
+++ b/src/Fl_Input_.cxx
@@ -377,7 +377,6 @@ void Fl_Input_::drawtext(int X, int Y, int W, int H) {
} else {
fl_rectf((int)(xpos+curx+0.5), Y+ypos, 2, height);
}
- Fl::insertion_point_location((int)xpos+curx, Y+ypos+height, height);
ypos_cur = ypos+height; //fix issue #270
}
diff --git a/src/Fl_Screen_Driver.H b/src/Fl_Screen_Driver.H
index 1e0b79d14..d6baf775f 100644
--- a/src/Fl_Screen_Driver.H
+++ b/src/Fl_Screen_Driver.H
@@ -122,12 +122,9 @@ public:
static int secret_input_character;
/* Implement to indicate whether complex text input may involve marked text.
- When it does, has_marked_text returns non zero and reset_marked_text() and
- insertion_point_location() must also be implemented.
+ When it does, has_marked_text returns non zero.
*/
virtual int has_marked_text() const { return 0; }
- virtual void reset_marked_text() {}
- virtual void insertion_point_location(int /*x*/, int /*y*/, int /*height*/) {}
// implement so text-editing widgets support dead keys
virtual int compose(int &del) {
del = 0;
diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx
index af9881541..faeafc090 100644
--- a/src/Fl_Text_Display.cxx
+++ b/src/Fl_Text_Display.cxx
@@ -2424,7 +2424,6 @@ void Fl_Text_Display::draw_cursor( int X, int Y ) {
if ( X < text_area.x - 1 || X > text_area.x + text_area.w )
return;
- Fl::insertion_point_location(X, bot, fontHeight);
/* For cursors other than the block, make them around 2/3 of a character
width, rounded to an even number of pixels so that X will draw an
odd number centered on the stem at x. */
diff --git a/src/Fl_Text_Editor.cxx b/src/Fl_Text_Editor.cxx
index eaab6f39e..a786ac498 100644
--- a/src/Fl_Text_Editor.cxx
+++ b/src/Fl_Text_Editor.cxx
@@ -670,9 +670,10 @@ int Fl_Text_Editor::handle(int event) {
if (Fl::screen_driver()->has_marked_text() && buffer()->selected() && Fl::compose_state) {
int pos = insert_position();
buffer()->select(pos, pos);
- Fl::reset_marked_text();
+ fl_reset_spot();
}
if (buffer()->selected()) redraw(); // Redraw selections...
+ // FALLTHROUGH
case FL_HIDE:
if (when() & FL_WHEN_RELEASE) maybe_do_callback();
return 1;
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index faab62392..6da31ad43 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -2674,7 +2674,7 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
- (void)unmarkText {
fl_lock_function();
- Fl::reset_marked_text();
+ Fl_Cocoa_Screen_Driver::reset_marked_text();
fl_unlock_function();
//NSLog(@"unmarkText");
}
@@ -2720,7 +2720,7 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
glyphRect.size.width = 0;
int x, y, height;
- if (((Fl_Cocoa_Screen_Driver*)Fl::screen_driver())->insertion_point_location(&x, &y, &height)) {
+ if (Fl_Cocoa_Screen_Driver::insertion_point_location(&x, &y, &height)) {
glyphRect.origin.x = (CGFloat)x;
glyphRect.origin.y = (CGFloat)y;
} else {
@@ -4624,3 +4624,12 @@ void Fl_Cocoa_Screen_Driver::default_icons(const Fl_RGB_Image *icons[], int coun
default_icon = rgb_to_nsimage(icons[0]);
}
}
+
+// Deprecated in 1.4 - only for backward compatibility with 1.3
+void Fl::insertion_point_location(int x, int y, int height) {
+ Fl_Cocoa_Screen_Driver::insertion_point_location(x, y, height);
+}
+// Deprecated in 1.4 - only for backward compatibility with 1.3
+void Fl::reset_marked_text() {
+ Fl_Cocoa_Screen_Driver::reset_marked_text();
+}
diff --git a/src/Fl_compose.cxx b/src/Fl_compose.cxx
index e05819eb2..356823ee1 100644
--- a/src/Fl_compose.cxx
+++ b/src/Fl_compose.cxx
@@ -40,32 +40,35 @@ int Fl::compose_state = 0;
<p>If <i>false</i> is returned, the keys should be treated as function
keys, and del is set to zero. You could insert the text anyways, if
you don't know what else to do.
+
+ <p>Text editing widgets can preferentially call fl_set_spot() to indicate the window
+ coordinates of the bottom of the current insertion point and the line height.
+ This way, auxiliary windows that help choosing among alternative characters
+ with some text input methods appear just below or above the insertion point.
+ If widgets don't do that, such auxiliary windows appear at the widget's bottom.
- <p>On the Mac OS platform, text input can involve marked text, that is,
+ <p>On some platforms, text input can involve marked text, that is,
temporary text replaced by other text during the input process. This occurs,
- e.g., when using dead keys or when entering CJK characters.
+ e.g., under macOS when using dead keys or when entering CJK characters.
Text editing widgets should preferentially signal
marked text, usually underlining it. Widgets can use
<tt>int Fl::compose_state</tt> <i>after</i> having called Fl::compose(int&)
to obtain the length in bytes of marked text that always finishes at the
current insertion point. Widgets should also call
- <tt>void Fl::reset_marked_text()</tt> when processing FL_UNFOCUS
- events. Optionally, widgets can also call
- <tt>void Fl::insertion_point_location(int x, int y, int height)</tt> to indicate the window
- coordinates of the bottom of the current insertion point and the line height.
- This way, auxiliary windows that help choosing among alternative characters
- appear just below the insertion point. If widgets don't do that,
- auxiliary windows appear at the widget's bottom. The
- Fl_Input and Fl_Text_Editor widgets underline marked text.
+ void fl_reset_spot() when processing FL_UNFOCUS
+ events. The Fl_Input and Fl_Text_Editor widgets underline marked text.
If none of this is done by a user-defined text editing widget,
text input will work, but will not signal to the user what text is marked.
- Finally, text editing widgets should call <tt>set_flag(MAC_USE_ACCENTS_MENU);</tt>
- in their constructor if they want to use the feature introduced with Mac OS 10.7 "Lion"
- where pressing and holding certain keys on the keyboard opens an accented-character menu window.
- <p>Though the current implementation returns immediately, future
- versions may take quite awhile, as they may pop up a window or do
- other user-interface things to allow characters to be selected.
+ <p>Finally, text editing widgets should call <tt>set_flag(MAC_USE_ACCENTS_MENU);</tt>
+ in their constructor if they want to use, on the macOS platform, the feature introduced with Mac OS 10.7 "Lion"
+ where pressing and holding certain keys on the keyboard opens a diacritic marks popup window.
+
+ \note For compatibility with FLTK 1.3, text editing widgets can call
+ <tt>Fl::insertion_point_location(int x, int y, int height)</tt> and <tt>Fl::reset_marked_text()</tt>
+ <u>only under the macOS platform</u> to indicate/reset the coordinates of the current insertion point.
+ This is deprecated in version 1.4 because redundant with the platform-independent
+ fl_set_spot() and fl_reset_spot() functions.
*/
int Fl::compose(int& del) {
return Fl::screen_driver()->compose(del);
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H
index a2ab981b4..dcd5c4f57 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H
+++ b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H
@@ -86,9 +86,9 @@ public:
virtual int has_timeout(Fl_Timeout_Handler cb, void *argp);
virtual void remove_timeout(Fl_Timeout_Handler cb, void *argp);
virtual int has_marked_text() const;
- virtual void reset_marked_text();
- virtual void insertion_point_location(int x, int y, int height);
- int insertion_point_location(int *px, int *py, int *pheight);
+ static void reset_marked_text();
+ static void insertion_point_location(int x, int y, int height);
+ static int insertion_point_location(int *px, int *py, int *pheight);
virtual int dnd(int use_selection);
virtual int compose(int &del);
virtual int input_widget_handle_key(int key, unsigned mods, unsigned shift, Fl_Input *input);
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H
index f59a39d79..fcbbe810b 100644
--- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H
+++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H
@@ -174,6 +174,8 @@ protected:
virtual void restore_scale(float);
virtual void antialias(int state);
virtual int antialias();
+ virtual void set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win);
+ virtual void reset_spot();
};
class Fl_Quartz_Printer_Graphics_Driver : public Fl_Quartz_Graphics_Driver {
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx
index c18f7c300..85872f9ed 100644
--- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx
+++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx
@@ -17,7 +17,7 @@
#include <config.h>
#include "Fl_Quartz_Graphics_Driver.H"
#include "../Darwin/Fl_Darwin_System_Driver.H"
-#include "../../Fl_Screen_Driver.H"
+#include "../Cocoa/Fl_Cocoa_Screen_Driver.H"
#include <FL/platform.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Image_Surface.H>
@@ -182,3 +182,11 @@ void Fl_Quartz_Graphics_Driver::restore_scale(float s) {
CGContextScaleCTM(gc_, s, s);
}
}
+
+void Fl_Quartz_Graphics_Driver::set_spot(int /*font*/, int size, int X, int Y, int /*W*/, int /*H*/, Fl_Window* /*win*/) {
+ Fl_Cocoa_Screen_Driver::insertion_point_location(X, Y, size);
+}
+
+void Fl_Quartz_Graphics_Driver::reset_spot() {
+ Fl_Cocoa_Screen_Driver::reset_marked_text();
+}