PHP Classes

File: hnwb_ListView/examples/hnwb_ListView.example_1.phpw

Recommend this page to a friend!
  Classes of Horst Nogajski   hnwb_ListView for WinBinder   hnwb_ListView/examples/hnwb_ListView.example_1.phpw   Download  
File: hnwb_ListView/examples/hnwb_ListView.example_1.phpw
Role: Example script
Content type: text/plain
Description: Example App with disabled Configurator-Window
Class: hnwb_ListView for WinBinder
Extend the WinBinder ListView control
Author: By
Last change: x
Date: 17 years ago
Size: 5,787 bytes
 

Contents

Class file image Download
<?PHP
/*****************************************************************************
  | @script_type - PHP-WinBinder
  | @scriptname - hnwb_ListView.example.phpw
  | @version - 1.0
  | -------------------------------------------------------------------------
  | @author - Horst Nogajski <coding@nogajski.de>
  | @copyright - (c) 1999 - 2007
  | @licence - LGPL
  | -------------------------------------------------------------------------
  | $Source: /WINBINDER/hnwb_ListViewClass/hnwb_ListView.example_1.phpw,v $
  | $Id: hnwb_ListView.example_1.phpw,v 1.3.2.1 2007/01/04 23:36:30 horst Exp $
 ****************************************************************************/



include('config.php');
define('APPNAME', basename( __FILE__ ));


//------------------------------------------------------------------------------


#--> STEP 1:
    // define ID-Constants for your ListViews
   
if(!defined('IDC_LISTVIEW_1')) define('IDC_LISTVIEW_1', 1001);




#--> STEP 2:
    // Create window with: WBC_NOTIFY, WBC_MOUSEMOVE | WBC_HEADERSEL !!!
   
$winmain = wb_create_window(null, AppWindow, APPNAME, WBC_CENTER, WBC_CENTER,
               
540, 449, WBC_NOTIFY, WBC_MOUSEMOVE | WBC_HEADERSEL );


/** EXAMPLE USAGE 1:
 *
 * with disabled Configurator-Window but therefor with manually defined
 * Column-Header-Names, optionally with values for width and alignment
 **/



#--> STEP 3:
    // create a global INI-Object without inifile, (is only needed for compatibility)
   
$ini = new hn_ini(null,FALSE,TRUE);



#--> STEP 4:
    // create an Object for the Listview.
    // Don't forget to set the WBC_SORT-Flag!
   
$lv1 = new hnwb_ListView($ini,TRUE,TRUE);
   
$lv1->ctrl = wb_create_control($winmain, ListView, '', 10, 25, 511, 345, IDC_LISTVIEW_1, WBC_VISIBLE | WBC_ENABLED | WBC_SORT | WBC_LINES | WBC_CHECKBOXES, 0, 0);


       
// disable the Configurator-Window for the Users
        // (it is enabled per default)
       
$lv1->enable_user_config(FALSE);


       
// you must know the DataSource, so you can
        // manually defined Column-Header-Names, optionally with values for width and alignment
       
$ColumnHeaders = array( array('company', 160), array('name', 130), array('firstname',90), array('id', 63, WBC_RIGHT) );

       
/*** set_Column_Header manually:
         *
         * first Param: required Array with names or ContainerArray with Array for each column:
         * array( name [,width] [,WBC_LEFT | WBC_CENTER | WBC_RIGHT] ),
         * at least you have to pass an array with that number of empty entries
         * you need Columns, e.g. 2 = array('','')
         * second Param: optional define the column with your unique datarecord id,
         * String or id (when use associative arrays), or integer id.
         * If there is no id column, pass NULL.
         * third Param: optional define if you serve associative DataArays to the Listview [True | False]
         */
       
$lv1->set_Column_Header($ColumnHeaders, 'id', TRUE);


       
// optionally define sorting-lists:
       
$lv1->set_extended_SortList('company',array('company','name','firstname'));
       
$lv1->set_extended_SortList('name',array('name','firstname'));
       
$lv1->set_extended_SortList('id',array('id'));


       
// optionally change/set Display & Styles
       
$lv1->set_Style_Lines(TRUE);
       
$lv1->set_Style_Checkboxes(TRUE);
       
$lv1->set_Style_Enabled(TRUE);


   
// end with manually Configuration.
    // If you use the (by default enabled) Configurator-Window, you need only _ONE_LINE_ of code for this.
    // See the Example_2 file!


    // initialize the Control
   
$lv1->initialize();


   
// get Data for the Listview (e.g. from MySQL-Query)
   
$data = example_data();


   
// add Data to ListView
   
$lv1->Data_PUT($data);



wb_set_handler($winmain, "process_main");
wb_main_loop();



//-------------------------------------------------------------------- FUNCTIONS


function process_main($window, $id, $ctrl=0, $lparam1=0, $lparam2=0)
{

#--> STEP 5:
    // make the ListView-ObjectHandlers global!
   
if(!isset($GLOBALS['LV_cfg'])) $GLOBALS['LV_cfg'] = null;
    global
$lv1;


    switch(
$id)
    {


#--> STEP 6:
        // For each ListView-ObjectHandler:
        // set a second Hook into the MainProcess-EventHandler,

       
case $lv1->get_ID():
           
$lv1->Event_Handler($window, $id, $ctrl, $lparam1, $lparam2, $GLOBALS['LV_cfg']);
            break;


#--> STEP 7:
        // For each ListView-ObjectHandler:
        // CleanUp at ProcessTermination

       
case IDCLOSE:
           
$GLOBALS['LV_cfg'] = null;
            unset(
$GLOBALS['LV_cfg']);

           
$lv1->Destroy();
           
$lv1=null;
            unset(
$lv1);

           
wb_destroy_window($window);
            break;

    }

}


function
example_data()
{
   
$data_src = array(
        array(
'company'=>'company', 'name'=>'doe', 'firstname'=>'john'),
        array(
'company'=>'', 'name'=>'doe', 'firstname'=>'john'),
        array(
'company'=>'ab ltd.', 'name'=>'doe', 'firstname'=>'john'),
        array(
'company'=>'de ltd.', 'name'=>'doe', 'firstname'=>'john'),
        array(
'company'=>'fg ltd.', 'name'=>'doe', 'firstname'=>'john'),
        array(
'company'=>'xy ltd.', 'name'=>'doe', 'firstname'=>'john'),
        array(
'company'=>'company', 'name'=>'wesson', 'firstname'=>'al'),
        array(
'company'=>'company', 'name'=>'baker', 'firstname'=>'barry'),
        array(
'company'=>'company', 'name'=>'butcher', 'firstname'=>'barry'),
        array(
'company'=>'company', 'name'=>'baker', 'firstname'=>'terry'),
        array(
'company'=>'xy ltd.', 'name'=>'patterson','firstname'=>'aldus'),
        array(
'company'=>'trade united', 'name'=>'hugley', 'firstname'=>'jenny')
    );
   
$data = array();
   
$uid = 0;
    for(
$i=0;$i<3;$i++)
    {
        foreach(
$data_src as $d)
        {
           
$data[] = array_merge($d,array('id'=>$uid));
           
$uid++;
        }
    }
    return
$data;
}

?>