home *** CD-ROM | disk | FTP | other *** search
- // Program : BLDRSC.CPP
- // Author : Eric Woodruff, CIS ID: 72134,1150
- // Updated : Wed 08/25/93 13:54:55
- // Note : Copyright 1993, Eric Woodruff, All rights reserved
- // Compiler: Borland C++ 3.1
- //
- // This program is a generic resource file builder. Plug in the
- // builder functions and declarations then compile.
- //
-
- #define RSC_FILENAME "EXPDEMO.RSC" // File to create.
-
- #define WriteResource(a,b,c) \
- cout << c << endl; \
- a = b(); \
- if( a == 0 ) \
- { \
- strcpy(endString, RSC_FILENAME ": Creation failure\n"); \
- TObject::destroy(rsc); \
- exit(1); \
- } \
- rsc->put(a,c); \
- TObject::destroy(a)
-
- #define WriteObject(a,c) \
- cout << c << endl; \
- if(a == 0) \
- { \
- strcpy(endString, RSC_FILENAME ": Creation failure\n"); \
- TObject::destroy(rsc); \
- exit(1); \
- } \
- rsc->put(a,c); \
- TObject::destroy(a)
-
- #include <conio.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- #define Uses_TApplication
- #define Uses_TButton
- #define Uses_TCheckBoxes
- #define Uses_TDeskTop
- #define Uses_TDialog
- #define Uses_TInputLine
- #define Uses_TKeys
- #define Uses_TLabel
- #define Uses_TMenuBar
- #define Uses_TMenuItem
- #define Uses_TProgram
- #define Uses_TRadioButtons
- #define Uses_TRect
- #define Uses_TResourceFile
- #define Uses_TSItem
- #define Uses_TStaticText
- #define Uses_TStatusDef
- #define Uses_TStatusItem
- #define Uses_TStatusLine
- #define Uses_TSubMenu
- #define Uses_TView
- #define Uses_fpstream
- #include <tv.h>
-
- __link(RButton)
- __link(RCheckBoxes)
- __link(RCluster )
- __link(RInputLine)
- __link(RLabel)
- __link(RMenuBar)
- __link(RRadioButtons)
- __link(RResourceCollection)
- __link(RStaticText)
- __link(RStatusLine)
-
- #define Uses_TExplodeWindow
- #define Uses_TExplodeDialog
- #include <texplode.h>
-
- // NOTE: Always be sure to include these two lines somewhere in your
- // program if you are using streamed TExplodeWindow and/or
- // TExplodeDialog objects (i.e. loading them from a resource file)!
- __link(RExplodeWindow)
- __link(RExplodeDialog)
-
- #include <expdemo.h>
-
- // ============================================================================
- TDialog *AboutBox(void);
- TMenuBar *initMenuBar(void);
- TStatusLine *initStatusLine(void);
-
- Boolean createDemo3Window(void);
- TDialog *createDemo4Dialog(void);
-
- // ============================================================================
-
- fpstream *s;
- TResourceFile* rsc;
- char endString[255] = "";
-
- // ============================================================================
-
- void exitfunc(void)
- {
- cout << endl << endString << endl;
- }
-
- #pragma exit exitfunc 31
-
- void main(void)
- {
- TDialog *dlg;
- TMenuBar *menuBar;
- TStatusLine *statusLine;
-
- cout << "Creating " RSC_FILENAME << endl;
-
- // Construct stream and resource.
- s = new fpstream (RSC_FILENAME, ios::trunc | ios::binary);
- rsc = new TResourceFile(s);
-
- // Create all of the necessary dialogs for the program.
- WriteResource(dlg, AboutBox, "AboutBox");
-
- if(!createDemo3Window()) // Writes directly to the stream.
- {
- cout << RSC_FILENAME << ": Creation failure" << endl; \
- TObject::destroy(rsc); \
- exit(1); \
- }
- WriteResource(dlg, createDemo4Dialog, "Demo4");
-
- // Create the menus and status line.
- WriteResource(menuBar, initMenuBar, "MenuBar");
- WriteResource(statusLine, initStatusLine, "StatusLine");
-
- TObject::destroy(rsc);
- strcpy(endString, RSC_FILENAME " creation completed.");
- }
-
- // ============================================================================
-
- TDialog *AboutBox(void)
- {
- TExplodeDialog *aboutBox = new TExplodeDialog(TRect(0, 0, 46, 11),
- "About");
- aboutBox->options |= ofCentered;
- aboutBox->MakeItExplode(30); // Change explode/implode rate.
-
- aboutBox->insert(new TStaticText(TRect(2, 2, 45, 7),
- "\003TExplodeWindow/TExplodeDialog Class Demo\n"
- "\003Streamable Versions\n\003\n"
- "\003by Eric Woodruff\n\003CIS ID: 72134,1150\n"));
-
- TButton *b = new TButton(TRect(11,8,23,10), "O~K~", cmOK, bfDefault);
- b->options |= ofCenterX;
- aboutBox->insert(b);
-
- return aboutBox;
- }
-
- TMenuBar *initMenuBar(void)
- {
- TSubMenu& MiscMenu = *new TSubMenu( "~\xF0~", 0 ) +
- *new TMenuItem( "~A~bout...", cmAboutCmd, kbNoKey) +
- newLine() +
- *new TMenuItem( "E~x~it", cmQuit, kbAltX, hcNoContext, "Alt+X" );
-
- TSubMenu& DemoMenu = *new TSubMenu("~E~xplode Demos", 0) +
- *new TMenuItem("~T~ExplodeWindow demo", cmDemo1, kbF2,
- hcNoContext, "F2") +
- *new TMenuItem("T~E~xplodeDialog demo", cmDemo2, kbF3,
- hcNoContext, "F3") +
- *new TMenuItem("~G~et TExplodeWindow from stream", cmDemo3, kbF7,
- hcNoContext, "F7") +
- *new TMenuItem("Get TE~x~plodeDialog from stream", cmDemo4, kbF8,
- hcNoContext, "F8");
-
- TSubMenu& WindowMenu = *new TSubMenu( "~W~indows", 0 ) +
- *new TMenuItem( "~S~ize/move", cmResize, kbCtrlF5, hcNoContext, "Ctrl+F5" ) +
- *new TMenuItem( "~Z~oom", cmZoom, kbF5, hcNoContext, "F5" ) +
- *new TMenuItem( "~N~ext", cmNext, kbF6, hcNoContext, "F6" ) +
- *new TMenuItem( "~P~revious", cmPrev, kbShiftF6, hcNoContext, "Shift+F6" ) +
- *new TMenuItem( "~C~lose", cmClose, kbAltF3, hcNoContext, "Alt+F3" ) +
- newLine() +
- *new TMenuItem( "T~o~ggle screen size", cmScreenSize, kbNoKey) +
- *new TMenuItem( "C~l~ose all tileable windows", cmCloseTileable, kbNoKey) +
- *new TMenuItem( "~T~ile", cmTile, kbNoKey) +
- *new TMenuItem( "C~a~scade", cmCascade, kbNoKey);
-
- return new TMenuBar( TRect(0, 0, 80, 1), MiscMenu + DemoMenu +
- WindowMenu);
- }
-
- TStatusLine *initStatusLine(void)
- {
- return new TStatusLine( TRect(0, 24, 80, 25),
- *new TStatusDef( 0, 0xFFFF ) +
- *new TStatusItem( NULL, kbF10, cmMenu ) +
- *new TStatusItem( "~Alt+X~ Exit", kbAltX, cmQuit ) +
- *new TStatusItem( "~Alt+F3~ Close", kbAltF3, cmClose ) +
- *new TStatusItem( "~F2~ Window", kbF2, cmDemo1 ) +
- *new TStatusItem( "~F3~ Dialog", kbF3, cmDemo2 ) +
- *new TStatusItem( "~F7~ Get Window", kbF7, cmDemo3 ) +
- *new TStatusItem( "~F8~ Get Dialog", kbF8, cmDemo4 ));
- }
-
- Boolean createDemo3Window(void)
- {
- TExplodeWindow *xw = new TExplodeWindow(TRect(0,0,80,23),
- "Resource File Exploding Window Demo", 0);
-
- if(!xw)
- return False;
-
- xw->MakeItExplode(0); // Explode it as fast as possible.
- xw->options |= ofTileable;
- xw->growMode = gfGrowAll | gfGrowRel;
-
- TRect r = xw->getExtent();
- r.grow(-1, -1);
-
- TStaticText *s = new TStaticText(r, "This is a streamed test.");
- s->growMode = gfGrowHiX | gfGrowHiY;
- xw->insert(s);
-
- WriteObject(xw, "Demo3");
-
- return True; // Successful.
- }
-
- TDialog *createDemo4Dialog(void)
- {
- TExplodeDialog *xd = new TExplodeDialog(TRect(0,0,80,23),
- "Resource File Exploding Dialog Box Demo");
-
- if(!xd)
- return NULL;
-
- xd->options |= ofCentered;
- xd->MakeItExplode(0); // Make it explode as fast as possible.
-
- TRadioButtons *r = new TRadioButtons(TRect(3,2,26,21),
- new TSItem("Radio Button #1",
- new TSItem("Radio Button #2",
- new TSItem("Radio Button #3",
- new TSItem("Radio Button #4",
- new TSItem("Radio Button #5",
- new TSItem("Radio Button #6",
- new TSItem("Radio Button #7",
- new TSItem("Radio Button #8",
- new TSItem("Radio Button #9",
- new TSItem("Radio Button #10",
- new TSItem("Radio Button #11",
- new TSItem("Radio Button #12",
- new TSItem("Radio Button #13",
- new TSItem("Radio Button #14",
- new TSItem("Radio Button #15",
- new TSItem("Radio Button #16",
- new TSItem("Radio Button #17",
- new TSItem("Radio Button #18",
- new TSItem("Radio Button #19", 0))))))))))))))))))));
- xd->insert(r);
- xd->insert(new TLabel(TRect(2,1,23,2), "~R~adio Buttons", r));
-
- TCheckBoxes *c = new TCheckBoxes(TRect(28,2,51,21),
- new TSItem("Checkbox #1",
- new TSItem("Checkbox #2",
- new TSItem("Checkbox #3",
- new TSItem("Checkbox #4",
- new TSItem("Checkbox #5",
- new TSItem("Checkbox #6",
- new TSItem("Checkbox #7",
- new TSItem("Checkbox #8",
- new TSItem("Checkbox #9",
- new TSItem("Checkbox #10",
- new TSItem("Checkbox #11",
- new TSItem("Checkbox #12",
- new TSItem("Checkbox #13",
- new TSItem("Checkbox #14",
- new TSItem("Checkbox #15",
- new TSItem("Checkbox #16",
- new TSItem("Checkbox #17",
- new TSItem("Checkbox #18",
- new TSItem("Checkbox #19", 0))))))))))))))))))));
- xd->insert(c);
- xd->insert(new TLabel(TRect(27,1,48,2), "~C~heckboxes", c));
-
- c = new TCheckBoxes(TRect(53,3,77,9),
- new TSItem("Test #1",
- new TSItem("Test #2",
- new TSItem("Test #3",
- new TSItem("Test #4",
- new TSItem("Test #5",
- new TSItem("Test #6", 0)))))));
- xd->insert(c);
- xd->insert(new TLabel(TRect(52,2,72,3), "~M~ore checkboxes", c));
-
- TInputLine *i = new TInputLine(TRect(53,10,77,11), 50);
- xd->insert(i);
- xd->insert(new TLabel(TRect(52,9,63,10), "Input #~1~", i));
-
- i = new TInputLine(TRect(53,12,77,13), 50);
- xd->insert(i);
- xd->insert(new TLabel(TRect(52,11,63,12), "Input #~2~", i));
-
- i = new TInputLine(TRect(53,15,63,16), 50);
- xd->insert(i);
- xd->insert(new TLabel(TRect(52,14,63,15), "Input #~3~", i));
-
- i = new TInputLine(TRect(53,18,63,19), 50);
- xd->insert(i);
- xd->insert(new TLabel(TRect(52,17,63,18), "Input #~4~", i));
-
- i = new TInputLine(TRect(66,18,74,19), 50);
- xd->insert(i);
- xd->insert(new TLabel(TRect(65,17,74,18), "Input #~5~", i));
-
- TButton *btn = new TButton(TRect(53,20,63,22), "O~K~", cmOK, bfDefault);
- xd->insert(btn);
-
- btn = new TButton(TRect(67,20,77,22), "Cancel", cmCancel, bfNormal);
- xd->insert(btn);
-
- xd->selectNext(False);
-
- return xd;
- }
-