Back to index

texmacs  1.0.7.15
aqua_dialogues.mm
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : aqua_dialogues.mm
00004 * DESCRIPTION: Aqua dialogues widgets classes
00005 * COPYRIGHT  : (C) 2007  Massimiliano Gubinelli
00006 *******************************************************************************
00007 * This software falls under the GNU general public license version 3 or later.
00008 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00009 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00010 ******************************************************************************/
00011 
00012 #include "mac_cocoa.h" 
00013 
00014 #include "aqua_dialogues.h"
00015 
00016 #include "gui.hpp" 
00017 #include "widget.hpp" 
00018 #include "message.hpp"
00019 #include "aqua_utilities.h"
00020 #include "aqua_other_widgets.h"
00021 #include "aqua_basic_widgets.h"
00022 
00023 #include "url.hpp"
00024 #include "analyze.hpp"
00025 
00026 #define TYPE_CHECK(b) ASSERT (b, "type mismatch")
00027 #define NOT_IMPLEMENTED \
00028   { if (DEBUG_EVENTS) cout << "STILL NOT IMPLEMENTED\n";  }
00029 
00030 #pragma mark aqua_chooser_widget_rep
00031 
00032 class aqua_chooser_widget_rep: public aqua_widget_rep {
00033 protected:    
00034   command cmd;
00035   string type;
00036   bool   save;
00037   string win_title;
00038   string directory;
00039   coord2 position;
00040   coord2 size;
00041   string file;
00042        
00043 public:
00044   aqua_chooser_widget_rep (command, string, bool);
00045   ~aqua_chooser_widget_rep ();
00046        
00047   virtual void send (slot s, blackbox val);
00048   virtual blackbox query (slot s, int type_id);
00049   virtual widget read (slot s, blackbox index);
00050   virtual void write (slot s, blackbox index, widget w);
00051   virtual void notify (slot s, blackbox new_val);
00052   //  virtual void connect (slot s, widget w2, slot s2);
00053   //  virtual void deconnect (slot s, widget w2, slot s2);
00054   virtual widget plain_window_widget (string s);
00055 
00056   void perform_dialog();
00057 };
00058 
00059 aqua_chooser_widget_rep::aqua_chooser_widget_rep (command _cmd, string _type, bool _save) 
00060 : aqua_widget_rep(), cmd(_cmd), type(_type), 
00061   save(_save), position (coord2 (0, 0)), 
00062   size (coord2 (100, 100)), file ("")
00063 {
00064 }
00065 
00066 aqua_chooser_widget_rep::~aqua_chooser_widget_rep()  {  }
00067 
00068 
00069 
00070 void
00071 aqua_chooser_widget_rep::send (slot s, blackbox val) {
00072   switch (s) {
00073   case SLOT_VISIBILITY:
00074     {  
00075       check_type<bool> (val, "SLOT_VISIBILITY");
00076       bool flag = open_box<bool> (val);
00077       (void) flag;
00078       NOT_IMPLEMENTED
00079        }      
00080     break;
00081   case SLOT_SIZE:
00082     {
00083       TYPE_CHECK (type_box (val) == type_helper<coord2>::id);
00084       size = open_box<coord2> (val);
00085     }
00086     break;
00087   case SLOT_POSITION:
00088     {
00089       TYPE_CHECK (type_box (val) == type_helper<coord2>::id);
00090       position = open_box<coord2> (val);
00091     }
00092     break;
00093   case SLOT_KEYBOARD_FOCUS:
00094     {
00095       TYPE_CHECK (type_box (val) == type_helper<bool>::id);
00096       perform_dialog();
00097     }
00098     break;
00099     
00100   case SLOT_STRING_INPUT:
00101     //        send_string (THIS, "input", val);
00102     NOT_IMPLEMENTED 
00103       break;
00104   case SLOT_INPUT_TYPE:
00105     TYPE_CHECK (type_box (val) == type_helper<string>::id);
00106     type = open_box<string> (val);        
00107     // send_string (THIS, "type", val);
00108     break;
00109 #if 0
00110   case SLOT_INPUT_PROPOSAL:
00111     //send_string (THIS, "default", val);
00112     break;
00113 #endif
00114   case SLOT_FILE:
00115     //send_string (THIS, "file", val);
00116     NOT_IMPLEMENTED
00117       break;
00118   case SLOT_DIRECTORY:
00119     TYPE_CHECK (type_box (val) == type_helper<string>::id);
00120     directory = open_box<string> (val);
00121     directory = as_string (url_pwd () * url_system (directory));
00122     break;
00123     
00124   default:
00125     aqua_widget_rep::send(s,val);
00126   }
00127 }
00128 
00129 
00130 blackbox
00131 aqua_chooser_widget_rep::query (slot s, int type_id) {
00132   switch (s) {
00133   case SLOT_POSITION:  
00134     {
00135       typedef pair<SI,SI> coord2;
00136       TYPE_CHECK (type_id == type_helper<coord2>::id);
00137       return close_box<coord2> (position);
00138     }
00139   case SLOT_SIZE:
00140     {
00141       typedef pair<SI,SI> coord2;
00142       TYPE_CHECK (type_id == type_helper<coord2>::id);
00143       return close_box<coord2> (size);
00144     }
00145                      
00146   case SLOT_STRING_INPUT:
00147     {
00148       TYPE_CHECK (type_id == type_helper<string>::id);
00149       return close_box<string> (file);
00150     }
00151     
00152   default:
00153     return aqua_widget_rep::query(s,type_id);
00154   }
00155 }
00156 
00157 
00158 void
00159 aqua_chooser_widget_rep::notify (slot s, blackbox new_val) {
00160   switch (s) {
00161   default: ;
00162   }
00163   widget_rep::notify (s, new_val);
00164 }
00165 
00166 widget
00167 aqua_chooser_widget_rep::read (slot s, blackbox index) {
00168   switch (s) {
00169   case SLOT_WINDOW:
00170     check_type_void (index, "SLOT_WINDOW");
00171     return this;
00172   case SLOT_FORM_FIELD:
00173     check_type<int> (index, "SLOT_FORM_FIELD");
00174     return this;
00175   case SLOT_FILE:
00176     check_type_void (index, "SLOT_FILE");
00177     return this;
00178   case SLOT_DIRECTORY:
00179     check_type_void (index, "SLOT_DIRECTORY");
00180     return this;
00181   default:
00182     return aqua_widget_rep::read(s,index);
00183   }
00184 }
00185 
00186 void
00187 aqua_chooser_widget_rep::write (slot s, blackbox index, widget w) {
00188   switch (s) {
00189   default:
00190     aqua_widget_rep::write(s,index,w);
00191   }
00192 }
00193 
00194 
00195 widget aqua_chooser_widget_rep::plain_window_widget (string s)
00196 {
00197   win_title = s;
00198   return this;
00199 }
00200 
00201 
00202 
00203 widget file_chooser_widget (command cmd, string type, bool save) 
00204 // file chooser widget for files of a given type; for files of type "image",
00205 // the widget includes a previsualizer and a default magnification
00206 // for importation can be specified
00207 {
00208   return tm_new <aqua_chooser_widget_rep> (cmd, type, save);
00209 }
00210 
00211 
00212 @interface TMSavePanel : NSSavePanel
00213 {
00214 }
00215 - (BOOL)_overwriteExistingFileCheck:(NSString *)filename;
00216 @end
00217 
00218 @implementation TMSavePanel
00219 - (BOOL)_overwriteExistingFileCheck:(NSString *)filename
00220 {
00221   return YES;
00222 }
00223 @end
00224 
00225 #if 0
00226 void aqua_chooser_widget_rep::perform_dialog()
00227 {
00228   int result;
00229   NSArray *fileTypes = [NSArray arrayWithObject:@"tm"];
00230   NSOpenPanel *oPanel = [NSOpenPanel openPanel];
00231   [oPanel setTitle:to_nsstring(win_title)];
00232   [oPanel setAllowsMultipleSelection:YES];
00233   result = [oPanel runModalForDirectory:NSHomeDirectory()
00234                  file:nil types:fileTypes];
00235   if (result == NSOKButton) {
00236     NSArray *filesToOpen = [oPanel filenames];
00237     int i, count = [filesToOpen count];
00238     for (i=0; i<count; i++) {
00239       NSString *aFile = [filesToOpen objectAtIndex:i];
00240       //                    id currentDoc = [[ToDoDoc alloc] initWithFile:aFile];
00241     }
00242     if (count > 0) {
00243       file = from_nsstring([filesToOpen objectAtIndex:0]);
00244       url u= url_system (scm_unquote (file));
00245       file = "(url-system " * scm_quote (as_string (u)) * ")";
00246       
00247     }
00248   }
00249   cmd();      
00250 }
00251 #else
00252 void aqua_chooser_widget_rep::perform_dialog()
00253 {
00254   int result;
00255   NSArray *fileTypes = [NSArray arrayWithObject:@"tm"];
00256   NSSavePanel *oPanel = [TMSavePanel savePanel];
00257   [oPanel setTitle:to_nsstring(win_title)];
00258   //  [oPanel setMessage:@"Choose a file."];
00259   [oPanel setNameFieldLabel:@"File:"];
00260   [oPanel setPrompt:@"Choose"];
00261   [oPanel setAllowedFileTypes:fileTypes];
00262   // [oPanel setAllowsMultipleSelection:YES];
00263   NSPoint pos = to_nspoint(position);
00264   NSRect r = NSMakeRect(0,0,0,0);
00265   r.size = [oPanel frame].size;
00266   NSOffsetRect(r, pos.x - r.size.width/2, pos.y - r.size.height/2);
00267   [oPanel setFrameOrigin:r.origin];
00268   
00269   result = [oPanel runModalForDirectory:to_nsstring(directory)
00270                  file:nil ];
00271   if (result == NSOKButton) {
00272     file = from_nsstring([oPanel filename]);
00273     url u= url_system (scm_unquote (file));
00274     if (type == "image")
00275       file = "(list (url-system " * scm_quote (as_string (u)) *
00276              ") \"\" \"\" \"\" \"\")";
00277     //FIXME: fake image dimensions
00278     else
00279       file = "(url-system " * scm_quote (as_string (u)) * ")";
00280   } else {
00281     file = "#f";
00282   }
00283   cmd ();     
00284 }
00285 
00286 #endif
00287 #pragma mark aqua_input_widget_rep
00288 
00289 class aqua_field_widget;
00290 
00291 class aqua_input_widget_rep: public aqua_widget_rep {
00292 protected:    
00293   command cmd;
00294   array<aqua_field_widget> fields;
00295   coord2 size, position;
00296   string win_title;  
00297 public:
00298   aqua_input_widget_rep (command, array<string>);
00299   ~aqua_input_widget_rep ();
00300        
00301   virtual void send (slot s, blackbox val);
00302   virtual blackbox query (slot s, int type_id);
00303   virtual widget read (slot s, blackbox index);
00304   virtual void write (slot s, blackbox index, widget w);
00305   virtual void notify (slot s, blackbox new_val);
00306   //  virtual void connect (slot s, widget w2, slot s2);
00307   //  virtual void deconnect (slot s, widget w2, slot s2);
00308   virtual widget plain_window_widget (string s);
00309   
00310   void perform_dialog();
00311 };
00312 
00313 class aqua_field_widget_rep : public widget_rep {
00314   string prompt;
00315   string input;
00316   string type;
00317   array<string> proposals;
00318   aqua_input_widget_rep *parent;
00319  public:
00320  aqua_field_widget_rep(aqua_input_widget_rep *_parent) : widget_rep(), prompt(""), input(""),  proposals(), parent(_parent) {};
00321   virtual void send (slot s, blackbox val);
00322   virtual blackbox query (slot s, int type_id);
00323   
00324   friend class aqua_input_widget_rep;
00325 };
00326 
00327 
00328 void
00329 aqua_field_widget_rep::send (slot s, blackbox val) {
00330   switch (s) {
00331   case SLOT_STRING_INPUT:
00332     {
00333       TYPE_CHECK (type_box (val) == type_helper<string>::id);
00334       input =  open_box<string> (val);
00335     }
00336     //        send_string (THIS, "input", val);
00337     break;
00338   case SLOT_INPUT_TYPE:
00339     {
00340       TYPE_CHECK (type_box (val) == type_helper<string>::id);
00341       type =  open_box<string> (val);
00342     }
00343     break;
00344   case SLOT_INPUT_PROPOSAL:
00345     {
00346       TYPE_CHECK (type_box (val) == type_helper<string>::id);
00347       proposals <<  open_box<string> (val);
00348     }
00349     //send_string (THIS, "default", val);
00350     break;
00351   case SLOT_KEYBOARD_FOCUS:
00352     {
00353       parent->send(s,val);
00354     }
00355     break;
00356   default:
00357     widget_rep::send(s,val);
00358   }
00359 }
00360 
00361 blackbox
00362 aqua_field_widget_rep::query (slot s, int type_id) {
00363   switch (s) {
00364   case SLOT_STRING_INPUT:
00365     {
00366       TYPE_CHECK (type_id == type_helper<string>::id);
00367       return close_box<string> (input);
00368     }
00369     
00370   default:
00371     return widget_rep::query(s,type_id);
00372   }
00373 }
00374 
00375 
00376 class aqua_field_widget {
00377 public:
00378 ABSTRACT_NULL(aqua_field_widget);
00379 };
00380 ABSTRACT_NULL_CODE(aqua_field_widget);
00381 
00382 
00383 
00384 aqua_input_widget_rep::aqua_input_widget_rep (command _cmd, array<string> _prompts) 
00385 : aqua_widget_rep(), cmd(_cmd), fields(N(_prompts)), size(coord2(100,100)), position(coord2(0,0)), win_title("") 
00386 {
00387   for(int i=0; i < N(_prompts); i++) {
00388     fields[i] = tm_new <aqua_field_widget_rep> (this);
00389     fields[i]->prompt = _prompts[i];
00390   }
00391 }
00392 
00393 aqua_input_widget_rep::~aqua_input_widget_rep()  {  }
00394 
00395 
00396 
00397 void
00398 aqua_input_widget_rep::send (slot s, blackbox val) {
00399   switch (s) {
00400   case SLOT_VISIBILITY:
00401     {  
00402       check_type<bool> (val, "SLOT_VISIBILITY");
00403       bool flag = open_box<bool> (val);
00404       (void) flag;
00405       NOT_IMPLEMENTED 
00406        }      
00407     break;
00408   case SLOT_SIZE:
00409     {
00410       TYPE_CHECK (type_box (val) == type_helper<coord2>::id);
00411       size = open_box<coord2> (val);
00412     }
00413     break;
00414   case SLOT_POSITION:
00415     {
00416       TYPE_CHECK (type_box (val) == type_helper<coord2>::id);
00417       position = open_box<coord2> (val);
00418     }
00419     break;
00420   case SLOT_KEYBOARD_FOCUS:
00421     {
00422       TYPE_CHECK (type_box (val) == type_helper<bool>::id);
00423       perform_dialog();
00424     }
00425     break;
00426     
00427     
00428   default:
00429     aqua_widget_rep::send(s,val);
00430   }
00431 }
00432 
00433 
00434 blackbox
00435 aqua_input_widget_rep::query (slot s, int type_id) {
00436   switch (s) {
00437   case SLOT_POSITION:  
00438     {
00439       typedef pair<SI,SI> coord2;
00440       TYPE_CHECK (type_id == type_helper<coord2>::id);
00441       return close_box<coord2> (position);
00442     }
00443   case SLOT_SIZE:
00444     {
00445       typedef pair<SI,SI> coord2;
00446       TYPE_CHECK (type_id == type_helper<coord2>::id);
00447       return close_box<coord2> (size);
00448     }
00449   case SLOT_STRING_INPUT:
00450     return fields[0]->query(s,type_id);
00451     
00452     
00453   default:
00454     return aqua_widget_rep::query(s,type_id);
00455   }
00456 }
00457 
00458 
00459 void
00460 aqua_input_widget_rep::notify (slot s, blackbox new_val) {
00461   switch (s) {
00462   default: ;
00463   }
00464   widget_rep::notify (s, new_val);
00465 }
00466 
00467 widget
00468 aqua_input_widget_rep::read (slot s, blackbox index) {
00469   switch (s) {
00470   case SLOT_WINDOW:
00471     check_type_void (index, "SLOT_WINDOW");
00472     return this;
00473   case SLOT_FORM_FIELD:
00474     check_type<int> (index, "SLOT_FORM_FIELD");
00475     return (widget_rep*)(fields[open_box<int>(index)].rep);
00476   default:
00477     return aqua_widget_rep::read(s,index);
00478   }
00479 }
00480 
00481 void
00482 aqua_input_widget_rep::write (slot s, blackbox index, widget w) {
00483   switch (s) {
00484   default:
00485     aqua_widget_rep::write(s,index,w);
00486   }
00487 }
00488 
00489 
00490 widget aqua_input_widget_rep::plain_window_widget (string s)
00491 {
00492   win_title = s;
00493   return this;
00494 }
00495 
00496 
00497 @interface TMInputHelper : NSObject
00498 {
00499 @public
00500   IBOutlet NSMatrix *form;
00501   IBOutlet NSWindow *dialog;
00502   aqua_tm_widget_rep *wid;
00503 }
00504 - (IBAction) doForm:(id)sender;
00505 @end
00506 
00507 @implementation TMInputHelper
00508 - (id) init
00509 {
00510   self = [super init];
00511   if (self != nil) {
00512     NSRect panelRect = NSMakeRect(0, 0, 480, 360);
00513     dialog = [[NSWindow alloc] initWithContentRect:panelRect
00514                                         styleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask
00515                                           backing:NSBackingStoreBuffered defer:YES];
00516     form = [[[NSMatrix alloc] initWithFrame: NSMakeRect(20, 60, 440, 280) ] autorelease];
00517     NSButton* cancelButton = [[[NSButton alloc] initWithFrame: NSMakeRect(274, 12, 96, 32) ] autorelease];
00518     NSButton* okButton = [[[NSButton alloc] initWithFrame: NSMakeRect(370, 12, 96, 32) ] autorelease];
00519     [cancelButton setTitle:@"Cancel"];
00520     [okButton setTitle:@"Ok"];
00521 
00522     [okButton setButtonType:   NSMomentaryPushInButton];
00523     [cancelButton setButtonType:   NSMomentaryPushInButton];
00524 
00525     [okButton setBezelStyle: NSRoundedBezelStyle];
00526     [cancelButton setBezelStyle: NSRoundedBezelStyle];
00527     
00528     [cancelButton setTag: 1];
00529     [okButton setTag: 0];
00530     [okButton setTarget: self];
00531     [okButton setAction: @selector(doForm:)];
00532     [cancelButton setTarget: self];
00533     [cancelButton setAction: @selector(doForm:)];
00534 
00535     [okButton setKeyEquivalent:@"\r"];
00536     [cancelButton setKeyEquivalent:@"\E"];
00537  
00538     [form   setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];
00539     [okButton setAutoresizingMask: NSViewMinXMargin | NSViewMaxYMargin];
00540     [cancelButton setAutoresizingMask: NSViewMinXMargin | NSViewMaxYMargin];
00541     
00542     [[dialog contentView] addSubview: form];
00543     [[dialog contentView] addSubview: cancelButton];
00544     [[dialog contentView] addSubview: okButton];
00545     
00546     [dialog makeFirstResponder: form];
00547     [form setNextKeyView: cancelButton];
00548     [cancelButton setNextKeyView: okButton];
00549     [okButton setNextKeyView: form];
00550     
00551     [form retain];   
00552 
00553     [dialog setReleasedWhenClosed:NO];
00554     wid = NULL;
00555   }
00556   return self;
00557 }
00558 - (void) dealloc
00559 {
00560   [dialog release];
00561   [form release];
00562   [super dealloc];
00563 }
00564 
00565 - (IBAction) doForm:(id)sender
00566 {
00567   if ([sender tag] == 0)
00568   {
00569     [NSApp stopModalWithCode:0]; // OK button
00570   }
00571   else
00572   {
00573     [NSApp stopModalWithCode:1]; // Cancel button
00574   }
00575 }
00576 
00577 - (void) delayedRun
00578 {
00579   int code = [NSApp runModalForWindow: dialog];
00580   // Dialog is up here.
00581   [NSApp endSheet: dialog];
00582   [dialog orderOut: self];
00583   
00584   
00585   if (code == 0) { // Ok button
00586     NSString *ans = [(NSComboBoxCell*)[form cellAtRow:0 column:1] stringValue];
00587     ((aqua_input_text_widget_rep*)wid->int_input.rep)->text = scm_quote(from_nsstring(ans));
00588     ((aqua_input_text_widget_rep*)wid->int_input.rep)->cmd();
00589   }
00590   else  { // Cancel button
00591   }
00592   
00593   
00594   [self release]; // autodestroy
00595 }
00596 @end
00597 
00598 
00599 void aqua_input_widget_rep::perform_dialog()
00600 {
00601   TMInputHelper *ih = [[TMInputHelper alloc] init];
00602   NSMatrix *form = ih->form;
00603   [form renewRows:N(fields) columns:2];
00604   for(int i=0; i<N(fields); i++) {
00605     NSCell *cell = [[[NSCell alloc] initTextCell:to_nsstring(fields[i]->prompt)] autorelease];
00606     [form putCell:cell atRow:i column:0];
00607     NSComboBoxCell *cell2 = [[[NSComboBoxCell alloc] initTextCell:to_nsstring(fields[i]->input)] autorelease];
00608     [cell2 setEditable:YES];
00609     [cell2 setCompletes:YES];
00610     [form putCell:cell2 atRow:i column:1];
00611   //  [cell2 addItemWithObjectValue:to_nsstring(fields[i]->input)];
00612     for(int j=0; j < N(fields[i]->proposals); j++)
00613     {
00614       [cell2 addItemWithObjectValue:to_nsstring(fields[i]->proposals[j])];
00615     }
00616   }
00617   
00618   NSRect rect0 = [form frame];
00619   [form sizeToFit];
00620   NSRect rect1 = [form frame];
00621   [form setFrame:rect0];
00622   NSRect frame = [ih->dialog frame];
00623   frame.size.width += rect1.size.width - rect0.size.width;
00624   frame.size.height += rect1.size.height - rect0.size.height;
00625   [ih->dialog setFrame:frame display:NO];
00626   
00627   NSModalSession session = [NSApp beginModalSessionForWindow:ih->dialog];
00628   NSInteger code;
00629   for (;;) {
00630     code = [NSApp runModalSession:session];
00631     if (code != NSRunContinuesResponse)
00632       break;
00633     //   [self doSomeWork];
00634   }
00635   [NSApp endModalSession:session];
00636   [ih->dialog close];
00637 
00638   if (code == 0) { // Ok button
00639     
00640     for(int i=0; i<N(fields); i++) {
00641       NSString *ans = [(NSComboBoxCell*)[form cellAtRow:i column:1] stringValue];
00642       fields[i]->input = scm_quote(from_nsstring(ans));
00643     }
00644   }
00645   else  { // Cancel button
00646     for(int i=0; i<N(fields); i++) {
00647       fields[i]->input = "#f";
00648     }
00649   }
00650  
00651   
00652   [ih release];
00653   cmd();
00654 }
00655 
00656 
00657 
00658 
00659 widget inputs_list_widget (command call_back, array<string> prompts)
00660 // a dialogue widget with Ok and Cancel buttons and a series of textual
00661 // input widgets with specified prompts
00662 {
00663        return tm_new <aqua_input_widget_rep> (call_back,prompts);
00664 
00665 }
00666 
00667 
00668 
00669 widget input_text_widget (command call_back, string type, array<string> def,
00670                           int style, string width)
00671 // a textual input widget for input of a given type and a list of suggested
00672 // default inputs (the first one should be displayed, if there is one)
00673 {
00674   (void) style; (void) width;
00675   return tm_new <aqua_input_text_widget_rep> (call_back, type, def);
00676 }
00677 
00678 
00679 void aqua_tm_widget_rep::do_interactive_prompt()
00680 {
00681   TMInputHelper *ih = [[TMInputHelper alloc] init];
00682   ih->wid = this;
00683   NSMatrix *form = ih->form;
00684   [form renewRows:1 columns:2];
00685   NSCell *cell = [[[NSCell alloc] initTextCell:to_nsstring(((aqua_text_widget_rep*)int_prompt.rep)->str)] autorelease];
00686   [form putCell:cell atRow:0 column:0];
00687   NSComboBoxCell *cell2 = [[[NSComboBoxCell alloc] initTextCell:@""] autorelease];
00688   [cell2 setEditable:YES];
00689   [cell2 setCompletes:YES];
00690   [form putCell:cell2 atRow:0 column:1];
00691   [form setKeyCell:cell2];
00692   aqua_input_text_widget_rep *it = (aqua_input_text_widget_rep*)int_input.rep;
00693   for(int j=0; j < N(it->def); j++)
00694   {
00695     if (j==0) [cell2 setStringValue:to_nsstring(it->def[j])];
00696     [cell2 addItemWithObjectValue:to_nsstring(it->def[j])];
00697   }
00698   
00699   NSRect rect0 = [form frame];
00700   [form sizeToFit];
00701   NSRect rect1 = [form frame];
00702   [form setFrame:rect0];
00703   NSRect frame = [ih->dialog frame];
00704   frame.size.width += rect1.size.width - rect0.size.width;
00705   frame.size.height += rect1.size.height - rect0.size.height;
00706   [ih->dialog setFrame:frame display:NO];
00707   
00708   [NSApp beginSheet: ih->dialog
00709      modalForWindow: [view window]
00710       modalDelegate: nil
00711      didEndSelector: nil
00712         contextInfo: nil];
00713   [ih performSelector:@selector(delayedRun) withObject:nil afterDelay:0.0];
00714 }
00715 
00716 widget 
00717 printer_widget (command cmd, url u) {
00718   (void) u;
00719   return menu_button (text_widget ("Cancel", 0, black), cmd, "", "", 0);
00720 }
00721 
00722 
00723 widget
00724 color_picker_widget (command call_back, bool bg, array<tree> proposals) {
00725   // widgets for selecting a color, a pattern or a background image,
00726   // encoded by a tree. On input, we give a list of recently used proposals
00727   // on termination the command is called with the selected color as argument
00728   // the bg flag specifies whether we are picking a background color or fill
00729   NOT_IMPLEMENTED;
00730   (void) call_back; (void) bg; (void) proposals;
00731   return glue_widget (false, false, 100*PIXEL, 100*PIXEL);
00732 }