Author: manolo
Date: 2012-12-17 09:44:15 -0800 (Mon, 17 Dec 2012)
New Revision: 9761
Log:
Mac OS: improved text input support with visible display of marked text in text
widgets.
Modified:
branches/branch-1.3/FL/mac.H
branches/branch-1.3/src/Fl_Text_Display.cxx
branches/branch-1.3/src/Fl_cocoa.mm
branches/branch-1.3/src/Fl_compose.cxx
Modified: branches/branch-1.3/FL/mac.H
===================================================================
--- branches/branch-1.3/FL/mac.H 2012-12-16 16:32:19 UTC (rev 9760)
+++ branches/branch-1.3/FL/mac.H 2012-12-17 17:44:15 UTC (rev 9761)
@@ -131,6 +131,7 @@
static CGContextRef none_cursor_image(void);
static void *get_carbon_function(const char *name);
static void screen_work_area(int &X, int &Y, int &W, int &H, int n); //
compute work area of a given screen
+ static void compose_state(int);
private:
static void relink(Fl_Window*, Fl_Window*);
bool subwindow;
Modified: branches/branch-1.3/src/Fl_Text_Display.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Text_Display.cxx 2012-12-16 16:32:19 UTC (rev
9760)
+++ branches/branch-1.3/src/Fl_Text_Display.cxx 2012-12-17 17:44:15 UTC (rev
9761)
@@ -1943,7 +1943,7 @@
if (Fl::focus() == (Fl_Widget*)this) background = selection_color();
else background = fl_color_average(color(), selection_color(), 0.4f);
} else if (style & HIGHLIGHT_MASK) {
- if (Fl::focus() == (Fl_Widget*)this) background =
fl_color_average(color(), selection_color(), 0.5f);
+ if (Fl::focus() == (Fl_Widget*)this) background =
fl_color_average(color(), selection_color(), Fl::compose_state ? 0.3f : 0.5f);
else background = fl_color_average(color(), selection_color(), 0.6f);
} else background = color();
foreground = fl_contrast(styleRec->color, background);
Modified: branches/branch-1.3/src/Fl_cocoa.mm
===================================================================
--- branches/branch-1.3/src/Fl_cocoa.mm 2012-12-16 16:32:19 UTC (rev 9760)
+++ branches/branch-1.3/src/Fl_cocoa.mm 2012-12-17 17:44:15 UTC (rev 9761)
@@ -44,6 +44,7 @@
#include <FL/Fl_Sys_Menu_Bar.H>
#include <FL/Fl_Printer.H>
#include <FL/Fl_Input_.H>
+#include <FL/Fl_Secret_Input.H>
#include <FL/Fl_Text_Display.H>
#include <stdio.h>
#include <stdlib.h>
@@ -1674,7 +1675,6 @@
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
- (void)draggingExited:(id < NSDraggingInfo >)sender;
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal;
-- (void)FLselectMarkedText;
@end
@implementation FLView
@@ -1937,8 +1937,7 @@
// Transform character palette actions to FL_PASTE events.
Fl_Window *target = [(FLWindow*)[self window] getFl_Window];
Fl::handle( (in_key_event || Fl::compose_state) ? FL_KEYBOARD : FL_PASTE,
target);
- Fl::compose_state = 0;
- [self FLselectMarkedText];
+ Fl_X::compose_state(0);
// for some reason, with the palette, the window does not redraw until the
next mouse move or button push
// sending a 'redraw()' or 'awake()' does not solve the issue!
@@ -1961,32 +1960,14 @@
received, newSelection.location, newSelection.length,
Fl::compose_state, Fl::e_length);*/
Fl_Window *target = [(FLWindow*)[self window] getFl_Window];
Fl::handle(FL_KEYBOARD, target);
- Fl::compose_state = Fl::e_length;
- [self FLselectMarkedText];
+ Fl_X::compose_state(Fl::e_length);
fl_unlock_function();
}
-- (void)FLselectMarkedText
-{ // set/clear marked text as selected in text widgets
- Fl_Widget *widget = Fl::focus();
- if (!widget) return;
- if (dynamic_cast<Fl_Input_*>(widget) != NULL) {
- Fl_Input_* input = (Fl_Input_*)widget;
- input->mark( input->position() - Fl::compose_state );
- }
- else if (dynamic_cast<Fl_Text_Display*>(widget) != NULL) {
- Fl_Text_Display* input = (Fl_Text_Display*)widget;
- Fl_Text_Selection* sel =
(Fl_Text_Selection*)input->buffer()->highlight_selection();
- int pos = input->insert_position();
- sel->set(pos - Fl::compose_state, pos);
- }
-}
-
- (void)unmarkText {
fl_lock_function();
- Fl::compose_state = 0;
- [self FLselectMarkedText];
+ Fl_X::compose_state(0);
fl_unlock_function();
//NSLog(@"unmarkText");
}
@@ -2052,6 +2033,24 @@
@end
+void Fl_X::compose_state(int new_val)
+{ // highlight marked text in text widgets
+ if (Fl::compose_state == 0 && new_val == 0) return;
+ Fl::compose_state = new_val;
+ Fl_Widget *widget = Fl::focus();
+ if (!widget) return;
+ if (dynamic_cast<Fl_Input_*>(widget) != NULL) {
+ if (dynamic_cast<Fl_Secret_Input*>(widget) != NULL) return;
+ Fl_Input_* input = (Fl_Input_*)widget;
+ input->mark( input->position() - Fl::compose_state );
+ }
+ else if (dynamic_cast<Fl_Text_Display*>(widget) != NULL) {
+ Fl_Text_Display* input = (Fl_Text_Display*)widget;
+ int pos = input->insert_position();
+ input->buffer()->highlight(pos - Fl::compose_state, pos);
+ }
+}
+
void Fl_Window::fullscreen_x() {
_set_fullscreen();
/* On OS X < 10.6, it is necessary to recreate the window. This is done
Modified: branches/branch-1.3/src/Fl_compose.cxx
===================================================================
--- branches/branch-1.3/src/Fl_compose.cxx 2012-12-16 16:32:19 UTC (rev
9760)
+++ branches/branch-1.3/src/Fl_compose.cxx 2012-12-17 17:44:15 UTC (rev
9761)
@@ -84,10 +84,14 @@
*/
void Fl::compose_reset()
{
+#ifdef __APPLE__
+ Fl_X::compose_state(0);
+#else
Fl::compose_state = 0;
-#if !defined(WIN32) && !defined(__APPLE__)
+#if !defined(WIN32)
if (fl_xim_ic) XmbResetIC(fl_xim_ic);
#endif
+#endif
}
//
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit