FLTK logo

[Library] r8228 - in branches/branch-1.3: FL src

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[Library] r8228 - in branches/branch-1.3: FL src fltk-dev Jan 09, 2011  
 
Author: manolo
Date: 2011-01-09 08:07:13 -0800 (Sun, 09 Jan 2011)
New Revision: 8228
Log:
First step to support CJK input under Mac OS: implementation of the function 
firstRectForCharacterRange of the NSTextInput protocol.

Modified:
   branches/branch-1.3/FL/Fl_Text_Display.H
   branches/branch-1.3/src/Fl_cocoa.mm

Modified: branches/branch-1.3/FL/Fl_Text_Display.H
===================================================================
--- branches/branch-1.3/FL/Fl_Text_Display.H	2011-01-09 14:38:38 UTC (rev 8227)
+++ branches/branch-1.3/FL/Fl_Text_Display.H	2011-01-09 16:07:13 UTC (rev 8228)
@@ -142,7 +142,8 @@
    \return insert position index into text buffer 
    */
   int insert_position() const { return mCursorPos; }
-  
+  int position_to_xy(int pos, int* x, int* y) const;
+
   int in_selection(int x, int y) const;
   void show_insert_position();
   
@@ -364,8 +365,6 @@
   
   void xy_to_rowcol(int x, int y, int* row, int* column,
                     int PosType = CHARACTER_POS) const;
-  
-  int position_to_xy(int pos, int* x, int* y) const;
   void maintain_absolute_top_line_number(int state);
   int get_absolute_top_line_number() const;
   void absolute_top_line_number(int oldFirstChar);

Modified: branches/branch-1.3/src/Fl_cocoa.mm
===================================================================
--- branches/branch-1.3/src/Fl_cocoa.mm	2011-01-09 14:38:38 UTC (rev 8227)
+++ branches/branch-1.3/src/Fl_cocoa.mm	2011-01-09 16:07:13 UTC (rev 8228)
@@ -1818,13 +1818,26 @@
 }
 
 - (NSRect)firstRectForCharacterRange:(NSRange)aRange {
-  NSRect glyphRect, frame;
+  NSRect glyphRect;
+  Fl_Widget *focus = Fl::focus();
+  Fl_Window *wfocus = focus->window();
+  while (wfocus->window()) wfocus = wfocus->window();
+  glyphRect.size.width = 0;
   
-  frame = [self frame];
-  glyphRect.origin.x = frame.size.width;
-  glyphRect.origin.y = 0;
-  glyphRect.size.width = glyphRect.size.height = 0;
+  if (dynamic_cast<Fl_Text_Display*>(focus) != NULL) {
+    int x, y;
+    Fl_Text_Display *current = (Fl_Text_Display*)focus;
+    current->position_to_xy( current->insert_position(), &x, &y );
+    glyphRect.origin.x = (CGFloat)x;
+    glyphRect.origin.y = (CGFloat)y + current->textsize();
+    glyphRect.size.height = current->textsize();
+  } else {
+    glyphRect.origin.x = (CGFloat)Fl::event_x();
+    glyphRect.origin.y = (CGFloat)Fl::event_y() + 12;
+    glyphRect.size.height = 12;
+  }
   // Convert the rect to screen coordinates
+  glyphRect.origin.y = wfocus->h() - glyphRect.origin.y;
   glyphRect.origin = [[self window] convertBaseToScreen:glyphRect.origin];
   return glyphRect;
 }

Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.