cdar

diff unit_Editor_ws.pas @ 0:ef71164288c1

begin of using hg for cdar
author "Meillo r e t u r n s <meillo@marmaro.de>"
date Sun, 03 Dec 2006 21:54:43 +0100
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/unit_Editor_ws.pas	Sun Dec 03 21:54:43 2006 +0100
     1.3 @@ -0,0 +1,408 @@
     1.4 +unit unit_Editor_ws;
     1.5 +
     1.6 +interface//####################################################################################
     1.7 +
     1.8 +uses
     1.9 +  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    1.10 +  Dialogs, StdCtrls, ExtCtrls, jpeg, ExtDlgs;
    1.11 +
    1.12 +type
    1.13 +  Tform_Editor_ws = class(TForm)
    1.14 +    btn_cancel: TButton;
    1.15 +    btn_Apply: TButton;
    1.16 +    gbx_BilderLaden: TGroupBox;
    1.17 +    btn_bp: TButton;
    1.18 +    lbl_1: TLabel;
    1.19 +    tbx_BackgroundPath: TEdit;
    1.20 +    tbx_EnterPath: TEdit;
    1.21 +    btn_ep: TButton;
    1.22 +    lbl_2: TLabel;
    1.23 +    gbx_EnterPos: TGroupBox;
    1.24 +    hsb_EnterXPos: TScrollBar;
    1.25 +    tbx_XPos: TEdit;
    1.26 +    lbl_3: TLabel;
    1.27 +    tbx_YPos: TEdit;
    1.28 +    lbl_4: TLabel;
    1.29 +    vsb_EnterYPos: TScrollBar;
    1.30 +    gbx_ShowTill: TGroupBox;
    1.31 +    rbtn_DoShow: TRadioButton;
    1.32 +    rbtn_NotShow: TRadioButton;
    1.33 +    pan_ShowTill: TPanel;
    1.34 +    rbtn_TillClick: TRadioButton;
    1.35 +    rbtn_TillTime: TRadioButton;
    1.36 +    cobx_Delay: TComboBox;
    1.37 +    lbl_5: TLabel;
    1.38 +    lbl_6: TLabel;
    1.39 +    OpenDialog1: TOpenPictureDialog;
    1.40 +    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    1.41 +    procedure FormCreate(Sender: TObject);
    1.42 +    procedure hsb_EnterXPosChange(Sender: TObject);
    1.43 +    procedure vsb_EnterYPosChange(Sender: TObject);
    1.44 +    procedure rbtn_NotShowClick(Sender: TObject);
    1.45 +    procedure rbtn_DoShowClick(Sender: TObject);
    1.46 +    procedure btn_bpClick(Sender: TObject);
    1.47 +    procedure btn_epClick(Sender: TObject);
    1.48 +    procedure FormShow(Sender: TObject);
    1.49 +    procedure btn_ApplyClick(Sender: TObject);
    1.50 +    procedure btn_cancelClick(Sender: TObject);
    1.51 +    procedure rbtn_TillTimeClick(Sender: TObject);
    1.52 +    procedure rbtn_TillClickClick(Sender: TObject);
    1.53 +    procedure tbx_BackgroundPathChange(Sender: TObject);
    1.54 +    procedure tbx_EnterPathChange(Sender: TObject);
    1.55 +  private
    1.56 +    { Private declarations }
    1.57 +  public
    1.58 +    { Public declarations }
    1.59 +  end;
    1.60 +
    1.61 +var
    1.62 +  form_Editor_ws: Tform_Editor_ws;
    1.63 +
    1.64 +implementation//###############################################################################
    1.65 +uses unit_Editor;
    1.66 +{$R *.dfm}//###################################################################################
    1.67 +
    1.68 +//------------------------------------------------------------------------------ form create
    1.69 +procedure Tform_Editor_ws.FormCreate(Sender: TObject);
    1.70 +begin
    1.71 +  // set language
    1.72 +    if form_editor.englisch = true then
    1.73 +      begin // English
    1.74 +        form_Editor_ws.Caption := 'Welcome-Screen Settings';
    1.75 +        btn_cancel.Caption := 'Cancel Changes';
    1.76 +        btn_Apply.Caption := 'Apply Changes';
    1.77 +        btn_bp.Caption := 'Browse';
    1.78 +        btn_ep.Caption := 'Browse';
    1.79 +        lbl_1.Caption := 'Background-Picture:  (600x450 px)';
    1.80 +        lbl_2.caption := 'Enter-Picture:  (150x40 px recommended)';
    1.81 +        lbl_5.Caption := '... of the Enter-Picture';
    1.82 +        lbl_6.Caption := '(You can move by Drag n Drop too)';
    1.83 +        rbtn_DoShow.Caption := 'Show Welcome-Screen ...';
    1.84 +        rbtn_NotShow.Caption := 'Do not show Welcome-Screen';
    1.85 +        rbtn_TillClick.Caption := '... till click';
    1.86 +        rbtn_TillTime.Caption := '...                seconds';
    1.87 +      end
    1.88 +    else
    1.89 +      begin // German
    1.90 +        form_Editor_ws.Caption := 'Begrüßungsbild Optionen';
    1.91 +        btn_cancel.Caption := 'Abbrechen';
    1.92 +        btn_Apply.Caption := 'Übernehmen';
    1.93 +        btn_bp.Caption := 'Durchsuchen';
    1.94 +        btn_ep.Caption := 'Durchsuchen';
    1.95 +        lbl_1.Caption := 'Hintergrundbild:  (600x450 px)';
    1.96 +        lbl_2.caption := 'Enterbild:  (150x40 px empfohlen)';
    1.97 +        lbl_5.Caption := '... des Enterbilds';
    1.98 +        lbl_6.Caption := '(Drag n Drop ist auch möglich)';             
    1.99 +        rbtn_DoShow.Caption := 'Begrüßungsbild anzeigen ...';
   1.100 +        rbtn_NotShow.Caption := 'Kein Begrüßungsbild anzeigen';
   1.101 +        rbtn_TillClick.Caption := '... bis Klick';
   1.102 +        rbtn_TillTime.Caption := '...                Sekunden';
   1.103 +      end;
   1.104 +
   1.105 +  // set standard path
   1.106 +  opendialog1.InitialDir := extractfilepath(paramstr(0));
   1.107 +end;//--------------------------------------------------------------------------
   1.108 +//------------------------------------------------------------------------------ form show
   1.109 +procedure Tform_Editor_ws.FormShow(Sender: TObject);
   1.110 +begin
   1.111 +  // disable drag'n'drop
   1.112 +    form_editor.draggingstatus := 3;
   1.113 +  // disable menu
   1.114 +    form_editor.mnu_Tutorial.enabled := false;
   1.115 +    form_editor.mnu_WelcomeScreen.Enabled := false;
   1.116 +    form_editor.mnu_Autorun.Enabled := false;
   1.117 +    form_editor.mnu_CreateAR.enabled := false;
   1.118 +    form_editor.mnu_Sprache.enabled := false;
   1.119 +
   1.120 +  // init
   1.121 +    // set picture path
   1.122 +      tbx_BackgroundPath.text := form_Editor.PfadHG_alt;
   1.123 +      tbx_EnterPath.text := form_Editor.PfadEnter_alt;
   1.124 +    // set 'img_button'-positon
   1.125 +      tbx_XPos.text := inttostr(form_Editor.xEnter_alt);
   1.126 +      tbx_YPos.text := inttostr(form_Editor.yEnter_alt);
   1.127 +    // kind of welcome action
   1.128 +      if form_Editor.Welcomekind_alt = 'none' then
   1.129 +        begin
   1.130 +          rbtn_notshow.checked := true;
   1.131 +
   1.132 +          rbtn_tillclick.Enabled := false;
   1.133 +          rbtn_tilltime.Enabled := false;
   1.134 +        end
   1.135 +      else
   1.136 +        begin
   1.137 +          if form_Editor.Welcomekind_alt = 'click' then
   1.138 +            begin
   1.139 +              rbtn_tillClick.checked := true;
   1.140 +              rbtn_doshow.Checked := true;
   1.141 +            end
   1.142 +          else
   1.143 +            begin
   1.144 +              rbtn_tilltime.Checked := true;
   1.145 +              rbtn_doshow.Checked := true;              
   1.146 +            end;
   1.147 +        end;
   1.148 +    // delay
   1.149 +    cobx_delay.ItemIndex := form_Editor.Delay_alt;
   1.150 +
   1.151 +  // set scrollbar values
   1.152 +    hsb_enterXpos.Max := form_editor.img_Background.Width - form_editor.img_button.Width;
   1.153 +    hsb_enterXpos.Position := form_editor.img_button.Left;
   1.154 +    vsb_enterYpos.Max := form_editor.img_Background.height - form_editor.img_button.height;
   1.155 +    vsb_enterYpos.Position := form_editor.img_button.top;
   1.156 +end;//--------------------------------------------------------------------------
   1.157 +//------------------------------------------------------------------------------ form close
   1.158 +procedure Tform_Editor_ws.FormClose(Sender: TObject;
   1.159 +  var Action: TCloseAction);
   1.160 +begin
   1.161 +  // reenable drag'n'drop
   1.162 +    form_editor.draggingstatus := 0;
   1.163 +  // reenable menu
   1.164 +    form_editor.mnu_Tutorial.enabled := true;
   1.165 +    form_editor.mnu_WelcomeScreen.Enabled := true;
   1.166 +    form_editor.mnu_Autorun.Enabled := true;
   1.167 +    form_editor.mnu_CreateAR.enabled := true;
   1.168 +    form_editor.mnu_Sprache.enabled := true;
   1.169 +end;//--------------------------------------------------------------------------
   1.170 +
   1.171 +//#############################################################################################
   1.172 +
   1.173 +//------------------------------------------------------------------------------ change x-position
   1.174 +procedure Tform_Editor_ws.hsb_EnterXPosChange(Sender: TObject);
   1.175 +begin
   1.176 +  tbx_xpos.Text := inttostr(hsb_enterXpos.Position);
   1.177 +  form_editor.img_button.Left := hsb_enterXpos.position;
   1.178 +end;//--------------------------------------------------------------------------
   1.179 +//------------------------------------------------------------------------------ change y-position
   1.180 +procedure Tform_Editor_ws.vsb_EnterYPosChange(Sender: TObject);
   1.181 +begin
   1.182 +  tbx_ypos.Text := inttostr(vsb_enterYpos.Position);
   1.183 +  form_editor.img_button.top := vsb_enterYpos.position;
   1.184 +end;//--------------------------------------------------------------------------
   1.185 +
   1.186 +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   1.187 +
   1.188 +//------------------------------------------------------------------------------ NotShow
   1.189 +procedure Tform_Editor_ws.rbtn_NotShowClick(Sender: TObject);
   1.190 +begin
   1.191 +  //
   1.192 +    rbtn_tillclick.Enabled := false;
   1.193 +    rbtn_tilltime.Enabled := false;
   1.194 +    cobx_Delay.enabled := false;
   1.195 +
   1.196 +    tbx_BackgroundPath.Enabled := false;
   1.197 +    btn_bp.Enabled := false;
   1.198 +    tbx_EnterPath.Enabled := false;
   1.199 +    btn_ep.Enabled := false;
   1.200 +    hsb_EnterXPos.Enabled := false;
   1.201 +    vsb_EnterYPos.Enabled := false;
   1.202 +end;//--------------------------------------------------------------------------
   1.203 +//------------------------------------------------------------------------------ Show
   1.204 +procedure Tform_Editor_ws.rbtn_DoShowClick(Sender: TObject);
   1.205 +begin
   1.206 +  //
   1.207 +    rbtn_tillclick.Enabled := true;
   1.208 +    rbtn_tilltime.Enabled := true;
   1.209 +    if rbtn_tilltime.Checked = true then
   1.210 +      begin
   1.211 +        cobx_Delay.Enabled := true;   // time
   1.212 +
   1.213 +        tbx_BackgroundPath.Enabled := true;
   1.214 +        btn_bp.Enabled := true;
   1.215 +        tbx_EnterPath.Enabled := false;
   1.216 +        btn_ep.Enabled := false;
   1.217 +        hsb_EnterXPos.Enabled := false;
   1.218 +        vsb_EnterYPos.Enabled := false;
   1.219 +      end
   1.220 +    else
   1.221 +      begin
   1.222 +        cobx_Delay.enabled := false;   // click
   1.223 +
   1.224 +        tbx_BackgroundPath.Enabled := true;
   1.225 +        btn_bp.Enabled := true;
   1.226 +        tbx_EnterPath.Enabled := true;
   1.227 +        btn_ep.Enabled := true;
   1.228 +        hsb_EnterXPos.Enabled := true;
   1.229 +        vsb_EnterYPos.Enabled := true;
   1.230 +      end;
   1.231 +end;//--------------------------------------------------------------------------
   1.232 +//------------------------------------------------------------------------------ TillClick
   1.233 +procedure Tform_Editor_ws.rbtn_TillClickClick(Sender: TObject);
   1.234 +begin
   1.235 +  cobx_Delay.Enabled := false;
   1.236 +
   1.237 +  tbx_BackgroundPath.Enabled := true;
   1.238 +  btn_bp.Enabled := true;
   1.239 +  tbx_EnterPath.Enabled := true;
   1.240 +  btn_ep.Enabled := true;
   1.241 +  hsb_EnterXPos.Enabled := true;
   1.242 +  vsb_EnterYPos.Enabled := true;
   1.243 +end;//--------------------------------------------------------------------------
   1.244 +//------------------------------------------------------------------------------ TillIime
   1.245 +procedure Tform_Editor_ws.rbtn_TillTimeClick(Sender: TObject);
   1.246 +begin
   1.247 +  cobx_Delay.Enabled := true;
   1.248 +
   1.249 +  tbx_BackgroundPath.Enabled := true;
   1.250 +  btn_bp.Enabled := true;
   1.251 +  tbx_EnterPath.Enabled := false;
   1.252 +  btn_ep.Enabled := false;
   1.253 +  hsb_EnterXPos.Enabled := false;
   1.254 +  vsb_EnterYPos.Enabled := false;
   1.255 +end;//--------------------------------------------------------------------------
   1.256 +
   1.257 +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   1.258 +
   1.259 +//------------------------------------------------------------------------------ Back-Pic
   1.260 +procedure Tform_Editor_ws.btn_bpClick(Sender: TObject);
   1.261 +begin
   1.262 +  // Browse Background-Picture
   1.263 +    if opendialog1.Execute then
   1.264 +      begin
   1.265 +          tbx_backgroundpath.Text := opendialog1.FileName;
   1.266 +        // load picture
   1.267 +          form_editor.img_Background.Picture.LoadFromFile(tbx_backgroundpath.text);
   1.268 +      end;
   1.269 +end;//--------------------------------------------------------------------------
   1.270 +//------------------------------------------------------------------------------ Enter-Pic
   1.271 +procedure Tform_Editor_ws.btn_epClick(Sender: TObject);
   1.272 +begin
   1.273 +  // Browse Enter-Picture
   1.274 +    if opendialog1.Execute then
   1.275 +      begin
   1.276 +          tbx_enterpath.Text := opendialog1.FileName;
   1.277 +        // load picture
   1.278 +          form_editor.img_button.Picture.LoadFromFile(tbx_enterpath.text);
   1.279 +        // if enter-button gets to large
   1.280 +          if form_editor.img_button.Width > form_editor.img_Background.Width then
   1.281 +            begin
   1.282 +              form_editor.img_button.Picture := nil;
   1.283 +              tbx_enterpath.Text := '';
   1.284 +              form_editor.img_button.Width := 0;
   1.285 +              form_editor.img_button.Height := 0;
   1.286 +            end;
   1.287 +          if form_editor.img_button.height > form_editor.img_Background.height then
   1.288 +            begin
   1.289 +              form_editor.img_button.Picture := nil;
   1.290 +              tbx_enterpath.Text := '';
   1.291 +              form_editor.img_button.Width := 0;
   1.292 +              form_editor.img_button.Height := 0;              
   1.293 +            end;
   1.294 +        // config scrollbars
   1.295 +          hsb_enterXpos.Max := form_editor.img_Background.Width - form_editor.img_button.Width;
   1.296 +          hsb_enterXpos.Position := form_editor.img_button.Left;
   1.297 +          vsb_enterYpos.Max := form_editor.img_Background.height - form_editor.img_button.height;
   1.298 +          vsb_enterYpos.Position := form_editor.img_button.top;
   1.299 +        // if enter-button is fullscreen, then dont use a background-pic
   1.300 +          if form_editor.img_button.Width = form_editor.img_Background.Width then
   1.301 +            begin
   1.302 +              if form_editor.img_button.Height = form_editor.img_Background.Height then
   1.303 +                begin
   1.304 +                  tbx_BackgroundPath.Enabled := false;
   1.305 +                  btn_bp.Enabled := false;
   1.306 +                end
   1.307 +              else
   1.308 +                begin
   1.309 +                  tbx_BackgroundPath.Enabled := true;
   1.310 +                  btn_bp.Enabled := true;
   1.311 +                end;
   1.312 +            end;
   1.313 +      end;
   1.314 +end;//--------------------------------------------------------------------------
   1.315 +
   1.316 +//------------------------------------------------------------------------------ no pic
   1.317 +procedure Tform_Editor_ws.tbx_BackgroundPathChange(Sender: TObject);
   1.318 +begin
   1.319 +  if tbx_BackgroundPath.Text = '' then
   1.320 +    begin
   1.321 +      form_editor.img_Background.Picture := nil;
   1.322 +    end;
   1.323 +end;//--------------------------------------------------------------------------
   1.324 +//------------------------------------------------------------------------------ no pic
   1.325 +procedure Tform_Editor_ws.tbx_EnterPathChange(Sender: TObject);
   1.326 +begin
   1.327 +  if tbx_EnterPath.Text = '' then
   1.328 +    begin
   1.329 +      form_editor.img_Button.Picture := nil;
   1.330 +      tbx_BackgroundPath.Enabled := true;
   1.331 +      btn_bp.Enabled := true;
   1.332 +    end;
   1.333 +end;//--------------------------------------------------------------------------
   1.334 +
   1.335 +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   1.336 +
   1.337 +//------------------------------------------------------------------------------ apply
   1.338 +procedure Tform_Editor_ws.btn_ApplyClick(Sender: TObject);
   1.339 +begin
   1.340 +  // set new data to '*_neu'
   1.341 +    form_Editor.pfadHG_neu := tbx_backgroundpath.text;
   1.342 +    form_Editor.pfadEnter_neu := tbx_Enterpath.text;
   1.343 +    form_Editor.xEnter_neu := strtoint(tbx_xpos.text);
   1.344 +    form_Editor.yEnter_neu := strtoint(tbx_ypos.text);
   1.345 +    form_Editor.Delay_neu := cobx_Delay.ItemIndex;
   1.346 +    // kind of welcome action
   1.347 +      if rbtn_notshow.checked then
   1.348 +        begin
   1.349 +          form_Editor.Welcomekind_neu := 'none';
   1.350 +        end
   1.351 +      else
   1.352 +        begin
   1.353 +          if rbtn_tillClick.checked then
   1.354 +            begin
   1.355 +              form_Editor.Welcomekind_neu := 'click';
   1.356 +            end
   1.357 +          else
   1.358 +            begin
   1.359 +              form_Editor.Welcomekind_neu := 'time';
   1.360 +            end;
   1.361 +        end;
   1.362 +
   1.363 +  // '*_neu' to '*_alt'
   1.364 +    with form_Editor do
   1.365 +    begin
   1.366 +      PfadHG_alt := PfadHG_neu;
   1.367 +      PfadEnter_alt := PfadEnter_neu;
   1.368 +      xEnter_alt := xEnter_neu;
   1.369 +      yEnter_alt := yEnter_neu;
   1.370 +      WelcomeKind_alt := WelcomeKind_neu;
   1.371 +      Delay_alt := Delay_neu;
   1.372 +    end;
   1.373 +
   1.374 +  // delay
   1.375 +    form_Editor.Delay := cobx_Delay.text;
   1.376 +
   1.377 +
   1.378 +  // close
   1.379 +    form_editor_ws.Close;
   1.380 +end;//--------------------------------------------------------------------------
   1.381 +//------------------------------------------------------------------------------ cancel
   1.382 +procedure Tform_Editor_ws.btn_cancelClick(Sender: TObject);
   1.383 +begin
   1.384 +  // restore old settings
   1.385 +    // background-pic
   1.386 +      if form_Editor.PfadHG_alt = '' then
   1.387 +        begin
   1.388 +          form_Editor.img_background.Picture := nil;
   1.389 +        end
   1.390 +      else
   1.391 +        begin
   1.392 +          form_editor.img_Background.Picture.LoadFromFile(form_Editor.PfadHG_alt);
   1.393 +        end;
   1.394 +    // enter-pic
   1.395 +      if form_Editor.PfadEnter_alt = '' then
   1.396 +        begin
   1.397 +          form_Editor.img_button.Picture := nil;
   1.398 +        end
   1.399 +      else
   1.400 +        begin
   1.401 +          form_editor.img_button.Picture.LoadFromFile(form_Editor.PfadEnter_alt);
   1.402 +        end;
   1.403 +    // button-pos
   1.404 +      form_editor.img_button.Left := form_Editor.xEnter_alt;
   1.405 +      form_editor.img_button.top := form_Editor.yEnter_alt;
   1.406 +
   1.407 +  // close
   1.408 +    form_editor_ws.Close;
   1.409 +end;//--------------------------------------------------------------------------
   1.410 +
   1.411 +end.//#########################################################################################