home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l044 / 2.ddi / INTRFACE.ZIP / DIALOGS.INT < prev    next >
Encoding:
Text File  |  1990-10-23  |  11.5 KB  |  439 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Turbo Pascal Version 6.0                        }
  5. {       Turbo Vision Unit                               }
  6. {                                                       }
  7. {       Copyright (c) 1990 Borland International        }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. unit Dialogs;
  12.  
  13. {$O+,F+,S-,X+}
  14.  
  15. interface
  16.  
  17. uses Objects, Drivers, Views;
  18.  
  19. const
  20.  
  21. { Color palettes }
  22.  
  23.   CDialog        = #32#33#34#35#36#37#38#39#40#41#42#43#44#45#46#47 +
  24.                    #48#49#50#51#52#53#54#55#56#57#58#59#60#61#62#63;
  25.   CStaticText    = #6;
  26.   CLabel         = #7#8#9#9;
  27.   CButton        = #10#11#12#13#14#14#14#15;
  28.   CCluster       = #16#17#18#18;
  29.   CInputLine     = #19#19#20#21;
  30.   CHistory       = #22#23;
  31.   CHistoryWindow = #19#19#21#24#25#19#20;
  32.   CHistoryViewer = #6#6#7#6#6;
  33.  
  34. { TButton flags }
  35.  
  36.   bfNormal    = $00;
  37.   bfDefault   = $01;
  38.   bfLeftJust  = $02;
  39.   bfBroadcast = $04;
  40.  
  41. type
  42.  
  43. { TDialog object }
  44.  
  45.   { Palette layout }
  46.   {  1 = Frame passive }
  47.   {  2 = Frame active }
  48.   {  3 = Frame icon }
  49.   {  4 = ScrollBar page area }
  50.   {  5 = ScrollBar controls }
  51.   {  6 = StaticText }
  52.   {  7 = Label normal }
  53.   {  8 = Label selected }
  54.   {  9 = Label shortcut }
  55.   { 10 = Button normal }
  56.   { 11 = Button default }
  57.   { 12 = Button selected }
  58.   { 13 = Button disabled }
  59.   { 14 = Button shortcut }
  60.   { 15 = Button shadow }
  61.   { 16 = Cluster normal }
  62.   { 17 = Cluster selected }
  63.   { 18 = Cluster shortcut }
  64.   { 19 = InputLine normal text }
  65.   { 20 = InputLine selected text }
  66.   { 21 = InputLine arrows }
  67.   { 22 = History arrow }
  68.   { 23 = History sides }
  69.   { 24 = HistoryWindow scrollbar page area }
  70.   { 25 = HistoryWindow scrollbar controls }
  71.   { 26 = ListViewer normal }
  72.   { 27 = ListViewer focused }
  73.   { 28 = ListViewer selected }
  74.   { 29 = ListViewer divider }
  75.   { 30 = InfoPane }
  76.   { 31 = Reserved }
  77.   { 32 = Reserved }
  78.  
  79.   PDialog = ^TDialog;
  80.   TDialog = object(TWindow)
  81.     constructor Init(var Bounds: TRect; ATitle: TTitleStr);
  82.     function GetPalette: PPalette; virtual;
  83.     procedure HandleEvent(var Event: TEvent); virtual;
  84.     function Valid(Command: Word): Boolean; virtual;
  85.   end;
  86.  
  87. { TSItem }
  88.  
  89.   PSItem = ^TSItem;
  90.   TSItem = record
  91.     Value: PString;
  92.     Next: PSItem;
  93.   end;
  94.  
  95. { TInputLine object }
  96.  
  97.   { Palette layout }
  98.   { 1 = Passive }
  99.   { 2 = Active }
  100.   { 3 = Selected }
  101.   { 4 = Arrows }
  102.  
  103.   PInputLine = ^TInputLine;
  104.   TInputLine = object(TView)
  105.     Data: PString;
  106.     MaxLen: Integer;
  107.     CurPos: Integer;
  108.     FirstPos: Integer;
  109.     SelStart: Integer;
  110.     SelEnd: Integer;
  111.     constructor Init(var Bounds: TRect; AMaxLen: Integer);
  112.     constructor Load(var S: TStream);
  113.     destructor Done; virtual;
  114.     function DataSize: Word; virtual;
  115.     procedure Draw; virtual;
  116.     procedure GetData(var Rec); virtual;
  117.     function GetPalette: PPalette; virtual;
  118.     procedure HandleEvent(var Event: TEvent); virtual;
  119.     procedure SelectAll(Enable: Boolean);
  120.     procedure SetData(var Rec); virtual;
  121.     procedure SetState(AState: Word; Enable: Boolean); virtual;
  122.     procedure Store(var S: TStream);
  123.   end;
  124.  
  125. { TButton object }
  126.  
  127.   { Palette layout }
  128.   { 1 = Normal text }
  129.   { 2 = Default text }
  130.   { 3 = Selected text }
  131.   { 4 = Disabled text }
  132.   { 5 = Normal shortcut }
  133.   { 6 = Default shortcut }
  134.   { 7 = Selected shortcut }
  135.   { 8 = Shadow }
  136.  
  137.   PButton = ^TButton;
  138.   TButton = object(TView)
  139.     Title: PString;
  140.     Command: Word;
  141.     Flags: Byte;
  142.     AmDefault: Boolean;
  143.     constructor Init(var Bounds: TRect; ATitle: TTitleStr; ACommand: Word;
  144.       AFlags: Word);
  145.     constructor Load(var S: TStream);
  146.     destructor Done; virtual;
  147.     procedure Draw; virtual;
  148.     procedure DrawState(Down: Boolean);
  149.     function GetPalette: PPalette; virtual;
  150.     procedure HandleEvent(var Event: TEvent); virtual;
  151.     procedure MakeDefault(Enable: Boolean);
  152.     procedure Press; virtual;
  153.     procedure SetState(AState: Word; Enable: Boolean); virtual;
  154.     procedure Store(var S: TStream);
  155.   end;
  156.  
  157. { TCluster }
  158.  
  159.   { Palette layout }
  160.   { 1 = Normal text }
  161.   { 2 = Selected text }
  162.   { 3 = Normal shortcut }
  163.   { 4 = Selected shortcut }
  164.  
  165.   PCluster = ^TCluster;
  166.   TCluster = object(TView)
  167.     Value: Word;
  168.     Sel: Integer;
  169.     Strings: TStringCollection;
  170.     constructor Init(var Bounds: TRect; AStrings: PSItem);
  171.     constructor Load(var S: TStream);
  172.     destructor Done; virtual;
  173.     function DataSize: Word; virtual;
  174.     procedure DrawBox(Icon: String; Marker: Char);
  175.     procedure GetData(var Rec); virtual;
  176.     function GetHelpCtx: Word; virtual;
  177.     function GetPalette: PPalette; virtual;
  178.     procedure HandleEvent(var Event: TEvent); virtual;
  179.     function Mark(Item: Integer): Boolean; virtual;
  180.     procedure Press(Item: Integer); virtual;
  181.     procedure MovedTo(Item: Integer); virtual;
  182.     procedure SetData(var Rec); virtual;
  183.     procedure SetState(AState: Word; Enable: Boolean); virtual;
  184.     procedure Store(var S: TStream);
  185.   end;
  186.  
  187. { TRadioButtons }
  188.  
  189.   { Palette layout }
  190.   { 1 = Normal text }
  191.   { 2 = Selected text }
  192.   { 3 = Normal shortcut }
  193.   { 4 = Selected shortcut }
  194.  
  195.   PRadioButtons = ^TRadioButtons;
  196.   TRadioButtons = object(TCluster)
  197.     procedure Draw; virtual;
  198.     function Mark(Item: Integer): Boolean; virtual;
  199.     procedure MovedTo(Item: Integer); virtual;
  200.     procedure Press(Item: Integer); virtual;
  201.     procedure SetData(var Rec); virtual;
  202.   end;
  203.  
  204. { TCheckBoxes }
  205.  
  206.   { Palette layout }
  207.   { 1 = Normal text }
  208.   { 2 = Selected text }
  209.   { 3 = Normal shortcut }
  210.   { 4 = Selected shortcut }
  211.  
  212.   PCheckBoxes = ^TCheckBoxes;
  213.   TCheckBoxes = object(TCluster)
  214.     procedure Draw; virtual;
  215.     function Mark(Item: Integer): Boolean; virtual;
  216.     procedure Press(Item: Integer); virtual;
  217.   end;
  218.  
  219. { TListBox }
  220.  
  221.   { Palette layout }
  222.   { 1 = Active }
  223.   { 2 = Inactive }
  224.   { 3 = Focused }
  225.   { 4 = Selected }
  226.   { 5 = Divider }
  227.  
  228.   PListBox = ^TListBox;
  229.   TListBox = object(TListViewer)
  230.     List: PCollection;
  231.     constructor Init(var Bounds: TRect; ANumCols: Word;
  232.       AScrollBar: PScrollBar);
  233.     constructor Load(var S: TStream);
  234.     function DataSize: Word; virtual;
  235.     procedure GetData(var Rec); virtual;
  236.     function GetText(Item: Integer; MaxLen: Integer): String; virtual;
  237.     procedure NewList(AList: PCollection); virtual;
  238.     procedure SetData(var Rec); virtual;
  239.     procedure Store(var S: TStream);
  240.   end;
  241.  
  242. { TStaticText }
  243.  
  244.   { Palette layout }
  245.   { 1 = Text }
  246.  
  247.   PStaticText = ^TStaticText;
  248.   TStaticText = object(TView)
  249.     Text: PString;
  250.     constructor Init(var Bounds: TRect; AText: String);
  251.     constructor Load(var S: TStream);
  252.     destructor Done; virtual;
  253.     procedure Draw; virtual;
  254.     function GetPalette: PPalette; virtual;
  255.     procedure GetText(var S: String); virtual;
  256.     procedure Store(var S: TStream);
  257.   end;
  258.  
  259. { TParamText }
  260.  
  261.   { Palette layout }
  262.   { 1 = Text }
  263.  
  264.   PParamText = ^TParamText;
  265.   TParamText = object(TStaticText)
  266.     ParamCount: Integer;
  267.     ParamList: Pointer;
  268.     constructor Init(var Bounds: TRect; AText: String;
  269.       AParamCount: Integer);
  270.     constructor Load(var S: TStream);
  271.     function DataSize: Word; virtual;
  272.     procedure GetText(var S: String); virtual;
  273.     procedure SetData(var Rec); virtual;
  274.     procedure Store(var S: TStream);
  275.   end;
  276.  
  277. { TLabel }
  278.  
  279.   { Palette layout }
  280.   { 1 = Normal text }
  281.   { 2 = Selected text }
  282.   { 3 = Normal shortcut }
  283.   { 4 = Selected shortcut }
  284.  
  285.   PLabel = ^TLabel;
  286.   TLabel = object(TStaticText)
  287.     Link: PView;
  288.     Light: Boolean;
  289.     constructor Init(var Bounds: TRect; AText: String; ALink: PView);
  290.     constructor Load(var S: TStream);
  291.     procedure Draw; virtual;
  292.     function GetPalette: PPalette; virtual;
  293.     procedure HandleEvent(var Event: TEvent); virtual;
  294.     procedure Store(var S: TStream);
  295.   end;
  296.  
  297. { THistoryViewer }
  298.  
  299.   { Palette layout }
  300.   { 1 = Active }
  301.   { 2 = Inactive }
  302.   { 3 = Focused }
  303.   { 4 = Selected }
  304.   { 5 = Divider }
  305.  
  306.   PHistoryViewer = ^THistoryViewer;
  307.   THistoryViewer = object(TListViewer)
  308.     HistoryId: Word;
  309.     constructor Init(var Bounds: TRect; AHScrollBar, AVScrollBar: PScrollBar;
  310.       AHistoryId: Word);
  311.     function GetPalette: PPalette; virtual;
  312.     function GetText(Item: Integer; MaxLen: Integer): String; virtual;
  313.     procedure HandleEvent(var Event: TEvent); virtual;
  314.     function HistoryWidth: Integer;
  315.   end;
  316.  
  317. { THistoryWindow }
  318.  
  319.   { Palette layout }
  320.   { 1 = Frame passive }
  321.   { 2 = Frame active }
  322.   { 3 = Frame icon }
  323.   { 4 = ScrollBar page area }
  324.   { 5 = ScrollBar controls }
  325.   { 6 = HistoryViewer normal text }
  326.   { 7 = HistoryViewer selected text }
  327.  
  328.   PHistoryWindow = ^THistoryWindow;
  329.   THistoryWindow = object(TWindow)
  330.     Viewer: PListViewer;
  331.     constructor Init(var Bounds: TRect; HistoryId: Word);
  332.     function GetPalette: PPalette; virtual;
  333.     function GetSelection: String; virtual;
  334.     procedure InitViewer(HistoryId: Word); virtual;
  335.   end;
  336.  
  337. { THistory }
  338.  
  339.   { Palette layout }
  340.   { 1 = Arrow }
  341.   { 2 = Sides }
  342.  
  343.   PHistory = ^THistory;
  344.   THistory = object(TView)
  345.     Link: PInputLine;
  346.     HistoryId: Word;
  347.     constructor Init(var Bounds: TRect; ALink: PInputLine; AHistoryId: Word);
  348.     constructor Load(var S: TStream);
  349.     procedure Draw; virtual;
  350.     function GetPalette: PPalette; virtual;
  351.     procedure HandleEvent(var Event: TEvent); virtual;
  352.     function InitHistoryWindow(var Bounds: TRect): PHistoryWindow; virtual;
  353.     procedure Store(var S: TStream);
  354.   end;
  355.  
  356. { SItem routines }
  357.  
  358. function NewSItem(Str: String; ANext: PSItem): PSItem;
  359.  
  360. { Dialogs registration procedure }
  361.  
  362. procedure RegisterDialogs;
  363.  
  364. { Stream Registration Records }
  365.  
  366. const
  367.   RDialog: TStreamRec = (
  368.      ObjType: 10;
  369.      VmtLink: Ofs(TypeOf(TDialog)^);
  370.      Load:    @TDialog.Load;
  371.      Store:   @TDialog.Store
  372.   );
  373.   RInputLine: TStreamRec = (
  374.      ObjType: 11;
  375.      VmtLink: Ofs(TypeOf(TInputLine)^);
  376.      Load:    @TInputLine.Load;
  377.      Store:   @TInputLine.Store
  378.   );
  379.   RButton: TStreamRec = (
  380.      ObjType: 12;
  381.      VmtLink: Ofs(TypeOf(TButton)^);
  382.      Load:    @TButton.Load;
  383.      Store:   @TButton.Store
  384.   );
  385.   RCluster: TStreamRec = (
  386.      ObjType: 13;
  387.      VmtLink: Ofs(TypeOf(TCluster)^);
  388.      Load:    @TCluster.Load;
  389.      Store:   @TCluster.Store
  390.   );
  391.   RRadioButtons: TStreamRec = (
  392.      ObjType: 14;
  393.      VmtLink: Ofs(TypeOf(TRadioButtons)^);
  394.      Load:    @TRadioButtons.Load;
  395.      Store:   @TRadioButtons.Store
  396.   );
  397.   RCheckBoxes: TStreamRec = (
  398.      ObjType: 15;
  399.      VmtLink: Ofs(TypeOf(TCheckBoxes)^);
  400.      Load:    @TCheckBoxes.Load;
  401.      Store:   @TCheckBoxes.Store
  402.   );
  403.   RListBox: TStreamRec = (
  404.      ObjType: 16;
  405.      VmtLink: Ofs(TypeOf(TListBox)^);
  406.      Load:    @TListBox.Load;
  407.      Store:   @TListBox.Store
  408.   );
  409.   RStaticText: TStreamRec = (
  410.      ObjType: 17;
  411.      VmtLink: Ofs(TypeOf(TStaticText)^);
  412.      Load:    @TStaticText.Load;
  413.      Store:   @TStaticText.Store
  414.   );
  415.   RLabel: TStreamRec = (
  416.      ObjType: 18;
  417.      VmtLink: Ofs(TypeOf(TLabel)^);
  418.      Load:    @TLabel.Load;
  419.      Store:   @TLabel.Store
  420.   );
  421.   RHistory: TStreamRec = (
  422.      ObjType: 19;
  423.      VmtLink: Ofs(TypeOf(THistory)^);
  424.      Load:    @THistory.Load;
  425.      Store:   @THistory.Store
  426.   );
  427.   RParamText: TStreamRec = (
  428.      ObjType: 20;
  429.      VmtLink: Ofs(TypeOf(TParamText)^);
  430.      Load:    @TParamText.Load;
  431.      Store:   @TParamText.Store
  432.   );
  433.  
  434. const
  435.  
  436. { Dialog broadcast commands }
  437.  
  438.   cmRecordHistory = 60;
  439.