home *** CD-ROM | disk | FTP | other *** search
- /*-----------------------------------------------------------------------*/
- /* filename - tdemo1.cpp */
- /* */
- /* function(s) */
- /* definitions for the TDemoApp class */
- /* */
- /* Author - Michael "Mick" Newton */
- /* */
- /*-----------------------------------------------------------------------*/
-
- /*-----------------------------------------------------------------------*/
- /* */
- /* TDEMO1.CPP */
- /* */
- /* TVColorDialog shareware version 2.0 */
- /* Copyright (C) 1992,1993 Comsoft Software */
- /* All Rights Reserved. */
- /* */
- /* */
- /*-----------------------------------------------------------------------*/
-
- // Define Turbo Vision classes used ***************************************
-
- #define Uses_TApplication
- #define Uses_TBackground
- #define Uses_TButton
- #define Uses_TCheckBoxes
- #define Uses_TCluster
- #define Uses_TCollection
- #define Uses_TColorGroup
- #define Uses_TColorItem
- #define Uses_TDeskTop
- #define Uses_TDialog
- #define Uses_TDisplay
- #define Uses_TEvent
- #define Uses_TFrame
- #define Uses_TGroup
- #define Uses_THistory
- #define Uses_TInputLine
- #define Uses_TKeys
- #define Uses_TLabel
- #define Uses_TListBox
- #define Uses_TListViewer
- #define Uses_TMenu
- #define Uses_TMenuBar
- #define Uses_TMenuItem
- #define Uses_TMenuView
- #define Uses_TObject
- #define Uses_TPalette
- #define Uses_TPoint
- #define Uses_TProgram
- #define Uses_TRadioButtons
- #define Uses_TRect
- #define Uses_TScreen
- #define Uses_TScrollBar
- #define Uses_TStaticText
- #define Uses_TStatusDef
- #define Uses_TStatusItem
- #define Uses_TStatusLine
- #define Uses_TSItem
- #define Uses_TStringCollection
- #define Uses_TSubMenu
- #define Uses_TView
- #define Uses_TWindow
- #define Uses_MsgBox
- #define Uses_fpstream
-
- #include <tv.h>
-
-
-
-
-
- // CRTL header files ******************************************************
-
- #if !defined __STDLIB_H
- #include <stdlib.h>
- #endif
-
- #if !defined __STDIO_H
- #include <stdio.h>
- #endif
-
- #if !defined __CONIO_H
- #include <conio.h>
- #endif
-
- #if !defined __STRSTREAM_H
- #include <strstrea.h>
- #endif
-
- #if !defined __STRING_H
- #include <string.h>
- #endif
-
-
-
-
-
- // Non-CRTL header files **************************************************
-
- #if !defined __TDEMO1_HPP // TDemoApp
- #include "tdemo1.hpp"
- #endif
-
- #if !defined __TDEMO2_HPP // xdialogs, statusline, etc
- #include "tdemo2.hpp"
- #endif
-
- #if !defined __COLORDLG_HPP // TVColorDialog
- #include "colordlg.hpp"
- #endif
-
-
-
-
-
- // Constants **************************************************************
-
- // Menubar commands
- const cmNone = 0,
- cmAbout = 100,
- cmWritePal = 101,
- cmColors = 102,
- cmOptions = 103,
- cmXDialog1 = 104,
- cmXDialog2 = 105,
- cmXDialog3 = 106;
-
-
-
-
-
- // External global variable references ************************************
-
- extern TPoint shadowSize;
- extern unsigned _stklen = 8192; // 8K stack
-
- #if defined __OVERLAY__
- extern unsigned _ovrbuffer = 0x2000;
- #endif
-
-
-
-
-
- // TMenuItem **************************************************************
-
- TMenuItem& operator +(TMenuItem& item1, TMenuItem& item2)
- {
- // For building the application menubar
-
- TMenuItem *p = &item1;
-
- while(p->next != NULL)
- p = p->next;
-
- p->next = &item2;
-
- return item1;
- }
-
-
-
-
-
- // TDemoApp ***************************************************************
-
- /* ┌───────────────────────────────────────────────────────────────────┐ */
- /* │ TDemoApp palette layout │ */
- /* ╞═══════════════════════════════════════════════════════════════════╡ */
- /* │ │ */
- /* │ NOTE: │ */
- /* │ Since elements of a palette are of type char, the maximum number │ */
- /* │ of elements for a palette is 255. Since the char data type has a │ */
- /* │ range of -128 to 127, TVColorDialog treats palette entries as │ */
- /* │ unsigned chars, which range from 0 to 255. │ */
- /* │ │ */
- /* │ This demo's palette contains 240 elements, not all of which are │ */
- /* │ used. The unused elements are for future expansion. │ */
- /* │ │ */
- /* ╞═══════╤═══════╤═══════════════════════════════════════════════════╡ */
- /* │ Start │ End │ │ */
- /* │ index │ index │ Items (* non-standard palette) │ */
- /* ├───────┼───────┼───────────────────────────────────────────────────┤ */
- /* │ │ 1 │ Desktop background │ */
- /* │ 2 │ 7 │ Menus │ */
- /* │ 8 │ 15 │ Windows (blue) │ */
- /* │ 16 │ 23 │ Windows (cyan) │ */
- /* │ 24 │ 31 │ Windows (gray) │ */
- /* │ 32 │ 63 │ TDialog │ */
- /* │ * 64 │ 113 │ TXDialog1 │ */
- /* │ * 114 │ 163 │ TXDialog2 │ */
- /* │ * 164 │ 213 │ TXDialog3 │ */
- /* │ * 214 │ 219 │ TAppStatusLine │ */
- /* │ * 220 │ 240 │ Unused │ */
- /* └───────┴───────┴───────────────────────────────────────────────────┘ */
-
- // Application color palette
- #define cpAppColor \
- "\x08\x17\x18\x1F\x0E\x08\x0A\x48\x4E\x4E" \
- "\x09\x1F\x4F\x4D\x4A\x4B\x70\x7F\x7E\x78" \
- "\x71\x40\x00\x70\x7F\x7A\x13\x13\x70\x7F" \
- "\x00\x78\x70\x7F\x0C\x0E\x70\x70\x7F\x7E" \
- "\x17\x1E\x1F\x18\x1A\x78\x03\x4F\x0F\x03" \
- "\x0C\x0A\x70\x78\x0C\x0E\x03\x4F\x0E\x70" \
- "\x0A\x00\x00\x18\x1F\x0E\x0D\x4F\x17\x1F" \
- "\x1E\x1A\x70\x7E\x4F\x78\x7B\x10\x03\x4F" \
- "\x0E\x03\x0C\x0A\x1E\x17\x0C\x0E\x03\x4F" \
- "\x0E\x1F\x0A\x2E\x0C\x7E\x5B\x4F\x58\x7F" \
- "\x57\x4A\x00\x18\x1F\x70\x7F\x31\x13\x00" \
- "\x00\x18\x1E\x58\x5F\x0E\x0A\x4F\x57\x5F" \
- "\x5E\x5B\x70\x7F\x4F\x78\x7E\x50\x03\x4F" \
- "\x0E\x03\x0C\x0A\x5E\x57\x0C\x4E\x03\x4F" \
- "\x0E\x5F\x0A\x31\x30\x3E\x3E\x4F\x37\x3F" \
- "\x3D\x4D\x60\x58\x5F\x70\x30\x3A\x6F\x6E" \
- "\x17\x1B\x1F\x28\x2F\x0E\x09\x4E\x20\x2F" \
- "\x2E\x24\x70\x7F\x4F\x78\x7E\x20\x03\x4F" \
- "\x0E\x03\x0C\x0A\x2E\x20\x0C\x0E\x03\x4F" \
- "\x0E\x2F\x0A\x1F\x4F\x5E\x7A\x7F\x78\x5F" \
- "\x7D\x70\x0C\x28\x2F\x5F\x5E\x3E\x17\x1B" \
- "\x1F\x18\x1E\x17\x18\x1F\x4F\x4E\x48\x18" \
- "\x17\x0E\x0C\x4E\x17\x1E\x4F\x47\x4E\x70" \
- "\x7E\x30\x3F\x1B\x0A\x31\x13\x00\x00\x00"
-
- // Application black and white palette
- #define cpAppBlackWhite \
- "\x07\x70\x78\x7F\x0F\x08\x07\x07\x0F\x07" \
- "\x70\x70\x07\x70\x00\x07\x0F\x07\x70\x70" \
- "\x07\x70\x00\x70\x7F\x7F\x70\x07\x70\x07" \
- "\x00\x70\x7F\x7F\x70\x07\x70\x70\x7F\x7F" \
- "\x07\x0F\x0F\x78\x0F\x78\x07\x0F\x0F\x0F" \
- "\x70\x0F\x07\x70\x70\x70\x07\x70\x0F\x07" \
- "\x07\x00\x00\x07\x70\x0F\x70\x0F\x70\x70" \
- "\x7F\x78\x07\x0F\x7F\x08\x07\x78\x7F\x0F" \
- "\x78\x07\x0F\x78\x0F\x78\x07\x0F\x07\x0F" \
- "\x70\x07\x0F\x70\x70\x7F\x70\x0F\x78\x78" \
- "\x07\x08\x00\x70\x7F\x70\x0F\x07\x07\x00" \
- "\x00\x70\x7F\x7F\x70\x07\x70\x70\x7F\x7F" \
- "\x07\x0F\x0F\x78\x0F\x78\x07\x0F\x0F\x0F" \
- "\x70\x0F\x07\x70\x70\x70\x07\x70\x0F\x07" \
- "\x07\x07\x00\x70\x07\x70\x0F\x07\x07\x00" \
- "\x00\x70\x7F\x7F\x70\x07\x70\x70\x7F\x7F" \
- "\x07\x0F\x0F\x78\x0F\x78\x07\x0F\x0F\x0F" \
- "\x70\x0F\x07\x70\x70\x70\x07\x70\x0F\x07" \
- "\x07\x07\x0F\x7F\x07\x70\x0F\x07\x07\x0F" \
- "\x7F\x07\x0F\x07\x70\x70\x70\x07\x70\x70" \
- "\x7F\x7F\x70\x07\x70\x70\x7F\x7F\x07\x0F" \
- "\x0F\x78\x0F\x70\x78\x7F\x0F\x07\x08\x0F" \
- "\x07\x70\x70\x70\x07\x70\x0F\x07\x07\x00" \
- "\x00\x70\x07\x70\x0F\x07\x07\x00\x00\x00"
-
- // Application monochrome palette
- #define cpAppMonochrome \
- "\x07\x07\x01\x0F\x70\x70\x01\x07\x0F\x07" \
- "\x70\x70\x07\x70\x00\x07\x0F\x07\x70\x70" \
- "\x07\x70\x00\x70\x70\x70\x07\x07\x70\x07" \
- "\x00\x07\x70\x0F\x07\x0F\x70\x70\x0F\x01" \
- "\x07\x01\x0F\x70\x01\x70\x07\x0F\x01\x07" \
- "\x0F\x0F\x07\x07\x07\x0F\x07\x70\x0F\x07" \
- "\x07\x00\x00\x07\x0F\x07\x70\x70\x07\x0F" \
- "\x70\x70\x70\x70\x07\x07\x70\x70\x70\x0F" \
- "\x07\x07\x0F\x70\x0F\x70\x07\x0F\x0F\x07" \
- "\x70\x07\x07\x70\x07\x07\x07\x70\x0F\x07" \
- "\x07\x00\x00\x07\x07\x70\x0F\x07\x07\x00" \
- "\x00\x70\x70\x70\x07\x07\x70\x70\x70\x0F" \
- "\x07\x07\x0F\x70\x0F\x70\x07\x0F\x0F\x07" \
- "\x70\x07\x07\x70\x07\x07\x07\x70\x0F\x07" \
- "\x07\x00\x00\x07\x07\x70\x0F\x07\x07\x00" \
- "\x00\x70\x70\x70\x07\x07\x70\x70\x70\x0F" \
- "\x07\x07\x0F\x70\x0F\x70\x07\x0F\x0F\x07" \
- "\x70\x07\x07\x70\x07\x07\x07\x70\x0F\x07" \
- "\x07\x00\x00\x07\x07\x70\x0F\x07\x07\x00" \
- "\x00\x07\x0F\x07\x70\x70\x70\x07\x0F\x70" \
- "\x70\x70\x07\x07\x70\x70\x70\x0F\x07\x07" \
- "\x0F\x70\x0F\x07\x70\x0F\x01\x07\x70\x07" \
- "\x07\x70\x07\x07\x07\x70\x0F\x07\x07\x00" \
- "\x00\x07\x07\x70\x0F\x07\x07\x00\x00\x00"
-
-
- TDemoApp::TDemoApp() :
- TProgInit(initStatusLine, initMenuBar, initDeskTop),
- patternIndex(4)
- {
- // Set default options in optrec data structure
- optrec.addHelp = 1;
- optrec.patternCount = 2;
- optrec.videoMode = 0;
-
- // Set default desktop pattern and redraw
- deskTop->background->setPattern(patterns[patternIndex]);
- setState(sfExposed, True);
- redraw();
-
- // Display the "about" box
- TEvent event;
- event.what = evCommand;
- event.message.command = cmAbout;
- putEvent(event);
- clearEvent(event);
- }
-
-
- void TDemoApp::shutDown()
- {
- TApplication::shutDown();
- }
-
-
- TDeskTop *TDemoApp::initDeskTop(TRect r)
- {
- r.a.y++;
- r.b.y--;
-
- // Stop the application from drawing in default colors
- TProgram::application->setState(sfExposed, False);
-
- TDeskTop *desktop = new TDeskTop(r);
-
- return desktop;
- }
-
-
- TMenuBar *TDemoApp::initMenuBar(TRect r)
- {
- // Builds the program's menubar
-
- r.b.y = r.a.y + 1;
-
- TMenuItem *sys;
- sys = new TMenuItem("~\360~", kbAltSpace, new TMenu(
- *new TMenuItem("~A~bout", cmAbout, kbNoKey, hcAbout) +
- *new TMenuItem("~W~rite palette to file", cmWritePal, kbNoKey,
- hcWritePal)), hcSystem);
-
- TMenuItem *exit;
- exit = new TMenuItem("E~x~it", cmQuit, kbAltX, hcExit, 0);
-
- TMenuItem *colors;
- colors = new TMenuItem("~T~VColorDialog", cmColors, kbAltT,
- hcColors, 0);
-
- TMenuItem *opts;
- opts = new TMenuItem("~O~ptions", cmOptions, kbAltO, hcOptions, 0);
-
- TMenuItem *xdlg;
- xdlg = new TMenuItem("~D~ialogs", kbAltD, new TMenu(
- *new TMenuItem("TXDialog~1~", cmXDialog1, kbNoKey, hcXDialogs) +
- *new TMenuItem("TXDialog~2~", cmXDialog2, kbNoKey, hcXDialogs) +
- *new TMenuItem("TXDialog~3~", cmXDialog3, kbNoKey, hcXDialogs)),
- hcXDialogs);
-
- TMenu *menu = new TMenu(*sys + *exit + *colors + *opts + *xdlg);
- TMenuBar *menubar = new TMenuBar(r, menu);
-
- return menubar;
- }
-
-
- TStatusLine *TDemoApp::initStatusLine(TRect r)
- {
- // Builds the program's status line.
- //
- // NOTE: Actually returns a pointer to a TAppStatusLine object.
- // See tdemo2.cpp for definition of TAppStatusLine class.
-
- r.a.y = r.b.y - 1;
-
- return new TAppStatusLine(r,
- *new TStatusDef(0, 0xFFFF) +
- *new TStatusItem("~Alt-X~ Exit", kbAltX, cmQuit) +
- *new TStatusItem("~F10~ Menu", kbF10, cmMenu));
- }
-
-
- TPalette& TDemoApp::getPalette() const
- {
- // Returns a reference to either the color, monochrome, or
- // black and white palette, depending on value of 'appPalette'.
-
- static TPalette pal1(cpAppColor, sizeof(cpAppColor) - 1);
- static TPalette pal2(cpAppBlackWhite, sizeof(cpAppBlackWhite) - 1);
- static TPalette pal3(cpAppMonochrome, sizeof(cpAppMonochrome) - 1);
- static TPalette *palettes[] = {&pal1, &pal2, &pal3};
- return *(palettes[appPalette]);
- }
-
-
- void TDemoApp::getEvent(TEvent& event)
- {
- static Boolean helpInUse = False;
-
- TApplication::getEvent(event);
-
- switch(event.what)
- {
- case evCommand:
- if(event.message.command == cmHelp && !helpInUse)
- {
- helpInUse = True;
- helpDialog();
- helpCtx = hcNoContext;
- helpInUse = False;
- clearEvent(event);
- }
- break;
- case evMouseDown:
- if(event.mouse.buttons != mbLeftButton)
- event.what = evNothing;
- break;
- }
-
- // getEvent
- }
-
-
- void TDemoApp::handleEvent(TEvent& event)
- {
- TApplication::handleEvent(event);
-
- if(event.what == evCommand)
- {
- switch(event.message.command)
- {
- case cmAbout:
- about();
- break;
- case cmWritePal:
- writePalette();
- break;
- case cmColors:
- colors();
- break;
- case cmOptions:
- options();
- break;
- case cmXDialog1:
- xdialog1();
- break;
- case cmXDialog2:
- xdialog2();
- break;
- case cmXDialog3:
- xdialog3();
- break;
- }
- }
-
- clearEvent(event);
- }
-
-
- void TDemoApp::about()
- {
- // Displays information about this demo application
-
- TDialog *dialog = new TDialog(TRect(10, 1, 70, 21), "About");
-
- if(dialog == NULL)
- return;
-
- dialog->options |= ofCentered;
- dialog->helpCtx = hcAbout;
-
- TView *box;
- box = new TView(TRect(1, 12, 59, 15));
- box->options |= ofFramed | ofCenterX;
- dialog->insert(box);
-
- TStaticText *t;
- t = new TStaticText(TRect(25, 2, 34, 3), "TDEMO.EXE");
- t->options |= ofCenterX;
- dialog->insert(t);
-
- t = new TStaticText(TRect(11, 3, 49, 4),
- "Demonstrates the TVColorDialog library");
- t->options |= ofCenterX;
- dialog->insert(t);
-
- char ver[36];
- strcpy(ver, "TVColorDialog shareware version ");
- strcat(ver, colorDlgVerStr);
-
- t = new TStaticText(TRect(12, 5, 47, 6), ver);
- t->options |= ofCenterX;
- dialog->insert(t);
-
- t = new TStaticText(TRect(10, 6, 50, 7),
- "(C) Copyright 1992,1993 Comsoft Software");
- t->options |= ofCenterX;
- dialog->insert(t);
-
- t = new TStaticText(TRect(20, 7, 40, 8), "All rights reserved.");
- t->options |= ofCenterX;
- dialog->insert(t);
-
- t = new TStaticText(TRect(7, 9, 53, 10),
- "Created by Michael Newton for Comsoft Software");
- t->options |= ofCenterX;
- dialog->insert(t);
-
- t = new TStaticText(TRect(3, 12, 57, 13),
- "See the file COLORDLG.DOC for information"
- " on obtaining");
- t->options |= ofCenterX;
- dialog->insert(t);
-
- t = new TStaticText(TRect(4, 13, 56, 14),
- "a registered version of TVColorDialog"
- " complete with");
- t->options |= ofCenterX;
- dialog->insert(t);
-
- t = new TStaticText(TRect(16, 14, 44, 15),
- "fully commented source code!");
- t->options |= ofCenterX;
- dialog->insert(t);
-
- TButton *b;
- b = new TButton(TRect(14, 17, 46, 19), "~O~k", cmOK, bfDefault);
- b->options |= ofCenterX;
- dialog->insert(b);
-
- if(validView(dialog))
- {
- deskTop->execView(dialog);
- TObject::destroy((TDialog *) dialog);
- }
- }
-
-
- void TDemoApp::writePalette()
- {
- // Writes the applications palettes to a text file formatted as they
- // appear in the TDemoApp palette #defines above.
- //
- // NOTE: The resulting text file can be pasted into this code to
- // replace the current application palettes
- //
-
- char filename[256];
- memset(filename, '\0', 256);
-
- ushort result = inputBox("Path and/or filename for palette file",
- "Path/Filename", filename, 255);
-
- if(result == cmCancel)
- return;
-
- char buff[512];
- ostrstream os(buff, sizeof buff);
-
- fpstream *f = new fpstream(filename, ios::out | ios::trunc);
-
- if(!f->good())
- {
- os << "\003Could not create palette file:\n\003"
- << filename
- << ends;
- messageBox(buff, mfError | mfOKButton);
- return;
- }
-
- char *commentLine[] =
- {
- "// Application color palette",
- "// Application black and white palette",
- "// Application monochrome palette"
- };
- char *paletteName[] =
- {
- "#define cpAppColor ",
- "#define cpAppBlackWhite ",
- "#define cpAppMonochrome "
- };
- char reverseSlant[] = "\\";
- char quotationMark[] = "\"";
- opstream& strm = *f;
- int curpal = appPalette;
-
- // Write all three application palettes to stream
- for(int paletteCtr = 0; paletteCtr < 3; paletteCtr++)
- {
- char oldFill;
- os.seekp(0);
- os << commentLine[paletteCtr]
- << endl
- << paletteName[paletteCtr]
- << reverseSlant
- << endl
- << " "
- << quotationMark
- << ends;
- strm.writeBytes(buff, strlen(buff));
- os.setf(ios::uppercase);
- os.setf(ios::hex, ios::basefield);
- oldFill = os.fill('0');
- appPalette = paletteCtr;
- TPalette &palette = getPalette();
- int length = palette[0] & 0x00FF;
- for(int ctr = 1; ctr <= length; ctr++)
- {
- os.seekp(0);
- os << reverseSlant
- << "x";
- os.width(2);
- os << (unsigned int) palette[ctr];
- if(ctr == length)
- os << quotationMark;
- else if(ctr % 10 == 0)
- os << quotationMark
- << " "
- << reverseSlant
- << endl
- << " "
- << quotationMark;
- os << ends;
- strm.writeBytes(buff, strlen(buff));
- }
- os.fill(oldFill);
- os.seekp(0);
- os << endl
- << endl
- << ends;
- strm.writeBytes(buff, strlen(buff));
- }
-
- appPalette = curpal;
- f->close();
- delete((fpstream *) f);
- helpCtx = hcNoContext;
- }
-
-
- void TDemoApp::options()
- {
- // Displays a dialog which lets the user select TVColorDialog options
-
- TDialog *dialog;
- dialog = new TDialog(TRect(21, 1, 59, 21), "TVColorDialog options");
-
- if(dialog == NULL)
- return;
-
- dialog->options |= ofCentered;
- dialog->helpCtx = hcOptions;
-
- TCheckBoxes *helpCheckbox;
- helpCheckbox = new TCheckBoxes(TRect(3, 3, 35, 4),
- new TSItem("Include help button", 0));
- helpCheckbox->options |= ofFramed;
- dialog->insert(helpCheckbox);
-
- TLabel *l;
- l = new TLabel(TRect(4, 2, 17, 3), "~H~elp button ", helpCheckbox);
- dialog->insert(l);
-
- TRadioButtons *patbutton;
- patbutton = new TRadioButtons(TRect(3, 6, 35, 9),
- new TSItem("~4~ characters",
- new TSItem("~8~ characters",
- new TSItem("~1~6 characters", 0))));
- patbutton->options |= ofFramed;
- dialog->insert(patbutton);
-
- l = new TLabel(TRect(4, 5, 34, 6),
- "~N~umber of pattern characters ", patbutton);
- dialog->insert(l);
-
- TRadioButtons *modebutton;
- modebutton = new TRadioButtons(TRect(3, 11, 35, 15),
- new TSItem("~2~5 lines color",
- new TSItem("~4~3/50 lines color",
- new TSItem("~M~onochrome",
- new TSItem("~B~lack and white", 0)))));
- modebutton->options |= ofFramed;
- dialog->insert(modebutton);
-
- l = new TLabel(TRect(4, 10, 16, 11), "~V~ideo mode ", modebutton);
- dialog->insert(l);
-
- TButton *b;
- b = new TButton(TRect(4, 17, 18, 19), "~C~ancel", cmCancel, bfNormal);
- dialog->insert(b);
-
- b = new TButton(TRect(20, 17, 34, 19), "~O~k", cmOK, bfDefault);
- dialog->insert(b);
-
- dialog->selectNext(False);
- dialog->helpCtx = hcOptions;
-
- if(validView(dialog))
- {
- ushort curmode = optrec.videoMode;
- dialog->setData(&optrec);
- if(deskTop->execView(dialog) != cmCancel)
- {
- dialog->getData(&optrec);
- if(curmode != optrec.videoMode)
- setVideoMode();
- }
- TObject::destroy((TDialog *) dialog);
- }
- }
-
-
- void TDemoApp::setVideoMode()
- {
- // Sets the video mode to the mode stored in optrec
-
- ushort mode;
-
- switch(optrec.videoMode)
- {
- case 0:
- mode = TDisplay::smCO80;
- break;
- case 1:
- mode = TDisplay::smFont8x8;
- break;
- case 2:
- mode = TDisplay::smBW80;
- break;
- default:
- mode = TDisplay::smMono;
- break;
- }
-
- if((mode & TDisplay::smFont8x8) != 0)
- shadowSize.x = 1;
- else
- shadowSize.x = 2;
-
- // Set the selected mode
- setScreenMode(mode);
-
- // Force a redraw of the application
- setState(sfExposed, False);
- setState(sfExposed, True);
- redraw();
- }
-
-
- TColorGroup &TDemoApp::buildGroup1()
- {
- // Builds color group 1 for the TVColorDialog
-
- // Maximum visible length of a string in either the "groups" list
- // of "items" list is 37 characters
- // "1---------------to-----------------37"
-
- TColorGroup &g1 =
- *new TColorGroup("Desktop") +
- *new TColorItem("Background Color", 1);
-
- TColorGroup &g2 =
- *new TColorGroup("Menus") +
- *new TColorItem("Normal Text", 2) +
- *new TColorItem("Disabled Entry Text", 3) +
- *new TColorItem("Shortcut Letter", 4) +
- *new TColorItem("Selection Bar Normal Text", 5) +
- *new TColorItem("Selection Bar Disabled Text", 6) +
- *new TColorItem("Selection Bar Shortcut Letter", 7);
-
- TColorGroup &g3 =
- *new TColorGroup("Status Line") +
- *new TColorItem("Normal Text", 214) +
- *new TColorItem("Disabled Entry Text", 215) +
- *new TColorItem("Shortcut Letter", 216) +
- *new TColorItem("Selected Text", 217) +
- *new TColorItem("Selected Letter", 218) +
- *new TColorItem("Selected Disabled Text", 219);
-
- TColorGroup &group1 = g1 + g2 + g3;
-
- return group1;
- }
-
-
- TColorGroup &TDemoApp::buildGroup2()
- {
- // Builds color group 2 for the TVColorDialog
-
- // Maximum visible length of a string in either the "groups" list
- // of "items" list is 37 characters
- // "1---------------to-----------------37"
-
- TColorGroup &group2 =
- *new TColorGroup("Standard Dialogs") +
- *new TColorItem("Frame Passive", 32) +
- *new TColorItem("Frame Active", 33) +
- *new TColorItem("Frame Icons", 34) +
- *new TColorItem("Scrollbar Page Area", 35) +
- *new TColorItem("Scrollbar Icons", 36) +
- *new TColorItem("Static Text", 37) +
- *new TColorItem("Label Normal Text", 38) +
- *new TColorItem("Label Highlight Text", 39) +
- *new TColorItem("Label Shortcut Letter", 40) +
- *new TColorItem("Button Normal", 41) +
- *new TColorItem("Button Default", 42) +
- *new TColorItem("Button Selected", 43) +
- *new TColorItem("Button Disabled", 44) +
- *new TColorItem("Button Shortcut", 45) +
- *new TColorItem("Button Shadow", 46) +
- *new TColorItem("Cluster Normal", 47) +
- *new TColorItem("Cluster Selected", 48) +
- *new TColorItem("Cluster Shortcut", 49) +
- *new TColorItem("Input Line Normal Text", 50) +
- *new TColorItem("Input Line Selected Text", 51) +
- *new TColorItem("Input Line Arrows", 52) +
- *new TColorItem("History List Arrow", 53) +
- *new TColorItem("History List Arrow Sides", 54) +
- *new TColorItem("History List Scrollbar Page Area", 55) +
- *new TColorItem("History List Scrollbar Icons", 56) +
- *new TColorItem("List Viewer Normal Text", 57) +
- *new TColorItem("List Viewer Focused Text", 58) +
- *new TColorItem("List Viewer Selected Text", 59) +
- *new TColorItem("List Viewer Divider", 60);
-
- return group2;
- }
-
-
- TColorGroup &TDemoApp::buildGroup3()
- {
- // Builds color group 3 for the TVColorDialog
-
- // Maximum visible length of a string in either the "groups" list
- // of "items" list is 37 characters
- // "1---------------to-----------------37"
-
- TColorGroup &group3 =
- *new TColorGroup("Extended Palette Dialogs #1") +
- *new TColorItem("Title Passive", 104) +
- *new TColorItem("Title Active", 105) +
- *new TColorItem("Frame Passive", 64) +
- *new TColorItem("Frame Active", 65) +
- *new TColorItem("Frame Icons", 66) +
- *new TColorItem("Scrollbar Page Area", 67) +
- *new TColorItem("Scrollbar Icons", 68) +
- *new TColorItem("Static Text", 69) +
- *new TColorItem("Label Normal Text", 70) +
- *new TColorItem("Label Highlight Text", 71) +
- *new TColorItem("Label Shortcut Letter", 72) +
- *new TColorItem("Button Normal", 73) +
- *new TColorItem("Button Default", 74) +
- *new TColorItem("Button Selected", 75) +
- *new TColorItem("Button Disabled", 76) +
- *new TColorItem("Button Shortcut", 77) +
- *new TColorItem("Button Shadow", 78) +
- *new TColorItem("Cluster Normal", 79) +
- *new TColorItem("Cluster Selected", 80) +
- *new TColorItem("Cluster Shortcut", 81) +
- *new TColorItem("Input Line Normal Text", 82) +
- *new TColorItem("Input Line Selected Text", 83) +
- *new TColorItem("Input Line Arrows", 84) +
- *new TColorItem("History List Arrow", 85) +
- *new TColorItem("History List Arrow Sides", 86) +
- *new TColorItem("History List Scrollbar Page Area", 87) +
- *new TColorItem("History List Scrollbar Icons", 88) +
- *new TColorItem("List Viewer Normal Text", 89) +
- *new TColorItem("List Viewer Focused Text", 90) +
- *new TColorItem("List Viewer Selected Text", 91) +
- *new TColorItem("List Viewer Divider", 92) +
- *new TColorItem("Unused", 93) +
- *new TColorItem("Unused", 96) +
- *new TColorItem("Unused", 97) +
- *new TColorItem("Unused", 98) +
- *new TColorItem("Unused", 99) +
- *new TColorItem("Unused", 100) +
- *new TColorItem("Unused", 101) +
- *new TColorItem("Unused", 102) +
- *new TColorItem("Unused", 106) +
- *new TColorItem("Unused", 107);
-
- return group3;
- }
-
-
- TColorGroup &TDemoApp::buildGroup4()
- {
- // Builds color group for the TVColorDialog
-
- // Maximum visible length of a string in either the "groups" list
- // of "items" list is 37 characters
- // "1---------------to-----------------37"
-
- TColorGroup &group4 =
- *new TColorGroup("Extended Palette Dialogs #2") +
- *new TColorItem("Title Passive", 154) +
- *new TColorItem("Title Active", 155) +
- *new TColorItem("Frame Passive", 114) +
- *new TColorItem("Frame Active", 115) +
- *new TColorItem("Frame Icons", 116) +
- *new TColorItem("Scrollbar Page Area", 117) +
- *new TColorItem("Scrollbar Icons", 118) +
- *new TColorItem("Static Text", 119) +
- *new TColorItem("Label Normal Text", 120) +
- *new TColorItem("Label Highlight Text", 121) +
- *new TColorItem("Label Shortcut Letter", 122) +
- *new TColorItem("Button Normal", 123) +
- *new TColorItem("Button Default", 124) +
- *new TColorItem("Button Selected", 125) +
- *new TColorItem("Button Disabled", 126) +
- *new TColorItem("Button Shortcut", 127) +
- *new TColorItem("Button Shadow", 128) +
- *new TColorItem("Cluster Normal", 129) +
- *new TColorItem("Cluster Selected", 130) +
- *new TColorItem("Cluster Shortcut", 131) +
- *new TColorItem("Input Line Normal Text", 132) +
- *new TColorItem("Input Line Selected Text", 133) +
- *new TColorItem("Input Line Arrows", 134) +
- *new TColorItem("History List Arrow", 135) +
- *new TColorItem("History List Arrow Sides", 136) +
- *new TColorItem("History List Scrollbar Page Area", 137) +
- *new TColorItem("History List Scrollbar Icons", 138) +
- *new TColorItem("List Viewer Normal Text", 139) +
- *new TColorItem("List Viewer Focused Text", 140) +
- *new TColorItem("List Viewer Selected Text", 141) +
- *new TColorItem("List Viewer Divider", 142) +
- *new TColorItem("Unused", 143) +
- *new TColorItem("Unused", 146) +
- *new TColorItem("Unused", 147) +
- *new TColorItem("Unused", 148) +
- *new TColorItem("Unused", 149) +
- *new TColorItem("Unused", 150) +
- *new TColorItem("Unused", 151) +
- *new TColorItem("Unused", 152) +
- *new TColorItem("Unused", 156) +
- *new TColorItem("Unused", 157);
-
- return group4;
- }
-
-
- TColorGroup &TDemoApp::buildGroup5()
- {
- // Builds color group 5 for the TVColorDialog
-
- // Maximum visible length of a string in either the "groups" list
- // of "items" list is 37 characters
- // "1---------------to-----------------37"
-
- TColorGroup &group5 =
- *new TColorGroup("Extended Palette Dialogs #3") +
- *new TColorItem("Title Passive", 204) +
- *new TColorItem("Title Active", 205) +
- *new TColorItem("Frame Passive", 164) +
- *new TColorItem("Frame Active", 165) +
- *new TColorItem("Frame Icons", 166) +
- *new TColorItem("Scrollbar Page Area", 167) +
- *new TColorItem("Scrollbar Icons", 168) +
- *new TColorItem("Static Text", 169) +
- *new TColorItem("Label Normal Text", 170) +
- *new TColorItem("Label Highlight Text", 171) +
- *new TColorItem("Label Shortcut Letter", 172) +
- *new TColorItem("Button Normal", 173) +
- *new TColorItem("Button Default", 174) +
- *new TColorItem("Button Selected", 175) +
- *new TColorItem("Button Disabled", 176) +
- *new TColorItem("Button Shortcut", 177) +
- *new TColorItem("Button Shadow", 178) +
- *new TColorItem("Cluster Normal", 179) +
- *new TColorItem("Cluster Selected", 180) +
- *new TColorItem("Cluster Shortcut", 181) +
- *new TColorItem("Input Line Normal Text", 182) +
- *new TColorItem("Input Line Selected Text", 183) +
- *new TColorItem("Input Line Arrows", 184) +
- *new TColorItem("History List Arrow", 185) +
- *new TColorItem("History List Arrow Sides", 186) +
- *new TColorItem("History List Scrollbar Page Area", 187) +
- *new TColorItem("History List Scrollbar Icons", 188) +
- *new TColorItem("List Viewer Normal Text", 189) +
- *new TColorItem("List Viewer Focused Text", 190) +
- *new TColorItem("List Viewer Selected Text", 191) +
- *new TColorItem("List Viewer Divider", 192) +
- *new TColorItem("Unused", 193) +
- *new TColorItem("Unused", 196) +
- *new TColorItem("Unused", 197) +
- *new TColorItem("Unused", 198) +
- *new TColorItem("Unused", 199) +
- *new TColorItem("Unused", 200) +
- *new TColorItem("Unused", 201) +
- *new TColorItem("Unused", 202) +
- *new TColorItem("Unused", 206) +
- *new TColorItem("Unused", 207);
-
- return group5;
- }
-
-
- void TDemoApp::colors()
- {
- // Displays the TVColorDialog dialog
-
- // Build the color groups
- TColorGroup &g1 = buildGroup1();
- TColorGroup &g2 = buildGroup2();
- TColorGroup &g3 = buildGroup3();
- TColorGroup &g4 = buildGroup4();
- TColorGroup &g5 = buildGroup5();
- TColorGroup &groups = g1 + g2 + g3 + g4 + g5;
-
- // Copy patterns string into a temp buffer
- char buff[MAXPATTERNS + 1];
- strcpy(buff, patterns);
-
- // Check optrec to see how many patterns to display (4, 8, or 16).
- // Set patternIndex to zero if out of range.
- if(optrec.patternCount == 0)
- {
- buff[4] = 0;
- if(patternIndex > 3)
- patternIndex = 0;
- }
- else if(optrec.patternCount == 1)
- {
- buff[8] = 0;
- if(patternIndex > 7)
- patternIndex = 0;
- }
-
- // Check optrec to see if we want a help button in the dialog
- Boolean addHelp = False;
- if(optrec.addHelp)
- addHelp = True;
-
- // Create the TVColorDialog
- TVColorDialog *dialog;
- dialog = new TVColorDialog(&getPalette(), &groups, buff, addHelp);
-
- if(validView(dialog))
- {
- dialog->helpCtx = hcColors; // Set dialog's help context
- TVColorDialogRec rec; // Struct for setData
- TPalette *p = &getPalette(); // Point to app's palette
- rec.pal = p; // Init struct with palette...
- rec.pattern = patternIndex; // and pattern index
- dialog->setData(&rec); // Set dialog's data
- ushort choice = deskTop->execView(dialog);
- if(choice != cmCancel)
- {
- dialog->getData(&rec);
- patternIndex = rec.pattern; // Store pattern index
- // Set the desktop pattern index
- deskTop->background->setPattern(buff[patternIndex]);
- // Force a redraw of the application
- setState(sfExposed, False);
- setState(sfExposed, True);
- redraw();
- }
- TObject::destroy((TVColorDialog *) dialog);
- }
- }
-
-
- void TDemoApp::xdialog1()
- {
- // Inserts a TXDialog1 dialog (see TDEMO2.CPP) into the desktop
- // to demonstrate the colors selected in TVColorDialog
-
- TXDialog1 *dialog;
- dialog = new TXDialog1(TRect(6, 2, 73, 21),
- "Extended Palette TXDialog1");
-
- if(dialog == NULL)
- return;
-
- dialog->options |= ofCentered;
- dialog->helpCtx = hcXDialogs;
-
- TView *v;
- v = new TView(TRect(1, 2, 33, 6));
- v->options |= ofFramed;
- dialog->insert(v);
-
- v = new TView(TRect(1, 7, 33, 11));
- v->options |= ofFramed;
- dialog->insert(v);
-
- v = new TView(TRect(1, 12, 33, 14));
- v->options |= ofFramed;
- dialog->insert(v);
-
- v = new TView(TRect(34, 2, 66, 11));
- v->options |= ofFramed;
- dialog->insert(v);
-
- v = new TView(TRect(34, 12, 66, 14));
- v->options |= ofFramed;
- dialog->insert(v);
-
- TCheckBoxes *cb = new TCheckBoxes(TRect(2, 3, 31, 6),
- new TSItem("~W~indows",
- new TSItem("~U~nix",
- new TSItem("~O~S/2", 0))));
- dialog->insert(cb);
-
- dialog->insert(new TLabel(TRect(2, 2, 14, 3), "~C~heckboxes", cb));
-
- TRadioButtons *rb = new TRadioButtons(TRect(2, 8, 31, 11),
- new TSItem("~A~pples",
- new TSItem("~O~ranges",
- new TSItem("~B~anannas", 0))));
- dialog->insert(rb);
-
- dialog->insert(new TLabel(TRect(2, 7, 17, 8), "~R~adio buttons", rb));
-
- TStaticText *t;
- t = new TStaticText(TRect(2, 12, 31, 14), "\003This is a sample\n"
- "\003TStaticText view.");
- dialog->insert(t);
-
- TScrollBar *sb = new TScrollBar(TRect(64, 3, 65, 10));
- dialog->insert(sb);
-
- dialog->listbox = new TListBox(TRect(36, 3, 64, 10), 2, sb);
- dialog->insert(dialog->listbox);
-
- TStringCollection *strings;
- strings = new TStringCollection(20, 10);
-
- for(short ctr = 0; ctr < 20; ctr++)
- {
- short num = ctr + 1;
- char str[16];
- ostrstream os(str, sizeof str);
- os << "List item #" << num << ends;
- strings->atInsert(ctr, newStr(str));
- }
-
- dialog->listbox->newList(strings);
-
- dialog->insert(new TLabel(TRect(36, 2, 45, 3), "~L~istbox ",
- dialog->listbox));
-
- TInputLine *i = new TInputLine(TRect(35, 13, 62, 14), 129);
- dialog->insert(i);
-
- THistory *h;
- h = new THistory(TRect(62, 13, 65, 14), i, 1);
- dialog->insert(h);
-
- dialog->insert(new TLabel(TRect(35, 12, 46, 13), "~T~InputLine", i));
-
- TButton *b;
- b = new TButton(TRect(4, 16, 22, 18), "Button ~1~", cmNone, bfNormal);
- dialog->insert(b);
-
- b = new TButton(TRect(24, 16, 43, 18), "Button ~2~", cmNone, bfNormal);
- dialog->insert(b);
-
- b = new TButton(TRect(45, 16, 63, 18), "~C~lose", cmCloseX, bfDefault);
- dialog->insert(b);
-
- dialog->selectNext(False);
-
- if(validView(dialog))
- deskTop->insert(dialog);
- }
-
-
- void TDemoApp::xdialog2()
- {
- // Inserts a TXDialog2 dialog (see TDEMO2.CPP) into the desktop
- // to demonstrate the colors selected in TVColorDialog
-
- TXDialog2 *dialog;
- dialog = new TXDialog2(TRect(6, 2, 73, 21),
- "Extended Palette TXDialog2");
-
- if(dialog == NULL)
- return;
-
- dialog->options |= ofCentered;
- dialog->helpCtx = hcXDialogs;
-
- TView *v;
- v = new TView(TRect(1, 2, 33, 6));
- v->options |= ofFramed;
- dialog->insert(v);
-
- v = new TView(TRect(1, 7, 33, 11));
- v->options |= ofFramed;
- dialog->insert(v);
-
- v = new TView(TRect(1, 12, 33, 14));
- v->options |= ofFramed;
- dialog->insert(v);
-
- v = new TView(TRect(34, 2, 66, 11));
- v->options |= ofFramed;
- dialog->insert(v);
-
- v = new TView(TRect(34, 12, 66, 14));
- v->options |= ofFramed;
- dialog->insert(v);
-
- TCheckBoxes *cb = new TCheckBoxes(TRect(2, 3, 31, 6),
- new TSItem("~W~indows",
- new TSItem("~U~nix",
- new TSItem("~O~S/2", 0))));
- dialog->insert(cb);
-
- dialog->insert(new TLabel(TRect(2, 2, 14, 3), "~C~heckboxes", cb));
-
- TRadioButtons *rb = new TRadioButtons(TRect(2, 8, 31, 11),
- new TSItem("~A~pples",
- new TSItem("~O~ranges",
- new TSItem("~B~anannas", 0))));
- dialog->insert(rb);
-
- dialog->insert(new TLabel(TRect(2, 7, 17, 8), "~R~adio buttons", rb));
-
- TStaticText *t;
- t = new TStaticText(TRect(2, 12, 31, 14), "\003This is a sample\n"
- "\003TStaticText view.");
- dialog->insert(t);
-
- TScrollBar *sb = new TScrollBar(TRect(64, 3, 65, 10));
- dialog->insert(sb);
-
- dialog->listbox = new TListBox(TRect(36, 3, 64, 10), 2, sb);
- dialog->insert(dialog->listbox);
-
- TStringCollection *strings;
- strings = new TStringCollection(20, 10);
-
- for(short ctr = 0; ctr < 20; ctr++)
- {
- short num = ctr + 1;
- char str[16];
- ostrstream os(str, sizeof str);
- os << "List item #" << num << ends;
- strings->atInsert(ctr, newStr(str));
- }
-
- dialog->listbox->newList(strings);
-
- dialog->insert(new TLabel(TRect(36, 2, 45, 3), "~L~istbox ",
- dialog->listbox));
-
- TInputLine *i = new TInputLine(TRect(35, 13, 62, 14), 129);
- dialog->insert(i);
-
- THistory *h;
- h = new THistory(TRect(62, 13, 65, 14), i, 1);
- dialog->insert(h);
-
- dialog->insert(new TLabel(TRect(35, 12, 46, 13), "~T~InputLine", i));
-
- TButton *b;
- b = new TButton(TRect(4, 16, 22, 18), "Button ~1~", cmNone, bfNormal);
- dialog->insert(b);
-
- b = new TButton(TRect(24, 16, 43, 18), "Button ~2~", cmNone, bfNormal);
- dialog->insert(b);
-
- b = new TButton(TRect(45, 16, 63, 18), "~C~lose", cmCloseX, bfDefault);
- dialog->insert(b);
-
- dialog->selectNext(False);
-
- if(validView(dialog))
- deskTop->insert(dialog);
- }
-
-
- void TDemoApp::xdialog3()
- {
- // Inserts a TXDialog3 dialog (see TDEMO2.CPP) into the desktop
- // to demonstrate the colors selected in TVColorDialog
-
- TXDialog3 *dialog;
- dialog = new TXDialog3(TRect(6, 2, 73, 21),
- "Extended Palette TXDialog3");
-
- if(dialog == NULL)
- return;
-
- dialog->options |= ofCentered;
- dialog->helpCtx = hcXDialogs;
-
- TView *v;
- v = new TView(TRect(1, 2, 33, 6));
- v->options |= ofFramed;
- dialog->insert(v);
-
- v = new TView(TRect(1, 7, 33, 11));
- v->options |= ofFramed;
- dialog->insert(v);
-
- v = new TView(TRect(1, 12, 33, 14));
- v->options |= ofFramed;
- dialog->insert(v);
-
- v = new TView(TRect(34, 2, 66, 11));
- v->options |= ofFramed;
- dialog->insert(v);
-
- v = new TView(TRect(34, 12, 66, 14));
- v->options |= ofFramed;
- dialog->insert(v);
-
- TCheckBoxes *cb = new TCheckBoxes(TRect(2, 3, 31, 6),
- new TSItem("~W~indows",
- new TSItem("~U~nix",
- new TSItem("~O~S/2", 0))));
- dialog->insert(cb);
-
- dialog->insert(new TLabel(TRect(2, 2, 14, 3), "~C~heckboxes", cb));
-
- TRadioButtons *rb = new TRadioButtons(TRect(2, 8, 31, 11),
- new TSItem("~A~pples",
- new TSItem("~O~ranges",
- new TSItem("~B~anannas", 0))));
- dialog->insert(rb);
-
- dialog->insert(new TLabel(TRect(2, 7, 17, 8), "~R~adio buttons", rb));
-
- TStaticText *t;
- t = new TStaticText(TRect(2, 12, 31, 14), "\003This is a sample\n"
- "\003TStaticText view.");
- dialog->insert(t);
-
- TScrollBar *sb = new TScrollBar(TRect(64, 3, 65, 10));
- dialog->insert(sb);
-
- dialog->listbox = new TListBox(TRect(36, 3, 64, 10), 2, sb);
- dialog->insert(dialog->listbox);
-
- TStringCollection *strings;
- strings = new TStringCollection(20, 10);
-
- for(short ctr = 0; ctr < 20; ctr++)
- {
- short num = ctr + 1;
- char str[16];
- ostrstream os(str, sizeof str);
- os << "List item #" << num << ends;
- strings->atInsert(ctr, newStr(str));
- }
-
- dialog->listbox->newList(strings);
-
- dialog->insert(new TLabel(TRect(36, 2, 45, 3), "~L~istbox ",
- dialog->listbox));
-
- TInputLine *i = new TInputLine(TRect(35, 13, 62, 14), 129);
- dialog->insert(i);
-
- THistory *h;
- h = new THistory(TRect(62, 13, 65, 14), i, 1);
- dialog->insert(h);
-
- dialog->insert(new TLabel(TRect(35, 12, 46, 13), "~T~InputLine", i));
-
- TButton *b;
- b = new TButton(TRect(4, 16, 22, 18), "Button ~1~", cmNone, bfNormal);
- dialog->insert(b);
-
- b = new TButton(TRect(24, 16, 43, 18), "Button ~2~", cmNone, bfNormal);
- dialog->insert(b);
-
- b = new TButton(TRect(45, 16, 63, 18), "~C~lose", cmCloseX, bfDefault);
- dialog->insert(b);
-
- dialog->selectNext(False);
-
- if(validView(dialog))
- deskTop->insert(dialog);
- }
-
-
- void TDemoApp::helpDialog()
- {
- // Displays a dialog to demonstrate that the help button in
- // TVColorDialog was pressed. There is currently no help file
- // in the demonstration program. Soon, we hope! <G>
-
- TDialog *dialog;
- dialog = new TDialog(TRect(13, 6, 66, 17),
- "TVColorDialog help button information");
-
- if(dialog == NULL)
- return;
-
- dialog->options |= ofCentered;
-
- TStaticText *t;
- t = new TStaticText(TRect(3, 2, 50, 3),
- "The help button in TVColorDialog sends a cmHelp");
- dialog->insert(t);
-
- t = new TStaticText(TRect(3, 3, 50, 4),
- "command to the application. Unfortunately there");
- dialog->insert(t);
-
- t = new TStaticText(TRect(3, 4, 50, 5),
- "is no help file available in this demonstration");
- dialog->insert(t);
-
- t = new TStaticText(TRect(3, 5, 15, 6), "application.");
- dialog->insert(t);
-
- TButton *b;
- b = new TButton(TRect(11, 8, 41, 10), "~O~k", cmOK, bfDefault);
- b->options |= ofCenterX;
- dialog->insert(b);
-
- if(validView(dialog))
- {
- deskTop->execView(dialog);
- TObject::destroy((TDialog *) dialog);
- }
- }
-
-
-
-
-
- // Non-member function definitions ****************************************
-
- void exitfunc(void)
- {
- // Prints an exit message
-
- cout << endl
- << endl
- << "┌────────────────────────────────────────────┐" << endl
- << "│ Thank you for testing TVColorDialog! │" << endl
- << "├────────────────────────────────────────────┤" << endl
- << "│ TVColorDialog shareware version "
- << colorDlgVerStr
- << " │" << endl
- << "│ Copyright (C) 1992,1993 Comsoft Software │" << endl
- << "│ All rights reserved. │" << endl
- << "└────────────────────────────────────────────┘" << endl
- << ends;
- }
-
-
- #pragma exit exitfunc 31 // Register exitfunc
-
-
- int main()
- {
- TDemoApp *program = new TDemoApp();
-
- if(!program->valid(cmValid))
- {
- TObject::destroy((TDemoApp *) program);
- return 2;
- }
-
- program->run();
- TObject::destroy((TDemoApp *) program);
-
- return 0;
- }
-
-
- // End of TDEMO.CPP
-
-