Italian community of Lazarus and Free Pascal

Programmazione => Lazarus e il web => Topic aperto da: xinyiman - Agosto 27, 2012, 03:39:44 pm

Titolo: Raudus VS ExtPascal
Inserito da: xinyiman - Agosto 27, 2012, 03:39:44 pm
Ragazzi, un po' di tempo fa avevo scritto delle guide e delle video guide per usare extpascal. Ora vorrei portare alla vostra attenzione Raudus.

Sito: http://www.raudus.com/

E dalla versione 0.8.9 supporta anche Lazarus nativamente. Basta fare il download, installre il package per lazarus e il gioco è fatto. Unico neo è che ancora non ho trovato come fare le griglie per i db, ma sto aspettando risposta da loro per quello.

Come si installa con lazarus: http://raudus.wikispaces.com/Install+in+Lazarus

Ed ecco la pagina che ne parla: http://www.raudus.com/2012/08/24/raudus-0-9-0-released/

Spero davvero che sia supportato a lungo perchè è un ottimo strumento. Poi è corredato da ottimi esempi.

Che ne pensate?!
Titolo: Re:Raudus VS ExtPascal
Inserito da: nomorelogic - Agosto 27, 2012, 04:11:29 pm
penso che mi hai fregato di 5 minuti nel fare il post :D
a parte gli scherzi, non c'è il wysiwyg ma ha l'aria altamente interessante
Titolo: Re:Raudus VS ExtPascal
Inserito da: xinyiman - Agosto 27, 2012, 04:13:46 pm
Hahahahaha  ;)

Si è sicuramente uno strumento da tenere molto in considerazione. Appena saprò di più al riguardo delle griglie db vi terrò informati.  :)
Titolo: Re:Raudus VS ExtPascal
Inserito da: xinyiman - Agosto 27, 2012, 04:14:30 pm
Anche perchè mi sembra di aver capito che permette di sviluppare anche per android con dei particolari accorgimenti. Sarebbe una figata pazzesca!
Titolo: Re:Raudus VS ExtPascal
Inserito da: nomorelogic - Agosto 27, 2012, 04:45:12 pm
anche android?! approfondisco!

nel frattempo, per gli interessati ad android:
http://blogs.embarcadero.com/jtembarcadero/2012/08/20/xe3-and-beyond/
Titolo: Re:Raudus VS ExtPascal
Inserito da: xinyiman - Agosto 27, 2012, 05:15:26 pm
Ecco cosa mi ha risposto l'autore di raudus:

Non ci sono ancora le griglie. RaVCL è un insieme di controllo nuovo e ancora mancano dei controlli. Nella prossima versione 0.9.1 vorrei aggiungere il controllo TRaDBGrid. Ma ora è possibile utilizzare la ListBox come una griglia. Sostituire il codice seguente nella unit1.pas dell'esempio "FishFacts". E vedere il risultato:

Codice: [Seleziona]
                                             
unit Unit1;

{$DEFINE RAUDUS} // comment to look at DelphiVCL application instead of RaVCL

interface

uses
  Classes, SysUtils, Controls,
{$IFDEF RAUDUS}
  RaApplication, RaBase, RaControlsVCL,
{$ENDIF}
  Forms, StdCtrls, ExtCtrls, DBCtrls, DB, IBDatabase, IBCustomDataSet;

{$IFNDEF RAUDUS}
type // DelphiVCL fallback and similarity testing
  TRaVCLFormCompatible = class(TForm);
  TRaPanel = class(TPanel);
  TRaButton = class(TButton);
  TRaLabel = class(TLabel);
  TRaDBImage = class(TDBImage);
  TRaDBEdit = class(TDBEdit);
  TRaDBLookupListBox = class(TDBLookupListBox);
  TRaDBComboBox = class(TDBComboBox);
{$ENDIF}

type
  TForm1 = class(TRaVCLFormCompatible)
    RaDBLookupListBox1: TRaDBLookupListBox;
    RaDBImage1: TRaDBImage;
    RaPanel1: TRaPanel;
    RaButton1: TRaButton;
    RaButton2: TRaButton;
    RaButton3: TRaButton;
    RaButton4: TRaButton;
    IBDatabase1: TIBDatabase;
    IBTransaction1: TIBTransaction;
    IBDataSet1: TIBDataSet;
    IBDataSet1SPECIES_NO: TIntegerField;
    IBDataSet1CATEGORY: TIBStringField;
    IBDataSet1COMMON_NAME: TIBStringField;
    IBDataSet1SPECIES_NAME: TIBStringField;
    IBDataSet1LENGTH_CM: TIntegerField;
    IBDataSet1LENGTH_IN: TIntegerField;
    IBDataSet1NOTES: TBlobField;
    IBDataSet1GRAPHIC: TBlobField;
    DataSource1: TDataSource;
    procedure FormCreate(Sender: TObject);
    procedure IBDataSet1AfterScroll(DataSet: TDataSet);
    procedure IBDataSet1COMMON_NAMEGetText(Sender: TField;
      var Text: String; DisplayText: Boolean);
    procedure RaButton1Click(Sender: TObject);
    procedure RaButton2Click(Sender: TObject);
    procedure RaButton3Click(Sender: TObject);
    procedure RaButton4Click(Sender: TObject);
{$IFDEF RAUDUS}
  public
    RaApplicationEvents1: TRaApplicationEvents;
    procedure RaApplicationEvents1Boot(Sender: TObject);
  private
    ThemeApplied: Boolean;
    ScaleValue: Single;
    procedure CheckMobileDevice;
  public
    MobileDevice: Boolean;
    function CalculateScale(AForm: TCustomControl): Single;
    function CalculateScaleWithLimit(AForm: TCustomControl; AValue: Integer; ALimit: Integer): Single;
{$ENDIF}
  private
    CurrentFish: Integer;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

