[Windows Mobile Software Development] poyensa:
You can do your own widget just changing PoyTEST - PoyText1 - PoyGraphic1 for your own names

The best way to make a new widget is start from another widget, in this case we can start from PoyTEST, its a simple widget with 2 variables to display in the home screen of our devices: one graphic file as background and one text field. This 2 fields (or variables) will be created by the mode9 file. We have to give unique names for all the variables so the easiest way is just to change PoyTEST - PoyText1 - PoyGraphic1 - for your own names in every line of the files involved. So open file 30182CB6_manila using m9editor and do the changes. (If you are not familiar with m9editro go here)

The mode9 file 30182CB6_manila use to define also the content of the graphic variables (SetTexture) but we will do it later for this example. Other important thing is the order in mode9 stablish the order of the elements shown in ours screen. It means that we will see PoyText1 over PoyGraphic1 as we like.

Now we have to change the file CHTWidgetDev.lua using Notepad2 and change all the PoyTEST - PoyGraphic1 & PoyText1 for the name previously used in the mode9 file. It not dificult just change PoyTEST -nothing else- in every line where it appears, substitute for the name previously used in mode9 file. YES YOU HAVE TO LEAVE THE SMALL w

Some important things:

Be careful with capital and lower letters. For lua languaje 'PoyTEST' is different than 'poyTEST' so only one letter can make the widget not working.

If the line strat with '--' then the line is dissabled, this is usefull for notes & reminders and also to activate and deactivate lines. If you use Notepad2 the deactivated line will be green coloured.

The files 30182CB6_manila (mode9) & CHTWidgetDev.lua always have to be in any CHTwidget, and they must have always the same structure. In mode9 file 30182CB6_manila we do create the variables and in CHTWidgetDev.lua (renamed as CHTlua_manila in the cab) we connect the widget to the rest of Co0kie Home Tab.

Now we do not need to change anything, may be later when we are more familiar with widgets:

* Lines 3-8 is to register the widget in CHT

* Line 8 is connected to line 82-83-84. We define there how many layouts is going to have the widget (black-white-etc). We leave everything as it is now ...

* Lines 10-48 are to control the size of the widget, in the future you can play there a bit specially in line 42 if you wish your widget bigger, but now we leave it as it is.

* Lines 50-62 are very important. We do nothing there -never- just change the names for our's widget name. Specially line 62 we put there the object (clockface, bakcground, etc) that is going to react when we press it with our finger. In our case it will be PoyGraphic1 (change it for the variable name used in mode9 file 30182CB6_manila).

* Line 64 conect to our widget lua file. As you may know the lua file defines the behaviour of the widget. In this lua file we are going to say what our widget is going to do. Is time to open ManilaHash and find the manila name of our widget's lua file. Dont change the path just the final name, you can use any but by convention better use something like CreatorName_WidgetName.lua

* Lines 82-84 is to add more layouts in our widget. You can see some examples in other widgets and also in CHT_Widgets.lua (CHT source), but dont forget to modify line 8 then!

* Lines 88-104 is defined the animation effect how the widget comes to the screen when swipping between levels. I never touch anything there.

* same for lines 106-116. It was there before me and i never modify anything there (just the widget name) :)

* Now have a look again to every line, check the spelling, capital letters, etc.

Now you are using manilaHash you can also find the name for any other graphic file you are going to use. e. Dont change the path just the final name

Now we can start to modify the file PoyTEST.lua. Using Notepad2 you have to change PoyTEST for your widget name used in the previous lua file and also modify the name of the variables defined in the mode9 file 30182CB6_manila (PoyText1 & PoyGraphic1) in all the lines where those appears.

In this lua file can be added some properties that use to be set in mode9 file (lines 15-25) I do that for one reason: This file does not change the name in the widget installation process, as the other CHT files (CHTmode9_manila & CHTlua_manila) does. This file will be always 41CBC6DC_manila in \windows\ folder so it is easy to substitute later to correct some bugs, etc.

You can get out of the line 29 (just put -- at the begining of the line it will be green cloured) This is a test I am doing for translate widgets regarding this post. If so you have also to activate the line 28 (delete -- then the line will be black colour) and delete file PoyTESTtranslation.lua in \PoyTEST\workspace\_lua

I cannot say much more for this file. Here comes the problems. How to do things? I am not a coder I have only read and read and read a lot of code in other widgets and CHT_Widgets.lua and other files in CHT source, and try and try and try a lot, and finally ask rat_2665 :D

* Line 33 is a way to set texture for graphic fields in lua files instead of mode9 files

* Lines 38-63 is to define what the widget does when pressed

You can do your own widget just changing PoyTEST - PoyText1 - PoyGraphic1 for your own names

Now is time to check the USB conection, device is sinchronized, then click on _Deploy_to_device_in_dev_mode.bat and see your widget working! :)

[[be sure the .bat file has been edited correctly by adding your widget name, as explained in post#8]]

Sense crashed ... dont worry. Nobody has got it at the first time! :eek::D

1. Be sure you are in DevMode

2. Check that all the names are correctly written, specially capital letters- lower letters

3. if you got an error in the black screen after run .bat file, read it slowly. It will help

4. Once you make the corrections you can run again .bat, even with sense crashed.

MAKING THE CAB

Be sure that you have edited the file _Generate_files_for_cab.bat with your own name widget as explained in post#8. By running this file all the lua files will be recompiled automatically and all the files will go from \workspace\ to \cab\_final_files\ If you have a look to the screenshot you will notice that some files names have changed: we will find there CHTlua_manila & CHTmode9_manila. This 2 files will change the name again when the cab be installed in the device, depending the free slot asigned will take the final manila in \windows\ folder in your device. Isn't magic? :)

Dont forget to add the magic setup.dll. When you add the files into the cab select windows as location. Then in cabinet properties - Installation directory do create a folder in \root\CHTAddons\NameOfTheWidget with the same name as your widget (line 5 of chtwidgetdev.lua) and mark hard-coded-path. Finally save the cab.

CHTScheduler

If we add a xml file named as CHTWidget_NameOfYourWidget.xml (CHTWidget_PoyTEST.xml in this case) directly in \windows\ folder with just a description of the manila files names used in our widget (see some of them as example) this widget will be used by CHTSheduler for diferents profiles, baselines, etc.

It does not seems dificult, isnt it? it simple but if you substitute the qtc file attached 1F88A376_manila, and change the color property for the text in line 17 of PoyTEST.lua to black (0,0,0,255) .... it could be the begining of an usefull widget :)

1.- Lets do our own CHTwidget

2.- Using JMLMenuSense

3.- Final touches

4.- A Bit of CHTS