Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation since 06/20/2019 in all areas

  1. 6 points
    jarto

    Development updates

    New update is available in the development-channel: IDE: Anchors (and other sets) can be set in the Object Inspector Improvements to generated Form implementation code: Wait until created components are ready before setting properties and creating children Set Anchors last Prevent conflicting keyboard shortcuts from being saved Use better default project options (no manifests, do not embed Javascript) Add new units to units defaults and improve formatting RTL: Add xml-js to Libraries. New ECMA.Promise unit from api docs System.JSON: Support for adding/setting JSON arrays Add TJSONObject.Delete Set form size to 100% before calling InitializeObject Add missing units to SmartCL.Controls Setting control's angle did not work in Firefox Don't raise an exception while freeing a form which is not registered Themes: default styles were not applied for all elements in Android and iOS Fixes a bug where textarea's size is too big in TW3Memo Note, that while the anchors can be set in the Object Inspector, it does not result in visible changes in the Visual Designer.
  2. 3 points
    lynkfs

    file system

    This code works (File system in the browser) create and mount a FileSystem create a directory write a file with some contents read the stats of this file read the contents of this file write another file list the directory contents in a memo Demo procedure TForm1.InitializeForm; begin inherited; // this is a good place to initialize components var Script := browserapi.document.createElement('script'); Script.src := 'res/filer.js'; //https://raw.githubusercontent.com/filerjs/filer/develop/dist/filer.js browserapi.document.head.appendChild(Script); Script.onload := procedure begin writeln('filer loaded'); var Filer := browserapi.window.Filer; writeln('instance created'); var fs : variant := new JObject; asm @fs = new (@Filer).FileSystem({ name: "myfilesystem01", flags: [ 'FORMAT' ] }); end; writeln('filesystem created'); //mkdir fs.mkdir('/docs', procedure(err:boolean) begin if (err) then writeln('Unable to create /docs dir'); end); //write file fs.writeFile('/docs/firstDoc.txt', 'Hello World', procedure(err:boolean) begin if (err) then writeln('Unable to write /docs/firstDoc.txt'); end); //stats fs.stat('/docs/firstDoc.txt', procedure(err, stats:variant) begin if (err) then writeln ('Unable to stat /docs/first.txt') else writeln(stats); end); // Read file fs.readFile('/docs/firstDoc.txt', 'utf8', procedure (err:boolean; data:string ) begin if (err) then writeln ('Unable to read /docs/firstDoc.txt') else writeln(data); end); //write second file fs.writeFile('/docs/secondDoc.txt', 'Brave new world', procedure(err:boolean) begin if (err) then writeln('Unable to write /docs/secondDoc.txt'); end); //get reference to shell var sh : variant := new JObject; asm @sh = new (@fs).Shell(); end; // list directory, shallow listing sh.ls('/docs', procedure(err:boolean; entries: array of variant) begin if (err) then writeln ('Unable to read /docs directory') else begin W3Memo1.Text := '/docs' + #10; for var i := 0 to entries.length -1 do begin writeln(entries[i].name); W3Memo1.Text := W3Memo1.Text + ' ' + entries[i].name + #10; end; end; end); end; end; I like this a lot note : works from file or server, not in the ide
  3. 3 points
    "Prompt" is the command that you are after.
  4. 3 points
    lynkfs

    printing

    Edited. And then there is IPP : Internet Printing Protocol This protocol allows direct access to networked printers, ask for their capabilities, prepare print jobs, manage print queues, execute print jobs and get results. Exactly what I was after. I read through the documentation on the website of "The Printer Working Group", which looks after the standardisation of this protocol. (http://www.pwg.org/ipp/ippguide.html). To actually use this protocol, there are various IPP client libraries available (C, Java, Python). Fortunately there is a node.js variant as well (https://github.com/williamkapke/ipp). Both these links give some examples on how to use IPP in real world situations However the code examples on both sites contain many errors. Amazing. On the plus side, apparently some 98% of all networkable printers have an IPP driver installed by default, and should be adressable this way. To test this all out, I selected a printer on my network. The first thing to find out is the identification of the printer. IPP has its own protocol : ipp(s)://<printer uri> where the printer uri is the printers ip address followed by a path. Example : ipp://192.168.1.233/ipp/print Behind the scenes all traffic is actually routed over http(s), and printer uri's can also be specified as http over port 631. Example : http://192.168.1.233:631/ipp/print The ip address can usually be found in the OS printer settings somewhere and the path is mostly standardised to be just '/ipp/print' Not too bad. After installing the node.js ipp library (npm install ipp) the following node.js code queries the printers capabilities var ipp = require("ipp"); var printer = ipp.Printer("http://192.168.1.233:631/ipp/print"); var msg = { "operation-attributes-tag": { "requesting-user-name": "John Doe", "document-format": "image/pwg-raster", "requested-attributes": ["printer-description", "job-template", "media-col-database"] } }; printer.execute("Get-Printer-Attributes", msg, function(err, res) { console.log(err); console.log(res); }); This produces quite a list. To print a textfile to this printer, I got this code working var ipp = require("ipp"); var printer = ipp.Printer("http://192.168.1.233:631/ipp/print"); var fs = require("fs"); fs.readFile("example.txt", function(err, content) { if (err) throw err; var msg = { "operation-attributes-tag": { "requesting-user-name": "John Doe", "document-format": "application/octet-stream" }, data: content }; printer.execute("Print-Job", msg, function(err, res) { console.log(err); console.log(res); }); }); Edited : The javascript sources above can be produced by a regular smart project : create a new node project and replace unit1 with unit Unit1; interface uses nodeBasics; //https://forums.smartmobilestudio.com/topic/4652-node-ground-zero/?tab=comments#comment-23115 type TNodeProgram = class(TObject) public constructor Create; virtual; ipp, msg, printer : variant; procedure callback(err, res: variant); procedure Execute; end; implementation constructor TNodeProgram.Create; begin inherited Create; ipp := RequireModule('ipp'); printer := ipp.Printer("http://192.168.1.233:631/ipp/print"); msg := new JObject; asm @msg = { "operation-attributes-tag": { "requesting-user-name": "John Doe", "document-format": "image/pwg-raster", "requested-attributes": ["printer-description", "job-template", "media-col-database"] } }; end; end; procedure TNodeProgram.callback(err, res: variant); begin console.log(err); console.log(res); end; procedure TNodeProgram.Execute; begin printer.execute("Get-Printer-Attributes", msg, @callback); end; end. note : unfortunately we can't make up anonymous classes with hyphens in the classname, otherwise the msg variable could have been constructed as var msg = class operation-attributes-tag = class requesting-user-name = "John Doe", document-format = "image/pwg-raster", requested-attributes : array[0..2] of string = ["printer-description", "job-template", "media-col-database"]; end; end; Next step is to see if this can be made to work in the browser as well
  5. 2 points
    lynkfs

    file system

    The original html5 spec had a file api which allowed to read and write files clientside (the File Directories and System Api). This was only fully implemented by Chrome at one point, but even then Chrome needed to be started with a switch (-allow-file-access-from-files). Today clientside storage is limited to cookies, local/session storage, indexedDB and the Cache API. While I understand the reasons for limiting file handling on the client, it is sometimes annoying. Fortunately some pretty creative solutions have emerged. One of them is Filer. This is a nodejs fs filesystem look-a-like which uses indexedDB for storage, and runs in the browser. Basically it allows for a complete filesystem clientside. Not bad at all. To continue stacking : Filer is stacked on top of indexedDB. Stack nohost on top of Filer and you have a web fileserver (based on service workers) in the browser. Amazing. Will certainly try this out.
  6. 2 points
    jarto

    Getting user's input from input box

    A simple solution is Prompt, like @Daniel Eiszelewrote: var Answer:=Prompt('Question'); WriteLn(Answer); If you want a more beautiful solution, then you can make a form for the input and show it modally. That way you can control everything.
  7. 2 points
    lynkfs

    Favicon

    The standard generated index file in smart doesn't contain a link tag for a favicon (something like <link id="favicon" rel="icon" href="res/favicon.png" type="image/png" sizes="16x16"> However this can be added in code (or add it manually to the default.html file in the template directory, or add it to a Custom Template in the ide) In code : procedure TForm1.InitializeForm; begin inherited; // this is a good place to initialize components var link := w3_createHtmlElement('link'); link.id := 'favicon'; link.href := 'res/favicon.png'; link.rel := 'icon'; link.&type := 'image/png'; link.sizes := '16x16'; browserapi.document.getElementsByTagName('head')[0].appendChild(link); end; If you want to change the icon later on, you can do that too procedure TForm1.W3Button1Click(Sender: TObject); begin var favicon := browserapi.document.getElementById('favicon'); favicon.href := 'res/favicon2.png'; end;
  8. 2 points
    tristan

    TW3StringGrid is available

    For anyone needing something similar unit SmartCL.Controls.StringGrid.ImageColumn; interface uses W3C.DOM, System.Types, System.Types.Graphics, System.Types.Convert, System.Time, System.Dictionaries, SmartCL.Application, SmartCL.Components, SmartCL.System, SmartCL.Theme, SmartCL.Css.Classes, SmartCL.Scroll, SmartCL.Controls.Label, SmartCL.Controls.StringGrid, SmartCL.Controls.Image; type TW3StringGridImageColumn = class(TW3StringGridColumn) protected function GetClasses: String; override; public constructor Create; override; function GenerateHtml(GridLine: TW3RenderedGridLine; ColumnIndex, CurrentLeft: Integer): String; override; procedure SetColumnEvents(Sender: TW3CustomStringGrid; GridLine: TW3RenderedGridLine; ColumnIndex: Integer); override; end; implementation constructor TW3StringGridImageColumn.Create; begin FBaseClass := 'TW3Image'; AlignText := taCenter; VAlign := tvCenter; BorderType := btLightBorderRight; BackgroundType := bsNone; end; function TW3StringGridImageColumn.GenerateHtml(GridLine: TW3RenderedGridLine; ColumnIndex, CurrentLeft: Integer): String; begin var ItemId:=Grid.Handle.id+'_row_'+IntToStr(GridLine.DataIndex)+'_btncol_'+IntToStr(ColumnIndex); GridLine.ItemIds.Add(ItemId); result:='<img id="'+ItemId+'" class="'+GetClasses+'" style="visibility: visible; display: inline-block; overflow: hidden; left: '+IntToStr(CurrentLeft)+'px; position: absolute; width: '+IntToStr(Width)+'px; height: 100%;border-radius: 0px;" src="'+TString.EncodeTags(Grid.Cells[GridLine.DataIndex,ColumnIndex])+'"</img>'; end; function TW3StringGridImageColumn.GetClasses: String; begin result:=inherited GetClasses+' TW3ButtonBackground'; end; procedure TW3StringGridImageColumn.SetColumnEvents(Sender: TW3CustomStringGrid; GridLine: TW3RenderedGridLine; ColumnIndex: Integer); // Note: This is used by the combo box too var cHandle: THandle; begin try cHandle := GridLine.FixedCols.Handle.GetChildById(GridLine.ItemIds[ColumnIndex]); if not (cHandle) then cHandle := GridLine.ScrollableCols.Handle.GetChildById(GridLine.ItemIds[ColumnIndex]); // cHandle['oninput'] := @Sender.HandleDataChanged; except end; end; end.
  9. 2 points
    IElite

    TW3StringGrid is available

    @tristan You will need to create your own / derive your own column from TW3StringGridColumn located in the unit SmartCL.Controls.StringGrid. Take a look at the SmartCL.Controls.StringGrid unit and see how for example, the button column (TW3StringGridButtonColumn) is created TW3StringGridButtonColumn = class(TW3StringGridColumn) protected function GetClasses: String; override; public constructor Create; override; function GenerateHtml(GridLine: TW3RenderedGridLine; ColumnIndex, CurrentLeft: Integer): String; override; procedure SetColumnEvents(Sender: TW3CustomStringGrid; GridLine: TW3RenderedGridLine; ColumnIndex: Integer); override; end; { TW3StringGridButtonColumn } constructor TW3StringGridButtonColumn.Create; begin FBaseClass := 'TW3Button'; AlignText := taLeft; VAlign := tvCenter; BorderType := btLightBorderRight; BackgroundType := bsNone; end; function TW3StringGridButtonColumn.GenerateHtml(GridLine: TW3RenderedGridLine; ColumnIndex, CurrentLeft: Integer): String; begin var ItemId:=Grid.Handle.id+'_row_'+IntToStr(GridLine.DataIndex)+'_btncol_'+IntToStr(ColumnIndex); GridLine.ItemIds.Add(ItemId); result:='<input id="'+ItemId+'" type="button" class="'+GetClasses+'" style="visibility: visible; display: inline-block; overflow: hidden; left: '+IntToStr(CurrentLeft)+'px; position: absolute; width: '+IntToStr(Width)+'px; height: 100%;border-radius: 0px;" value="'+TString.EncodeTags(Grid.Cells[GridLine.DataIndex,ColumnIndex])+'"</input>'; end; function TW3StringGridButtonColumn.GetClasses: String; begin result:=inherited GetClasses+' TW3ButtonBackground'; end; procedure TW3StringGridButtonColumn.SetColumnEvents(Sender: TW3CustomStringGrid; GridLine: TW3RenderedGridLine; ColumnIndex: Integer); // Note: This is used by the combo box too var cHandle: THandle; begin try cHandle := GridLine.FixedCols.Handle.GetChildById(GridLine.ItemIds[ColumnIndex]); if not (cHandle) then cHandle := GridLine.ScrollableCols.Handle.GetChildById(GridLine.ItemIds[ColumnIndex]); cHandle['oninput'] := @Sender.HandleDataChanged; except end; end;
  10. 2 points
    Tim Koscielski

    Development updates

    Jarto, I think in the Update list, the date for this update readme lists 2018 and not 2019. You just might want to check. tim
  11. 2 points
    lynkfs

    printing

    Printers used to be dumb peripherals. Not so with the latest receipt printers (epson). They have actually an apache webserver built in, and the printer can act as the hub for displays, scanners and other (dumb) peripherals. amazing. Connecting them to Smart looks like not too difficult.
  12. 2 points
    lynkfs

    menu component

    Probably not the most inspiring topic, but just sharing a menu component I needed for some project. There are quite a few css based menu components around, but I wanted to have a pure smart one. This one has an unlimited number of submenus and is instantiated as a hamburger menu on a toolbar Hamburger := TCHMenu.Create(self); //nodes : id,parent,description,procedure Hamburger.Add('root','','Hamburger menu'); //root Hamburger.Add( 'projects','root','Projects'); Hamburger.Add( 'project0','projects','New project'); Hamburger.Add( 'project1','projects','Open project'); Hamburger.Add( 'project2','projects','Delete project'); Hamburger.Add( 'designers','root','Designer'); Hamburger.Add( 'designer0','designers','Domain info',clickproc); //<== execproc Hamburger.Add( 'designer1','designers','Data development'); ... Hamburger.Add( 'designer5','designers','Goal Metrics'); //some test cases below Hamburger.Add( 'test','project0','test3'); // test level 3 Hamburger.Add( 'designer5','designers','Goal Metrics'); //test on double entries Hamburger.Add( 'test0','root','test',procedure begin writeln('clickproc'); end); //test on no children Hamburger.Add( 'designer6','designers','extra test'); //test on out of order demo and project files on the .../Menu subdir
  13. 1 point
    DavidRM

    Bugs and Features 3.1.0.88

    I just saw it happen when I selected a block of lines from the bottom up (instead of top down). -David
  14. 1 point
    tristan

    Bugs and Features 3.1.0.88

    Hi, Thanks for all the effort in making Smart Mobile Studio a powerful tool for pascal web development. After having a license for over a year I am finally making some effort at building a real life application. I just want to provide some feedback; I did try a quick search in the forum to avoid duplication. I believe I am testing the latest development version; however I do find it difficult to know with any certainty. Versioning Release notes in SmartUpdate have incorrect date (I think). Can you make it easier to identify the version available? SmartUpdate fails with DEVELOPMENT not available unless re-run with /changechannel /showhidden parameters IDE Import existing form. I could not find an intuitive way to import a form created from another project. Copy form into new project folder, add external, not added to Form section Switch comment (CTRL + /) will not include the last line selected Controls TabControl AnimateTabs with Forms in tabs, will cause form contents to disappear (in particular memo and stringrids) (See TabForms demo with TMemo on form3) Turning off AnimateTabs will resolve the issue. TabForms.zip
  15. 1 point
    jarto

    Development updates

    New update available: IDE: Zip Entire Project did not include Form .sfm -files RTL: Bug fixes to TW3TabControl
  16. 1 point
    jarto

    Development updates

    The Development-channel in SmartUpdate contains all the latest changes in Smart Mobile Studio. It's a good channel to follow for those who want all the new features and bug fixes right away, instead of waiting for the next formal release. To follow the Development-channel: Make a new folder and add: SmartUpdate.exe Your own user.lic from your current Smart Mobile Studio folder. To get all the latest changes in the Development-channel: Run: SmartUpdate /changechannel /showhidden When asked for which channel to follow, choose Development The purpose of this topic is to inform about all the new features and fixes.
  17. 1 point
    DavidRM

    PixiJS v5

    How hard would it be to to get the PixiJS unit included with SMS updated to the latest release (v5)? Thanks! -David
  18. 1 point
    @Tim Koscielski Here's my best guess about what is going on: I assume you have added the Grid in the Designer. That means that the Grid control is created in Form.InitializeObject here: {$I 'Form_ProjectMasterListN:impl'} The compiler generates the code to create the grid and set its properties. After that you call InitGrid. Now, when a control is created in JavaScript, the browser initializes it asynchronously. This means that your code continues to run but it takes some time before the control is actually ready. It may be that on your computer it takes so long that the Grid's handle is not ready when you start accessing it. In the latest development update I changed the code that is created for that impl section. When earlier the control was just created and properties were set, now the generated code waits for the object to be ready. Only after that it starts setting properties. It eliminates random problems. To be sure that the Grid is ready, you can call InitGrid like this: TW3Dispatch.WaitFor([W3Grid1], procedure begin InitGrid; end); That's the same way the code generated by the IDE does it.
  19. 1 point
    so does this: procedure TForm1.InitGrid; var Col_ProjectId: TW3TextColumn; begin Col_ProjectId := TW3TextColumn.Create(W3Grid1 as IW3ColumnsControl); Col_ProjectId.Header.Caption := '#'; Col_ProjectId.Header.Alignment:= taCenter; Col_ProjectId.Alignment := taCenter; Col_ProjectId.Width:= 100; W3Grid1.Columns.Add(Col_ProjectId); end; procedure TForm1.InitializeObject; begin inherited; {$I 'Form1:impl'} InitGrid; end;
  20. 1 point
    This works for me just fine. Not sure where you are calling InitGrid from procedure TForm1.W3Button1Click(Sender: TObject); var Col_ProjectId: TW3TextColumn; begin Col_ProjectId := TW3TextColumn.Create(W3Grid1 as IW3ColumnsControl); Col_ProjectId.Header.Caption := '#'; Col_ProjectId.Header.Alignment:= taCenter; Col_ProjectId.Alignment := taCenter; Col_ProjectId.Width:= 100; W3Grid1.Columns.Add(Col_ProjectId); end;
  21. 1 point
    kockas

    TW3StringGrid is available

    Thank you Jarto! Finally I found what was the problem...... I worked with the master channel where the stringgrid absolute not available and the the normal grid was so promising ..... while I not found the Development channel... Now I feel good with the new components. The "new" stringgrid likeable!!
  22. 1 point
    Czar

    components lose name - little IDE bug

    Components on the visual form lose their name property if they are cut and paste. I use this quite often as I will use a panel to organise related editboxes, and labels. 1. drop a label on the visual forum and call it lbl1 2. now drop a panel on the form. 3. We will cut the label and paste it inside form. select the lbl + ctrl X. And then select the panel and ctrl + v to paste the label into the form. 4 . This works fine but the label is now call w3label1 It would be nice if the component retained the name property.
  23. 1 point
    jarto

    UI layout

  24. 1 point
    jarto

    UI layout

    Yes, we need anchors and aligns. Now that I'm about to get TW3StringGrid finished, I'll have a look at Anchors and Align.
  25. 0 points
    lynkfs

    reserved project name

    I accidentally gave a project a reserved name ('implementation'). Not a good idea: compiles then crashes
×