PHP Classes
Icontem

File: hnwb_ListView/examples/hnwb_ListView.example_4.phpw


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Horst Nogajski  >  hnwb_ListView for WinBinder  >  hnwb_ListView/examples/hnwb_ListView.example_4.phpw  
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
 

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(nullAppWindowAPPNAMEWBC_CENTERWBC_CENTER,
                
540449WBC_NOTIFYWBC_MOUSEMOVE WBC_HEADERSEL );



/** EXAMPLE USAGE 4:
 *
 *  a ListView with Buttons on a TabControl
 *
 **/

    
$tab wb_create_control($winmainTabControl"Tab1\nTab2\nTab3"510525270IDC_TABCONTROL0x0000000000);
    
$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($tabListView''2518476175IDC_LISTVIEW_1WBC_VISIBLE WBC_ENABLED WBC_SORT WBC_LINES WBC_CHECKBOXES0$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;
}

?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products