Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation since 03/26/2019 in all areas

  1. 7 points
    jarto

    TW3StringGrid is available

    A new update is available in the development-channel of SmartUpdate. It contains a completely new Grid: TW3StringGrid. It's a completely new design, which was made to be very fast and able to handle lots of data. This is achieved through dynamic drawing: Only the visible grid lines are rendered. There is a new StringGrid-demo in the Featured Demos. It downloads a json file and populates the grid with data from it. TW3StringGrid supports six different column types: Text (column class TW3StringGridTextColumn) Numeric (column class TW3StringGridNumericColumn) EditBox (column class TW3StringGridEditColumn) ComboBox (column class TW3StringGridComboColumn) Checkmark (column class TW3StringGridCheckmarkColumn) Button (column class TW3StringGridButtonColumn) Columns are created by calling: MyNewColumn:=Grid.AddColumn(ColumnClass); If no ColumnClass is given, a Text column is created. Column properties: Caption Width BorderType Default is btLightBorderRight. Set to btNone if you don't want any vertical borders. Backgroundtype Default is btNone to let the line color through. AlignText (The same way as in TW3Label) taLeft (default) taCenter taRight SelectOptions (for TW3StringGridComboColumn only) This is an array of selectable values. First value (index 0) is the value for no selection. For example: SelectOptions:=['','First','Second','Third']; RowBorderType: Default is btLightBorderBottom. Set to btNone if you don't want any horizontal borders. RowBackgroundType: Default is bsListItemBackground. Set to bsDecorativeListItemBackground (or test other backgrounds) to change the background style for even rows. RowOddBorderType: Default is btLightBorderBottom. Set to btNone if you don't want any horizontal borders. Affects odd rows. RowOddBackgroundType: Default is bsListItemBackground. Set to bsDecorativeListItemBackground (or test other backgrounds) to change the background style for odd rows. Grid properties: RowCount: Set number of rows to show FixedColumns: How many columns should be fixed (aka not scrollable horizontally) LineHeight MultiSelect Events: OnCellClick: Is triggered when the row is clicked. OnCellChanged: Is triggered when cell content changes through editing (for example: through editing) OnDrawGridLineTheme: 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) Methods: InvalidateGrid: Triggers a repaint of the grid. Sort Sorting TW3StringGrid supports sorting based on one of multiple columns. Clicking on the column headers sets or reverses sort order. You can also control sorting in code: procedure AddSortColumn(Index: Integer; SortOrder: TW3SortOrder = soNormal); overload; procedure AddSortColumn(Col: TW3StringGridColumn; SortOrder: TW3SortOrder = soNormal); overload; procedure SetSortColumn(Index: Integer; SortOrder: TW3SortOrder = soNormal); overload; procedure SetSortColumn(Col: TW3StringGridColumn; SortOrder: TW3SortOrder = soNormal); overload; procedure ToggleSortColumn(Index: Integer); For example: Grid.SortOptions.AddSortColumn(3,soReverse); //Set primary sort column Grid.SortOptions.AddSortColumn(1); //Add secondary sort columns Grid.Sort; Working with sorted data When the Grid is sorted, it only affects how data is shown. Sorting does not change Grid data itself at all. When you work with a sorted grid events and indexes (for example SelectedIndex) always refer to the index in the grid data itself and NOT the visible line number. TW3StringGrid uses these events: TW3StringGridColumnEvent = procedure(const Sender: TW3StringGridColumn; const Row: Integer); TW3StringGridEvent = procedure(const Sender: TObject; const Row, Col: Integer); If you have a Grid where "Australia" is on line 2, SelectedIndex:=2 selects that row regardless of how the grid is sorted. Clicking on that row or changing data on that row also returns Row=2 regardless of how the grid is sorted.
  2. 4 points
    lynkfs

    JQWidget integration

    and here is the Grid - JQWidgets implementation working sms demo here Notes : there are 2 different formats of defining the grid, one using jQuery explicitly and one as a web-component. The latter format has a bug somewhere and comes up consistently with a runtime error. The former format works fine. the 'export to Excel' button actually fires up Excel if installed and run locally (sms demo is grid only but take my word)
  3. 4 points
    lynkfs

    JQWidget integration

    I got asked to have a look at how to integrate jqxWidgets in SMS There are a heap of ready-made widgets under the name of jQuery UI Widgets, ranging from grids to calendars to tooltips and many more. The example here is a jqxButton with an image in the left top corner. The vanilla html file for this looks like <!DOCTYPE html> <html lang="en"> <head> <meta name="keywords" content="jQuery Button, CheckBox, Toggle Button, Repeat Button, Radio Button, Link Button, Button" /> <meta name="description" content="The jqxButton widget allows you to display a button on the Web page." /> <title id='Description'>The jqxButton widget allows you to display a button on the Web page.</title> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1 minimum-scale=1" /> <script type="text/javascript" src="https://www.jqwidgets.com/jquery-widgets-demo/scripts/jquery-1.11.1.min.js"></script> <script type="text/javascript" src="https://www.jqwidgets.com/jquery-widgets-demo/jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="https://www.jqwidgets.com/jquery-widgets-demo/jqwidgets/jqxbuttons.js"></script> <script type="text/javascript"> $(document).ready(function () { // Create jqxButton widgets. $("#jqxButton").jqxButton({ width: 120, height: 40 }); // Subscribe to Click events. $("#jqxButton").on('click', function () { $("#events").find('span').remove(); $("#events").append('<span>Button Clicked</span'); }); }); </script> </head> <body class='default'> <div> <input type="button" value="Button" id='jqxButton' /> </div> <div style='font-size: 12px; font-family: Verdana; margin-top: 10px;'> <div>Events:</div> <div id='events'> </div> </div> </body> </html> which requires a number of external js and css files. These can be local or reside on a cdn server somewhere. Make sure they are served from either http or https, same as the platform the app is executed on. The widgets are created first, immediately after the document is dom-ready, and they will be rendered on a placeholder element with the same element.id as the created widgets. This can be simplified considerably in SMS : All functions can be recoded using this function tied to the ubiquitous jQuery "$" directive : function jqxQuery(aTagObj: string): Variant; external '$'; which results in this code : var props : variant := new JObject; props.height := 40; props.width := 120; props.imgSrc := "https://www.jqwidgets.com/jquery-widgets-demo/images/twitter.png"; props.imgPosition := "topLeft"; jqxQuery( "#jqxButton1" ).jqxButton(props); jqxQuery( "#jqxButton1" ).on('click', procedure() begin browserapi.window.alert('clicked button1'); end); and the placeholder element jqxButton1 := TW3Panel.Create(self); jqxButton1.SetBounds(30,20,126,46); jqxButton1.handle.style.border := '1px solid grey'; jqxButton1.handle.innerHTML := '<input type="button" value="Button" id="jqxButton1" />'; Sort of a rough and tumble approach, but it does work. A better way is to encapsulate these widgets in a dedicated component : unit jqxButton; { **************************************************************************** } { } { Smart Mobile Studio } { } { **************************************************************************** } interface {$I 'Smart.inc'} uses System.Types, {$IFDEF THEME_AUTOSTYLE} SmartCL.Theme, {$ENDIF} SmartCL.System, SmartCL.Components; type TJQXButton = class(TW3CustomControl) protected function MakeElementTagObj: THandle; override; procedure InitializeObject; override; published property caption: string; // read GetCaption write SetCaption; end; function jqxQuery(aTagObj: string): Variant; external '$'; implementation //############################################################################# // TJQXButton //############################################################################# procedure TJQXButton.InitializeObject; begin inherited; Caption := 'Button'; //default Handle.ReadyExecute( procedure () begin var Script := browserapi.document.createElement('script'); Script.src := 'https://www.jqwidgets.com/jquery-widgets-demo/jqwidgets/jqxcore.js'; browserapi.document.head.appendChild(Script); Script.onload := procedure begin writeln('jqxcore loaded'); var props : variant := new JObject; props.height := self.height-2; props.width := self.width-2; props.imgSrc := "https://www.jqwidgets.com/jquery-widgets-demo/images/twitter.png"; props.imgPosition := "topLeft"; jqxQuery( "#jqx" + self.handle.id ).jqxButton(props); end; handle.innerHTML := '<input type="button" value="' + Caption + '" id="jqx' + self.handle.id + '" />'; end); end; function TJQXButton.MakeElementTagObj: THandle; begin result := w3_createHtmlElement('div'); end; end. which can be instantiated as simple as jqxButton2 := TJQXButton.Create(self); jqxButton2.SetBounds(230,20,130,50); jqxButton2.Caption := 'Button2'; jqxButton2.OnClick := procedure(Sender:TObject) begin browserapi.window.alert('clicked button2'); end; Project demo here and source code here
  4. 3 points
    jarto

    Development updates

    A new update is available. This one contains a completely new Grid: TW3StringGrid. It's a completely new design, which was made to be very fast and able to handle lots of data. This is achieved through dynamic drawing: Only the visible grid lines are rendered. There is a new StringGrid-demo in the Featured Demos. It downloads a json file and populates the grid with data from it. RTL: New control: TW3StringGrid New featured demo for the StringGrid. New TW3CustomScrollControl, for developing scroll controls with scrollbars/indicators-support. New border types: btLightBorderTop, -Bottom, -Left, -Right, -Horiz and -Vert EventManager: Check TouchPreventDefault before trying to prevent extra artificial mouse events from touch events Improvements to TW3BlockBox and Modal dialogs: TW3BlockBox did not trigger a resize Dialogs did not get resized when window was resized or device flipped Make sure the dialogs are not too big
  5. 2 points
    lynkfs

    css styling

    Browsers are certainly talented as multi-language processors. They have to understand html, css, javascript, svg and lately web-assembly as a fifth language. XML and Json are format specifiers, but could be borderline categorised as languages as well. Smart elevates javascript to great heights, but sort of leaves the other ones at the periphery. Especially css. Css can be used for a) component styling including colours, fonts etc, b) visual layout of pages/forms and reacting responsively to screen size and orientation and c) interactivity in various forms. Some of this overlaps with the js domain. Smart basically uses css for a) but not for b) or c). Looking at various css frameworks out there, I would categorise these as on one end of the scale there are many UI kit frameworks where the emphasis is on components - buttons, accordions, cards etc. Sometimes as css stand-alone files, sometimes in conjunction with js. Most of these also have functionality for layout purposes, usually based on flexbox or internal grid structures. on the other end of the scale there are frameworks which forego the component focus, but instead provide a large number of elementary styling functions, which can be applied to any component. and many which occupy a space in between This post is about the open source Tailwind framework, belonging in the second category above, just to see how that would work in the Smart environment. Tailwind comes in 2 flavours : a static framework which can be accessed locally or from a cdn, and a more dynamic version. The latter can be tailored dynamically for any specific project and basically needs to be part of the build toolchain. To keep it simple I used the static version. Change the res/app.css reference to the tailwind css file (either just replace it or change the reference in the index.html file). Now any component can be made to use this styling. Because this is not more (or less) than a list of individual styling functions, the use boils down to defining what you want. Tell a story as in "give me a button with a green background, which turns to blue on hover, has rounded corners and white text and a shadow effect which makes it seem floating". In code : W3Button1.handle.className := "bg-green-500 hover:bg-blue-700 text-white rounded shadow-2xl"; The second button in the demo project (see below) has a different story (className sequence), which gives it a totally different look and feel. I kind of like this approach, it works very well with any component, thus also with the built in Smart components. It is a bit of a drag specifying these className sequences by hand, so it would be nice if this would be supported in the IDE. There are after all only a small number of categories of these elementary styling bits : backgrounds, typography, borders, spacing, sizing, svg, interactivity and effects. And a relatively limited list of functions per category (bg-green-500 means a green background, 500 is the fifth shade in the green colour scheme. So there will be a bg-green-600, a bg-blue-200 etc). Doable I think. Apart from these styling functions, Tailwind also has a number of layout functions. Smart has its own layout mechanism, however the Tailwind functions can be used as well. See the 'card' component in the demo. Demo and source
  6. 2 points
    jarto

    Development updates

    A new update is available. RTL: Improvements to TW3StringGrid: New column types: TW3StringGridNumericColumn TW3StringGridButtonColumn Added sorting New event: OnCellChanged TStringList and TObjectList: Add Sort() with CompareFunction. Fix CSS browser prefix for Firefox Themes: Use normal size and style text in buttons.
  7. 2 points
    jarto

    RoadMap 2019

    Well, I believe that open sourcing is not a silver bullet that will magically bring new resources to the project. If there are people who are interested in participating, I'll be more than happy to actually offer them contract work. Before I joined this project, SMS was in an eternal "coming soon" -stage. A new update was just around the corner but days turned into weeks and weeks to months and years. I didn't like that as a customer. So when I've been running this development, I've not wanted to make promises that I can't keep. Before this my family owned and ran a very succesfull software company that developed the best and most used School Administration software in Finland. We did constant development making new features. We used constant evolution. I've been doing that same thing with Smart Mobile Studio and we really have seen a lot of development and improvements. And we will see constant and good development in the future too. When it comes to a roadmap, I've noticed that I'm really bad at making one. A software project is a moving target. A lot of features are being worked on. In the end, it's not clear when a feature will be finished and delivered. That's because priorities do change and sometimes (for example the new Grid) technology throws us a hard challenge that takes a very long time to solve. At the moment our top priorities are: Improve documentation, tutorials, demos. Update internal browser to a newer version of Chromium. Upgrade compiler to use a newer version of DWScript. Improve IDE (Designer, Wizards) On top of that we keep a keen eye on the needs and requests of our users and add new features/components to the RTL based on that. @Czar Thanks for the tip about the events related bug in the IDE. I was able to reproduce it. There are restrictions on what the IDE can do at the moment. And some restrictions actually depend on what's the best way of developing for the browser. For example, it's a lot better to have fonts and font sizes in CSS instead of setting them in the Object Inspector. @IElite Let me know what you want to see regarding mobile devices.
  8. 2 points
    lynkfs

    css styling

    Wow, you guys are funny. The question I had was : what is the easiest way to style Smart components. Smart ships with a couple of standard stylesheets, or themes, so styling is a matter of selecting one of these. To change the styling of a specific component in a theme, just change the css specifications in the stylesheet, either manually or through code. A different topic altogether is to develop new themes. It is not a simple task to f.i. develop a Metro theme stylesheet which covers all of the current Smart visual components. That's why I had a look at externally available css frameworks, to see if any of those would help with developing themes, or even work within the Smart development environment and if they are useful to begin with. I focused on one particular framework : Tailwindcss One of the problems with themes is when it becomes necessary to deviate from it. Say a project has chosen the default theme (default.css), but for some legitimate reason somewhere in the project a standard component has to be styled differently. Example : colour a button green to amplify a positive choice and colour it red to amplify dangerous choices ("do you really want to download these files from an unknown source ?" and then display a green "No" button and a red "Yes" button). It's not that simple to make this actually happen. Lets say we change the styling of the green button (based on the standard button), and opt to do that in code : var Button2 : TW3Button := TW3Button.Create(self); Button2.SetBounds(20,120,150,40); Button2.Caption := 'No'; // Button2.handle.style.background := '#48bb78'; //Button2.Color := clTeal; Button2.handle.style.border := '1px solid #48bb78'; //Button2.Border.Color := clTeal; Button2.handle.style.borderRadius := '0px'; //Button2.borderradius := 0; Button2.handle.style.color := 'white'; // //simulate hover Button2.handle.onmouseover := procedure(event: variant) begin event.target.style.background := 'orange'; end; Button2.handle.onmouseout := procedure(event: variant) begin event.target.style.background := '#48bb78'; end; works sort of ok, but requires a bit of effort Alternatively we can change the stylesheet, so if we opt to do that for the red button then this requires var Button3 : TW3Button := TW3Button.Create(self); Button3.SetBounds(200,120,150,40); Button3.Caption := 'Yes'; // Button3.TagStyle.Clear; Button3.TagStyle.Add('TW3Button TW3ButtonRed'); var cssProperties := 'background-color: red;'; browserapi.document.styleSheets[0].insertRule(".TW3ButtonRed { " + cssProperties + " }", 0); /* .TW3ButtonRed { background-color: red; } */ cssProperties := 'background-color: orange;'; browserapi.document.styleSheets[0].insertRule(".TW3ButtonRed:hover { " + cssProperties + " }", 0); either in code or adding the .TW3ButtonRed and the .TW3ButtonRed:hover manually to the stylesheet Again, works but requires some effort Using the Tailwind css framework, the above would be simplified to //green var Button4 : TW3Button := TW3Button.Create(self); Button4.SetBounds(20,220,150,40); Button4.Caption := 'No'; Button4.handle.className := "bg-green-500 hover:bg-blue-700 px-6 text-white rounded shadow-xl"; //red var Button5 : TW3Button := TW3Button.Create(self); Button5.SetBounds(200,220,150,40); Button5.Caption := 'Yes'; Button5.TagStyle.Clear; Button5.TagStyle.Add("bg-red-500 hover:bg-blue-700 px-6 text-white rounded shadow-xl"); Button1 : standard styling Button2 : changing standard styling in code Button3 : changing standard styling using css Button4/5 : using Tailwind I've probably confused everyone even more now Anyway, these are my thoughts : Tailwind has the advantage that it can style any of the standard Smart components. As such it could be used to make up a f.i. Metro theme. Still a significant task, but doable. Apart from that, I actually quite like Tailwind to style components on a need-to-do basis, their styling functions make the standard SMS buttons, panels, editboxes, memos etc look really good and modern. (A card btw is just a panel with a certain layout, where usually multiple of these panels appear on a form or page.)
  9. 2 points
    jarto

    Font size and style in buttons

    I'd like to open up a little discussion about font sizes. Specifically, the font size in buttons, which to my eyes looks too big and bulky compared to all other text: Suggestion 1: Decrease font size: Suggestion 2: Decrease font size, remove bold and text shadow, black text: Which one do you guys like most?
  10. 2 points
    warleyalex

    vendor prefix

    The CSS browser prefixes that you can use are: Android: -webkit- Chrome: -webkit- Firefox: -moz- Internet Explorer: -ms- iOS: -webkit- Opera: -o- Safari: -webkit- Please, fix the smartCL.System --> unitFCSSToken := 'Moz'; ---> I think should be lowecase w3_setStyle(FParticles.Handle, BrowserAPI.PrefixDef('transform'), 'scale(0.5,0.5)'); w3_setStyle(FParticles.Handle, BrowserAPI.PrefixDef('transform-origin'), 'left top');
  11. 2 points
    jarto

    TW3StringGrid is available

    Sure, I can add a Button column type too. Also OnCellChanged will be added in the next update. I've also been working on sorting. As the data is dynamically drawn, it's actually surprisingly easy to add. The trickiest is just to decide how the sorting interface should be done (properties etc.) so that I don't unnecessarily restrict future features. For example, in many Delphi grids there are quite detailed possibilities to control sorting.
  12. 2 points
    lynkfs

    visual processing

    See previous post : any type of no-code / lo-code solution requires a visual ide, not only for the visual components like buttons etc but also for the non-visual process components. Such an ide allows for both visual and non-visual components to be connected according to the principles of FBP. See previous post and link here. To see how this would pan out, I made this proof of concept no-code / lo-code web-based ide. (Proof of concept not being a full fledged finished product, but at least gives some insights) To diminish the strain on the brain a bit, the layout is based on the Smart ide, including the shameless reuse of its icons. Some highlights : - drag and drop placement of components rather than point and select - the usual component move and resize facilities but now including Delphi-type align options - drag and drop fbp connections between components using jsPlumb A quick rundown : 1) drag a button on the design pane 2) select 'Database' from the top tab-control, and drag both a grid and mySQL component on the design pane. Note the property pane is updated in realtime 3) (optionally click-select any dragged component to resize them. Select both grid and button, right-click on either for alignment options) 4) switch to the No-code tab and connect the button to the mySQL component, and the mySQL component to the grid 5) right-click the mySQL component and provide details (user-id, server, passwords etc). Not shown 6) switch to the Preview tab and click the button This project compiles to 63 KB (0.06 M. Not bad Project code here
  13. 2 points
    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.
  14. 1 point
    jarto

    TW3StringGrid is available

    I just updated the first post here with new events, column classes and sort documentation.
  15. 1 point
    DavidRM

    RTL Search

    I would find a built-in search of the RTL quite handy. Sorta like the "Find in Files...", where it brings up a list of hits, but searching the current SMS RTL folders and files instead. Could even just be a checkbox option in "Find in Files..." This would be a step in the direction of "better documentation". 😃 Or, at least, easier to review what's already available. Currently, I do this using Notepad++, but that doesn't let me open the results in the SMS IDE. Being in the IDE would provide access to "Find Declaration" and similar features. -David
  16. 1 point
    lynkfs

    css styling

    I think sometimes I'm very bad at explaining things. I'll respond over the weekend
  17. 1 point
    Czar

    RoadMap 2019

    I too would love to see a roadmap plan for the next 12 months. The efforts have been going into special projects that not many people will probably have a use for and the bread-and-butter has been left at a usable but not great state. For example, the IDE could do with love. The fact that the visual components don't surface basics like font size/colour etc and requires work arounds and non-intuitive knowledge suggests low hanging fruit for improvements. The ide has lots of bugs and irritating issues. for example events on buttons will often be reoved or doubled up. e.g., OnSubmitClick for button can be set once but if double click on it again often it breaks. Would the team consider open sourcing the IDE? Or maybe looking at a completly different model. I am invested in using SMS but I did so in the hope of meaningful improvements. Jarto I believe you are only active owner and I really appreciate your efforts but you are one person and this project could be so much more with greater input from more people.
  18. 1 point
    jarto

    Font size and style in buttons

    When Lennart had his latest competition, I suggested also adding a category for Themes. I'd love to for example have a theme that looks like Windows Metro.
  19. 1 point
    jarto

    layout, wordwrap and label nightmare

    Controls currently have no information about how they are resized or moved. They don't know that the layout is controlling it. It is possible to add a flag for that if it is beneficial. However, in this case I believe that it's easiest to just change how Autosize works: AutoSize True Resize width based on content. Resizing happens before WordWrap. Resize height based on content. AutoSize False Width comes from the control itself. Layout sets it in this example we've been handling. If WordWrap True, content is split into lines. If height is too small, it's increased.
  20. 1 point
    lynkfs

    Font size and style in buttons

    it is a difficult job to develop themes. If you have an example of a theme you prefer, I might have a look (depending on the bounty) Cheers
  21. 1 point
    Czar

    Font size and style in buttons

    It would be awesome if we had a few more CSS options/themes available. I find it difficult to come up with a consistent style that varies from the ones provided. Maybe we could create a bounty to encourage someone to develop some themes?
  22. 1 point
    jarto

    layout, wordwrap and label nightmare

    I was travelling, so didn't get to have a look right away. Gonna take a good look at this today.
  23. 1 point
    jarto

    layout, wordwrap and label nightmare

    @Czar if you can update the zip file, I'll certainly take a look. If there are issues with TW3Label, I'll certainly want to fix them as SimpleLabel is an inferior control.
  24. 1 point
    warleyalex

    layout, wordwrap and label nightmare

    We simply cannot open your project at labelissue.zip, missing "Form1.sfm"! It's an old married, TW3Label does not like the TW3Layout. Anyway, I think the unfinished widget SimpleLabel (TW3SimpleLabel => SmartCL.Controls.SimpleLabel.pas) works "almost" as expected. projTeste.zip
  25. 1 point
    jarto

    restrict width of page?

    Yes, because left is changed to 0 when the form is shown.
×