template "U++ Turtle application with main window" main; id "Main window class name" classname = PACKAGE; select("No layouts", "Generate layout file", "Main window has layout", "Main window has OK/Cancel") "Layout" lay = 2; option "Imagelist file" iml; text "Server URL" host = "localhost"; text "Connection port" port = "8888"; text "Connection limit" limit = "100"; option "Debug mode" debugmode; option "Add GUI mode switch" guiflag; @@<:PACKAGE:>.h #ifndef _<:PACKAGE:>_<:PACKAGE:>_h #define _<:PACKAGE:>_<:PACKAGE:>_h <:?guiflag:> #ifdef flagTURTLEGUI #include #else #include #endif <:/:> #include <:.:> namespace Upp {<:?lay:> #define LAYOUTFILE <<:PACKAGE:>/<:PACKAGE:>.lay> #include <:.:><:?iml:> #define IMAGEFILE <<:PACKAGE:>/<:PACKAGE:>.iml> #include <:.:> class <:classname:> : public <:lay > 1 ? "With" + classname + "Layout" : "TopWindow":> { public: typedef <:classname:> CLASSNAME; <:classname:>(); }; } #endif @@main.cpp #include "<:PACKAGE:>.h"<:?iml:> #define IMAGEFILE <<:PACKAGE:>/<:PACKAGE:>.iml> #include <:.:> using namespace Upp; <:classname:>::<:classname:>() {<:?lay > 1:> CtrlLayout<:(lay == 3 ? "OKCancel" : ""):>(*this, "Window title");<:.:> } void AppMainLoop() { // "Main" stuff should go in here... <:classname:>().Run(); } <:?guiflag:> #ifdef flagTURTLEGUI <:.:> CONSOLE_APP_MAIN { <:?debugmode:> #ifdef _DEBUG TurtleServer::DebugMode(); #endif <:.:> // MemoryLimitKb(100000000); // Can aid preventing DDoS attacks. TurtleServer guiserver; guiserver.Host("<:host:>"); guiserver.Port(<:port:>); guiserver.MaxConnections(<:limit:>); RunTurtleGui(guiserver, AppMainLoop); } <:?guiflag:> #else GUI_APP_MAIN { AppMainLoop(); } #endif <:.:> @@<:PACKAGE:>.lay ??lay LAYOUT(<:classname:>Layout, 200, 100)<:?lay == 3:> ITEM(Button, ok, SetLabel("OK").RightPosZ(90, 80).BottomPosZ(4, 22)) ITEM(Button, cancel, SetLabel("Cancel").RightPosZ(4, 80).BottomPosZ(4, 22))<:.:> END_LAYOUT @@<:PACKAGE:>.iml ??iml @@<:PACKAGE:>.upp <:?guiflag:> uses (TURTLEGUI) Turtle; uses (!TURTLEGUI) CtrlLib; <:/:> uses Turtle; <:.:> file <:PACKAGE:>.h, main.cpp<:?lay:>, <:PACKAGE:>.lay<:.:><:?iml:>, <:PACKAGE:>.iml<:.:>; mainconfig "" = "TURTLEGUI"<:?guiflag:>,<:/:>;<:.:> <:?guiflag:>"" = "GUI";<:.:>