×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    39

    Is it possible to use $if conditional blocks in FragmentTemplates in Carbide.vs?

    Hi,

    I'm able to use $if()..endif() blocks in ProjectTemplates, but in FragmentTemplates nothing happens and nothing is replaced. The documentation about Carbide.vs templates is very poor. Can some nokia experts help me? How can I use $if() in code fragment templates?

    Thanks

  2. #2
    Super Contributor
    Join Date
    Sep 2004
    Posts
    1,048

    Re: Is it possible to use $if conditional blocks in FragmentTemplates in Carbide.vs?

    First of all, if you find the template documentation poor, have you checked the template design guide in C:\Nokia\Tools\Carbide_vs\doc (assuming you took the defaults at installation)? In my view, it gives quite detailed information about the use of the templates.

    Now for your actual question, I'm not quite sure what you are asking but..

    It seems you are asking for some conditional code replacement when the template is used and the project/fragment is created. Basically this was never something that was intended so if that somehow works, it's a nice accident. Evidently, if we never intended to support it, it will not be described in the docs. So IF this was what you asked for, then this is not supported (in any of the template types). But, on the other hand, if it indeed does work in this way under some circumstances could you share some more details in what you can do with it?

    The templates themselves have a conditional if-clause that is intended to be used only with the "file source" statement, see page 16 in the template design doc. This should work in any kind of template but as normally fragment templates do not contain "file source" statements then you would not normally use this in a fragment template. The if-clause cannot be used to conditionally modify what goes into the file using a fragment (or at least was not intended to support that :-).

    Finally, once you have created a file, then any ifdef's in the code are honoured if the file is preprocessed during the build, for details on what files are preprocessed during a build, you need to check standard Visual Studio documentation for the WINS/WINSCW targets and SDK documentation for the ARMI/THYMB/GCCE targets. Eg, the MMP file is now preprocessed duing WINSCW builds but is preprocessed as part of the phone target builds, just to give an example.

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    39

    Exclamation Re: Is it possible to use $if conditional blocks in FragmentTemplates in Carbide.vs?

    Hi mitts,

    Thanks for your reply. I will be more specific. First of all, I have carefully read pdf file about carbide templates. But I still missed some points. For example I had to find how does "boolean" property work. There was examples about properties with type "input" and "select", but not about "boolean". Ok, this is minor question. The main question remains the same.

    I can use next template as ProjectTemplates:

    HTML Code:
    <?xml version = '1.0' encoding = 'ISO-8859-1'?>
    <template type = 'ProjectTemplate'
              version = '2.1' 
              supplier = 'Payu Sergey' ... >
              
        <property-group name = 'basics' 
                        label = 'Basic Settings' 
                        description = 'Basic properties of a project'>
                        
             <property name = 'series60'
                      label = 'Compatibility'
                      description = 'SDK version compatibility. If 2.x selected skin support added'
                      type = 'select'>
    
                      <item label = 'S60 2.x or later' value = '2.x' selected = 'true'/>
                      <item label = 'S60 1.x or later' value = '1.x'/>
    
            </property>
    
            ...
                        
        </property-group>
       
        ...
     
        <!-- Source files -->
        <file source = 'src/BasenameApp.cpp' target = '$(sourceDir)/$(Basename)App.cpp'/>
    
        ...
    </template>
    Then in source file I can do following:

    Code:
    // ------------------------------------------------------------------
    // C$(Basename)Container::Draw(const TRect& aRect) const
    // Draws data to screen.
    // ------------------------------------------------------------------
    //
    void C$(Basename)Container::Draw(const TRect& aRect) const
        {
        CWindowGc& gc = SystemGc();
    
        // TODO: Add your drawing code here
        
    $if(series60!=1.x)
        MAknsSkinInstance* skin = AknsUtils::SkinInstance();
    	MAknsControlContext* cc = AknsDrawUtils::ControlContext(this);
        AknsDrawUtils::Background(skin, cc, this, gc, aRect);
    $endif()
    $if(series60==1.x)  
        gc.SetPenStyle(CGraphicsContext::ENullPen);
        gc.SetBrushColor(KRgbBlue);
        gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
        gc.DrawRect(aRect);
    $endif()
        }
    With this template everything works OK. I select new project, pickup my template and see wizzard, where I can choose compatibility of newly created project. The wizzard correctly handles $if() blocks and paste needed block of code depending on my selection. Then I have tried to do the same in FragmentTemplates:

    HTML Code:
    <?xml version='1.0' encoding='ISO-8859-1'?>
    <template type = 'CodeFragmentTemplate' 
              version = '2.1' 
              supplier = 'Payu Sergey' ... >
              
        <property-group name = 'Properties' 
                        label = 'Properties' 
                        description = 'Listbox properties'>
                        
            ...
                   
            <property name = 'construction'
                      label = 'Construction Type'
                      description = 'Constructs listbox from resource or dynamically'
                      type = 'select'>
                      
                <item label = 'Resources' value = 'res' selected = 'true'/>
                <item label = 'Dynamically' value = 'dyn'/>
                    
            </property>
    
        <file source = 'Listbox.cpp' target = 'Clipboard'/>
        
    </template>
    With this source:

    Code:
        iListBox = new (ELeave) CAknSingleStyleListBox();
        CleanupStack::PushL(iListBox);
            
    $if(construction==res)       
        SetListBoxFromResourceL(iListBox, R_$(BASENAME)_LISTBOX);
    $enif()
    $if(construction!=res)       
        SetListBoxFromInnerDescriptionL(iListBox);
    $enif()
    
    $if(icons==on)
        SetGraphicIconL(iListBox);
        
    $endif()
        iListBox->ActivateL();
    The template is created in right way. I see the right wizzard, I can select whatever I want, but then code inserted with all $if() and $endif symbols. Only $(BASENAME) works and replaces the right name. But none of $if() block. It's really sad, because with this possibility in code fragmetns templates becomes REALLY POWERFULL tool. I will be able to create huge code in several clicks thru wizzard. For example, I'm trying to create listbox wizzard, where I can select listbox type, include or not icons and choose from dynamical and resource creation.

    This will be very usefull for me. I hope you can help. If this doesn't work in 2.0.1 it will be great, if you can add this functionality in later versions.

    Thanks,
    Sergey

  4. #4
    Super Contributor
    Join Date
    Sep 2004
    Posts
    1,048

    Re: Is it possible to use $if conditional blocks in FragmentTemplates in Carbide.vs?

    OK, thanks for your clarification.

    As I suspected, you have found a way to use the templates that we did not plan nor anticipate. It is interesting to see that it actually does work :-). So therefore it is not documented nor available for other templates (if you say so). Thanks for sharing the info.

    And actually I think we did quite a good job if only the definitions for "boolean" were missing from the doc, I see from your example that you were able to figure it out in the end :-).

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    39

    Re: Is it possible to use $if conditional blocks in FragmentTemplates in Carbide.vs?

    Hi mitts!

    What do you mean by "we did not plan nor anticipate"? I take example of Compatibility property in ProjectTemplates from pre-installed templates, you can check this in Templates foder of Carbide.vs. This is expected behaviour. The question is why doesn't it work for FragmentTemplates. Why do we need all that properties, all types other from "imput", if we can't use them?

    If you didn't plan this, can you include this into next version? As I said, it will be very-very usefull. I spent a lot of time copying some code snipplets from project to project.

    Sergey

  6. #6
    Super Contributor
    Join Date
    Sep 2004
    Posts
    1,048

    Re: Is it possible to use $if conditional blocks in FragmentTemplates in Carbide.vs?

    You are right ofcourse. But this is one of those occurences where this was actually not in the spec - but seems to have gotten into the product regardless. So still, this is why it is not in the the doc's, the doc's we write based on the spec'ed out features and also for those we try to create a unified experience. This was a bonus :-).

    You didn't try it out with the Class templates did you?

    Sometimes product development works in interesting ways.. If we get to make a new version, we'll certainly see if we can make this official and not just "bonus".

  7. #7
    Registered User
    Join Date
    Sep 2006
    Posts
    39

    Re: Is it possible to use $if conditional blocks in FragmentTemplates in Carbide.vs?

    No, I haven't tried it in ClassTemplate. Will try now.

    It will be excellent if all templates will support $if() blocks. Their functionality will be increased in several times.

    Sergey

Similar Threads

  1. Request for input on Carbide.vs 2.0 Help
    By mitts in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2006-01-10, 09:16

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×