home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Multimed / Multimed.zip / mp3osr05.zip / src / sorttype.pas < prev    next >
Pascal/Delphi Source File  |  1999-12-12  |  6KB  |  245 lines

  1. (*
  2.  * part of MPEG searcher project
  3.  *  (c) 1999 by Alexander Trunov, 2:5069/10, jnc@mail.ru
  4.  *)
  5.  
  6. unit SortType;
  7.  
  8. interface
  9.  
  10. {&Use32+}
  11.  
  12. uses
  13.   Objects, Views, App, Dialogs, Sortings;
  14.  
  15. type
  16.  
  17.   TTwoItemsRec = record
  18.     firstFactor, secondFactor: TSepFactor;
  19.   end;
  20.  
  21.   POneItemDialog = ^TOneItemDialog;
  22.   TOneItemDialog = object(TDialog)
  23.     rdoOption: PRadioButtons;
  24.     constructor Init;
  25.     procedure GetData(var R); virtual;
  26.     function DataSize: Integer; virtual;
  27.     procedure SetData(var R); virtual;
  28.   end;
  29.  
  30.   PTwoItemsDialog = ^TTwoItemsDialog;
  31.   TTwoItemsDialog = object(TDialog)
  32.     rdoFirstOption, rdoSecondOption: PRadioButtons;
  33.     constructor Init(theCaption: string);
  34.     procedure GetData(var R); virtual;
  35.     function DataSize: Integer; virtual;
  36.     procedure SetData(var R); virtual;
  37.   end;
  38.  
  39.   PTemplateDialog = ^TTemplateDialog;
  40.   TTemplateDialog = object(TDialog)
  41.     lstList: PListBox;
  42.     constructor Init(templates: PStringCollection);
  43.     destructor Done; virtual;
  44.     procedure GetData(var R); virtual;
  45.     function DataSize: Integer; virtual;
  46.     procedure SetData(var R); virtual;
  47.   end;
  48.  
  49. implementation
  50.  
  51. procedure TTemplateDialog.GetData(var R);
  52. begin
  53.   Byte(R) := lstList^.Focused;
  54. end;
  55.  
  56. function TTemplateDialog.DataSize: Integer;
  57. begin
  58.   Result := SizeOf(Byte);
  59. end;
  60.  
  61. procedure TTemplateDialog.SetData(var R);
  62. begin
  63.   lstList^.FocusItem(Byte(R));
  64. end;
  65.  
  66. constructor TTemplateDialog.Init(templates: PStringCollection);
  67. var
  68.   R: TRect;
  69.   i: Integer;
  70. begin
  71.   R.Assign(0, 0, 31, 9);
  72.   inherited Init(R, 'Choose a template');
  73.  
  74.   Options := Options or ofCentered;
  75.  
  76.   R.Assign(2, 2, 16, 7);
  77.   lstList := New(PListBox, Init(R, 1, nil));
  78.   Insert(lstList);
  79.   lstList^.NewList(New(PStringCollection, Init(10, 10)));
  80.  
  81.   for i := 0 to templates^.Count - 1 do
  82.   begin
  83.     lstList^.List^.AtInsert(lstList^.List^.Count,
  84.       NewStr(PString(templates^.Items^[i])^));
  85.   end;
  86.  
  87.   lstList^.SetRange(lstList^.List^.Count);
  88.  
  89.   R.Assign(17, 2, 29, 4);
  90.   Insert(New(PButton, Init(R, 'O~K~', cmOk, bfDefault)));
  91.  
  92.   R.Assign(17, 5, 29, 7);
  93.   Insert(New(PButton, Init(R, '~C~ancel', cmCancel, 0)));
  94.  
  95.   lstList^.Select;
  96. end;
  97.  
  98. destructor TTemplateDialog.Done;
  99. begin
  100.   lstList^.NewList(nil);
  101.   inherited Done;
  102. end;
  103.  
  104. constructor TTwoItemsDialog.Init(theCaption: string);
  105. var
  106.   R: TRect;
  107. begin
  108.   R.Assign(0, 0, 46, 10);
  109.   inherited Init(R, theCaption);
  110.  
  111.   Options := Options or ofCentered;
  112.  
  113.   R.Assign(2, 3, 16, 8);
  114.   rdoFirstOption := New(PRadioButtons, Init(R,
  115.     NewSItem('~a~rtist',
  116.     NewSItem('~t~itle',
  117.     NewSItem('a~l~bum',
  118.     NewSItem('c~o~mment',
  119.     NewSItem('~y~ear', nil)))))));
  120.   Insert(rdoFirstOption);
  121.  
  122.   R.Assign(2, 2, 16, 3);
  123.   Insert(New(PLabel, Init(R, '~F~irst:', rdoFirstOption)));
  124.  
  125.   R.Assign(17, 3, 31, 8);
  126.   rdoSecondOption := New(PRadioButtons, Init(R,
  127.     NewSItem('a~r~tist',
  128.     NewSItem('t~i~tle',
  129.     NewSItem('al~b~um',
  130.     NewSItem('co~m~ment',
  131.     NewSItem('y~e~ar', nil)))))));
  132.   Insert(rdoSecondOption);
  133.  
  134.   R.Assign(17, 2, 31, 3);
  135.   Insert(New(PLabel, Init(R, '~S~econd:', rdoSecondOption)));
  136.  
  137.   R.Assign(32, 3, 44, 5);
  138.   Insert(New(PButton, Init(R, 'O~K~', cmOk, bfDefault)));
  139.  
  140.   R.Assign(32, 6, 44, 8);
  141.   Insert(New(PButton, Init(R, '~C~ancel', cmCancel, 0)));
  142.  
  143.   rdoFirstOption^.Select;
  144. end;
  145.  
  146. procedure TTwoItemsDialog.GetData(var R);
  147. begin
  148.   case rdoFirstOption^.Value of
  149.     0: TTwoItemsRec(R).firstFactor := faArtist;
  150.     1: TTwoItemsRec(R).firstFactor := faTitle;
  151.     2: TTwoItemsRec(R).firstFactor := faAlbum;
  152.     3: TTwoItemsRec(R).firstFactor := faComment;
  153.     4: TTwoItemsRec(R).firstFactor := faYear;
  154.   end;
  155.   case rdoSecondOption^.Value of
  156.     0: TTwoItemsRec(R).secondFactor := faArtist;
  157.     1: TTwoItemsRec(R).secondFactor := faTitle;
  158.     2: TTwoItemsRec(R).secondFactor := faAlbum;
  159.     3: TTwoItemsRec(R).secondFactor := faComment;
  160.     4: TTwoItemsRec(R).secondFactor := faYear;
  161.   end;
  162. end;
  163.  
  164. function TTwoItemsDialog.DataSize: Longint;
  165. begin
  166.   Result := SizeOf(TTwoItemsRec);
  167. end;
  168.  
  169. procedure TTwoItemsDialog.SetData(var R);
  170. begin
  171.   rdoSecondOption^.Select;
  172.   case TTwoItemsRec(R).secondFactor of
  173.     faArtist: rdoSecondOption^.Press(0);
  174.     faTitle: rdoSecondOption^.Press(1);
  175.     faAlbum: rdoSecondOption^.Press(2);
  176.     faComment: rdoSecondOption^.Press(3);
  177.     faYear: rdoSecondOption^.Press(4);
  178.   end;
  179.   rdoFirstOption^.Select;
  180.   case TTwoItemsRec(R).firstFactor of
  181.     faArtist: rdoFirstOption^.Press(0);
  182.     faTitle: rdoFirstOption^.Press(1);
  183.     faAlbum: rdoFirstOption^.Press(2);
  184.     faComment: rdoFirstOption^.Press(3);
  185.     faYear: rdoFirstOption^.Press(4);
  186.   end;
  187. end;
  188.  
  189. constructor TOneItemDialog.Init;
  190. var
  191.   R: TRect;
  192. begin
  193.   R.Assign(0, 0, 31, 9);
  194.   inherited Init(R, 'One item sort options');
  195.  
  196.   Options := Options or ofCentered;
  197.  
  198.   R.Assign(2, 2, 16, 7);
  199.   rdoOption := New(PRadioButtons, Init(R,
  200.     NewSItem('~a~rtist',
  201.     NewSItem('~t~itle',
  202.     NewSItem('a~l~bum',
  203.     NewSItem('c~o~mment',
  204.     NewSItem('~y~ear', nil)))))));
  205.   Insert(rdoOption);
  206.  
  207.   R.Assign(17, 2, 29, 4);
  208.   Insert(New(PButton, Init(R, 'O~K~', cmOk, bfDefault)));
  209.  
  210.   R.Assign(17, 5, 29, 7);
  211.   Insert(New(PButton, Init(R, '~C~ancel', cmCancel, 0)));
  212.  
  213.   rdoOption^.Select;
  214. end;
  215.  
  216. procedure TOneItemDialog.GetData(var R);
  217. begin
  218.   case rdoOption^.Value of
  219.     0: TSepFactor(R) := faArtist;
  220.     1: TSepFactor(R) := faTitle;
  221.     2: TSepFactor(R) := faAlbum;
  222.     3: TSepFactor(R) := faComment;
  223.     4: TSepFactor(R) := faYear;
  224.   end;
  225. end;
  226.  
  227. function TOneItemDialog.DataSize: Integer;
  228. begin
  229.   Result := SizeOf(TSepFactor);
  230. end;
  231.  
  232. procedure TOneItemDialog.SetData(var R);
  233. begin
  234.   case TSepFactor(R) of
  235.     faArtist: rdoOption^.Press(0);
  236.     faTitle: rdoOption^.Press(1);
  237.     faAlbum: rdoOption^.Press(2);
  238.     faComment: rdoOption^.Press(3);
  239.     faYear: rdoOption^.Press(4);
  240.   end;
  241.   Redraw;
  242. end;
  243.  
  244. end.
  245.