Return to MyOutputWindowController.m CVS log | Up to [local] / OpenXM / src / cfep |
File: [local] / OpenXM / src / cfep / MyOutputWindowController.m (download)
Revision 1.3, Tue Mar 7 11:15:23 2006 UTC (18 years, 6 months ago) by takayama
1. Added the following new OpenGL commands. cfep.glib_init_send("0; [glClearColor,0.0,0.5,0.5,0.1]"); /* GL_COLOR_BUFFER_BIT 0x4000, = 16384 GL_DEPTH_BUFFER_BIT 0x100 */ cfep.glib_init_send("0; [glClear,(int)16384]"); cfep.glib_send("0; [glColor4f,1.0,0,0,0]"); cfep.glib_send("0; [glRectf,-0.5,-0.1,0.5,0.1]"); cfep.glib_send("0; [glFlush]"); cfep.glib_send("0;meta_showListOfOglComm"); meta_removeLast, meta_removeAll, meta_removeLastInit, meta_removeAllInit 2. small improvement of the interface of "goto next line". |
// // MyOutputWindowController.m // cfep // // Created by nobuki on 06/01/25. // Copyright 2006 __MyCompanyName__. All rights reserved. // #import "MyOutputWindowController.h" #import "MyDocument.h" @implementation MyOutputWindowController +(MyOutputWindowController *) sharedMyOutputWindowController: (MyDocument *) sender action: (enum actionType) act { static NSMutableDictionary * sharedMOWC; // class variable. MyOutputWindowController *owin; if (sharedMOWC == nil) { sharedMOWC = [NSMutableDictionary dictionaryWithCapacity: 1024]; //BUG. finite number. [sharedMOWC retain]; } if (act == FIND) { owin = [sharedMOWC objectForKey: [sender getMyDocumentKey]]; if (owin != nil) return owin; owin = [[MyOutputWindowController allocWithZone:[MyOutputWindowController zone]] init]; [owin retain]; NSLog(@"MyOutputWindowController. new owc is created.\n"); [sharedMOWC setObject: owin forKey: [sender getMyDocumentKey]]; return owin; }else{ // REMOVE owin = [sharedMOWC objectForKey: [sender getMyDocumentKey]]; if (!owin) [sharedMOWC removeObjectForKey: [sender getMyDocumentKey]]; // [owin autorelease]; return owin; } } +(MyOutputWindowController *) sharedMyOutputWindowController: (MyDocument *)sender { return [self sharedMyOutputWindowController: sender action: FIND]; } -(id) init { static int serial; self = [self initWithWindowNibName: @"MyOutputWindow"]; if (self) [self setWindowFrameAutosaveName: @"cfep Output View"]; winNo = serial++; return self; } -(void) windowDidLoad { [super windowDidLoad]; // [textViewOut retain]; ? } -(void) dealloc { NSLog(@"dealloc of MyOutputWindowController instance.\n"); [[NSNotificationCenter defaultCenter] removeObserver: self]; [super dealloc]; } -(void) closeMyOutputWindow: (MyDocument *) md { NSLog(@"closeMyOutputWindow. \n"); [MyOutputWindowController sharedMyOutputWindowController: md action: REMOVE]; removable = 1; [self close]; } -(BOOL) windowShouldClose: (NSWindow *)sender { // book. p.149 Delegate outlet of Window should me File's owner. if (removable) return [super windowShouldClose: sender]; return NO; } -(void)outputStringToOutputWindow:(NSString *)msg { [self outputStringToOutputWindow: msg withColor: [NSColor blackColor]]; } -(void)outputStringToOutputWindow:(NSString *)msg withColor: (NSColor *) color { int oldEnd, newEnd; NSRange myRange = NSMakeRange([[textViewOut textStorage] length],0); oldEnd = myRange.location; // NSLog(@"<MyOutputWindowController> outputStringToOutputWindow\n"); [textViewOut replaceCharactersInRange: myRange withString: msg]; myRange = NSMakeRange([[textViewOut textStorage] length],0); newEnd = myRange.location; [textViewOut setTextColor: color range: NSMakeRange(oldEnd,newEnd-oldEnd)]; [textViewOut scrollRangeToVisible: myRange]; } -(void)insertText: (id) text { NSRange myRange = NSMakeRange([[textViewOut textStorage] length],0); [textViewOut replaceCharactersInRange: myRange withString: @""]; // goto the end of output window. [textViewOut insertText: text]; [textViewOut scrollRangeToVisible: NSMakeRange([[textViewOut textStorage] length],0)]; } -(void)printErrorMessageToOutputWindow:(NSString *)msg { int oldEnd; int newEnd; oldEnd = [[textViewOut textStorage] length]; NSRange myRange = NSMakeRange(oldEnd,0); [textViewOut replaceCharactersInRange: myRange withString: msg]; newEnd = [[textViewOut textStorage] length]; [textViewOut setTextColor: [NSColor redColor] range: NSMakeRange(oldEnd,newEnd-oldEnd)]; [textViewOut scrollRangeToVisible: NSMakeRange(newEnd,0)]; } -(void)clearOutputWindow { NSRange myRange = NSMakeRange(0,[[textViewOut textStorage] length]); [textViewOut replaceCharactersInRange: myRange withString: @""]; } -(void)changeWindowTitle: (NSString *)msg { NSLog(@"title=%@\n",[window title]); // [window setTitle: msg]; it does not work. Why? } -(void)showUp { if (displayed == 0) { [self showWindow: nil]; displayed = 1; [self changeWindowTitle: [[NSString stringWithFormat: @"OutputView %d",winNo] retain]]; } } -(void) printDocument: (id) sender { [textViewOut print: sender]; } @end