Jump to content

Cooch

Members
  • Content Count

    0
  • Joined

  • Last visited

Reputation Activity

  1. Thanks
    Cooch reacted to IElite in Google Maps API   
    Thank You! I needed this for an app I was currently working on
    However, for me, I needed to place the API code in its own unit...
    unit GoogleMaps; interface uses    System.Types,   System.Types.Convert,   SmartCL.System,   SmartCL.Components,   SmartCL.Require,   System.JSON,   W3C.HTML5,   W3C.DOM; type   JMap = partial Class external;   JLatLngLiteral = record     Property lat : Double;     Property lng : Double;   end;   JMapOptions = record     property Zoom : Integer;     property Center : JLatLngLiteral;   end;   JMarkerOptions = record     property position : JLatLngLiteral;     property map : JMap;     property title : String;   end;   JMarker = partial class external 'google.maps.Marker'   Public     Constructor Create(options:JMarkerOptions); external 'Marker';   end;      JMap = partial class external 'google.maps.Map'     public     Constructor Create(mapDiv:JElement; options : JMapOptions); external 'Map';     end;   procedure InitMap(AAPIKey, ATitle: String; ALat, ALong: Double; AControl: TW3CustomControl); var  Map : JMap; implementation procedure InitMap(AAPIKey, ATitle: String; ALat, ALong: Double; AControl: TW3CustomControl); var   LUluru : JLatLngLiteral;   LMapOptions : JMapOptions;   LMarkerOptions : JMarkerOptions;   LMarker : JMarker;   LMapElement : JElement; begin  Require(['https://maps.googleapis.com/maps/api/js?key=' + AAPIKey],procedure()   begin   LUluru.lat := ALat;   LUluru.lng := ALong;   LMapOptions.Zoom := 10;   LMapOptions.Center := LUluru;   LMapElement := Document.getElementById(AControl.Handle.id);   Map := JMap.Create(LMapElement,LMapOptions);   LMarkerOptions.position := LUluru;   LMarkerOptions.map := Map;   LMarkerOptions.title := ATitle;   LMarker := JMarker.Create(LMarkerOptions);   end); end; end.  
    Then I could call it on any form and Control I want 
    unit Form1; interface uses   System.Types,   SmartCL.Application,   SmartCL.System,   SmartCL.Forms,   SmartCL.Controls.Elements;  type   TForm1 = class(TW3Form)   private     {$I 'Form1:intf'}     MapDIV : TW3DIVHtmlElement;   protected     procedure InitializeForm; override;     procedure InitializeObject; override;     procedure Resize; override;   end; implementation uses GoogleMaps; { TForm1 } procedure TForm1.InitializeForm; begin   inherited; end; procedure TForm1.InitializeObject; begin   inherited;   {$I 'Form1:impl'}   MapDIV := TW3DIVHtmlElement.Create(Self); end; procedure TForm1.Resize; begin   inherited;   MapDiv.SetBounds(0,0,ClientWidth,ClientHeight);   InitMap('My API Key Here!', 'Mt Marcy', 44.112917, -73.923,  MapDIV); end; initialization   Forms.RegisterForm({$I %FILE%}, TForm1); end.  
  2. Thanks
    Cooch reacted to IElite in Google Maps API   
    the google map, defaults to the roadmap view, so I added the MapTypeId to the code i posted above
    just add the following to the interface section
    const   HYBRID = 'hybrid';   ROADMAP = 'roadmap';   SATELLITE = 'satellite';   TERRAIN = 'terrain';   JMapOptions = record     property Zoom : Integer;     property Center : JLatLngLiteral;     property mapTypeId: String;   end; change the following procedure to include the MapType param
    procedure InitMap(AAPIKey, ATitle: String;  AMapType: String; ALat, ALong: Double; AControl: TW3CustomControl); and then in the implementation section, modify the require to include the mapTypeId option 
    Require(['https://maps.googleapis.com/maps/api/js?key=' + AAPIKey],procedure()   begin   ...   LMapOptions.mapTypeId:= AMapType;   ...   end);  
    In my case, i needed my map to default to the TERRAIN view
    so, i used the TERRAIN const
    InitMap('myApiKey', Mountain, TERRAIN, Latitude, Longitude,  FMap); e.g.

     
  3. Thanks
    Cooch reacted to IElite in Wizards   
    @Jared, Try this......  a mixture of eveyones ideas and code  
    unit Unit1; interface uses   Pseudo.CreateForms, // auto-generated unit that creates forms during startup   System.Colors, System.Types, SmartCL.System, SmartCL.Components, SmartCL.Forms,   SmartCL.Application, SmartCL.Layout, SmartCL.Controls.Label, SmartCL.Controls.Panel, SmartCL.Controls.Button; const  MAXFORMCOUNT = 4; type   TApplication  = class(TW3CustomApplication)    private     fCurrent: integer;     fLayout: TLayout;     fHeader: TW3Label;     fBody: TW3Panel;     fNext: TW3Button;     fPrev: TW3Button;     procedure handleResize(sender: TObject);     procedure handlePrevClick(sender: TObject);     procedure handleNextClick(sender: TObject);   public     procedure ApplicationStarting; override;   end; implementation uses Form1, Form2, Form3, Form4; procedure TApplication.handlePrevClick(sender: TObject); begin if fCurrent <> 1 then begin dec(fCurrent); fHeader.Caption:= 'Form ' + intToStr(fCurrent); Application.GotoForm('Form' + intToStr(fCurrent)); end; end; procedure TApplication.handleNextClick(sender: TObject); begin  if fCurrent <> MAXFORMCOUNT then  begin   inc(fCurrent);   fHeader.Caption:= 'Form ' + intToStr(fCurrent);   Application.GotoForm('Form' + intToStr(fCurrent));  end; end; procedure TApplication.handleResize(sender: Tobject); begin   fLayout:= Layout.Client(                           [                            Layout.Top(Layout.Height(50), fHeader),                            Layout.Bottom(Layout.Height(32), Layout.Left(Layout.Stretch, [fPrev, fNext])),                            Layout.Client(fBody)                           ]                           );    if Assigned(fLayout) then    begin     fLayout.Resize(display);    end; end; procedure TApplication.ApplicationStarting; var   mForm: TW3CustomForm; begin   display.OnResize:= handleResize;   FHeader:=TW3Label.create(display);   fHeader.Color:= clWhite;   fHeader.AlignText:= taCenter;   fHeader.Caption:= 'Form 1';   FHeader.Height:= 50;   fBody:= TW3Panel.Create(display);   fPrev:= TW3Button.Create(display);   fPrev.Caption:= 'Prev';   fPrev.OnClick:= HandlePrevClick;   fNext:= TW3Button.Create(display);   fNext.Caption:= 'Next';   fNext.OnClick:= HandleNextClick;   mForm := TForm1.Create(fBody);   mForm.name := 'Form1';   RegisterFormInstance(mForm, True);   mForm := TForm2.Create(fBody);   mForm.name := 'Form2';   RegisterFormInstance(mForm, False);   mForm := TForm3.Create(fBody);   mForm.name := 'Form3';   RegisterFormInstance(mForm, True);   mForm := TForm4.Create(fBody);   mForm.name := 'Form4';   RegisterFormInstance(mForm, False);   fCurrent:= 1; end; end.  
    If you dont want to use Layout, just use SetBounds on each control to lay them out explicitly
     
  4. Like
    Cooch reacted to IElite in When is the next contest?   
    A repost from Facebook - dated January 9
     
    "Mid february it's time for a Smart competition again! This time the winner recieves the Asus Tinkerboard which is an absolute power-house of a SBC (single board computer). We ourselves use this board for running Smart Mobile Studio via EXAGEAR (x86 emulation for ARM devices), and also as a node.js and Android deployment device.
    Like our sister group, Delphi Developer, we are printing a special edition white "retro case" for this fantastic little machine (fresh off the mint, they were done printing yesterday at 25 hours each).
    The lucky winner recieves the following (pre assembled ofcourse):
    1 x "Special Edition" White Retro Case
    1 x Asus Tinkerboard
    1 x 32 Gb Samsung class 10 SD card
    1 x Fan to ensure reliable operational temperature
    1 x Red light diode power indicator
    1 x Smart ready Ubuntu installation
    (*) Samba is setup and registers on the network as "SmartDevice". PM2 which is the node.js clustering software used to run large Smart Mobile Studio cloud services is also "ready to go". Sftp is likewise there, so you can upload your compiled code as part of your build process (Smart has project options for this).
    More information about the competition will be released in due time (at least a month from now), but if you have been waiting for a nice competition - now is the chance to create, port or implement something amazing ?
    Looking forward to the submissions. We are lucky to have so many fine developers using Smart!"
     
  5. Like
    Cooch reacted to IElite in When is the next contest?   
    ????
    Haven't heard anymore about this and it looks like the post was deleted from FB
     
  6. Like
    Cooch reacted to IElite in FYI - TLayout - Beginner   
    FYI - TLayout - Beginner - How to place multiple controls on the form in Left Bar & Right Bar positions

    unit Form1; interface uses    SmartCL.System, SmartCL.Graphics, SmartCL.Components, SmartCL.Forms,    SmartCL.Fonts, SmartCL.Borders, SmartCL.Application, SmartCL.Layout,   SmartCL.Controls.Panel; type   TForm1 = class(TW3Form)   private     {$I 'Form1:intf'}     fLayout: TLayout;     fLeftBar: TW3Panel;     fRightBar: TW3Panel;   protected     procedure InitializeForm; override;     procedure InitializeObject; override;     procedure Resize; override;   end; implementation { TForm1 } procedure TForm1.InitializeForm; begin   inherited;   // this is a good place to initialize components end; procedure TForm1.InitializeObject; begin   inherited;   {$I 'Form1:impl'}   fLeftBar:= TW3Panel.create(self);   fRightBar:= TW3Panel.create(self);   fLayout:= Layout.Client(Layout.Margins(10),                           [Layout.Left(Layout.Width(100), fLeftBar),                           Layout.Right(Layout.Width(100), fRightBar)]                           ); end;   procedure TForm1.Resize; begin   inherited;   if Assigned(fLayout) then   begin    fLayout.Resize(self);   end; end;   initialization   Forms.RegisterForm({$I %FILE%}, TForm1); end.  
  7. Like
    Cooch reacted to IElite in FYI - TLayout - Beginner   
    FYI - TLayout - Beginner - HTML Layout

    Code on GitHub
  8. Like
    Cooch reacted to IElite in FYI - TLayout - Beginner   
    You can also use the devices dimensions to calculate your control's size. e.g. below, I create the layout height based on 1/4 the size of the ClientHeight
    procedure TForm1.Resize; begin   inherited;   if Handle <> nil then    fLayout:= Layout.Bottom(Layout.Height(ClientHeight Div 4).Margins(10), fPanel);   if Assigned(fLayout) then   begin    fLayout.Resize(self);   end; end;  
  9. Thanks
    Cooch reacted to IElite in FYI - TLayout - Beginner   
    FYI - TLayout - Beginner - Multiple Layouts

    Code on GitHub
  10. Like
    Cooch reacted to IElite in FYI - TLayout - Beginner   
    FYI - TLayout - Beginner - Layouts on Multiple Forms
    Note:  Be sure to set the Layout object = nil when the form deactivates

     
     Code on GitHub
  11. Like
    Cooch reacted to IElite in FYI - TLayout - Beginner   
    FYI - TLayout - Beginner - How to place multiple controls on the form in Header , Footer,  Body  positions

    unit Form1; interface uses    SmartCL.System, SmartCL.Graphics, SmartCL.Components, SmartCL.Forms,    SmartCL.Fonts, SmartCL.Borders, SmartCL.Application, SmartCL.Layout,   SmartCL.Controls.Panel; type   TForm1 = class(TW3Form)   private     {$I 'Form1:intf'}     fLayout: TLayout;     fHeader: TW3Panel;     fColumn: TW3Panel;     fFooter: TW3Panel;   protected     procedure InitializeForm; override;     procedure InitializeObject; override;     procedure Resize; override;   end; implementation { TForm1 } procedure TForm1.InitializeForm; begin   inherited;   // this is a good place to initialize components end; procedure TForm1.InitializeObject; begin   inherited;   {$I 'Form1:impl'}   fHeader:= TW3Panel.create(self);   fColumn:= TW3Panel.create(self);   fFooter:= TW3Panel.create(self);   fLayout:= Layout.Client(Layout.Margins(10).Spacing(10),                          [Layout.Top(Layout.Height(50), fHeader),                          Layout.Client(fColumn),                          Layout.Bottom(Layout.Height(50),fFooter)]                          ); end;   procedure TForm1.Resize; begin   inherited;   if Assigned(fLayout) then   begin    fLayout.Resize(self);   end; end;   initialization   Forms.RegisterForm({$I %FILE%}, TForm1); end.  
  12. Like
    Cooch reacted to IElite in FYI - TLayout - Beginner   
    FYI - TLayout - Beginner - How to place multiple controls on the form in Header , Footer,  Body,  RightBar  positions

    unit Form1; interface uses    SmartCL.System, SmartCL.Graphics, SmartCL.Components, SmartCL.Forms,    SmartCL.Fonts, SmartCL.Borders, SmartCL.Application, SmartCL.Layout,   SmartCL.Controls.Panel; type   TForm1 = class(TW3Form)   private     {$I 'Form1:intf'}     fLayout: TLayout;     fHeader: TW3Panel;     fRightBar: TW3Panel;     fBody: TW3Panel;     fFooter: TW3Panel;   protected     procedure InitializeForm; override;     procedure InitializeObject; override;     procedure Resize; override;   end; implementation { TForm1 } procedure TForm1.InitializeForm; begin   inherited;   // this is a good place to initialize components end; procedure TForm1.InitializeObject; begin   inherited;   {$I 'Form1:impl'}   fHeader:= TW3Panel.create(self);   fRightBar:= TW3Panel.create(self);   fBody:= TW3Panel.create(self);   fFooter:= TW3Panel.create(self);   fLayout:= Layout.Client(Layout.Margins(10).Spacing(10),                         [Layout.Top(Layout.Height(50), fHeader),                          Layout.Client(Layout.Spacing(10),[Layout.Client(fBody),Layout.Right(Layout.Width(75), fRightBar)]),                          Layout.Bottom(Layout.Height(50),fFooter)]   ); end;   procedure TForm1.Resize; begin   inherited;   if Assigned(fLayout) then   begin    fLayout.Resize(self);   end; end;   initialization   Forms.RegisterForm({$I %FILE%}, TForm1); end.  
  13. Thanks
    Cooch reacted to IElite in FYI - TLayout - Beginner   
    I will be posting a number of examples on how to use the TLayout object. I will be using tags (e.g. layout, tlayout, beginner) so that you can find them easily enough in the future. 
    Please be sure to read the Articles by @gabr42   http://smartmobilestudio.com/documentation/layout-manager
     
    FYI - TLayout - Beginner - How to center a control on the form

    Code on GitHub
     
×
×
  • Create New...