PHP Classes

File: hnwb_ListView/examples/hnwb_ListView.example_4.phpw

Recommend this page to a friend!
  Classes of Horst Nogajski   hnwb_ListView for WinBinder   hnwb_ListView/examples/hnwb_ListView.example_4.phpw   Download  
File: hnwb_ListView/examples/hnwb_ListView.example_4.phpw
Role: Example script
Content type: text/plain
Description: ExampleApp with ListView on a TabPage
Class: hnwb_ListView for WinBinder
Extend the WinBinder ListView control
Author: By
Last change:
Date: 17 years ago
Size: 5,329 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_4.phpw,v $
  | $Id: hnwb_ListView.example_4.phpw,v 1.2 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_TABCONTROL')) define('IDC_TABCONTROL', 1001);
    if(!
defined('IDC_LISTVIEW_1')) define('IDC_LISTVIEW_1', 1002);



#--> 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 4:
 *
 * a ListView with Buttons on a TabControl
 *
 **/

   
$tab = wb_create_control($winmain, TabControl, "Tab1\nTab2\nTab3", 5, 10, 525, 270, IDC_TABCONTROL, 0x00000000, 0, 0);
   
$lv_TabPage = 2;


#--> 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($tab, ListView, '', 25, 18, 476, 175, IDC_LISTVIEW_1, WBC_VISIBLE | WBC_ENABLED | WBC_SORT | WBC_LINES | WBC_CHECKBOXES, 0, $lv_TabPage);


//ATTENTION:
    // create a ClassProperty for the TabPage-ID with Name 'TabPage' and assign the TabPage-Id to it:
   
$lv1->TabPage = $lv_TabPage;


   
// 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 Button-Extended-ListView-ObjectHandler:
        // catch and proceed Button-Events

       
case $id >= $lv1->Button_ID_first && $id <= $lv1->Button_ID_last:
           
$lv1->Button_Event_Handler($id);
            break;


#--> STEP 10:
        // 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;
}

?>