home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 31 / CDASC_31_1996_juillet_aout.iso / vrac / tvrw31d.zip / APP.SKL next >
Text File  |  1996-04-16  |  6KB  |  269 lines

  1. !
  2. ! Application source skeleton file.
  3. !
  4. !  Copyright (c) 1995-96 Balázs Scheidler
  5. !  This file is part of Turbo Vision Resource WorkShop
  6. !
  7. ! Lines that begin with '!' are comments. All other lines are copied to the
  8. ! generated output.
  9. !
  10. ! Lines that begin with ` are quoted lines. Quoted lines are directly copied
  11. ! to output WITHOUT macro expansion. Use this if you need something in a line
  12. ! beginning with $(
  13. !
  14. ! The following macros are defined in this file:
  15. !
  16. !  $(FULLNAME)   = fully expanded filename
  17. !  $(FILENAME)   = 8+3 filename
  18. !  $(FNAME)      = 8 char file name
  19. !  $(FEXT)       = 3 char extension
  20. !  $(DESCRIPTION)= The description of the project
  21. !  $(VERSION)    = the version of this project
  22. !  $(AUTHOR)     = the author of the project
  23. !  $(APPNAME)    = the name of the application
  24. !  $(STATNAME)   = resource ID of the StatusLine
  25. !  $(MENUNAME)   = resource ID of the MenuBar
  26. !
  27. !  You can also use a conditional "macro". It is called $(IFDEF xxxx), where
  28. !  xxxx is one of the below listed strings. TVRW will ignore the lines
  29. !  between $(IFDEF) and $(ENDIF) if the symbol xxxx is not defined.
  30. !  NOTE: DO NOT write anything else in lines which contain $(IFDEF) and
  31. !  $(ENDIF)
  32. !
  33. !   xxxx can be one of the following:
  34. !     CPP
  35. !     PASCAL
  36. !
  37. !     anything else:  true if you gave them in the Sourcer Options dialog
  38. !                     Defines inputline.
  39. !
  40. ! These macros are case insensitive.
  41. !
  42. $(IFDEF PASCAL)
  43. {**************************************************************************
  44.   $(FILENAME), $(APPNAME) main program
  45.  
  46.   Copyright (c) 1996 $(AUTHOR)
  47.  
  48.   Generated by Turbo Vision Resource WorkShop
  49.  **************************************************************************}
  50. $(ENDIF)
  51. $(IFDEF CPP)
  52. /**************************************************************************
  53.   $(FILENAME), $(APPNAME) main module
  54.  
  55.   Copyright (c) 1996 $(AUTHOR)
  56.  
  57.   Generated by Turbo Vision Resource WorkShop
  58.  **************************************************************************/
  59. $(ENDIF)
  60. $(IFDEF PASCAL)
  61. program $(FNAME);
  62. uses
  63.   Drivers, Objects, Views, Dialogs, Menus, Validate, App;
  64. $(IFDEF RESOURCES)
  65. var
  66.   ResFile: PResourceFile;
  67. $(ENDIF)
  68.  
  69. type
  70.   T$(APPNAME) = Object(TApplication)
  71.     constructor Init;
  72.     destructor Done; virtual;
  73.     procedure HandleEvent(var Event: TEvent); virtual;
  74.     procedure InitMenuBar; virtual;
  75.     procedure InitStatusLine; virtual;
  76.   end;
  77.  
  78. constructor T$(APPNAME).Init;
  79. begin
  80. $(IFDEF RESOURCES)
  81.   ResFile := New(PResourceFile, Init(New(PBufStream, Init('$(APPNAME).RES', stOpenRead, 4096))));
  82.   RegisterObjects;
  83.   RegisterViews;
  84.   RegisterDialogs;
  85.   RegisterValidate;
  86.   RegisterMenus;
  87.   RegisterApp;
  88. $(ENDIF)
  89.   inherited Init;
  90. end;
  91.  
  92. destructor T$(APPNAME).Done;
  93. begin
  94.   inherited Done;
  95. $(IFDEF RESOURCES)
  96.   Dispose(ResFile, Done);
  97. $(ENDIF)
  98. end;
  99.  
  100. procedure T$(APPNAME).HandleEvent(var Event: TEvent);
  101. begin
  102.   inherited HandleEvent(Event);
  103.   case Event.What of
  104.     evCommand:
  105.       case Event.Command of
  106.         0: ; { This is only needed to make this code compilable }
  107.       end;
  108.   end;
  109. end;
  110.  
  111. procedure T$(APPNAME).InitMenuBar;
  112. var
  113.   R: TRect;
  114. begin
  115.   GetExtent(R);
  116.   R.B.Y := R.A.Y + 1;
  117. $(IFDEF RESOURCES)
  118.   MenuBar := PMenuBar(ResFile^.Get('$(MENUNAME)'));
  119.   MenuBar^.ChangeBounds(R);
  120. $(ENDIF)
  121. end;
  122.  
  123. procedure T$(APPNAME).InitStatusLine;
  124. var
  125.   R: TRect;
  126. begin
  127.   GetExtent(R);
  128.   R.A.Y := R.B.Y - 1;
  129. $(IFDEF RESOURCES)
  130.   StatusLine := PStatusLine(ResFile^.Get('$(STATNAME)'));
  131.   StatusLine^.ChangeBounds(R);
  132. $(ENDIF)
  133. end;
  134.  
  135. var
  136.   $(APPNAME): T$(APPNAME);
  137.  
  138. begin
  139.   $(APPNAME).Init;
  140.   $(APPNAME).Run;
  141.   $(APPNAME).Done;
  142. end.
  143.  
  144. $(ENDIF)
  145. $(IFDEF CPP)
  146. #define Uses_TApplication
  147. #define Uses_TKeys
  148. #define Uses_TRect
  149. #define Uses_TMenuBar
  150. #define Uses_TSubMenu
  151. #define Uses_TMenuItem
  152. #define Uses_TStatusLine
  153. #define Uses_TStatusItem
  154. #define Uses_TStatusDef
  155. #define Uses_TDeskTop
  156. #define Uses_TButton
  157. #define Uses_TLabel
  158. #define Uses_TStaticText
  159. #define Uses_TParamText
  160. #define Uses_TMemo
  161. #define Uses_TListBox
  162. #define Uses_TSortedListBox
  163. #define Uses_TScrollBar
  164. #define Uses_THistory
  165. #define Uses_TInputLine
  166. #define Uses_TCheckBoxes
  167. #define Uses_TRadioButtons
  168. #define Uses_TPXPictureValidator
  169. #define Uses_TStringLookupValidator
  170. #define Uses_TRangeValidator
  171. #define Uses_TDialog
  172. $(IFDEF RESOURCES)
  173. #define Uses_TResourceFile
  174. $(ENDIF)
  175. #include <tvision\tv.h>
  176.  
  177. $(IFDEF RESOURCES)
  178. __link(RButton);
  179. __link(RLabel);
  180. __link(RStaticText);
  181. __link(RParamText);
  182. __link(RMemo);
  183. __link(RListBox);
  184. __link(RSortedListBox);
  185. __link(RScrollBar);
  186. __link(RHistory);
  187. __link(RInputLine);
  188. __link(RCheckBoxes);
  189. __link(RRadioButtons);
  190. __link(RPXPictureValidator);
  191. __link(RStringLookupValidator);
  192. __link(RRangeValidator);
  193. __link(RDialog);
  194. $(ENDIF)
  195.  
  196. $(IFDEF RESOURCES)
  197.  
  198. char resFileName[] = "$(APPNAME).RES";
  199.  
  200. TResourceFile *resFile;
  201. $(ENDIF)
  202.  
  203. // application definition...
  204. class T$(APPNAME) : public TApplication
  205. {
  206.  
  207. public:
  208.     T$(APPNAME)();
  209.     ~T$(APPNAME)();
  210.     virtual void handleEvent(TEvent &);
  211.     static TStatusLine *initStatusLine( TRect r );
  212.     static TMenuBar *initMenuBar( TRect r );
  213. };
  214.  
  215. // application constructor
  216. T$(APPNAME)::T$(APPNAME)() :
  217.     TProgInit(&T$(APPNAME)::initStatusLine,
  218.          &T$(APPNAME)::initMenuBar,
  219.          &T$(APPNAME)::initDeskTop)
  220. {
  221. $(IFDEF RESOURCES)
  222.     resFile = new TResourceFile(new fpstream(resFileName, ios:in|ios:binary));
  223. $(ENDIF)
  224. }
  225.  
  226. // application destructor
  227. T$(APPNAME)::~T$(APPNAME)()
  228. {
  229. $(IFDEF RESOURCES)
  230.     destroy(resFile);
  231. $(ENDIF)
  232.     TApplication::~TApplication();
  233. }
  234.  
  235. void T$(APPNAME)::handleEvent(TEvent &event)
  236. {
  237.     TApplication::handleEvent(event);
  238.     switch (event.what) {
  239.         case evCommand:
  240.             break;
  241.     }
  242. }
  243.  
  244. TStatusLine *T$(APPNAME)::initStatusLine(TRect r)
  245. {
  246. $(IFDEF RESOURCES)
  247.     return (TStatusLine *) resFile->get("$(STATNAME)");
  248. $(ELSE)
  249.     return TApplication::initStatusLine(r);
  250. $(ENDIF)
  251. }
  252.  
  253. TMenuBar *T$(APPNAME)::initMenuBar( TRect r )
  254. {
  255. $(IFDEF RESOURCES)
  256.     return (TMenuBar *) resFile->get("$(MENUNAME)");
  257. $(ELSE)
  258.     return TApplication::initMenuBar(r);
  259. $(ENDIF)
  260. }
  261.  
  262. int main()
  263. {
  264.     T$(APPNAME) $(APPNAME);
  265.     $(APPNAME).run();
  266.     return 0;
  267. }
  268. $(ENDIF)
  269.