Jump to content

jarto

Administrators
  • Content count

    299
  • Joined

  • Last visited

  • Days Won

    22

jarto last won the day on September 10

jarto had the most liked content!

About jarto

  • Rank

  • Birthday 02/11/1970

Profile Information

  • Gender
    Male
  • Location
    Dubai

Business

  • Company name
    Karkkimala Consulting Oy
  • Sector
    Information technology

Smart Mobile Studio

  • Edition
    Enterprise

Recent Profile Visitors

309 profile views
  1. jarto

    Size of Components at Runtime

    This could be made a bit simpler by also making ClientWidth and ClientHeight writable.
  2. jarto

    Size of Components at Runtime

    @DavidRM var Btn1:=TW3Button.Create(ParentPanel); Btn1.Caption:='Ok'; var Btn2:=TW3Button.Create(ParentPanel); Btn2.Caption:='Cancel'; //Create label but don't give it a size var Lab2:=TW3Label.Create(ParentPanel); Lab2.MoveTo(0,0); Lab2.AutoSize:=True; //OnResize will be triggered when we set the label text. Lab2.OnResize:=procedure(Sender: TObject) begin //Resize based on label size and add 40 px for button row var PHeight:=Lab2.Height+40+ParentPanel.Height-ParentPanel.ClientHeight; var PWidth:=Lab2.Width+ParentPanel.Width-ParentPanel.ClientWidth; ParentPanel.SetSize(PWidth,PHeight); //Resize the buttons var BtnWidth:=ParentPanel.ClientWidth div 2; Btn1.SetBounds(0,Lab2.Height,BtnWidth,40); Btn2.SetBounds(BtnWidth,Lab2.Height,BtnWidth,40); end; Lab2.Caption:='A quick brown fox jumped over the lazy dog!'; So, basically we let the label autosize itself and react to it in OnResize. Label's Width and Height returns how much space it takes. When we resize the panel, Width-ClientWidth (and Height-ClientHeight) returns how much space the padding, margin and border takes.
  3. jarto

    Size of Components at Runtime

    @DavidRM Your code seems to have a lot of calculations about padding. Smart Mobile Studio uses positionmode pmSmart as default, which means that the RTL takes care of margins and paddings. I made a post about it here: https://forums.smartmobilestudio.com/topic/4423-smart-299-alpha-is-here/?do=findComment&comment=22250 Edit: Also added a new page to documentation about this: https://smartmobilestudio.com/documentation/getting-started/smart-mobile-studio-box-model-positionmode-margin-border-padding-etc/ I'll be happy to help if you have any questions.
  4. jarto

    tw3slider mouseup

    Yeah, true, as that component internally uses OnMouseDown, OnMouseMove and OnMouseUp. Edit: Fix will be in the next update.
  5. jarto

    a basic JSON question

    Yes. There are many ways you can do that. Here's a quick function that splits the string into a StrArray: function SplitJson(JsonStr: String): TStrArray; var i,Start,QCount: Integer; InQ: Boolean; begin Start:=1; for i:=1 to Length(JsonStr) do begin var ch:=JsonStr[i]; case ch of '"': begin if not InQ then InQ:=True else if JsonStr[i-1]<>'\' then InQ:=False; end; '{': begin if not InQ then inc(QCount); end; '}': begin if not InQ then dec(QCount); if QCount=0 then begin result.Add(copy(JsonStr,Start,i-Start+1)); Start:=i+1; end; end; end; end; if i>0 then result.Add(copy(JsonStr,Start,i-Start+1)); end;
  6. jarto

    a basic JSON question

    @Czar If you blindly concatenate json objects into string, you can't parse them back unless you make sure to separate the json objects from the string. So you need to have some way of knowing how long each json object is in the string and call json.parse on the substrings.
  7. jarto

    memo lines ?

    Ok, lets elaborate. This is pretty universal regardless of programming languages. Suppose I just add: property Lines: TStrArray read GetLines; ...and GetLines does take the current text and splits it into an array. Then you have code like this: for var i:=0 to Memo.Lines.Count-1 do WriteLn(Memo.Lines[i]); When the code is run, every time Memo.Lines is accessed, it results in a call to GetLines. So, if you have 1000 lines, the code above would result in 1001 calls to GetLines and 1001 splits of the whole text to an array. This is what my message meant. What @lynkfswrote is about a more advanced solution where the memo would store the contents as both text (as it does now) and a separate Lines-array. That would eliminate the performance problem, but it'd introduce other problems like: More memory usage as data is stored internally twice. All the challenges to make sure that both the text and the array match, no matter how the memo contents are changed. I haven't tested if @lynkfs solution works and what it requires.
  8. jarto

    memo lines ?

    Well, introducing Lines as a property is not hard if we do it by splitting the memo text. However, when you'd loop through it, it'd be horribly inefficient as every access to Lines (count or accessing any line), would trigger the split from original text.
  9. jarto

    memo lines ?

    He must have just written it without testing. 😀
  10. jarto

    memo lines ?

    Memo's text is just text. It's not internally stored as lines. So, to be able to access it by line, we need to specifically add that feature.
  11. jarto

    Save tw3image to desktop?

    I'm travelling for five days, so I can't help you now. Can @lennarthelp?
  12. Sorry, no. I can see the stack traces, but I can't solve the mystery with them. So I'd really appreciate it if I could get a zip of the project.
  13. jarto

    Paint box

    TW3Image.ToDataUrl returns a string containing the image as base64 encoded png. Will this help? If you need it as a stream, how about: var SS:=TStringStream.Create; SS.WriteString(img.ToDataUrl); SS.Position:=0;
  14. jarto

    Paint box

    @lennart Please have a look at this as you know streams best.
  15. Hmm, can't reproduce this. Can you send me a zip of your project to jt at smartmobilestudio.com?
×