home *** CD-ROM | disk | FTP | other *** search
/ PC Open 19 / pcopen19.iso / Zipped / CALMIR21.ZIP / SOURCE.ZIP / SRC / TASKPROP.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-02-20  |  5.9 KB  |  178 lines

  1. {**************************************************************************}
  2. {                                                                          }
  3. {    Calmira shell for Microsoft« Windows(TM) 3.1                          }
  4. {    Source Release 2.1                                                    }
  5. {    Copyright (C) 1997-1998 Li-Hsin Huang                                 }
  6. {                                                                          }
  7. {    This program is free software; you can redistribute it and/or modify  }
  8. {    it under the terms of the GNU General Public License as published by  }
  9. {    the Free Software Foundation; either version 2 of the License, or     }
  10. {    (at your option) any later version.                                   }
  11. {                                                                          }
  12. {    This program is distributed in the hope that it will be useful,       }
  13. {    but WITHOUT ANY WARRANTY; without even the implied warranty of        }
  14. {    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         }
  15. {    GNU General Public License for more details.                          }
  16. {                                                                          }
  17. {    You should have received a copy of the GNU General Public License     }
  18. {    along with this program; if not, write to the Free Software           }
  19. {    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.             }
  20. {                                                                          }
  21. {**************************************************************************}
  22.  
  23. unit Taskprop;
  24.  
  25. interface
  26.  
  27. uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, Buttons,
  28.   StdCtrls, Chklist, TabNotBk, ExtCtrls, Spin, StylSped;
  29.  
  30. type
  31.   TTaskPropDlg = class(TForm)
  32.     OKBtn: TBitBtn;
  33.     CancelBtn: TBitBtn;
  34.     Notebook: TTabbedNotebook;
  35.     CheckList: TCheckList;
  36.     AppTrayList: TListBox;
  37.     Header1: THeader;
  38.     Label1: TLabel;
  39.     AddAppBtn: TStyleSpeed;
  40.     RemoveBtn: TStyleSpeed;
  41.     RefreshEdit: TSpinEdit;
  42.     Label2: TLabel;
  43.     Bevel1: TBevel;
  44.     HelpBtn: TBitBtn;
  45.     Bevel2: TBevel;
  46.     Header2: THeader;
  47.     Label3: TLabel;
  48.     ExcludeList: TListBox;
  49.     AddExclusionBtn: TStyleSpeed;
  50.     RemoveExcludeBtn: TStyleSpeed;
  51.     Bevel3: TBevel;
  52.     procedure FormCreate(Sender: TObject);
  53.     procedure OKBtnClick(Sender: TObject);
  54.     procedure AppTrayListDrawItem(Control: TWinControl; Index: Integer;
  55.       Rect: TRect; State: TOwnerDrawState);
  56.     procedure AddAppBtnClick(Sender: TObject);
  57.     procedure RemoveBtnClick(Sender: TObject);
  58.     procedure Header1Sized(Sender: TObject; ASection, AWidth: Integer);
  59.     procedure ExcludeListDrawItem(Control: TWinControl; Index: Integer;
  60.       Rect: TRect; State: TOwnerDrawState);
  61.     procedure Header2Sized(Sender: TObject; ASection, AWidth: Integer);
  62.     procedure AddExclusionBtnClick(Sender: TObject);
  63.     procedure RemoveExcludeBtnClick(Sender: TObject);
  64.   private
  65.     { Private declarations }
  66.   public
  67.     { Public declarations }
  68.   end;
  69.  
  70. {
  71. var
  72.   TaskPropDlg: TTaskPropDlg;
  73. }
  74.  
  75.  
  76. implementation
  77.  
  78. {$R *.DFM}
  79.  
  80. uses Settings, Strings, Dialogs, SysUtils, Locale;
  81.  
  82. procedure TTaskPropDlg.FormCreate(Sender: TObject);
  83. begin
  84.   Notebook.PageIndex := 0;
  85.  
  86.   CheckList.SetData(
  87.     [DisableTaskbar, StayVisible, ShrinkMax, Clock24, PopupRes, PopupDate,
  88.      Animate, ButtonHints, ArrangeMin, HideMinApps, IconWindowTask,
  89.      ExplorerTask, FullFolderPath, DocNameFirst, DocNameLower]);
  90.  
  91.   ini.ReadSectionValues('Applet Tray', AppTrayList.Items);
  92.   ini.ReadStrings('Exclude', ExcludeList.Items);
  93.   RefreshEdit.Value := ini.ReadInteger('Taskbar', 'Refresh', 5);
  94. end;
  95.  
  96. procedure TTaskPropDlg.OKBtnClick(Sender: TObject);
  97. begin
  98.   CheckList.GetData(
  99.     [@DisableTaskbar, @StayVisible, @ShrinkMax, @Clock24, @PopupRes, @PopupDate,
  100.      @Animate, @ButtonHints, @ArrangeMin, @HideMinApps, @IconWindowTask,
  101.      @ExplorerTask, @FullFolderPath, @DocNameFirst, @DocNameLower]);
  102.  
  103.   SaveTaskProp;
  104.   ini.EraseSection('Applet Tray');
  105.   ini.WriteSectionValues('Applet Tray', AppTrayList.Items);
  106.   ini.WriteStrings('Exclude', ExcludeList.Items);
  107.   ini.WriteInteger('Taskbar', 'Refresh', RefreshEdit.Value);
  108.  
  109.   AnnounceSettingsChanged([scTaskbar]);
  110. end;
  111.  
  112.  
  113. procedure TTaskPropDlg.AppTrayListDrawItem(Control: TWinControl;
  114.   Index: Integer; Rect: TRect; State: TOwnerDrawState);
  115. begin
  116.   with AppTrayList do begin
  117.     Canvas.FillRect(Rect);
  118.     Canvas.TextOut(Rect.Left+2, Rect.Top+1, GetStrKey(Items[Index]));
  119.     Canvas.TextOut(Header1.SectionWidth[0], Rect.Top+1, GetStrValue(Items[Index]));
  120.   end;
  121. end;
  122.  
  123.  
  124. procedure TTaskPropDlg.AddAppBtnClick(Sender: TObject);
  125. var s: string;
  126. begin
  127.   s := '';
  128.   if InputQuery(LoadStr(SAddApplet), LoadStr(SAppletFormat), s) and
  129.     (s > '') then AppTrayList.Items.Add(s);
  130. end;
  131.  
  132. procedure TTaskPropDlg.RemoveBtnClick(Sender: TObject);
  133. begin
  134.   with AppTrayList do
  135.     if ItemIndex <> -1 then Items.Delete(ItemIndex);
  136. end;
  137.  
  138. procedure TTaskPropDlg.Header1Sized(Sender: TObject; ASection,
  139.   AWidth: Integer);
  140. begin
  141.   AppTrayList.Invalidate;
  142. end;
  143.  
  144. procedure TTaskPropDlg.ExcludeListDrawItem(Control: TWinControl;
  145.   Index: Integer; Rect: TRect; State: TOwnerDrawState);
  146. var
  147.   s: string[79];
  148. begin
  149.   with ExcludeList do begin
  150.     Canvas.FillRect(Rect);
  151.     s := Items[Index];
  152.     Canvas.TextOut(Rect.Left+2, Rect.Top+1, GetWord(s, ' '));
  153.     Canvas.TextOut(Header2.SectionWidth[0], Rect.Top+1, s);
  154.   end;
  155. end;
  156.  
  157. procedure TTaskPropDlg.Header2Sized(Sender: TObject; ASection,
  158.   AWidth: Integer);
  159. begin
  160.   ExcludeList.Invalidate;
  161. end;
  162.  
  163. procedure TTaskPropDlg.AddExclusionBtnClick(Sender: TObject);
  164. var s: string;
  165. begin
  166.   s := '';
  167.   if InputQuery(LoadStr(SAddExclusion), LoadStr(SModuleClass), s) and
  168.     (s > '') then ExcludeList.Items.Add(s);
  169. end;
  170.  
  171. procedure TTaskPropDlg.RemoveExcludeBtnClick(Sender: TObject);
  172. begin
  173.   with ExcludeList do
  174.     if ItemIndex <> -1 then Items.Delete(ItemIndex);
  175. end;
  176.  
  177. end.
  178.