File: programming/cocoa/MacScare-Source.zip/MacScare-Source/GlkWindow.m


//
//  GlkWindow.m
//  CocoaGlk
//
//  Created by Andrew Hunter on Wed Jun 11 2003.
//  Copyright (c) 2003 Andrew Hunter. All rights reserved.
//
 
#import "GlkWindow.h"
#import "GlkWindowView.h"
#import "GlkWindowStream.h"
 
#import "GlkImage.h"
 
// Utility functions
// Session initialisation
// Note: to finish a session, all windows must first be closed
// Styles
// Streams
// The view
// Speech synthesizer, if requested and available:
"speakOutput"// Release the old attributes
// -----------------------------------------------------------------------------
//	toggleSpeechSynthesis:
//		Menu item action for turning on/off speaking game output. Does nothing
//		if we're running a MacOS version where NSSpeechSynthesizer isn't
//		available.
//
//		This also changes the user defaults.
//
//	REVISIONS:
//		2004-04-02	witness	Created.
// -----------------------------------------------------------------------------
"speakOutput""NSSpeechSynthesizer"// We're running 10.3 or later?
"speakOutput"];
		}
	}
}
 
// -----------------------------------------------------------------------------
//	speechSynthesisOn:
//		Returns YES if speech synthesis is currently turned on for this
//		GlkWindow, no otherwise. Used to properly check our menu item.
//
//	REVISIONS:
//		2004-04-02	witness	Created.
// -----------------------------------------------------------------------------
// The glk functions
// Open by splitting this window
 
    // The parent of the two newly-split windows
// The new window
// Set up the parent window
// Set up the new window
// Re-jig the parents, etc
"Bug in window creation (parents fail to match)"// Force a rearrangement of the windows
"Warning: attempt to close window that's already open"// Don't want to disappear mysteriously...
// Close the stream
    res = [winStream close];
 
    // Remove from the tree
"Oops: window tree corrupted"// Wah, all gawn
//[ourSession setRootWindow: [[[GlkWindow allocWithZone: [self zone]] init] autorelease]];
""""' '//[view windowContentChanged];
"*** BUG: FUNCTION NOT IMPLEMENTED\n""*** BUG: FUNCTION NOT IMPLEMENTED\n""Warning: requestLineEvent called when there were already keyboard input requests pending""Warning: requestCharEvent called when there were already keyboard input requests pending"// There is input data waiting... Clear it out
""// == Some convienience functions for input handling ==
// Latin-1 character codes
// 'Special' character codes
"%i\n", chr);
 
    // Not our code
// == Our housekeeping functions ==
""""'\n') {
                // Newline
// Character
""""// [view windowContentChanged];
// == Styles ==
'-'"-"// Free up any rows that aren't being used any more
// Reallocate
// Create new rows
' '// Fill in the blanks
' '//[view windowContentChanged];
"0"// Release the old attributes
// Work out the font to use
// Start it off
// Add the various attributes as required
"Light"//addFontAttribute(fontsToTry, [NSArray arrayWithObject: @"Medium"]);
"Bold""Oblique",
                    @"Italic"// Try the various combinations until we find one that produces a
            // valid font
// Paragraph style
// Indentation
// Can't outdent
// Can't outdent
                paraIndent = 0;
            }
 
            [pStyle setHeadIndent: indent];
            [pStyle setTailIndent: -indent];
            [pStyle setFirstLineHeadIndent: paraIndent];
 
            // Alignment
// No style
// Colours
// Attributes
// == NSTextStorage delegate functions ==
// Set the input character attributes to the input style
// Check to see if there's any newlines in the input...
'\n'// Generate an event (the actual reading is done later)
// val1, val2 filled in later
// == Images ==
" ""Images only supported in graphics windows (FIXME)""drawImage called before the window image was created"// Annoying flipped coordinate system
"Images only supported in graphics windows (FIXME)""drawImage called before the window image was created"// Annoying flipped coordinate system
"setBackground called for non-graphics window"// Flip that coordinate system
// Find the last image without a flow break
// Add a flow break
"breakFlow not implemented for this window type"

This code uses the PclZip Zip File reading code, which is subject to the GNU LGPL. It also uses the GeSHi syntax highlighter, subject to the GPL. Ask if you want this for your own web site, it's free.