mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 22:22:11 +02:00
349 lines
20 KiB
HTML
349 lines
20 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
|
"http://www.w3.org/TR/html4/loose.dtd">
|
|
<html lang="en">
|
|
<head>
|
|
<link href="_stock/sysdoc.css" type="text/css" rel="stylesheet" media="screen">
|
|
<link href="_stock/sysdoc.css" type="text/css" rel="stylesheet" media="print">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
<title>Example template in How to extend the user interface using templates</title>
|
|
|
|
<style type="text/css" media="screen">
|
|
.ButtonBox { background-image: url(_stock/gradient.jpg); }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<table width="100%" border="0" cellspacing="0" cellpadding="0"><tbody><tr>
|
|
</tr><tr><td class="DocSetBox" width="25%">
|
|
<p> </p>
|
|
</td>
|
|
<td class="ButtonBox" align="right" width="40%">
|
|
<p><A href="../_index/index.html"></a>
|
|
<A href="Howtoregistertemplates.html"><IMG height=22 alt="[Previous]" src="_stock/btn_prev_wt.gif" width=85 border=0 ></a> <A href="index.html"></a></p>
|
|
</td>
|
|
</tr></tbody></table>
|
|
<hr noshade size="1">
|
|
<p class="breadcrumbNav"><span class="separator">»</span>
|
|
<A href="index.html">How to extend the user interface using templates</a> <span class="separator">»</span> Example template</p>
|
|
|
|
<hr noshade size="1">
|
|
<div class="AuthoredContent">
|
|
|
|
|
|
</div><div class="Head1">
|
|
|
|
<h1>Example template</h1>
|
|
</div><div class="Bodytext">
|
|
<p>
|
|
The following is an example template to create a simple Symbian OS
|
|
<code class="filename">EXE</code> project:
|
|
</p>
|
|
<p class="CodeBlock"><code><?xml version="1.0" encoding="ISO-8859-1"?><br>
|
|
<template type="ProjTempl" version="1.0" supplier="Symbian" revision="1.0" author="Bala Torati"<br>
|
|
id="EXE" label="Simple EXE" description="A skeletal Symbian OS EXE project. Creates a folder for sources and another for include."<br>
|
|
help="help.html"><br>
|
|
<br>
|
|
<property-group id="basics" label="Basic Settings" description="Basic properties of a project" type="PAGES-ONLY" help="help.html"><br>
|
|
<br>
|
|
<property id="uid2"<br>
|
|
label="UID 2"<br>
|
|
description="UID 2"<br>
|
|
default="0x00000000"<br>
|
|
type="input"<br>
|
|
pattern="0x[0-9a-fA-F]{8}"<br>
|
|
hidden="false"<br>
|
|
mandatory="true"<br>
|
|
persist="true"/><br>
|
|
<br>
|
|
<property id="uid3"<br>
|
|
label="UID 3"<br>
|
|
description="UID 3"<br>
|
|
default="0x00000000"<br>
|
|
type="input"<br>
|
|
pattern="0x[0-9a-fA-F]{8}"<br>
|
|
hidden="false"<br>
|
|
mandatory="false"<br>
|
|
persist="true"/><br>
|
|
<br>
|
|
<property id="vid"<br>
|
|
label="Vendor ID"<br>
|
|
description="Vendor ID"<br>
|
|
default="0x00000000"<br>
|
|
type="input"<br>
|
|
pattern="0x[0-9a-fA-F]{8}"<br>
|
|
hidden="false"<br>
|
|
mandatory="true"<br>
|
|
persist="true"/><br>
|
|
<br>
|
|
<property id="author"<br>
|
|
label="Author"<br>
|
|
description="Name of the author"<br>
|
|
type="input"<br>
|
|
pattern=".*"<br>
|
|
default=""<br>
|
|
hidden="false"<br>
|
|
persist="true"/><br>
|
|
<br>
|
|
<property id="copyright"<br>
|
|
label="Copyright notice"<br>
|
|
description="Your copyright notice"<br>
|
|
type="input"<br>
|
|
pattern=".*"<br>
|
|
default="Your copyright notice"<br>
|
|
hidden="false"<br>
|
|
persist="true"/><br>
|
|
<br>
|
|
<property id="targetType"<br>
|
|
label="Target Type"<br>
|
|
description="Select the target type"<br>
|
|
type="select"<br>
|
|
default="app"<br>
|
|
hidden="false"<br>
|
|
mandatory="true"<br>
|
|
persist="true"><br>
|
|
<item label="APP" value="app"/><br>
|
|
<item label="LIB" value="lib"/><br>
|
|
<item label="DLL" value="dll"/><br>
|
|
<item label="EXE" value="exe"/><br>
|
|
<item label="EXEDLL" value="exedll"/><br>
|
|
</property><br>
|
|
</property-group><br>
|
|
<br>
|
|
<property-group id="directories" label="Project Directories" description="Generated files will be copied to the specified directories under the project root directory" type="PAGES-ONLY" help="help.html"><br>
|
|
<property id="incDir"<br>
|
|
label="Include"<br>
|
|
description="Directory for C++ header files"<br>
|
|
type="input"<br>
|
|
default="inc"<br>
|
|
pattern="[a-zA-Z0-9]+"<br>
|
|
mandatory="true"<br>
|
|
persist="true"/><br>
|
|
<br>
|
|
<property id="sourceDir"<br>
|
|
label="Source"<br>
|
|
description="Directory for C++ source files"<br>
|
|
type="input"<br>
|
|
default="src"<br>
|
|
pattern="[a-zA-Z0-9]+"<br>
|
|
mandatory="true"<br>
|
|
persist="true"/><br>
|
|
</property-group><br>
|
|
<br>
|
|
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject"><br>
|
|
<simple name="name" value="$(projectName)"/><br>
|
|
<simple name="targetType" value="$(targetType)"/><br>
|
|
<simple name="uid2" value="$(uid2)"/><br>
|
|
<simple name="uid3" value="$(uid3)"/><br>
|
|
<simple name="vid" value="$(vid)"/><br>
|
|
</process><br>
|
|
<br>
|
|
<process type="org.eclipse.cdt.core.CreateSourceFolder"><br>
|
|
<simple name="projectName" value="$(projectName)"/><br>
|
|
<simple name="path" value="$(sourceDir)"/><br>
|
|
</process><br>
|
|
<br>
|
|
<process type="org.eclipse.cdt.managedbuilder.core.CreateIncludeFolder"><br>
|
|
<simple name="projectName" value="$(projectName)"/><br>
|
|
<simple name="path" value="$(incDir)"/><br>
|
|
</process><br>
|
|
<br>
|
|
<process type="org.eclipse.cdt.core.AddFiles"><br>
|
|
<simple name="projectName" value="$(projectName)"/><br>
|
|
<complex-array name="files"><br>
|
|
<element><br>
|
|
<simple name="source" value="inc/Basename.h"/><br>
|
|
<simple name="target" value="$(incDir)/$(baseName).h"/><br>
|
|
<simple name="replaceable" value="true"/><br>
|
|
</element><br>
|
|
<element><br>
|
|
<simple name="source" value="src/Basename.cpp"/><br>
|
|
<simple name="target" value="$(sourceDir)/$(baseName).cpp"/><br>
|
|
<simple name="replaceable" value="true"/><br>
|
|
</element><br>
|
|
</complex-array><br>
|
|
</process><br>
|
|
<br>
|
|
<process type="org.eclipse.cdt.managedbuilder.core.AppendToMBSStringListOptionValues"><br>
|
|
<simple
|
|
name="projectName" value= "$(projectName)"/> <br>
|
|
<complex-array name="resourcePaths"><br>
|
|
<element><br>
|
|
<simple name="id" value=".*linker\.libraries\.libraries.*" /><br>
|
|
<simple-array name="values"><br>
|
|
<element value="euser.lib" /><br>
|
|
</simple-array><br>
|
|
<simple name="path" value="" /><br>
|
|
</element><br>
|
|
</complex-array><br>
|
|
</process><br>
|
|
</template></code></p>
|
|
<p>
|
|
The above given template copies the following source (<code class="filename">.cpp</code>)
|
|
and header (<code class="filename">.h</code>) files in the <code>src</code> and <code>inc</code>
|
|
folders respectively. These files uses a set of macros to get the values
|
|
specified by the developer for file name, author name, copyright etc.
|
|
</p>
|
|
<p class="CodeBlock"><code>/*<br>
|
|
============================================================================<br>
|
|
Name : $(baseName).cpp<br>
|
|
Author : $(author)<br>
|
|
Version :<br>
|
|
Copyright : $(copyright)<br>
|
|
Description : Exe source file<br>
|
|
============================================================================<br>
|
|
*/<br>
|
|
<br>
|
|
// Include Files <br>
|
|
<br>
|
|
#include "$(baseName).h"<br>
|
|
#include <e32base.h><br>
|
|
#include <e32std.h><br>
|
|
#include <e32cons.h> // Console<br>
|
|
<br>
|
|
<br>
|
|
// Constants<br>
|
|
<br>
|
|
_LIT(KTextConsoleTitle, "Console");<br>
|
|
_LIT(KTextFailed, " failed, leave code = %d");<br>
|
|
_LIT(KTextPressAnyKey, " [press any key]\n");<br>
|
|
<br>
|
|
<br>
|
|
// Global Variables<br>
|
|
<br>
|
|
LOCAL_D CConsoleBase* console; // write all messages to this<br>
|
|
<br>
|
|
<br>
|
|
// Local Functions<br>
|
|
<br>
|
|
LOCAL_C void MainL(const TDesC& aArgs)<br>
|
|
{<br>
|
|
//<br>
|
|
// add your program code here, example code below<br>
|
|
//<br>
|
|
console->Write(_L("Hello, world!\n"));<br>
|
|
console->Printf(_L("Command line args: \"%S\"\n"), &aArgs);<br>
|
|
}<br>
|
|
<br>
|
|
<br>
|
|
LOCAL_C void DoStartL()<br>
|
|
{<br>
|
|
// Create active scheduler (to run active objects)<br>
|
|
CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();<br>
|
|
CleanupStack::PushL(scheduler);<br>
|
|
CActiveScheduler::Install(scheduler);<br>
|
|
<br>
|
|
// Call main function with command line<br>
|
|
TBuf<256> cmdLine;<br>
|
|
RProcess().CommandLine(cmdLine);<br>
|
|
MainL(cmdLine);<br>
|
|
<br>
|
|
// Delete active scheduler<br>
|
|
CleanupStack::PopAndDestroy(scheduler);<br>
|
|
}<br>
|
|
<br>
|
|
<br>
|
|
// Global Functions<br>
|
|
<br>
|
|
GLDEF_C TInt E32Main()<br>
|
|
{<br>
|
|
// Create cleanup stack<br>
|
|
__UHEAP_MARK;<br>
|
|
CTrapCleanup* cleanup = CTrapCleanup::New();<br>
|
|
<br>
|
|
// Create output console<br>
|
|
TRAPD(createError, console = Console::NewL(KTextConsoleTitle, TSize(KConsFullScreen,KConsFullScreen)));<br>
|
|
if (createError)<br>
|
|
return createError;<br>
|
|
<br>
|
|
// Run application code inside TRAP harness, wait keypress when terminated<br>
|
|
TRAPD(mainError, DoStartL());<br>
|
|
if (mainError)<br>
|
|
console->Printf(KTextFailed, mainError);<br>
|
|
console->Printf(KTextPressAnyKey);<br>
|
|
console->Getch();<br>
|
|
<br>
|
|
delete console;<br>
|
|
delete cleanup;<br>
|
|
__UHEAP_MARKEND;<br>
|
|
return KErrNone;<br>
|
|
}</code></p>
|
|
<p class="CodeBlock"><code>/*<br>
|
|
============================================================================<br>
|
|
Name : $(baseName).h<br>
|
|
Author : $(author)<br>
|
|
Version :<br>
|
|
Copyright : $(copyright)<br>
|
|
Description : Exe header file<br>
|
|
============================================================================<br>
|
|
*/<br>
|
|
<br>
|
|
#ifndef __$(baseName)_H__<br>
|
|
#define __$(baseName)_H__<br>
|
|
<br>
|
|
<br>
|
|
// Include Files<br>
|
|
<br>
|
|
#include <e32base.h><br>
|
|
<br>
|
|
<br>
|
|
// Function Prototypes<br>
|
|
<br>
|
|
GLDEF_C TInt E32Main();<br>
|
|
<br>
|
|
<br>
|
|
#endif // __$(baseName)_H__</code></p>
|
|
<p>
|
|
When the developer chooses the above template in the New Project wizard,
|
|
the following wizard pages are generated:
|
|
</p>
|
|
<div class="Figure">
|
|
<p class="Image"><a name="Basic Settings"><IMG alt="Basic Settings" src="_stock/basicsettings.gif" border=0></a></p>
|
|
<p class="Caption">
|
|
Basic Settings
|
|
</p>
|
|
</div>
|
|
<div class="Figure">
|
|
<p class="Image"><a name="Project Directories"><IMG alt="Project Directories" src="_stock/projectdirectories.gif" border=0></a></p>
|
|
<p class="Caption">
|
|
Project Directories
|
|
</p>
|
|
</div>
|
|
<p>
|
|
The input fields listed in the above given pages are as per the
|
|
definitions given in the template. In the template, the
|
|
<code>property-group</code> element with the ID "basics" defines all the input
|
|
fields required for the <code class="ProgramOutput">Basic Settings</code> page. While the
|
|
<code class="ProgramOutput">property-group</code> element with the ID "directories" defines all
|
|
the input fields required for the <code class="ProgramOutput">Project Directories</code> page.
|
|
</p>
|
|
<p>
|
|
The template will create a Symbian OS <code class="filename">EXE</code> project in the
|
|
Eclipse workspace with all the required resources.
|
|
</p>
|
|
<p>
|
|
The following <code class="ProgramOutput">C/C++ Projects</code> view shows the resources
|
|
created by the New Project wizard for the above given template:
|
|
</p>
|
|
<div class="Figure">
|
|
<p class="Image"><a name="Explorer view"><IMG alt="Explorer view" src="_stock/explorerview.gif" border=0></a></p>
|
|
<p class="Caption">
|
|
Explorer view
|
|
</p>
|
|
</div>
|
|
|
|
</div><div class="Footer">
|
|
<hr noshade size="1">
|
|
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
|
<tr>
|
|
<td class="ButtonBottomBox" align="right" height="12" width="67%">
|
|
<p>
|
|
<A href="Howtoregistertemplates.html"><IMG height=22 alt="[Previous]" src="_stock/btn_prev.gif" width=85 border=0></a>
|
|
<A href="#_top"><IMG height=22 alt="[Top]" src="_stock/btn_top.gif" width=51 align=bottom border=0 ></a>
|
|
<A href="index.html"></a>
|
|
</p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
|