Back to index

texmacs  1.0.7.15
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | Private Member Functions
TMView Class Reference

#import <TMView.h>

Inheritance diagram for TMView:
Inheritance graph
[legend]
Collaboration diagram for TMView:
Collaboration graph
[legend]

List of all members.

Public Member Functions

(void) - setWidget:
(widget_rep *) - widget
(void) - deleteWorkingText
(void) - map [implementation]
(void) - initkeymap [implementation]
(id) - initWithFrame: [implementation]
(void) - dealloc [implementation]
(void) - viewWillMoveToWindow: [implementation]
(void) - drawRect: [implementation]
(void) - keyDown: [implementation]
(void) - mouseDown: [implementation]
(void) - mouseUp: [implementation]
(void) - mouseDragged: [implementation]
(void) - mouseMoved: [implementation]
(BOOL) - isFlipped [implementation]
(BOOL) - isOpaque [implementation]
(void) - resizeWithOldSuperviewSize: [implementation]
(BOOL) - acceptsFirstResponder [implementation]
(void) - insertText: [implementation]
(void) - doCommandBySelector: [implementation]
(void) - setMarkedText:selectedRange: [implementation]
(void) - unmarkText [implementation]
(BOOL) - hasMarkedText [implementation]
(NSInteger) - conversationIdentifier [implementation]
(NSAttributedString *) - attributedSubstringFromRange: [implementation]
(NSRange) - markedRange [implementation]
(NSRange) - selectedRange [implementation]
(NSRect) - firstRectForCharacterRange: [implementation]
(NSUInteger) - characterIndexForPoint: [implementation]
(NSArray *) - validAttributesForMarkedText [implementation]

Static Public Member Functions

