Jump to content

All Activity

This stream auto-updates     

  1. Yesterday
  2. IgorSavkic

    Request for feedback: Changing class names in the RTL

    I also do not see much of point in W3 prefix, perhaps idea was to distinguish it from Delphi classes. Anyway if works I would add simple mapping from old to new directly in affected units without doing anything to IDE. Something like TW3Button = TButton or class(TButton)
  3. jarto

    Development updates

    New update available in the development-channel: Themes: New background for highlighting errors: bsErrorBackground TW3StringGrid: New event for setting custom row borders and backgrounds: OnDrawGridLineTheme
  4. jarto

    TW3StringGrid is available

    A new event was added: OnDrawGridLineTheme This event can be used to set custom backgrounds and borders for a row. For example, set background to bsErrorBackground for lines that should be highlighted to the user. Example: procedure TForm1.W3StringGrid1DrawGridLineTheme(const Sender: TObject; const Row: Integer; var BackgroundTheme: TW3ThemeBackground; var BorderTheme: TW3ThemeBorder); begin if Row=3 then BackgroundTheme := bsErrorBackground; end; Notice, that the Row is the data row. So it corresponds to the line in your data and NOT the physical line, as the physical line depends on how the grid is sorted. The update is available in the development-channel.
  5. jarto

    TW3StringGrid is available

    I'll have a look at this.
  6. sibar

    TW3StringGrid is available

    @IElite Yes, but I want the background to be different depending on data. Ie. normally all rows are white, but on error conditions the rows should be red.
  7. jarto

    UI layout

    The development-channel contains a new update that adds Align and Anchor-support in the RTL. We still have some work to do to get the Visual Designer and Object Inspector to support these properly. While we work on that, you can still use these by setting anchors in code. Align can actually be set in the Object Inspector, but do note that setting the alignment does not make any visual changes in the Visual Designer. I'm going to be travelling for a bit more than a week.. During that time I'll be able to participate in this forum but can't make any changes or bug fixes. If you happen to find situations when Anchors and Align does not work properly, please post examples. I'll be happy to have a look when I return from my trip.
  8. jarto

    Development updates

    New update available in the development-channel: Anchors and Align-support to the RTL. Bug fix to BoundsRect Please note that anchors can only be set in code at the moment. The next step is to add support for setting the anchors and align in the IDE's designer as well. Currently Align actually can be set in the Object Inspector, but the designer does not show the result by aligning components.
  9. I don't see much of an advantage to be honest. If the ide is changed to allow both versions, then that negates any code problems of course. There is however also documentation (Primoz book) and search to consider. Personally I don't use TButton etc (as that was your question).
  10. Last week
  11. DavidRM

    Request for feedback: Changing class names in the RTL

    This. ^^^^^ That said, I vote for the change. -David
  12. IElite

    TW3StringGrid is available

    @sibar You can use the built-in theme background from SmartCL.Theme.pas example: W3StringGrid1.RowBackgroundType:= bsDisplayBackground; W3StringGrid1.RowOddBackgroundType:= bsDisplayBackground; here are you choices/options TW3ThemeBackground = ( bsNone = 0, bsDisplayBackground, bsControlBackground, bsContainerBackground, bsListBackground, bsListItemBackground, bsDecorativeListItemBackground, bsListItemSelectedBackground, bsEditBackground, bsButtonBackground, bsDialogButtonBackground, bsDecorativeBackground, bsDecorativeInvertBackground, bsDecorativeDarkBackground, bsToolContainerBackground, bsToolButtonBackground, bsToolControlBackground, bsTransparentBackground ); you can do the same with the columns procedure TForm1.InitializeObject; var C: TW3StringGridColumn; begin inherited; {$I 'Form1:impl'} fSG:= TW3StringGrid.Create(self); C:= fSG.AddColumn; C.Caption:= 'One'; C.Width:= 100; c.BackgroundType := bsDecorativeDarkBackground; end;
  13. sibar

    TW3StringGrid is available

    Is there an easy way to have custom row (or column) color/background?
  14. I can lean either way. I am not against keeping "W3" nor would I be against getting rid of it.
  15. If it was possible to not break existing code then I would not be against it. I don't convert much delphi code so I don't see it as important from that point of view. It might make it more delphi friendly perhaps, making transition easier for people. I think what catches out more delphi users is that expected properties of components aren't there, something as simple as changing the form colour is not obvious. The paradigm shift is quite steep if you aren't used to working with CSS and HTML etc (which I am not) so it takes a little bit of adjustment.
  16. As you all know, almost all classes in Smart Mobile Studio are named TW3Something. For example: TW3Button, TW3Panel etc. The decision to do that was done during the first stages of development of Smart Mobile Studio. However, there's no technical reason why the "W3" has to be there. So basically, we could rename all the components and classes to be more compatible with Delphi and making code sharing and porting easier. I wrote a program yesterday evening that analyzed and renamed all the classes and records that start with TW3 in the RTL. There are 849 of them to be precise. The app also renamed themes and the IDE code, so that I was able to compile a new IDE and make my first app with TForm and TButton etc. It all worked nicely, except that the chart component is causing a bit of trouble. It's using TPanel and a couple of other classes that would cause conflicts. I'd be able to add remapping functions to the IDE so that you could load an old project and all the TW3Whatever-classes would be converted to TWhatever. But if you have your own components using names like TPanel, TButton, TList, TStringList, they would cause trouble. Question is: Do you have them and how much of code like this do you have? Any thoughts?
  17. Czar

    UI layout

    Being able to make more complex UI that works on all devices will make life much much easier Looking forward to finished product.
  18. DavidRM

    UI layout

    Now add some TW3Labels to your layout demo and experience Real Pain. 😉
  19. jarto

    UI layout

    ' Working on this now. Align in the RTL is at pretty good shape already.
  20. Earlier
  21. lynkfs

    css styling

    Thanks There are however a couple of minor / major (?) caveats doing it like this : I made up some more metro components, and it becomes apparent that it is unavoidable to use more modifier classes: TagStyle.Add('primary image-button outline icon-left rounded etc). this type of styling is not supported by the visual designer in the ide, so styling can be done in code only. Even though only one-liners (TagStayle.Add( ) (most rtl components (but not all) have a component, a border and a background theme class baked in. Not all of these can be reused, so sometimes the border and/or background classes may end up being empty) probably the second bullet (visual designer) is the most important one for future enhancements
  22. Czar

    Development updates

    I like the lighter default theme for buttons. Thanks for the update.
  23. DavidRM

    Node.JS WebSocket Client Socket

    This is me sharing again. The NodeJS WebSocket server socket is implemented in SMS. But I didn't find an implementation of the WebSocket client socket. Sometimes an SMS NodeJS server needs to connect to another server. So I kinda hacked this together using the server socket as a guide. unit UPBNCommonNJWebSocket; interface uses System.Types, System.Types.Convert, System.Time, System.Streams, System.Reader, System.Writer, System.Device.Storage, System.Objects, SmartNJ.System, SmartNJ.Streams, SmartNJ.Device.Storage, SmartNJ.Application, NodeJS.Core, NodeJS.WebSocket, SmartNJ.Server.WebSocket; type // Forward declarations TNJWebSocket = class; TNJWebSocketOpenEvent = procedure (Sender: TNJWebSocket); TNJWebSocketCloseEvent = procedure (Sender: TNJWebSocket; Code: integer; const Reason: string); TNJWebSocketErrorEvent = procedure (Sender: TNJWebSocket; Error: TJSErrorObject); TNJWebSocketMessageEvent = procedure (Sender: TNJWebSocket; Message: TNJWebsocketMessage); TNJWebSocket = class(TW3ErrorObject) private FSocket: JWsSocket; public property WSSocket: JWsSocket read FSocket; function SocketState: JWsReadyState; function Connected: boolean; function URL: string; function Protocol: string; procedure Connect(URL: string; Protocols: array of string); overload; procedure Connect(URL: string); overload; procedure Disconnect; overload; procedure Send(const Data: variant); overload; procedure Send(const Text: string); overload; procedure Send(const Data: TStream); overload; property TagData: variant; constructor Create; override; destructor Destroy; override; procedure Ping; published property OnOpen: TNJWebSocketOpenEvent; property OnClosed: TNJWebSocketCloseEvent; property OnMessage: TNJWebSocketMessageEvent; property OnError: TNJWebSocketErrorEvent; end; implementation constructor TNJWebSocket.Create; begin inherited Create; // We dont want to throw exceptions whenever SetLastError() is called ErrorOptions.ThrowExceptions := false; end; destructor TNJWebSocket.Destroy; begin FSocket := nil; inherited; end; procedure TNJWebSocket.Ping; begin if FSocket <> nil then asm (@FSocket).ping(function() {}); end; end; function TNJWebSocket.Protocol: string; begin if FSocket <> nil then Result := FSocket.protocol; end; function TNJWebSocket.URL:String; begin if FSocket <> nil then Result:=FSocket.url; end; function TNJWebSocket.SocketState: JWsReadyState; begin if FSocket <> nil then Result := JWsReadyState( integer( FSocket.readyState) ) else Result := rsClosed; end; function TNJWebSocket.Connected: boolean; begin Result := SocketState = rsOpen; end; procedure TNJWebSocket.Connect(URL: string); begin Connect(Url, []); end; procedure TNJWebSocket.Connect(URL: string; Protocols: Array of string); begin ClearLastError(); (* disconnect socket if already connected *) if connected then disconnect(); (* Allocate new socket *) var WebSocket = WebSocketAPI; asm (@self.FSocket) = new (@WebSocket)(@URL, @Protocols); end; // initialize standard socket events FSocket.on("open", procedure begin if assigned(OnOpen) then OnOpen(self); end); FSocket.on("error", procedure (error: variant) begin SetLastError("internal websocket error"); if assigned(OnError) then OnError(self, TJSErrorObject(error)); end); FSocket.on("message", procedure (message: variant) var ResData: TNJWebsocketMessage; begin if message.IsUint8Array then begin ResData.wiType := mtBinary; ResData.wiBuffer := JBuffer(message); end else begin ResData.wiType := mtText; ResData.wiText := message; end; if assigned(OnMessage) then OnMessage(self, ResData); end); Variant(FSocket).on("close", procedure (code: integer; reason: string) begin if assigned(OnClosed) then OnClosed(self, code, reason); end); end; procedure TNJWebSocket.Disconnect; begin ClearLastError(); if Connected then begin try FSocket.close(); finally FSocket := nil; end; end; end; procedure TNJWebSocket.Send(const Data: variant); begin FSocket.send(data); end; procedure TNJWebSocket.Send(const Text: string); begin FSocket.send(Text); end; procedure TNJWebSocket.Send(const Data: TStream); begin if Data <> nil then begin if Data.position < Data.Size then begin // Get bytes from stream var Bytes := Data.Read(Data.Size - Data.Position); // Convert to typed-array var TypedArray := TDataType.BytesToTypedArray(bytes); // Send as binary FSocket.Send(TypedArray); end; end; end; end. It might be a bit simplified, and it doesn't really follow the SMS component name convention, but it does what I need. And I figured I would share. -David
  24. jarto

    css styling

    @lynkfs I like it a lot!
  25. IElite

    RoadMap 2019

    @jarto Myself, I am more interested in examples of client/server related projects (e.g. writing SMS clients for mobile devices which talk to node.js server).
  26. jarto

    Sorting arrays and lists

    This is a tutorial for sorting arrays and lists in Smart Mobile Studio. String arrays and TStringList are pretty easy to sort. You only need to call Sort: var strarr: array of String; ... strarr.Sort; var strlist: TStringList; strlist:=TStringList.Create; ... strlist.Sort; But how do you sort arrays of records or arrays of classes? For example: TSortData = record Id: Integer; Data: String; end; You can't simply call Sort as your application does not know how you want to sort the records. You solve this by using a comparison function: function CompareSortData(Item1, Item2: TSortData): Integer; begin result:=CompareStr(Item1.Data, Item2.Data); end; . . . var objarr: array of TSortData; ... objarr.Sort(@CompareSortData); The comparison function should return a negative number if Item1 is smaller, positive number if Item1 is bigger and 0 if they are equal. In Smart Mobile Studio you can also use anonymous methods: var objarr: array of TSortData; ... objarr.Sort( function(Item1, Item2: TSortData): Integer begin result:=CompareStr(Item1.Data,Item2.Data); end); Comparison functions can also be used for TList and even for TStringList. For example, you may want to have greater control over how names are sorted (eliminating prefixes like von): function EliminatePrefix(Name: String): String; const Prefixes: array[0..1] of String = ['von ','af ']; begin result:=Name; for var a:=0 to High(Prefixes) do begin if pos(Prefixes[a],result)=1 then begin Delete(result,1,Length(Prefixes[a])); exit; end; end; end; . . . var StrList:=TStringList.Create; StrList.Add('Perry'); StrList.Add('Miller'); StrList.Add('von Essen'); StrList.Add('Stockton'); StrList.Add('af Trolle'); StrList.Sort( function(Name1,Name2: String): Integer begin result:=CompareStr(EliminatePrefix(Name1),EliminatePrefix(Name2)); end); for var a:=0 to StrList.Count-1 do WriteLn(StrList[a]);
  1. Load more activity
×