home *** CD-ROM | disk | FTP | other *** search
- unit ntc_client_planets;
- {
- Copyright (C) 2004 - 2006 Andrew Sprott
-
- http://astronomy.crysania.co.uk
- astro@trefach.co.uk
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- }
-
- interface
-
- uses
- Windows,
- Messages,
- SysUtils,
- Variants,
- Classes,
- Graphics,
- Controls,
- Forms,
- Dialogs,
- StdCtrls,
- Buttons,
- ExtCtrls,
- inifiles,
-
- ntc_client_form;
-
- const
- { 2 hours is a long time :] }
- a_long_time=2*60*60;
-
- type
- Tscope_planets = class(TForm)
- planets_panel: TPanel;
- planets_group: TGroupBox;
- mercury_button: TBitBtn;
- venus_button: TBitBtn;
- mars_button: TBitBtn;
- jupiter_button: TBitBtn;
- saturn_button: TBitBtn;
- uranus_button: TBitBtn;
- neptune_button: TBitBtn;
- pluto_button: TBitBtn;
- mercury_led: TEdit;
- venus_led: TEdit;
- mars_led: TEdit;
- jupiter_led: TEdit;
- saturn_led: TEdit;
- uranus_led: TEdit;
- neptune_led: TEdit;
- pluto_led: TEdit;
- merc_ra_edit: TEdit;
- venus_ra_edit: TEdit;
- mars_ra_edit: TEdit;
- jup_ra_edit: TEdit;
- sat_ra_edit: TEdit;
- uranus_ra_edit: TEdit;
- nep_ra_edit: TEdit;
- pluto_ra_edit: TEdit;
- merc_dec_edit: TEdit;
- venus_dec_edit: TEdit;
- mars_dec_edit: TEdit;
- jup_dec_edit: TEdit;
- sat_dec_edit: TEdit;
- uranus_dec_edit: TEdit;
- nep_dec_edit: TEdit;
- pluto_dec_edit: TEdit;
- slew_label: TLabel;
- visible_label: TLabel;
- ra_label: TLabel;
- dec_label: TLabel;
- poll_group: TGroupBox;
- msecs_edit: TEdit;
- refresh_button: TBitBtn;
- Label1: TLabel;
- refresh_check: TCheckBox;
- refresh_timer: TTimer;
- now_button: TBitBtn;
- { form functions }
- procedure formcreate(
- Sender:TObject);
-
- procedure form_close_query(
- Sender: TObject;
- var CanClose: Boolean);
-
- { configuration }
- procedure load_settings;
-
- procedure save_settings;
-
- { timer poll }
- procedure enable_refresh_timer;
- procedure disable_refresh_timer;
-
- { events }
- procedure FormShow(
- Sender:TObject);
-
- procedure adjust;
-
- procedure check_activate(
- Sender: TObject);
-
- procedure refresh_checkClick(
- Sender: TObject);
-
- procedure now_buttonClick(
- Sender: TObject);
-
- private
- { Private declarations }
- public
- { Public declarations }
- { configuration }
- dimensions:dimensions_record;
-
- { events }
- procedure check_visible_and_show_hide(
- sender:tobject);
-
- procedure hide_form;
- procedure show_form;
- end;
-
- var
- scope_planets: Tscope_planets;
-
- implementation
-
- {$R *.dfm}
-
- { -------------
- form controls
- ------------- }
-
- procedure tscope_planets.formcreate(
- Sender:TObject);
- begin
- disable_refresh_timer;
- msecs_edit.enabled:=false;
- load_settings;
- end;
-
- procedure tscope_planets.form_close_query(
- Sender: TObject;
- var CanClose: Boolean);
- begin
- canclose:=false;
- visible:=false;
- with dimensions do
- begin
- form_top:=top;
- form_left:=left;
- end;
- end;
-
- { -------------
- configuration
- ------------- }
-
- procedure tscope_planets.load_settings;
- begin
- ini_file:=tinifile.create(application_path+'client.ini');
- with ini_file do
- begin
- { form }
- scope.get_dimensions(scope_planets,@dimensions,'planets',ini_file);
- left:=dimensions.form_left;
- top:=dimensions.form_top;
- visible:=readbool('planets','visible',false);
- end;
- ini_file.free;
- end;
-
- procedure tscope_planets.save_settings;
- begin
- with ini_file do
- begin
- { form }
- scope.find_vdu(scope_planets,@dimensions);
- scope.write_dimensions(@dimensions,left,top,'planets',ini_file);
- writebool('planets','visible',visible);
- end;
- end;
-
- { ----------
- timer poll
- ---------- }
-
- procedure tscope_planets.enable_refresh_timer;
- begin
- with refresh_timer do
- begin
- enabled:=false;
- interval:=strtointdef(msecs_edit.text,0);
- if (interval<=0) or (interval>a_long_time) then
- interval:=5;
- now_button.caption:='Stop';
- enabled:=true
- end;
- end;
-
- procedure tscope_planets.disable_refresh_timer;
- begin
- refresh_timer.enabled:=false;
- now_button.caption:='Now';
- end;
-
- { ------
- events
- ------ }
-
- procedure tscope_planets.FormShow(
- Sender:TObject);
- begin
- with dimensions do
- begin
- top:=form_top;
- left:=form_left;
- end;
- end;
-
- procedure tscope_planets.adjust;
- begin
- with dimensions do
- begin
- form_top:=trunc(form_top/last_screen_height*current_height);
- form_left:=trunc(form_left/last_screen_width*current_width);
- end;
- if visible then
- show;
- end;
-
- procedure tscope_planets.check_visible_and_show_hide(
- sender:tobject);
- begin
- if visible then
- hide_form
- else
- show_form;
- scope.show_hide(sender,visible);
- end;
-
- procedure tscope_planets.hide_form;
- begin
- with dimensions do
- begin
- form_top:=top;
- form_left:=left;
- end;
- Visible:=false;
- end;
-
- procedure tscope_planets.show_form;
- begin
- Visible:=true;
- end;
-
- procedure tscope_planets.check_activate(
- Sender: TObject);
- begin
- scope.form_activate(scope_planets,@dimensions);
- end;
-
- procedure Tscope_planets.refresh_checkClick(
- Sender: TObject);
- begin
- if refresh_check.Checked then
- begin
- now_button.Enabled:=true;
- msecs_edit.enabled:=true;
- end
- else
- begin
- disable_refresh_timer;
- msecs_edit.enabled:=false;
- now_button.enabled:=false;
- end;
- end;
-
- procedure Tscope_planets.now_buttonClick(
- Sender: TObject);
- begin
- if not refresh_check.Checked or refresh_timer.Enabled then
- disable_refresh_timer
- else
- enable_refresh_timer;
- end;
-
- end.
-