(static unsigned int) + mouse_state [implementation]
(static string+ mouse_decode [implementation]

Public Attributes

void * isa

Protected Attributes

simple_widget_repwid
NSString * workingText
BOOL processingCompose
NSMutableArray * delayed_rects

Private Member Functions

(void) - setNeedsDisplayInTMRect: [implementation]
(void) - delayedUpdate [implementation]
(void) - focusIn [implementation]
(void) - focusOut [implementation]

Detailed Description

Definition at line 15 of file TMView.h.


Member Function Documentation

- (BOOL) acceptsFirstResponder [implementation]

Definition at line 551 of file TMView.mm.

{
       return YES;
}
- (NSAttributedString *) attributedSubstringFromRange: (NSRange)  theRange [implementation]

Definition at line 625 of file TMView.mm.

                                                     :(NSRange)theRange
{
  static NSAttributedString *str = nil;
  if (str == nil) str = [NSAttributedString new];
  return str;
}
- (NSUInteger) characterIndexForPoint: (NSPoint)  thePoint [implementation]

Definition at line 657 of file TMView.mm.

                                    :(NSPoint)thePoint
{
  return 0;
}
- (NSInteger) conversationIdentifier [implementation]

Definition at line 618 of file TMView.mm.

{
  return (NSInteger)self;
}
- (void) dealloc [implementation]

Definition at line 180 of file TMView.mm.

{
  [delayed_rects release];
  [self deleteWorkingText];
  [[NSNotificationCenter defaultCenter] removeObserver: self
                                                  name: @"NSWindowDidBecomeKeyNotification"
                                                object: nil];
  [[NSNotificationCenter defaultCenter] removeObserver: self
                                                  name: @"NSWindowDidBecomeKeyNotification"
                                                object: nil];
  
  [super dealloc];
}

Here is the call graph for this function:

- (void) delayedUpdate [implementation]

Definition at line 256 of file TMView.mm.

{
  NSMutableArray *arr = delayed_rects;
  NSEnumerator *enumerator = [arr objectEnumerator];
  TMRect *anObject;
  delayed_rects = [[NSMutableArray arrayWithCapacity:10] retain];
  while ((anObject = [enumerator nextObject])) {
    [self displayRect:[anObject rect]];
  }
  [arr release];
}

Definition at line 556 of file TMView.mm.

{ 
  if (workingText == nil)
    return;
  [workingText release];
  workingText = nil;
  processingCompose = NO;
  
  
}

Here is the caller graph for this function:

- (void) doCommandBySelector: (SEL)  aSelector [implementation]

Definition at line 589 of file TMView.mm.

                            :(SEL)aSelector
{
}
- (void) drawRect: (NSRect)  rect [implementation]

Definition at line 270 of file TMView.mm.

                :(NSRect)rect 
{
  if (aqua_update_flag) {
    [delayed_rects addObject:[[[TMRect alloc] initWithRect:rect] autorelease]];
    return;
  }
    
       // Drawing code here.
       if ([self inLiveResize])
       {
              NSRect bounds = [self bounds];
              [[NSColor blackColor] set];
              [NSBezierPath strokeRect:NSInsetRect(bounds,1,1)];
              //    return;
       }
//     cout << "DRAWING : " << rect.origin.x << ","<< rect.origin.x << ","<< rect.size.width<< "," << rect.size.height <<  "\n";
//     NSRect bounds = [self bounds];
       
  {
              basic_renderer r = the_aqua_renderer();
    int x1 = rect.origin.x;
    int y1 = rect.origin.y+rect.size.height;
    int x2 = rect.origin.x+rect.size.width;
    int y2 = rect.origin.y;
    
    r -> begin([NSGraphicsContext currentContext]);
  //  r -> set_origin(0,0);
    r -> encode (x1,y1);
    r -> encode (x2,y2);
 //   cout << "DRAWING RECT " << x1 << "," << y1 << "," << x2 << "," << y2 << LF;
    r -> set_clipping (x1,y1,x2,y2);
    wid->handle_repaint (x1,y1,x2,y2);
              r->end();
    if (r->interrupted())
      aqua_update_flag= true;
       }
//     cout << "END DRAWING" << "\n";
 
  if (aqua_update_flag) {
    if (DEBUG_EVENTS)
      cout << "Postponed redrawing\n"; 
    [self performSelector:@selector(delayedUpdate) withObject: nil afterDelay: 10];
  }
  
}

Here is the call graph for this function:

- (NSRect) firstRectForCharacterRange: (NSRange)  theRange [implementation]

Definition at line 650 of file TMView.mm.

                                     :(NSRange)theRange
{
  return NSMakeRect(0,0,50,50);
}
- (void) focusIn [implementation]

Definition at line 240 of file TMView.mm.

{
  if (DEBUG_EVENTS) cout << "FOCUSIN" << LF;
  if (wid) {
    wid -> handle_keyboard_focus (true, texmacs_time ());
  }
}

Here is the call graph for this function:

- (void) focusOut [implementation]

Definition at line 248 of file TMView.mm.

{
  if (DEBUG_EVENTS)   cout << "FOCUSOUT" << LF;
  if (wid) {
    wid -> handle_keyboard_focus (false, texmacs_time ());
  }
}

Here is the call graph for this function:

- (BOOL) hasMarkedText [implementation]

Definition at line 613 of file TMView.mm.

{
  return workingText != nil;
  
}
- (void) initkeymap [implementation]

Definition at line 80 of file TMView.mm.

{
  map(0x0d,"return");
  map(0x09,"tab");
  map(0xf728,"backspace");
  map(0xf003,"enter");
  map(0x1b,"escape");
  map(0x0003,"K-enter");
  map(0x7f,"backspace");
  
  map( NSUpArrowFunctionKey       ,"up" );
  map( NSDownArrowFunctionKey     ,"down" );
  map( NSLeftArrowFunctionKey     ,"left" );
  map( NSRightArrowFunctionKey    ,"right" );
  map( NSF1FunctionKey    ,"F1" );
  map( NSF2FunctionKey    ,"F2" );
  map( NSF3FunctionKey    ,"F3" );
  map( NSF4FunctionKey    ,"F4" );
  map( NSF5FunctionKey    ,"F5" );
  map( NSF6FunctionKey    ,"F6" );
  map( NSF7FunctionKey    ,"F7" );
  map( NSF8FunctionKey    ,"F8" );
  map( NSF9FunctionKey    ,"F9" );
  map( NSF10FunctionKey   ,"F10" );
  map( NSF11FunctionKey   ,"F11" );
  map( NSF12FunctionKey   ,"F12" );
  map( NSF13FunctionKey   ,"F13" );
  map( NSF14FunctionKey   ,"F14" );
  map( NSF15FunctionKey   ,"F15" );
  map( NSF16FunctionKey   ,"F16" );
  map( NSF17FunctionKey   ,"F17" );
  map( NSF18FunctionKey   ,"F18" );
  map( NSF19FunctionKey   ,"F19" );
  map( NSF20FunctionKey   ,"F20" );
  map( NSF21FunctionKey   ,"F21" );
  map( NSF22FunctionKey   ,"F22" );
  map( NSF23FunctionKey   ,"F23" );
  map( NSF24FunctionKey   ,"F24" );
  map( NSF25FunctionKey   ,"F25" );
  map( NSF26FunctionKey   ,"F26" );
  map( NSF27FunctionKey   ,"F27" );
  map( NSF28FunctionKey   ,"F28" );
  map( NSF29FunctionKey   ,"F29" );
  map( NSF30FunctionKey   ,"F30" );
  map( NSF31FunctionKey   ,"F31" );
  map( NSF32FunctionKey   ,"F32" );
  map( NSF33FunctionKey   ,"F33" );
  map( NSF34FunctionKey   ,"F34" );
  map( NSF35FunctionKey   ,"F35" );
  map( NSInsertFunctionKey        ,"insert" );
  map( NSDeleteFunctionKey        ,"delete" );
  map( NSHomeFunctionKey  ,"home" );
  map( NSBeginFunctionKey         ,"begin" );
  map( NSEndFunctionKey   ,"end" );
  map( NSPageUpFunctionKey        ,"pageup" );
  map( NSPageDownFunctionKey      ,"pagedown" );
  map( NSPrintScreenFunctionKey   ,"printscreen" );
  map( NSScrollLockFunctionKey    ,"scrolllock" );
  map( NSPauseFunctionKey         ,"pause" );
  map( NSSysReqFunctionKey        ,"sysreq" );
  map( NSBreakFunctionKey         ,"break" );
  map( NSResetFunctionKey         ,"reset" );
  map( NSStopFunctionKey  ,"stop" );
  map( NSMenuFunctionKey  ,"menu" );
  map( NSUserFunctionKey  ,"user" );
  map( NSSystemFunctionKey        ,"system" );
  map( NSPrintFunctionKey         ,"print" );
  map( NSClearLineFunctionKey     ,"clear" );
  map( NSClearDisplayFunctionKey  ,"cleardisplay" );
  map( NSInsertLineFunctionKey    ,"insertline" );
  map( NSDeleteLineFunctionKey    ,"deleteline" );
  map( NSInsertCharFunctionKey    ,"insert" );
  map( NSDeleteCharFunctionKey    ,"delete" );
  map( NSPrevFunctionKey  ,"prev" );
  map( NSNextFunctionKey  ,"next" );
  map( NSSelectFunctionKey        ,"select" );
  map( NSExecuteFunctionKey       ,"execute" );
  map( NSUndoFunctionKey  ,"undo" );
  map( NSRedoFunctionKey  ,"redo" );
  map( NSFindFunctionKey  ,"find" );
  map( NSHelpFunctionKey  ,"help" );
  map( NSModeSwitchFunctionKey    ,"modeswitch" );  
}

Here is the call graph for this function:

Here is the caller graph for this function:

- (id) initWithFrame: (NSRect)  frame [implementation]

Definition at line 165 of file TMView.mm.

                   :(NSRect)frame {
  self = [super initWithFrame:frame];
  if (self) {
    // Initialization code here.
    wid = NULL;
    processingCompose = NO;
    workingText = nil;
    delayed_rects = [[NSMutableArray arrayWithCapacity:100] retain];
    
    
    
  }
  return self;
}
- (void) insertText: (id)  aString [implementation]

Definition at line 570 of file TMView.mm.

                   :(id)aString
// instead of keyDown: aString can be NSString or NSAttributedString
{
  processingCompose = NO;
  NSLog(@"insertText: <%@>",aString);
  
  NSString *str = [aString respondsToSelector: @selector(string)] ?
  [aString string] : aString;
  
  static char buf[256];
  for(unsigned int i=0; i<[str length]; i++) {
    [[str substringWithRange:NSMakeRange(i, 1)] getCString:buf maxLength:256 encoding:NSUTF8StringEncoding];
    string rr (buf, strlen(buf));
    string s= utf8_to_cork (rr);          
    cout << "key press: " << s << LF;
    wid -> handle_keypress (s, texmacs_time());        
  }
}

Here is the call graph for this function:

- (BOOL) isFlipped [implementation]

Definition at line 530 of file TMView.mm.

{
  return YES;
}
- (BOOL) isOpaque [implementation]

Definition at line 535 of file TMView.mm.

{
  return YES;
}
- (void) keyDown: (NSEvent *)  theEvent [implementation]

Definition at line 378 of file TMView.mm.

               :(NSEvent *)theEvent
{
  if (!wid) return;

  time_credit= 25;
  timeout_time= texmacs_time () + time_credit;
  static bool fInit = false;
  if (!fInit) {
    if (DEBUG_EVENTS)
      cout << "Initializing keymap\n";
    initkeymap();
    fInit= true;
  }
  
  {
    // char str[256];
    string r;
    NSString *nss = [theEvent charactersIgnoringModifiers];
    unsigned int mods = [theEvent modifierFlags];
    
    string modstr;
    
    if (mods & NSControlKeyMask ) modstr= "C-" * modstr;
    if (mods & NSAlternateKeyMask) modstr= "A-" * modstr;
    if (mods & NSCommandKeyMask) modstr= "M-" * modstr;
    // if (mods & NSNumericPadKeyMask) modstr= "K-" * modstr;
    // if (mods & NSHelpKeyMask) modstr= "H-" * modstr;
    // if (mods & NSFunctionKeyMask) modstr= "F-" * modstr;
    
    //    if (!processingCompose)
    {
      if ([nss length]>0) {
        int key = [nss characterAtIndex:0];
        if (nskeymap->contains(key)) {
          r = nskeymap[key];
          r = ((mods & NSShiftKeyMask)? "S-" * modstr: modstr) * r;          
          cout << "function key press: " << r << LF;
          [self deleteWorkingText];
          wid -> handle_keypress (r, texmacs_time());    
          return;
        } else if (mods & (NSControlKeyMask  | NSCommandKeyMask | NSHelpKeyMask))
        {
          static char str[256];
          [nss getCString:str maxLength:256 encoding:NSUTF8StringEncoding];
          string rr (str, strlen(str));
          r= utf8_to_cork (rr);          
          
          string s ( modstr * r);
          cout << "modified  key press: " << s << LF;
          [self deleteWorkingText];
          wid -> handle_keypress (s, texmacs_time());    
          the_gui->update (); // FIXME: remove this line when
          // edit_typeset_rep::get_env_value will be faster

          return;
        }
      }
    }
    
    processingCompose = YES;
    static NSMutableArray *nsEvArray = nil;
    if (nsEvArray == nil)
      nsEvArray = [[NSMutableArray alloc] initWithCapacity: 1];
    
    [nsEvArray addObject: theEvent];
    [self interpretKeyEvents: nsEvArray];
    [nsEvArray removeObject: theEvent];
  }
}

Here is the call graph for this function:

- (void) map (int)  code
(string name 
[implementation]

Definition at line 75 of file TMView.mm.

{
  nskeymap(code) = name;
}
- (NSRange) markedRange [implementation]

Definition at line 634 of file TMView.mm.

{
  NSRange rng = workingText != nil
  ? NSMakeRange(0, [workingText length]) : NSMakeRange(NSNotFound, 0);
  return rng;
  
}
+ (static string) mouse_decode (unsigned int)  mstate [implementation]

Definition at line 463 of file TMView.mm.

                                   {
  if      (mstate & 1 ) return "left";
  else if (mstate & 2 ) return "middle";
  else if (mstate & 4 ) return "right";
  else if (mstate & 8 ) return "up";
  else if (mstate & 16) return "down";
  return "unknown";
}

Here is the caller graph for this function:

+ (static unsigned int) mouse_state (NSEvent *)  event
(bool)  flag 
[implementation]

Definition at line 451 of file TMView.mm.

                                        {
  unsigned int i= 0;
  i += 1 << min([event buttonNumber],4);
  unsigned int mods = [event modifierFlags];
  if (mods & NSAlternateKeyMask) i = 2;  
  if (mods & NSCommandKeyMask) i = 4;  
  if (mods & NSShiftKeyMask) i += 256;  
  if (mods & NSControlKeyMask) i += 2048;  
  return i;
}

Here is the caller graph for this function:

- (void) mouseDown: (NSEvent *)  theEvent [implementation]

Definition at line 474 of file TMView.mm.

                 :(NSEvent *)theEvent
{
  if (wid) {
    NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
       scale(point);
    unsigned int mstate= mouse_state (theEvent, false);
    string s= "press-" * mouse_decode (mstate);
    wid -> handle_mouse (s, point.x , point.y , mstate, texmacs_time ());
    if (DEBUG_EVENTS)
      cout << "mouse event: " << s << " at "
      << point.x << ", " << point.y  << LF;
  }
}

Here is the call graph for this function:

- (void) mouseDragged: (NSEvent *)  theEvent [implementation]

Definition at line 502 of file TMView.mm.

                    :(NSEvent *)theEvent
{
  if (wid) {
    NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
              scale(point);
    unsigned int mstate= mouse_state (theEvent, false);
    string s= "move";
    wid -> handle_mouse (s, point.x , point.y , mstate, texmacs_time ());
    if (DEBUG_EVENTS)
      cout << "mouse event: " << s << " at "
      << point.x  << ", " << point.y  << LF;
  }  
}

Here is the call graph for this function:

- (void) mouseMoved: (NSEvent *)  theEvent [implementation]

Definition at line 516 of file TMView.mm.

                  :(NSEvent *)theEvent
{
  if (wid) {
    NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
              scale(point);
    unsigned int mstate= mouse_state (theEvent, false);
    string s= "move";
    wid -> handle_mouse (s, point.x , point.y , mstate, texmacs_time ());
    if (DEBUG_EVENTS)
      cout << "mouse event: " << s << " at "
      << point.x  << ", " << point.y  << LF;
  }  
}

Here is the call graph for this function:

- (void) mouseUp: (NSEvent *)  theEvent [implementation]

Definition at line 488 of file TMView.mm.

               :(NSEvent *)theEvent
{
  if (wid) {
    NSPoint point = [self convertPoint:[theEvent locationInWindow] fromView:nil];
       scale(point);
    unsigned int mstate= mouse_state (theEvent, true);
    string s= "release-" * mouse_decode (mstate);
    wid -> handle_mouse (s, point.x , point.y , mstate, texmacs_time ());
    if (DEBUG_EVENTS)
      cout << "mouse event: " << s << " at "
      << point.x  << ", " << point.y  << LF;
  }
}

Here is the call graph for this function:

- (void) resizeWithOldSuperviewSize: (NSSize)  oldBoundsSize [implementation]

Definition at line 540 of file TMView.mm.

                                  :(NSSize)oldBoundsSize
{
  [super resizeWithOldSuperviewSize:oldBoundsSize];
  if (wid)  {
    NSSize size = [self bounds].size;
              scaleSize(size);
              wid-> handle_notify_resize (size.width, size.height);
  }
       
}

Here is the call graph for this function:

- (NSRange) selectedRange [implementation]

Definition at line 644 of file TMView.mm.

{
  return NSMakeRange(NSNotFound, 0);
}
- (void) setMarkedText: (id)  aString
selectedRange: (NSRange)  selRange 
[implementation]

Definition at line 594 of file TMView.mm.

                      :(id)aString selectedRange:(NSRange)selRange
{
  NSString *str = [aString respondsToSelector: @selector(string)] ?
  [aString string] : aString;
  
  if (workingText != nil)
    [self deleteWorkingText];
  if ([str length] == 0)
    return;
  workingText = [str copy];
  processingCompose = YES;
  NSLog(@"setMarkedText: <%@>",workingText);
  
}

Here is the call graph for this function:

- (void) setNeedsDisplayInTMRect: (TMRect*)  r [implementation]

Definition at line 204 of file TMView.mm.

                               :(TMRect*)r
{
  [self setNeedsDisplayInRect:[r rect]];
}
- (void) setWidget: (widget_rep*)  w

Definition at line 194 of file TMView.mm.

                  :(widget_rep*) w
{
       wid = (simple_widget_rep*)w;
}
- (void) unmarkText [implementation]

Definition at line 609 of file TMView.mm.

{
  [self deleteWorkingText];  
}

Here is the call graph for this function:

- (NSArray *) validAttributesForMarkedText [implementation]

Definition at line 664 of file TMView.mm.

{
  static NSArray *arr = nil;
  if (arr == nil) arr = [NSArray new];
  return arr;
}
- (void) viewWillMoveToWindow: (NSWindow *)  newWindow [implementation]

Definition at line 209 of file TMView.mm.

                            :(NSWindow *)newWindow
{
  // query widget preferred size
  SI w,h;
  wid->handle_get_size_hint (w,h);
  NSSize s = NSMakeSize(w,h);
  unscaleSize(s);
  [self setFrameSize:s];
  
  // register to receive focus in/out notifications  
  [[NSNotificationCenter defaultCenter] removeObserver: self
                                                  name: @"NSWindowDidBecomeKeyNotification"
                                                object: nil];
  [[NSNotificationCenter defaultCenter] removeObserver: self
                                                  name: @"NSWindowDidBecomeKeyNotification"
                                                object: nil];
  
  [[NSNotificationCenter defaultCenter] addObserver: self
                                           selector: @selector(focusIn)
                                               name: @"NSWindowDidBecomeKeyNotification"
                                             object: newWindow];
  
  [[NSNotificationCenter defaultCenter] addObserver: self
                                           selector: @selector(focusOut)
                                               name: @"NSWindowDidResignKeyNotification"
                                             object: newWindow];
  
}

Here is the call graph for this function:

Definition at line 199 of file TMView.mm.

{
       return  (widget_rep*)wid;
}

Member Data Documentation

- (NSMutableArray*) delayed_rects [protected]

Definition at line 21 of file TMView.h.

void* TeXmacs_NSView::isa [inherited]

Definition at line 19 of file aqua_widget.h.

- (BOOL) processingCompose [protected]

Definition at line 20 of file TMView.h.

- (simple_widget_rep*) wid [protected]

Definition at line 18 of file TMView.h.

- (NSString*) workingText [protected]

Definition at line 19 of file TMView.h.


The documentation for this class was generated from the following files: