home *** CD-ROM | disk | FTP | other *** search
- ┌────────────────────────────────────────────────────────────────────────────┐
- │ │
- │ DIALOG BOX MAKER │
- │ Version 1.02 │
- │ │
- │ by David R. Grigg │
- │ 1556 Main Road, │
- │ Research, Victoria 3095, │
- │ AUSTRALIA. │
- │ │
- │ (Compuserve 76264,2530) │
- │ │
- │ Takes a text file with a design of a dialog box and generates the │
- │ appropriate TurboVision code to generate that box. │
- │ │
- │ If you find this useful, send me a postcard, a letter, or your favorite │
- │ utility program. Appreciation, not money required! │
- │ │
- └────────────────────────────────────────────────────────────────────────────┘
-
- Surely, I say to myself, someone else must have written this program!
- But if they have, I can't find it on Compuserve.
-
- After writing my first applications using Turbo Vision, and having to
- hand-construct my first large dialog box, I nearly threw up my hands in
- despair. There had to be a better way! So, being a lazy kind of
- person, I wrote this program.
-
- DIALOGER takes an ASCII text file in which you have created the design
- of a dialog box, and turns it into a whole completed procedure to
- create that dialog box. All you need do is read the new file into
- your program and compile it. This (I think) is the best thing since
- sliced bread.
-
- Here's a sample text file with a dialog box design in it:
-
- ((((((((((((((((((Text File starts with following line:)))))))))))))))))))))
-
- Label:
- <------------------------------------->
-
- Type: Shape:
- ( ) Branch [ ] Invisible
- ( ) Indirect [ ] Plain
- ( ) Jump [ ] Bevelled
- ( ) Function [ ] Round
- ( ) Key [ ] Custom 1
- [ ] Custom 2
- Data:
- <------------------------------------->
-
- Position:
- X1: <---> Y1: <---> X2: <---> Y2: <--->
-
- { Ok } { Cancel } { Display }
-
- ((((((((((((((((Text file ends with previous line))))))))))))))))))))))))))
-
- ...and here is the code that DIALOGER generated:
- (NOTE by the way that DIALOGER's output is a file with the same name as
- the one you gave it for input, but with a .DIA extension. I don't check
- to see if such a file already exists, but just overwrite it. Be warned!)
-
- {--------------------------------------------------------------------------}
-
- procedure ShowDialogBox;
- var Dialog: PDialog;
- R: TRect;
- Control: word;
- B: PView;
- DataRecord : record
- InpLineData1: string[37];
- RButtonData1: word;
- CBoxData1: word;
- InpLineData2: string[37];
- InpLineData3: string[3];
- InpLineData4: string[3];
- InpLineData5: string[3];
- InpLineData6: string[3];
- end;
-
- begin
- with DataRecord do begin
- InpLineData1:= '';
- RButtonData1:= 0;
- CBoxData1:= 0;
- InpLineData2:= '';
- InpLineData3:= '';
- InpLineData4:= '';
- InpLineData5:= '';
- InpLineData6:= '';
- end; {with}
- R.Assign(20,0,63,21);
- Dialog:= New(PDialog, Init(R,'Button'));
- with Dialog^ do
- begin
- R.Assign(2,3,41,4);
- B:= New(PInputLine,Init(R,37));
- Insert(B);
- R.Assign(2,2,9,3);
- Insert(New(PLabel,Init(R,'Label:',B)));
- R.Assign(2,6,16,11);
- B:= New(PRadioButtons,Init(R,
- NewSItem('Branch ',
- NewSItem('Indirect ',
- NewSItem('Jump ',
- NewSItem('Function ',
- NewSItem('Key ',
- nil)))))
- ));
- Insert(B);
- R.Assign(2,5,8,6);
- Insert(New(PLabel,Init(R,'Type:',B)));
- R.Assign(23,6,37,12);
- B:= New(PCheckBoxes,Init(R,
- NewSItem('Invisible',
- NewSItem('Plain',
- NewSItem('Bevelled',
- NewSItem('Round',
- NewSItem('Custom_1',
- NewSItem('Custom_2',
- nil))))))
- ));
- Insert(B);
- R.Assign(23,5,30,6);
- Insert(New(PLabel,Init(R,'Shape:',B)));
- R.Assign(2,13,41,14);
- B:= New(PInputLine,Init(R,37));
- Insert(B);
- R.Assign(2,12,8,13);
- Insert(New(PLabel,Init(R,'Data:',B)));
- R.Assign(6,16,11,17);
- B:= New(PInputLine,Init(R,3));
- Insert(B);
- R.Assign(2,16,6,17);
- Insert(New(PLabel,Init(R,'X1:',B)));
- R.Assign(16,16,21,17);
- B:= New(PInputLine,Init(R,3));
- Insert(B);
- R.Assign(12,16,16,17);
- Insert(New(PLabel,Init(R,'Y1:',B)));
- R.Assign(26,16,31,17);
- B:= New(PInputLine,Init(R,3));
- Insert(B);
- R.Assign(22,16,26,17);
- Insert(New(PLabel,Init(R,'X2:',B)));
- R.Assign(36,16,41,17);
- B:= New(PInputLine,Init(R,3));
- Insert(B);
- R.Assign(32,16,36,17);
- Insert(New(PLabel,Init(R,'Y2:',B)));
- R.Assign(2,18,12,20);
- Insert(New(PButton,Init(R,'Ok',cmOk,bfNormal)));
- R.Assign(15,18,25,20);
- Insert(New(PButton,Init(R,'Cancel',cmCancel,bfNormal)));
- R.Assign(28,18,39,20);
- Insert(New(PButton,Init(R,'Display',cmDisplay,bfNormal)));
- R.Assign(2,15,11,16);
- B:= New(PStaticText,Init(R,'Position:'));
- Insert(B);
- SetData(DataRecord);
- end; {with}
- Control:= Desktop^.ExecView(Dialog);
- if Control<>cmCancel
- then begin
- Dialog^.GetData(DataRecord);
- end;
- Dispose(Dialog,Done);
- end; {ShowDialogBox}
-
- {--------------------------------------------------------------------------}
-
- Isn't this better than coding all the above yourself?
-
- As you can see, DIALOGER handles Radio Buttons, Check Boxes, Input Lines,
- Labels and Static Text.
-
- Naturally, there are some restrictions on the format of the input ASCII file,
- but they are very easy to understand and trivial to implement.
-
- The following rules apply:
-
- INPUT LINES are marked by '<' at the start and '>' at the end.
- The hyphens inbetween are not needed, but I think they help
- you see how the finished dialog box will look. They also
- indicate how many input characters will fit.
-
- RADIO BUTTONS are marked out by '( )' characters and must be immediately
- followed by the choice text, with only one space separating the
- choice text from the closing ')' character.
- They must run down the page with no gaps between choices.
-
- CHECK BOXES are exactly as for Radio Buttons, but the delimiting
- characters are '[ ]'.
-
- BUTTONS are marked out by '{' and '}'. The text between these
- characters is considered to be its label. NOTE that
- DIALOGER will also use the label to bind a cmXXXXX command
- to the button, eg a label such as 'Display' makes the code
- bind a 'cmDisplay' command to the button. This is likely to
- stop your program compiling, unless you take care to define
- these commands. This also means that button labels must be
- single words, ie include no embedded spaces, unless you are
- happy to fix up the code manually after generating it.
-
- LABELS: This was the hardest thing to implement. When is a bit of
- text a label and when is it static text? My rule is that a
- label must end in a colon ':', and must start either to the
- left of its associated input line, radio buttons, etc, or
- must be placed immediately above, with the first character over
- the delimiting character, eg the ( of a set of Radio Buttons.
-
- STATIC TEXT: is anything that isn't one of the above.
-
- TEXT: Version 1.0 of DIALOGER required that spaces within a
- label or within a piece of static text be replaced by
- underline characters. Quite frankly, I found this a pain
- in the neck, especially for long bits of static text. So the
- latest version is smarter in this respect. It recognises
- a double space rather than a single space as the end of a bit of
- text.
-
- That's it.
-
- Naturally, you will still need to work on the generated code to make it
- suitable for your own application. You might, for example, want the
- program to allow input text longer than the visible area on the screen.
- If so, you will need to get in and change some of the numbers in the
- generated code.
-
-
- Please note that this is the first version of DIALOGER, and I expect there
- are likely to be bugs in it. I'd be grateful for bug reports and other
- comments.
-
- --- David R Grigg.
- 2 May 1991.
-