PHP Classes

File: hnwb_ListView/examples/hnwb_ListView.example_2.phpw

Recommend this page to a friend!
  Classes of Horst Nogajski   hnwb_ListView for WinBinder   hnwb_ListView/examples/hnwb_ListView.example_2.phpw   Download  
File: hnwb_ListView/examples/hnwb_ListView.example_2.phpw
Role: Example script
Content type: text/plain
Description: Example App with enabled Configurator-Window and added Default-Buttons
Class: hnwb_ListView for WinBinder
Extend the WinBinder ListView control
Author: By
Last change: x
Date: 17 years ago
Size: 4,723 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_2.phpw,v $
  | $Id: hnwb_ListView.example_2.phpw,v 1.3 2007/01/04 22:21:42 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 2:
 *
 * with enabled Configurator-Window
 **/



#--> STEP 3:
    // create a global INI-Object with inifile
   
$inifile = str_replace('.phpw','', __FILE__).'.ini';
   
$ini = new hn_ini($inifile,TRUE,TRUE);



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



#--> STEP 5:
    // create an Extended-Object with Buttons for the Listview
   
$lv1 = new hnwb_ListView_Buttons($ini,TRUE,TRUE);

   
// define first ID for the Buttons
   
$lv1->define_Start_ID(7775);

   
// create the Control
    // Don't forget to set the WBC_SORT-Flag!
   
$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);

   
// setup the ini-object, (ATTENTION: THIS MUST BE CALLED DIRECTLY AFTER THE CONTROL IS CREATED)
   
$lv1->initialize_ini();

   
// use AutoConfigure for the Headernames without Uniqe-IDs
   
$lv1->set_ASSOC_AUTO_Column_Header($data);

   
// finally setup the enhanced Control, (ATTENTION: THIS MUST BE CALLED AFTER THE ColumnHeader ARE CREATED)
   
$lv1->initialize();

   
// 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 6:
    // make the ListView-ObjectHandlers global!
   
if(!isset($GLOBALS['LV_cfg'])) $GLOBALS['LV_cfg'] = null;
    global
$lv1;


    switch(
$id)
    {


#--> STEP 7:
        // For each ListView-ObjectHandler:
        // set a first Hook into the MainProcess-EventHandler, _without_ a break-command !

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


#--> STEP 8:
        // 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 9:
        // For each ListView-ObjectHandler:
        // CleanUp at ProcessTermination

       
case IDCLOSE:
           
$lv1->Destroy();
           
$lv1=null;
            unset(
$lv1);

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

           
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;
}

?>