Back to index

texmacs  1.0.7.15
Classes | Functions
aqua_menu.mm File Reference
#include "mac_cocoa.h"
#include "aqua_menu.h"
#include "aqua_utilities.h"
#include "aqua_renderer.h"
#include "aqua_simple_widget.h"
#include "aqua_basic_widgets.h"
#include "widget.hpp"
#include "message.hpp"
#include "analyze.hpp"
#include "promise.hpp"
#include <typeinfo>
#import "TMView.h"

Go to the source code of this file.

Classes

class  aqua_menu_rep
class  TMLazyMenu
class  TMTileView

Functions

NSMenu * alloc_menu ()
NSMenuItem * alloc_menuitem ()
widget horizontal_menu (array< widget > a)
widget horizontal_list (array< widget > a)
widget minibar_menu (array< widget > a)
widget vertical_menu (array< widget > a)
widget vertical_list (array< widget > a)
widget tile_menu (array< widget > a, int cols)
widget menu_separator (bool vertical)
widget menu_group (string name, int style)
widget pulldown_button (widget w, promise< widget > pw)
widget pullright_button (widget w, promise< widget > pw)
widget menu_button (widget w, command cmd, string pre, string ks, int style)
widget balloon_widget (widget w, widget help)
widget text_widget (string s, int style, color col, bool tsp)
widget xpm_widget (url file_name)
NSMenu * to_nsmenu (widget w)
NSMenuItem * to_nsmenuitem (widget w)

Function Documentation

NSMenu* alloc_menu ( )

Definition at line 29 of file aqua_menu.mm.

{ return [NSMenu alloc]; }
NSMenuItem* alloc_menuitem ( )

Definition at line 30 of file aqua_menu.mm.

{ return [NSMenuItem alloc]; }
widget balloon_widget ( widget  w,
widget  help 
)

Definition at line 437 of file aqua_menu.mm.

{ 
  return tm_new <aqua_balloon_widget_rep> (w,help);
}

Definition at line 228 of file aqua_menu.mm.

                                  {
  return horizontal_menu (a);
}  

Here is the call graph for this function:

Definition at line 213 of file aqua_menu.mm.

{
       NSMenuItem* mi = [[alloc_menuitem() initWithTitle:@"Menu" action:NULL keyEquivalent:@""] autorelease];
       NSMenu *menu = [[alloc_menu() init] autorelease];
       for(int i = 0; i < N(a); i++) {
              if (is_nil(a[i])) 
                     break;
      [menu addItem: concrete(a[i])->as_menuitem()];
       };
       [mi setSubmenu:menu];
       return tm_new <aqua_menu_rep> (mi);       
}

Here is the call graph for this function:

widget menu_button ( widget  w,
command  cmd,
string  pre,
string  ks,
int  style 
)

Definition at line 410 of file aqua_menu.mm.

{
  bool ok= (style & WIDGET_STYLE_INERT) == 0;
  TMMenuItem *mi = nil;
  
  if (typeid(*(w.rep)) == typeid(simple_widget_rep)) {
    mi = [[[TMMenuItem alloc] init] autorelease];
    [mi setWidget:(simple_widget_rep*)w.rep];
  } else  {
    mi = ((aqua_widget_rep*)w.rep)->as_menuitem();
  }

  [mi setCommand: cmd.rep];
  [mi setEnabled:(ok ? YES : NO)];
       // FIXME: implement complete prefix handling and keyboard shortcuts
       // cout << "ks: "<< ks << "\n";
       [mi setState:(pre!="" ? NSOnState: NSOffState)];
       if (pre == "v") {
       } else if (pre == "*") {
//            [mi setOnStateImage:[NSImage imageNamed:@"TMStarMenuBullet"]];
       } else if (pre == "o") {
       }
       return tm_new <aqua_menu_rep> (mi);
}

Here is the call graph for this function:

widget menu_group ( string  name,
int  style 
)

Definition at line 341 of file aqua_menu.mm.

{
       (void) style;
       NSMenuItem* mi = [[alloc_menuitem() initWithTitle:to_nsstring_utf8(name) action:NULL keyEquivalent:@""] autorelease];

       //     NSAttributedString *str = [mi attributedTitle];
       NSMutableParagraphStyle *pstyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
//     NSMutableParagraphStyle *style = [(NSParagraphStyle*)[str attribute:NSParagraphStyleAttributeName atIndex:0 effectiveRange:NULL] mutableCopy];
       [pstyle setAlignment: NSCenterTextAlignment];
       [mi setAttributedTitle:[[[NSAttributedString alloc] 
                               initWithString: [mi title]
                                   attributes: [NSDictionary 
                                      dictionaryWithObjectsAndKeys:pstyle, NSParagraphStyleAttributeName, nil]]
                                autorelease]];
       return tm_new <aqua_menu_rep> (mi);
}
widget menu_separator ( bool  vertical)

