{------------------------------------------------------------------------------} { Unit Name: OptionsForm Purpose : Options for Marker Author : Vesa Lappalainen Date : 10.2.2001 Changed : ToDo : } {------------------------------------------------------------------------------} unit OptionsForm; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, ComCtrls, ToolWin, StdCtrls, EditDouble, kEditPnl, kinicomp, savepos; type TFormOptions = class(TForm) ToolBar1: TToolBar; PanelColor: TPanel; EditWidth: TCtrlPanel; EditWidthEditDouble: TEditDouble; EditStyle: TCtrlPanel; EditStyleEditDouble: TEditDouble; ToolButton1: TToolButton; PanelRed: TPanel; PanelFuchsia: TPanel; PanelAqua: TPanel; PanelGreen: TPanel; PanelYellow: TPanel; ToolButton2: TToolButton; PanelW1: TPanel; PanelW10: TPanel; PanelW5: TPanel; PanelW3: TPanel; ToolButton3: TToolButton; PanelSCopy: TPanel; PanelSTransparent: TPanel; EditColor: TEditIni; PanelW20: TPanel; SavePos1: TSavePos; CBAutoHide: TCheckBoxIni; ToolButton4: TToolButton; ButtonClear: TPanel; ToolButton5: TToolButton; ButtonHide: TPanel; ToolButton6: TToolButton; CBFilled: TCheckBoxIni; ToolButton7: TToolButton; PanelSXOR: TPanel; EditType: TCtrlPanel; EditTypeComboBox: TComboBox; ToolButton8: TToolButton; procedure PanelYellowClick(Sender: TObject); procedure PanelW1Click(Sender: TObject); procedure PanelSCopyClick(Sender: TObject); procedure EditColorChange(Sender: TObject); procedure FormShow(Sender: TObject); procedure ButtonClearClick(Sender: TObject); procedure ButtonHideClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure EditTypeComboBoxChange(Sender: TObject); private procedure AutoHide; public procedure HandleKey(var Key:char); function IsLinux():boolean; end; var FormOptions: TFormOptions; implementation uses kstring,MarkerForm,DrawObject; {$R *.DFM} procedure TFormOptions.AutoHide; begin if ( CBAutoHide.Checked ) then Hide; end; procedure TFormOptions.PanelYellowClick(Sender: TObject); begin if not ( Sender is TPanel ) then exit; EditColor.Text := ChangeAll(Format('$%06x',[TPanel(Sender).Color]),' ','0'); // PanelColor.Color := TPanel(Sender).Color; AutoHide; end; procedure TFormOptions.PanelW1Click(Sender: TObject); begin if not ( Sender is TPanel ) then exit; EditWidth.AsString := TPanel(Sender).Caption; AutoHide; end; procedure TFormOptions.PanelSCopyClick(Sender: TObject); begin if not ( Sender is TPanel ) then exit; EditStyleEditDouble.Value := TPanel(Sender).Tag; AutoHide; end; procedure TFormOptions.EditColorChange(Sender: TObject); begin PanelColor.Color := StrToIntDef(EditColor.Text,0); end; procedure TFormOptions.HandleKey(var Key: char); begin if ( key in ['1'..'9'] ) then begin EditWidth.AsString := Key; exit; end; if ( key = '0' ) then begin EditWidth.AsString := '10'; exit; end; if ( key = '+' ) then begin EditWidth.AsString := '20'; exit; end; if ( key = 'x' ) then begin EditStyle.AsString := '15'; exit; end; if ( key = 't' ) then begin EditStyle.AsString := '12'; exit; end; if ( key = 'o' ) then begin EditStyle.AsString := '4'; exit; end; if ( key = 'r' ) then begin EditColor.AsString := '$0000ff'; exit; end; if ( key = 'g' ) then begin EditColor.AsString := '$00ff00'; exit; end; if ( key = 'y' ) then begin EditColor.AsString := '$00ffff'; exit; end; if ( key = 'v' ) then begin EditColor.AsString := '$ff00ff'; exit; end; if ( key = 'a' ) then begin EditColor.AsString := '$ffff00'; exit; end; if ( key = 's' ) then begin EditType.AsString := 'Rectangle'; exit; end; if ( key = 'l' ) then begin EditType.AsString := 'Line'; exit; end; if ( key = 'e' ) then begin EditType.AsString := 'Ellipse'; exit; end; if ( key = 'z' ) then begin EditType.AsString := 'FreeLine'; exit; end; if ( key = 'c' ) then begin FormMarker.Clear; exit; end; if ( key = ' ' ) then begin FormMarker.ReDraw; exit; end; if ( key = 'f' ) then begin CBFilled.Checked := not CBFilled.Checked; exit; end; if ( key = #8 ) then begin FormMarker.Undo; exit; end; if ( key = #127 ) then begin FormMarker.Redo; exit; end; if ( key = #13 ) then begin FormMarker.SetCurrent; exit; end; if ( not IsLinux ) then Application.Minimize; end; procedure TFormOptions.FormShow(Sender: TObject); begin if ( not CBAutoHide.Checked ) then exit; Top := Mouse.CursorPos.y - Height div 2; Left := Mouse.CursorPos.x - Width div 2; end; procedure TFormOptions.ButtonClearClick(Sender: TObject); begin AutoHide; FormMarker.Clear; end; procedure TFormOptions.ButtonHideClick(Sender: TObject); begin Application.Minimize; end; procedure TFormOptions.FormCreate(Sender: TObject); begin ExampleGObjects.FillList(EditTypeComboBox.Items); end; procedure TFormOptions.EditTypeComboBoxChange(Sender: TObject); begin AutoHide; end; function TFormOptions.IsLinux: boolean; begin Result := ( ParamStr(1) = '-l' ); end; end.