[[php_dhtml:exemple3]]
 
Table of Contents

Exemple3 - winApp class exemple

This one use the winApp class to create an very simple application.

Result

Code

<?php
/**
 * php_dhtml
 * Copyright (C) 2004  Eric Colinet <e.colinet@laposte.net>
 * http://wildphp.free.fr
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
include 'dhtml/winApp.inc';
 
$GLOBALS['WINAPP_RC_PATH']= 'rc/winapp_classic/';
 
class MyWinApp extends winApp {
	var $write_buffer;
 
	/**
	 * Global Init
	 */
	function on_init() {
		$this->toolbar->add_button( 'file', 'File', _f('buttons/new.png'),
			array(
				'file_new' => 'New',
				'file_open' => 'Open',
				'file_save' => 'Save',
				'-',
				'file_quit' => 'Quit',
				)
			);
		$this->toolbar->add_button( 'file_open', 'Ouvrir', _f('buttons/open.png') );
		$this->toolbar->add_button( 'file_save', 'Sauver', _f('buttons/save.png') );
		$this->toolbar->add_button( 'file_print', 'Imprimer', _f('buttons/print.png') );
		$this->toolbar->add_button( 'help', '', _f('buttons/help.png'),
				array(
					'help_about' => 'About',
					'help_about_php' => 'About Php'
				)
			);
	}	
 
	/**
	 * Default command handler
	 */
	function on_command($what) {
		$this->set_status("$what");
	}
 
	function on_command_file_new() {
		$this->clear();
		$this->writeln("<H2>New File</H2>");
		$this->writeln("This is the content of the new file");
	}
 
	function on_command_file_open() {
		$this->clear();
		$this->writeln("<H2>Open File</H2>");
		if( !extension_loaded('win32std') ) {
			$this->writeln("You don't have win32std loaded");
			return;
		}
		$this->writeln("Select file to open");
		$this->disable();
		$file= win_browse_file(1);
		$this->enable();
		$this->focus();
		$this->clear();
		$this->writeln("<H2>Open File</H2>");
		if( $file )
			$this->writeln("You have selected: ".$file);
		else
			$this->writeln("Selection canceled");
	}
	
	function on_command_file_save() {
		$this->clear();
		$this->writeln("<H2>Save file</H2>");
		$this->writeln("The file must be saved !");
	}
 
	function on_command_file_quit() { 
		$this->close(); 
	}
	
	function on_command_help_about() {
		new MessageBox($this, "<H4>WinApp Test</h4>Cool isn't it ? :)", "WinApp");
	}
	
	function on_command_help_about_php() {
		about_php($this);
	}
	
	function on_command_file_print() {
		$this->clear();
		$this->writeln("<H2>Print</H2>");
	}
 
	function clear() {
		$this->write_buffer= '';
		$this->id_html('window', $this->write_buffer);
	}
 
	function write( $string ) {
		$this->write_buffer.= $string;
		$this->id_html('window_frame', $this->write_buffer);
	}
	function writeln( $string ) {
		$this->write( $string.'<br/>' );
	}
 
}
 
new MyWinApp();
winApp::run();
?>
 
  php_dhtml/exemple3.txt · Last modified: 2004/12/02 21:22
 
Recent changes RSS feed Powered by PHP Driven by DokuWiki