Definition at line 339 of file aqua_menu.mm.

{ return tm_new <aqua_menu_rep> ([NSMenuItem separatorItem]); }

Definition at line 232 of file aqua_menu.mm.

                                      {
  return horizontal_menu (a);
}

Here is the call graph for this function:

Definition at line 359 of file aqua_menu.mm.

{
//     NSString *title = (is_nil(w)? @"":((aqua_menu_text_rep*)w.rep)->text);
//     NSMenuItem *mi = [[alloc_menuitem() initWithTitle:title action:NULL keyEquivalent:@""] autorelease];
//     TMMenuItem* mi =  (TMMenuItem*)((aqua_menu_rep*)w.rep) -> item;
  TMMenuItem* mi = concrete(w) -> as_menuitem();
   
  TMLazyMenu *lm = [[[TMLazyMenu alloc] init] autorelease];
       [lm setPromise:pw.rep];
       [mi setSubmenu: lm];
       return tm_new <aqua_menu_rep> (mi);
}

Here is the call graph for this function:

Definition at line 373 of file aqua_menu.mm.

{
       return pulldown_button(w, pw);
}

Here is the call graph for this function:

widget text_widget ( string  s,
int  style,
color  col,
bool  tsp 
)

Definition at line 444 of file aqua_menu.mm.

{
  (void) style;
  string t= tm_var_encode (s);
  return tm_new <aqua_text_widget_rep> (t,col,tsp);
}

Here is the call graph for this function:

widget tile_menu ( array< widget a,
int  cols 
)

Definition at line 317 of file aqua_menu.mm.

{ 
//     return horizontal_menu(a); 
       NSMutableArray *tiles = [NSMutableArray arrayWithCapacity:N(a)];
       for(int i = 0; i < N(a); i++) {
              if (is_nil(a[i]))  break;
//            [tiles addObject:( (aqua_menu_rep*)(a[i].rep))->item];
      [tiles addObject:concrete(a[i])->as_menuitem()];
       };
       TMTileView* tv = [[[TMTileView alloc] initWithObjects:tiles cols:cols] autorelease];
       
       NSMenuItem* mi = [[[NSMenuItem alloc] initWithTitle:@"Tile" action:NULL keyEquivalent:@""] autorelease];

       
       [mi setView:tv];
       return tm_new <aqua_menu_rep> (mi);
       
}

Here is the call graph for this function:

NSMenu* to_nsmenu ( widget  w)

Definition at line 466 of file aqua_menu.mm.

{
  if (typeid(*w.rep) == typeid(aqua_menu_rep)) {
    aqua_menu_rep *ww = ((aqua_menu_rep*)w.rep);
       NSMenu *m =[[[ww->item submenu] retain] autorelease];
       [ww->item setSubmenu:nil];
       return m;
  }
  else return nil;
}
NSMenuItem* to_nsmenuitem ( widget  w)

Definition at line 477 of file aqua_menu.mm.

{
       return ((aqua_menu_rep*)w.rep)->item;
}

Definition at line 240 of file aqua_menu.mm.

                                {
  return vertical_menu (a);
}

Here is the call graph for this function:

Definition at line 236 of file aqua_menu.mm.

{ return horizontal_menu(a); }

Here is the call graph for this function:

widget xpm_widget ( url  file_name)

Definition at line 451 of file aqua_menu.mm.

{
  return tm_new <aqua_image_widget_rep> (file_name);
#if 0  
       NSImage *image = the_aqua_renderer()->xpm_image(file_name);
//     TMMenuItem *mi = [[[TMMenuItem alloc] initWithTitle:to_nsstring(as_string(file_name)) action:NULL keyEquivalent:@""] autorelease];
       TMMenuItem *mi = [[[TMMenuItem alloc] initWithTitle:@"" action:NULL keyEquivalent:@""] autorelease];
       [mi setRepresentedObject:image];
       [mi setImage:image];
  return tm_new <aqua_menu_rep> (mi);
//     return new aqua_menu_text_rep(to_nsstring(as_string(file_name)));
#endif
}

Here is the call graph for this function: