Difference between revisions of "Datagrid Plugin"

From LinuxMCE
Jump to: navigation, search
m
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<table width="100%"> <tr><td bgcolor="#FFCFCF">This page was written by Pluto and imported with their permission when LinuxMCE branched off in February, 2007.  In general any information should apply to LinuxMCE.  However, this page should be edited to reflect changes to LinuxMCE and remove old references to Pluto.</td></tr> </table>Datagrid_Plugin provides an usefull feature for pluto, allowing other plugins to create datagrids which are serialized and sent to Orbiter(s). In order to create a datagrid, you will need to create and register a datagrid generator.
+
[[Category: Programmer's Guide]]
 +
[[Category:LinuxMCE_Plugins]]
  
 +
Datagrid_Plugin provides an useful feature for LinuxMCE, allowing other plug-ins to create data-grids which are serialized and sent to Orbiter(s). In order to create a data-grid, you will need to create and register a data-grid generator.
  
== How to create a datagrid generator ==
+
== How to create a data-grid generator ==
  
1. Add a new record in Datagrid table from pluto_main database.  
+
# Add a new record in Datagrid table from pluto_main database.
 +
# Then you'll have to use our sql2cpp tool to regenerates pluto_main database wrapper project. To confirm that it worked, go to pluto_main/Define_Database.h and scroll down, searching for the record you've just added. A new constant should be define there for your data-grid. Then commit that header file. '''Note:''' It is recommended to add that record on our main server rather that on your local server. If you choose the second solution, you'll need to use sqlCVS in order to synchronize your database with our database.
 +
# Once this step is done, you can go ahead and choose the plugin which handles better the type of data-grid you want to create. Let's say you want to display a list with files from the hard-drive; in this case you might want to choose File_Grids_Plugin. If it's related with some infrared stuff, Infrared_Plugin you'll be you choice. If the data-grid you want to create doesn't seem to match any plug-in scope, General_Info_Plugin is the best choice.
 +
# Add to that plug-in a method with this signature:
 +
<pre>
 +
''class DataGridTable *My_Datagrid_Generator(string GridID, string Parms, void *ExtraData, int *iPK_Variable, string *sValue_To_Assign, class Message *pMessage);''
 +
</pre>
 +
In that method, you have to create a DatagridTable object, create cells (DataGridCell objects) and assign them to the data-grid:
 +
<pre>
 +
''DataGridTable *pDataGrid = new DataGridTable();''
  
2. Then you'll have to use our sql2cpp tool to regenerates pluto_main database wrapper project. To confirm that it worked, go to pluto_main/Define_Database.h and scroll down, searching for the record you've just added. A new constant should be define there for your datagrid. Then commit that header file.
+
''//... some code here, maybe within a loop''
Note: It is recommended to add that record on our main server rather that on your local server. If you choose the second solution, you'll need to use sqlCVS in order to synchronize your database with our database.
+
 
+
3. Once this step is done, you can go ahead and choose the plugin which handles better the type of datagrid you want to create. Let's say you want to display a list with files from the harddrive; in this case you'll might want to choose File_Grids_Plugin. If it's related with some infrared stuff, Infrared_Plugin you'll be you choise. If the datagrid you want to create doesn't seem to match any plugin scope, General_Info_Plugin is the best choice.
+
 
+
4. Add to that plugin a method with this signature:
+
 
+
''class DataGridTable *My_Datagrid_Generator(string GridID, string Parms, void *ExtraData, int *iPK_Variable, string *sValue_To_Assign, class Message *pMessage);''
+
  
In that method, you have to create a DatagridTable object, create cells (DataGridCell objects) and assign them to the datagrid:
+
''DataGridCell *pCell = new DataGridCell(sTextToDisplay, sCellValue);''
  
''DataGridTable *pDataGrid = new DataGridTable();
+
''pDataGrid->SetData(nColumn, nRow, pCell);''
  
//... some code here, maybe within a loop
+
''//... some code here''
  
DataGridCell *pCell = new DataGridCell(sTextToDisplay, sCellValue);
+
''//in the end, just return the datagrid''
  
pDataGrid->SetData(nColumn, nRow, pCell);
+
''//Datagrid_Plugin will un-allocate the memory for data-grid once this was serialized and sent to Orbiter''
  
//... some code here
+
''return pDataGrid''
 +
</pre>
 +
== How to register a data-grid generator ==
 +
This is the easiest part: go to plugin's Register method and add a line like this:
 +
<pre>
 +
''m_pDatagrid_Plugin->RegisterDatagridGenerator(''
  
//in the end, just return the datagrid
+
''    new DataGridGeneratorCallBack(this, (DCEDataGridGeneratorFn)(&A_Pluto_Plugin::My_Datagrid_Generator)),''
  
//Datagrid_Plugin will deallocate the memory for datagrid once this was serialized and sent to Orbiter
+
''    DATAGRID_MY_DATAGRID_NAME_CONST,''
  
return pDataGrid''
+
''    PK_DeviceTemplate_get() ''
  
 +
'');''
 +
</pre>
 +
Where you'll have to replace A_Pluto_Plugin with the name of the plug-in were you've created that method, My_Datagrid_Generator with the name of your data-grid generator method and DATAGRID_MY_DATAGRID_NAME_CONST with the constant generator in pluto_main/Define_Datagrid.h
  
  
 +
== How to use a data-grid in Orbiter ==
  
== How to register a datagrid generator ==
+
Now you are ready to use the data-grid. For this, you'll have to use our tool "Designer" to add a data-grid object to a screen, with the PK_Datagrid the PK of the record you've added to Data-grid table. Most of the time, this task is accomplished by one of our guys which take care of Orbiter UI. Once the changes are made with the designer, you can just regenerate Orbiter with OrbiterGen tool, then go to that screen where the data-grid is and use it.
== How to use a datagrid in Orbiter ==
+

Latest revision as of 13:11, 2 December 2008


Datagrid_Plugin provides an useful feature for LinuxMCE, allowing other plug-ins to create data-grids which are serialized and sent to Orbiter(s). In order to create a data-grid, you will need to create and register a data-grid generator.

How to create a data-grid generator

  1. Add a new record in Datagrid table from pluto_main database.
  2. Then you'll have to use our sql2cpp tool to regenerates pluto_main database wrapper project. To confirm that it worked, go to pluto_main/Define_Database.h and scroll down, searching for the record you've just added. A new constant should be define there for your data-grid. Then commit that header file. Note: It is recommended to add that record on our main server rather that on your local server. If you choose the second solution, you'll need to use sqlCVS in order to synchronize your database with our database.
  3. Once this step is done, you can go ahead and choose the plugin which handles better the type of data-grid you want to create. Let's say you want to display a list with files from the hard-drive; in this case you might want to choose File_Grids_Plugin. If it's related with some infrared stuff, Infrared_Plugin you'll be you choice. If the data-grid you want to create doesn't seem to match any plug-in scope, General_Info_Plugin is the best choice.
  4. Add to that plug-in a method with this signature:
''class DataGridTable *My_Datagrid_Generator(string GridID, string Parms, void *ExtraData, int *iPK_Variable, string *sValue_To_Assign, class Message *pMessage);''

In that method, you have to create a DatagridTable object, create cells (DataGridCell objects) and assign them to the data-grid:

''DataGridTable *pDataGrid = new DataGridTable();''

''//... some code here, maybe within a loop''

''DataGridCell *pCell = new DataGridCell(sTextToDisplay, sCellValue);''

''pDataGrid->SetData(nColumn, nRow, pCell);''

''//... some code here''

''//in the end, just return the datagrid''

''//Datagrid_Plugin will un-allocate the memory for data-grid once this was serialized and sent to Orbiter''

''return pDataGrid''

How to register a data-grid generator

This is the easiest part: go to plugin's Register method and add a line like this:

''m_pDatagrid_Plugin->RegisterDatagridGenerator(''

''    new DataGridGeneratorCallBack(this, (DCEDataGridGeneratorFn)(&A_Pluto_Plugin::My_Datagrid_Generator)),''

''    DATAGRID_MY_DATAGRID_NAME_CONST,''

''    PK_DeviceTemplate_get() ''

'');''

Where you'll have to replace A_Pluto_Plugin with the name of the plug-in were you've created that method, My_Datagrid_Generator with the name of your data-grid generator method and DATAGRID_MY_DATAGRID_NAME_CONST with the constant generator in pluto_main/Define_Datagrid.h


How to use a data-grid in Orbiter

Now you are ready to use the data-grid. For this, you'll have to use our tool "Designer" to add a data-grid object to a screen, with the PK_Datagrid the PK of the record you've added to Data-grid table. Most of the time, this task is accomplished by one of our guys which take care of Orbiter UI. Once the changes are made with the designer, you can just regenerate Orbiter with OrbiterGen tool, then go to that screen where the data-grid is and use it.