/usr/share/doc/renaissance-doc/html/tutorial/node4.html is in renaissance-doc 0.9.0-4build7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--Converted with LaTeX2HTML 2K.1beta (1.48)
original version by: Nikos Drakos, CBLU, University of Leeds
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>4 Loading the gsmarkup file from the program</TITLE>
<META NAME="description" CONTENT="4 Loading the gsmarkup file from the program">
<META NAME="keywords" CONTENT="Renaissance">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="LaTeX2HTML v2K.1beta">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<LINK REL="STYLESHEET" HREF="Renaissance.css">
<LINK REL="next" HREF="node5.html">
<LINK REL="previous" HREF="node3.html">
<LINK REL="up" HREF="Renaissance.html">
<LINK REL="next" HREF="node5.html">
</HEAD>
<BODY BGCOLOR="#FFFFFF" text="#000000" link="#0000FF" vlink="#4444FF" alink="#3388FF">
<B> Next: <A NAME="tex2html58"
HREF="node5.html">5 Adding a menu</A> </B>
<B>Up: <A NAME="tex2html56"
HREF="Renaissance.html">GNUstep Renaissance</A> </B>
<B> Previous: <A NAME="tex2html50"
HREF="node3.html">3 Writing the gsmarkup</A> </B>
<BR> <P>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION00040000000000000000">
4 Loading the gsmarkup file from the program</A>
</H1>
We now need to load the Window.gsmarkup file (which we have created in
the previous section) in our program. GNUstep Renaissance provides
facilities to load gsmarkup files; ``loading'' a gsmarkup file means
reading the file and creating all the objects (and connections, as
will be clear later) described in the file. In this case, loading the
file will create a single, empty, window.
<P>
In order to load the <TT>Window.gsmarkup</TT> file, we just need to
use the code
<PRE>
[NSBundle loadGSMarkupNamed: @"Window" owner: self];
</PRE>
this will parse the <TT>Window.gsmarkup</TT> file and create the
objects (and connections) contained in the file. We can ignore the
<TT>owner:</TT> argument for now as we don't need it yet; passing
<TT>self</TT> (where <TT>self</TT> is the application's delegate) is
OK for now. This code will look for a file <TT>Window.gsmarkup</TT>
in the main bundle of the application, and load it. To compile this
line, you need to include the Renaissance header file
<TT><Renaissance/Renaissance.h></TT> at the beginning of your program.
<P>
The full program is then:
<PRE>
#include <Foundation/Foundation.h>
#include <AppKit/AppKit.h>
#include <Renaissance/Renaissance.h>
@interface MyDelegate : NSObject
{}
- (void) applicationDidFinishLaunching: (NSNotification *)not;
@end
@implementation MyDelegate : NSObject
- (void) applicationDidFinishLaunching: (NSNotification *)not;
{
[NSBundle loadGSMarkupNamed: @"Window" owner: self];
}
@end
int main (int argc, const char **argv)
{
[NSApplication sharedApplication];
[NSApp setDelegate: [MyDelegate new]];
return NSApplicationMain (argc, argv);
}
</PRE>
Save this code in a <TT>main.m</TT> file. Please note that, for
simplicity in this first example, we have omitted the creation of the
application menu; we'll add it in later sections. The given
<TT>#include</TT> directives work on both GNUstep and Apple Mac OS X.
<P>
To complete the example, we provide a GNUmakefile for the application:
<PRE>
include $(GNUSTEP_MAKEFILES)/common.make
APP_NAME = Example
Example_OBJC_FILES = main.m
Example_RESOURCE_FILES = Window.gsmarkup
ifeq ($(FOUNDATION_LIB), apple)
ADDITIONAL_INCLUDE_DIRS += -framework Renaissance
ADDITIONAL_GUI_LIBS += -framework Renaissance
else
ADDITIONAL_GUI_LIBS += -lRenaissance
endif
include $(GNUSTEP_MAKEFILES)/application.make
</PRE>
The few lines starting with
<PRE>
ifeq ($(FOUNDATION\_LIB), apple)
</PRE>
add <TT>-framework Renaissance</TT> on Apple Mac OS X, and
<TT>-lRenaissance</TT> on GNUstep, which makes sure that your program
compiles and runs on both GNUstep and Apple Mac OS X.
<P>
The program should now compile (using 'make') and run (using
``<TT>openapp Example.app</TT>'' on GNUstep, and ``<TT>open
Example.app</TT>'' on Apple Mac OS X). The program won't do much, except
displaying a small empty window. To close it, you probably need to
kill it (from the command line by typing <TT>Control-C</TT>, or using
the window manager).
<P>
We are assuming here that you use gnustep-make to compile on Apple
Mac OS X; you can do the equivalent with ProjectBuilder if you really want:
create a Cocoa application project, then add the Objective-C source
file, and the Window.gsmarkup resource file. You also need to specify
that you want the program to use the Renaissance framework. Then you
should be able to compile and build the program. We will make no more
mention of Project Builder; it should be easy to adapt the examples to
build using Project Builder if you want, but using gnustep-make and
the provided <TT>GNUmakefile</TT>s will give you almost seamless
portability, since the same code will compile without changes on
GNUstep and Apple Mac OS X.
<P>
<HR><B> Next: <A NAME="tex2html58"
HREF="node5.html">5 Adding a menu</A> </B>
<B>Up: <A NAME="tex2html56"
HREF="Renaissance.html">GNUstep Renaissance</A> </B>
<B> Previous: <A NAME="tex2html50"
HREF="node3.html">3 Writing the gsmarkup</A> </B>
<!--End of Navigation Panel-->
<ADDRESS>
Nicola
2003-01-31
</ADDRESS>
</BODY>
</HTML>
|