Code Search for Developers
 
 
  

Unit1.pas from Sector-37 at Krugle


Show Unit1.pas syntax highlighted

unit Unit1;

interface

{$I GLScene.inc}

uses
  //VCL
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls,
  //File formats
  JPEG,
  //GLScene
  GLBitmapFont, GLScene, GLObjects, GLWindows, GLMisc, GLGui,  GLTexture,
  GLWin32Viewer, GLWindowsFont, GLCrossPlatform,
  GLBehaviours, GLHUDObjects, GLWin32FullScreenViewer, GLCadencer,
  //Strange components
  StrangeGUI {$IFDEF STRANGE_INIFILE_SUPPORT},StrangeIniObjects{$ENDIF};

type
  TForm1 = class(TForm)
    GLGuiLayout1: TGLGuiLayout;
    GLWindowsBitmapFont1: TGLWindowsBitmapFont;
    GLScene1: TGLScene;
    GLCamera1: TGLCamera;
    GLSceneViewer1: TGLSceneViewer;
    GLForm1: TGLForm;
    GLButton1: TGLButton;
    GLLabel1: TGLLabel;
    GLMaterialLibrary1: TGLMaterialLibrary;
    GLCadencer1: TGLCadencer;
    GLPopupMenu1: TGLPopupMenu;
    GLPanel1: TGLPanel;
    GLEdit1: TGLEdit;
    GLCustomControl1: TGLCustomControl;
    GLStringGrid1: TGLStringGrid;
    GLScrollbar1: TGLScrollbar;
    GLCheckBox1: TGLCheckBox;
    GLCheckBox2: TGLCheckBox;
    GLCheckBox3: TGLCheckBox;
    GLAdvancedLabel1: TGLAdvancedLabel;
    FPSTimer: TTimer;
    GLButton2: TGLButton;
    GLButton3: TGLButton;
    GLCube1: TGLCube;
    GLPopupMenu2: TGLPopupMenu;
    GLCustomControl2: TGLCustomControl;
    OLNY_A_DUMMY: TGLDummyCube;
    GLPanel2: TGLPanel;
    GLLabel2: TGLLabel;
    GLEdit2: TGLEdit;
    progressBar: TGLScrollbar;
    ProgressBarTimer: TTimer;
    GLFullScreenViewer1: TGLFullScreenViewer;
    GLWindowsBitmapFont2: TGLWindowsBitmapFont;
    GLLightSource1: TGLLightSource;
    procedure GLLabel1MouseUp(Sender: TObject; Button: TGLMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure GLBaseControl1MouseDown(Sender: TObject; Button: TGLMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure GLForm1MouseDown(Sender: TObject; Button: TGLMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure GLSceneViewer1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure GLSceneViewer1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
    procedure GLSceneViewer1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure GLCadencer1Progress(Sender: TObject; const DeltaTime, newTime: Double);
    procedure GLButton1MouseDown(Sender: TObject; Button: TGLMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure GLButton1MouseUp(Sender: TObject; Button: TGLMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure FormKeyUp(Sender: TObject; var Key: word; Shift: TShiftState);
    procedure GLEdit1MouseUp(Sender: TObject; Button: TGLMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure GLPopupMenu1AcceptMouseQuery(Sender: TGLBaseControl; Shift: TShiftState; Action: TGLMouseAction; Button: TGLMouseButton; X, Y: Integer; var accept: Boolean);
    procedure GLPopupMenu1Click(Sender: TGLPopupMenu; index: Integer; const MenuItemText: string);
    procedure FormCreate(Sender: TObject);
    procedure GLButton1MouseLeave(Sender: TObject);
    procedure FPSTimerTimer(Sender: TObject);
    procedure FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
    procedure GLPopupMenu2Click(Sender: TGLPopupMenu; index: Integer; const MenuItemText: string);
    procedure GLCustomControl2MouseDown(Sender: TObject; Button: TGLMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure ProgressBarTimerTimer(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure GLFullScreenViewer1Close(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }

  end;

var
  Form1:    TForm1;
  cur_time: Single;

var
  ComboBox: TStrangeComboBox;

implementation

{$R *.dfm}

procedure TForm1.GLLabel1MouseUp(Sender: TObject; Button: TGLMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  //showmessage('label mouse down');
end;

procedure TForm1.GLBaseControl1MouseDown(Sender: TObject; Button: TGLMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  //showmessage('base mouse down');
end;

procedure TForm1.GLForm1MouseDown(Sender: TObject; Button: TGLMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  //showmessage('form mouse down');
end;

procedure TForm1.GLSceneViewer1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  GLForm1.MouseDown(Sender, TGLMouseButton(Button), Shift, X, Y);
end;

procedure TForm1.GLSceneViewer1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
  GLForm1.MouseMove(Sender, Shift, X, Y);
end;

procedure TForm1.GLSceneViewer1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  GLForm1.Mouseup(Sender, TGLMouseButton(Button), Shift, X, Y);
end;

procedure TForm1.GLCadencer1Progress(Sender: TObject; const DeltaTime, newTime: Double);
begin
  GLForm1.DoChanges;

  cur_time := cur_time + DeltaTime;
  if (progressBar.PageSize < progressBar.Max) then
    progressBar.PageSize := progressBar.Max * cur_time / ProgressBarTimer.Interval * 1000 + 4;
end;

procedure TForm1.GLButton1MouseDown(Sender: TObject; Button: TGLMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  GLButton1.Caption := 'button_down';

end;

procedure TForm1.GLButton1MouseUp(Sender: TObject; Button: TGLMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  GLButton1.Caption := 'button_up';
  GLButton1.Pressed := False;
end;

procedure TForm1.FormKeyDown(Sender: TObject; var Key: word; Shift: TShiftState);
begin
  GLForm1.KeyDown(Sender, Key, Shift);
end;

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
  GLForm1.KeyPress(Sender, Key);
end;

procedure TForm1.FormKeyUp(Sender: TObject; var Key: word; Shift: TShiftState);
begin
  GLForm1.KeyUp(Sender, Key, Shift);
end;


procedure TForm1.GLEdit1MouseUp(Sender: TObject; Button: TGLMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if TGLMouseButton(mb_right) = Button then
    Exit;
  GLPopupMenu1.Visible := True;
  GLPopupMenu1.Position.X := x;
  GLPopupMenu1.Position.y := y;
end;

procedure TForm1.GLPopupMenu1AcceptMouseQuery(Sender: TGLBaseControl; Shift: TShiftState; Action: TGLMouseAction; Button: TGLMouseButton; X, Y: Integer; var accept: Boolean);
begin
  if not Accept then
    Exit;
  //Beep;
end;

procedure TForm1.GLPopupMenu1Click(Sender: TGLPopupMenu; index: Integer; const MenuItemText: string);
begin
  glform1.Caption := IntToStr(index) + ' - ' + MenuItemText;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  GLMaterialLibrary1.Materials[0].Material.Texture.Image.loadFromFile('DefaultSkin.jpg');
  GLCustomControl1.Material.Texture.Image.LoadFromFile('DefaultSkin.jpg');

  GLStringGrid1.Row[0].Add('sdsab');
  GLStringGrid1.Row[0].Add('789456123');
  GLStringGrid1.Row[1].Add('r2cvx3');
  GLStringGrid1.Row[1].Add('3124123');
  GLStringGrid1.Row[2].Add('sd1xcv');
  GLStringGrid1.Row[2].Add('57858');
  GLStringGrid1.Row[3].Add('row 271');
  GLStringGrid1.Row[3].Add('563756');

  GLStringGrid1.Row[4].Add('sdsad2');
  GLStringGrid1.Row[4].Add('95453');
  GLStringGrid1.Row[5].Add('row322');
  GLStringGrid1.Row[5].Add('987');
  GLStringGrid1.Row[6].Add('sdd2');
  GLStringGrid1.Row[6].Add('53556');
  GLStringGrid1.Row[7].Add('rokll2');
  GLStringGrid1.Row[7].Add('535656');
  GLStringGrid1.Row[8].Add('row 8');
  GLStringGrid1.Row[9].Add('row 9');


  GLStringGrid1.Row[0][1] := 'replaced';

  progressBar.Locked := True;

  //GLStringGrid1.Scale(0.3);
  //GLFullScreenViewer1.Active:=True;
  //GLSceneViewer1.Visible:=false;

  ComboBox := TStrangeComboBox.Create(GLForm1);
  GLForm1.Insert(0, ComboBox);
  ComboBox.Top := 35;
  ComboBox.Width := 100;
  ComboBox.Height := 20;
  ComboBox.Left := 250;
  ComboBox.GuiLayoutName := 'edit';
  ComboBox.GuiLayoutNameMenu := 'checkbox_unchecked';
  ComboBox.GuiLayoutNameButton := 'panel';
  ComboBox.GuiLayout := GLGuiLayout1;
  ComboBox.BitmapFont := GLWindowsBitmapFont1;
  ComboBox.DefaultColor := clMaroon;
  ComboBox.Items.Add('1111111');
  ComboBox.Items.Add('3333333');
  ComboBox.Caption := 'click...';
  ComboBox.Bitmap.LoadFromFile('oo.bmp');
end;

procedure TForm1.GLButton1MouseLeave(Sender: TObject);
begin
  GLButton1.Pressed := False;
  GLButton1.Caption := 'button_up';
end;

procedure TForm1.FPSTimerTimer(Sender: TObject);
begin
  Caption := 'StrangeGUI Demo  by Da Stranger  -  ' + GLSceneViewer1.FramesPerSecondText;
  GLSceneViewer1.ResetPerformanceMonitor;
end;

procedure TForm1.FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
begin
  if WheelDelta > 0 then
    GLScrollbar1.StepUp
  else
    GLScrollbar1.StepDown;
end;

procedure TForm1.GLPopupMenu2Click(Sender: TGLPopupMenu; index: Integer; const MenuItemText: string);
begin
  GLLabel2.Caption := MenuItemText;
  GLEdit2.Caption := MenuItemText;
end;

procedure TForm1.GLCustomControl2MouseDown(Sender: TObject; Button: TGLMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  GLPopupMenu2.Visible := True;
end;

procedure TForm1.ProgressBarTimerTimer(Sender: TObject);
begin
  cur_time := 0;
  progressBar.PageSize := 0;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  ComboBox.Free;// it can be freed direcly or when GLScene1 self-destructs ;)
end;

procedure TForm1.GLFullScreenViewer1Close(Sender: TObject; var Action: TCloseAction);
begin
  Close;
end;

end.




See more files for this project here

Sector-37

Sector-37 (real time 3D cosmic strategy)

Project homepage: http://sourceforge.net/projects/sector37
Programming language(s): Pascal
License: lgpl21

  Default.layout
  DefaultSkin.JPG
  Slider Backgr.JPG
  Slider itself.JPG
  StrangeGUIDemo.dpr
  StrangeGUIDemo.res
  Unit1.dfm
  Unit1.pas
  _Cleanup.bat
  oo.bmp