var
  VDatabaseName: String;

implementation

uses Unit2, Unit3;

{$R *.dfm}

{$IFDEF RAUDUS}
function CheckUserAgent(ASubString: String): Boolean;
begin
  Result := Pos(ASubString, RaApplication.Application.RemoteUserAgent) > 0;
end;

procedure TForm1.CheckMobileDevice;
begin
//  MobileDevice := True; Exit; // uncomment to target only mobile
  MobileDevice := (CheckUserAgent('iPhone')) or (CheckUserAgent('iPad')) or
    (CheckUserAgent('iPod')) or (CheckUserAgent('Android')) or
    (CheckUserAgent('Fennec') or (CheckUserAgent('Symbian') and CheckUserAgent('WebKit')));

end;

function TForm1.CalculateScale(AForm: TCustomControl): Single;
var
  FS: TFormatSettings;
  SPR: Single;
begin
  FS.DecimalSeparator := '.';
  SPR := StrToFloatDef(RaApplication.Application.ScreenPixelRatio, 1.0, FS);
  if (SPR > 1.95) then begin
    Result := SPR * 1.25;
  end else begin
    Result := SPR * 1.333;
  end;

end;

function TForm1.CalculateScaleWithLimit(AForm: TCustomControl; AValue: Integer; ALimit: Integer): Single;
begin
  Result := Self.CalculateScale(AForm);
  // limit scaling
  if ALimit < AValue * Result then begin
    Result := ALimit / AValue;
  end;

end;
{$ENDIF}

procedure TForm1.FormCreate(Sender: TObject);
begin
{$IFDEF RAUDUS}
  RaApplicationEvents1 := TRaApplicationEvents.Create(Self);
  with RaApplicationEvents1 do begin
    OnBoot := RaApplicationEvents1Boot;
    OnScreenResize := RaApplicationEvents1Boot;
  end;
{$ENDIF}

  IBDatabase1.DatabaseName := VDatabaseName;
  IBDatabase1.Open;
  IBDataSet1.Open;

end;

{$IFDEF RAUDUS}
procedure TForm1.RaApplicationEvents1Boot(Sender: TObject);
(*
var
  BestWidthOfListBox: Integer;
*)
begin
  if not ThemeApplied then begin
    ThemeApplied := True;
    CheckMobileDevice;
    if MobileDevice then begin
      // TODO Self.UI := '??';
      Self.BorderStyle := bsNone;
      Self.WindowState := wsMaximized;
      if RaApplication.Application.ScreenWidth >= 490 then begin
        ScaleValue := CalculateScale(Self);
      end else begin
        ScaleValue := CalculateScaleWithLimit(Self, 240, RaApplication.Application.ScreenWidth);
      end;
      if Self.Font.Size = 0 then Self.Font.Size := 8; // 0 is Lazarus default
      Self.ScaleBy(Trunc(ScaleValue * 100), 100);
      RaPanel1.Color := $00604030;
      RaDBLookupListBox1.BorderStyle := bsNone;
    end;
  end;

  RaDBImage1.Parent := Form3;
  RaDBLookupListBox1.Align := alClient;
(*
  if MobileDevice then begin
    BestWidthOfListBox := Trunc(180 * ScaleValue);
    // check if picture fits in right space
    if RaApplication.Application.ScreenWidth - BestWidthOfListBox < 250 then begin
      RaDBImage1.Parent := Form3;
      RaDBLookupListBox1.Align := alClient;
      RaButton2.Visible := True;
    end else begin
      RaDBImage1.Parent := Form1;
      if Form3.Visible then Form3.Close;
      RaDBLookupListBox1.Align := alLeft;
      RaDBLookupListBox1.Width := BestWidthOfListBox;
      RaButton2.Visible := False;
    end;
  end;
*)

end;
{$ENDIF}

procedure TForm1.IBDataSet1AfterScroll(DataSet: TDataSet);
begin
  CurrentFish := DataSet.RecNo;
  DataSet.Refresh;

end;

procedure TForm1.IBDataSet1COMMON_NAMEGetText(Sender: TField;
  var Text: String; DisplayText: Boolean);
begin
  if DisplayText then begin
    Text := '<div style="float:left;display:block;width:120px">' +
              // IfThen(IsCurrentFish, 'Common name:<br>') +
              Sender.AsString + '</div>' +
            '<div style="float:left;display:block;width:180px">' +
              // IfThen(IsCurrentFish, 'Species name:<br>') +
              Sender.DataSet.FieldByName('SPECIES_NAME').AsString + '</div>' +
            '<div style="float:left;display:block;width:100px">' +
              // IfThen(IsCurrentFish, 'Category:<br>') +
              Sender.DataSet.FieldByName('CATEGORY').AsString + '</div>' +
            '<div style="float:left;display:block">' +
              // IfThen(IsCurrentFish, 'Length:<br>') +
              Sender.DataSet.FieldByName('LENGTH_IN').AsString + ' inches' + '</div>' +
            '<div style="clear:both"></div>';
  end else begin
    Text := Sender.AsString;
  end;

end;

procedure TForm1.RaButton1Click(Sender: TObject);
begin
  Form2.{$IFDEF RAUDUS}ShowModalNonBlocking{$ELSE}ShowModal{$ENDIF};

end;

procedure TForm1.RaButton2Click(Sender: TObject);
begin
  Form3.{$IFDEF RAUDUS}ShowModalNonBlocking{$ELSE}ShowModal{$ENDIF};

end;

procedure TForm1.RaButton3Click(Sender: TObject);
begin
  IBDataSet1.Prior;

end;

procedure TForm1.RaButton4Click(Sender: TObject);
begin
  IBDataSet1.Next;

end;

end.