Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 23

Thread: How to Subclass an object?

  1. #11
    Lianja Support Team lianjasupport's Avatar
    Join Date
    Feb 2012
    Location
    Boston USA, Wokingham UK
    Posts
    1,259
    Can you briefly provide me with an idea of what it is you are wanting to achieve by Subclassing a canvas control. Is it appearance or what?

  2. #12
    My classing requirements are rarely to do with appearance. Nearly always functionality.

    I have a number of built in features with my combobox class (which itself is actually based on Ken Weber's 1999 version)

    For example, most of my combo popup lists include the options "/No Value", "\Add New" and "\Modify Item" which, respectively, allow users to clear a combolist value, Add new items to the option list and to modify existing items on that list.

    All the code for which is handled in the Valid method.

    I'm quite happy to paste in the relevant code into a Lianja combobox on a dummy form then copy that control wherever I want it in a "real" app.

    Would that work?

  3. #13
    Lianja Support Team lianjasupport's Avatar
    Join Date
    Feb 2012
    Location
    Boston USA, Wokingham UK
    Posts
    1,259
    No I don't think it will as i explained earlier there are a fixed set of UI controls which are customized by attributes and delegates.

    When v2 development is underway we will be looking at the ability to subclass components from a component library as I already mentioned.

    As it stands now you can do whatever you want in custom sections but canvas sections do not support Subclassing of custom components.

    You have to bear in mind that Lianja is not just for building desktop apps but for web and mobile also so we always look at the best way to implement functionality that makes sense across all clients.

  4. #14
    are you, therefore, also saying we can't "clone" pages and apps? That EVERY app has to be created from scratch? That doesn't make sense. In fact it's not even consistent with the tutorials where I'm sure we can go in and modify example apps, save them as our own and continue to modify...

    If we can do that I cannot understand what would stop me copying a control from one app to another. Please enlighten!

  5. #15
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Hi Harry,

    I know what you are talking about. And I can see misunderstanding. There is no such thing as we did in VFP. I will explain to others. We had foundation classes and for every Microsoft VFP "base" class we made our derived one with some specific attributes. This is subclassing in VFP slang, and this was example of implementation:

    Name:  _SP32-20150102-173025.jpg
Views: 238
Size:  27.5 KB

    Base class: TEXTBOX
    Class: PTEXTBOX
    ClassLibrary: D:\..........\PCNTRL.VCX

    When we instanced it for objects in form, they all got characteristics not from "base" class but from our new derived class. This way we can change characteristics of all textboxes...

    In Lianja subclassing is this (define class cls_listbox as ListBox):

    //--------------------------------------------------------------------------
    // Subclass a Listbox so that we can define the Click event procedure
    define class cls_listbox as ListBox
    proc click()
    ui_grid.clear
    // Note how the AddItems method of Grid, ListBox and Combobox can take
    // a SQL SELECT statement as an argument
    if trim(this.text) = "All"
    ui_grid.additems('select * from example where last_name != " "')
    else
    ui_grid.additems('select * from example where;
    upper(left(last_name,1)) = "' + trim(this.text) + '"')
    endif
    ui_grid.refresh()
    endproc
    enddefine
    ...
    //--------------------------------------------------------------------------
    // Step 6: Add a subclassed ListBox to the Container and set some of its properties
    ui_cont.addobject("ui_listbox", "cls_listbox")
    ui_listbox.fixedwidth = 200
    http://www.lianja.com/documentation/...-visual-FoxPro

    Lianja is device independent and we do not think in pixells because you do not know on what device will run your app. Like browsers, Lianja is based on CSS. This way the main reason we subclassed in VFP is now obsolete. That is why Lianja team is asking you what you want to achieve. Canvas example is missleading.

    In Lianja there are templates, where you can prepare your own sections with characteristic you want and use them everywhere for same look and feel.
    There are themes.
    I still need to add some of my own (eg Case
    You have addproperty()
    And can add your method:

    Due to the nature of dynamic scripting languages, you can assign procedures to property names and call them as methods.

    Code:
    proc myClickHandler 
    endproc
    myobject.click = myClickHandler
    Passing the name of a method as a character parameter and then using macro substitution achieves what you mention.
    Last edited by lianjasupport; 2015-01-02 at 11:03. Reason: Corrected example

  6. #16
    Lianja Support Team lianjasupport's Avatar
    Join Date
    Feb 2012
    Location
    Boston USA, Wokingham UK
    Posts
    1,259
    Yes you can copy apps and save pages and sections as templates.

    You will learn by asking questions politely and someone will respond at some stage.

    You should search the forums first and if no info exists or you are unsure ask.

    Thats what the forums are for. Open discussion which builds up a knowledgebase.

    So the way to get a response is to not shout but just ask. How do I...

    And you will be pointed at the doc or a video tutorial whatever is appropriate.

    ISVs have early access to releases during their development cycle.

  7. #17
    Josipradnik, thanks again.

    I grok the difference in approach, and the prospect of being able to write apps which will work on other devices is precisely why I'm interested in Lianja. I also fully understand that this will require a new paradigm. What I'm not getting is a feel for the boundaries, which, currently, seem rather arbitrary.

    Your explanation is helpful but it still seems to me that what you're describing would have to be done every time you wanted to create that modified listbox (or whatever).

    What I'm asking is

    a) whether, having done that modification once, you can copy and paste your modified listbox elsewhere (specifically to another app - elsewhere with the same app is assumed but not much use)

    b) if not, why not?

    Specifically, that's how we used to handle things before VFP came along with its own object model. In Foxpro for Dos, we could create elaborate controls or procs and copy them wherever we wanted. I'm suggesting that's the obvious compromise with Lianja until they get the subclassing up and running.

    If something within the Lianja environment makes that impossible it's not at all clear to me (yet) what that obstacle is. And if that obstacle exists and is as proscriptive as implied, I can't see how we could hope to do (or even model) any serious development within the Lianja environment (at least, not until V2 brings subclassing into play)

  8. #18
    Perhaps I am missing something.

    If I have a object that I want to reuse again, I add it to my library and subclass it in a custom section.

    I create it one time.


    Here is a simple example.

    1. Go to the Library, right click, class, select new.
    2. Define your class. In this case, I have defined a class called herbTextBox. It has a default text value of "default text"


    Name:  CreateCls.jpg
Views: 277
Size:  72.7 KB

    The I go to my app, add a custom VFP section (this is not a canvas section - no drop and drag).

    You will see a blank section. Click on the little keyboard Icon on the section (or the blank page with a pencil Icon on the top of the page - this is called the apps workspace).

    In the init() event of your section, set the classlib to your library.

    In this case, I have a blank page. So I add a container, change the background to lightblue and add my textbox from the class.

    Name:  UseCls.jpg
Views: 273
Size:  96.7 KB

    Click back on the empty page Icon at the top to go back to the app designer and you will see the sub-classed textbox has been used.


    Name:  resultCls.jpg
Views: 130
Size:  17.4 KB


    Herb

  9. #19
    aha. That looks very close to achieving what we need. I'll play with that and see if it's doing what we want. Thanks a lot.

  10. #20
    hmmm... got as far as creating the class. Took the opportunity to paste in code from my standard textbox class and edit it a bit. Saved it. Nothing appeared under "Class Files". Rightclicked Class Files again, chose new, entered the name I'd just used and the code reappeared. So it obviously has saved it, but I can't see it to work further through the example.

    (edit)
    I'm a liar. Just spotted it under "Script Files". Will try to use it from that position, but I'm guessing that's the wrong place. If so can anyone tell me what the right place is and how to put it there? Just tried dragging it to Class Files and that doesn't work. Physically copied it (outside Lianja) into the Class Files folder but that doesn't make it appear inside Lianja's file manager folder.
    Last edited by HarryStottle; 2015-01-03 at 12:01.

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us