apostila php gtk

608
PHP-GTK Manual James Moore Steph Fox Andrei Zmievski et al. Editado por Pablo Dall'Oglio Thomas Gonzalez Miranda Direitos Autorais © 2001, 2002, 2003, 2004 por Grupo de Documentação PHP-GTK Copyright Este manual é ©2001 - 2004 para o Grupo de Documentação PHP-GTK. Os membros e editores estão listados na página inicial do manual. Copyright ©2001 - 2004 Grupo de Documentação PHP-GTK. É permitido copiar distribuir e/ou modificar este documento perante os termos da GNU Free Software Documentation License, versão 1.1 publicada pela Free Software Foundation; with no Invariant Sections, with no Front-Cover texts and with no Back-Cover texts. Uma cópia da licensa está incluída na seção entitulada "GNU Free Documentation License". Sun Jan 29 20:57:59 CST 2006 _________________________________________________________________ Índice Prefácio Guia do Usuário Tutoriais sobre PHP-GTK Guia de Referêcia Apêndice Prefácio _________________________________________________________________ Este manual está divido em três partes. A primeira parte é o Guia do Usuário. Nela é abordado os temas sobre conceitos gerais por trás da criação de aplicativos com Interfaces Gráficas para Usuários (GUI). A segunda parte é o Guia de Referêcia. Nela é explicado detalhadamente cada um dos objetos GTK bem como os métodos e sinais que podem ser atribuídos à eles. Na terceira e última parte, há uma seção nomeada Tutoriais, onde você poderá obter alguns exemplos de aplicações prontas feitas em PHP-GTK. Somente a seção de Referência está incluída no sistema de busca (nas versões em PHP).

Upload: wanderlei-s-santos

Post on 16-Apr-2015

214 views

Category:

Documents


35 download

TRANSCRIPT

Page 1: Apostila PHP GTK

PHP-GTK Manual

James MooreSteph FoxAndrei Zmievskiet al.

Editado por

Pablo Dall'OglioThomas Gonzalez Miranda

Direitos Autorais © 2001, 2002, 2003, 2004 por Grupo de DocumentaçãoPHP-GTK

Copyright

Este manual é ©2001 - 2004 para o Grupo de Documentação PHP-GTK. Osmembros e editores estão listados na página inicial do manual.

Copyright ©2001 - 2004 Grupo de Documentação PHP-GTK. É permitidocopiar distribuir e/ou modificar este documento perante os termos daGNU Free Software Documentation License, versão 1.1 publicada pelaFree Software Foundation; with no Invariant Sections, with noFront-Cover texts and with no Back-Cover texts. Uma cópia da licensaestá incluída na seção entitulada "GNU Free Documentation License".

Sun Jan 29 20:57:59 CST 2006_________________________________________________________________

Índice

PrefácioGuia do UsuárioTutoriais sobre PHP-GTKGuia de ReferêciaApêndice

Prefácio_________________________________________________________________

Este manual está divido em três partes.

A primeira parte é o Guia do Usuário. Nela é abordado os temas sobreconceitos gerais por trás da criação de aplicativos com InterfacesGráficas para Usuários (GUI). A segunda parte é o Guia de Referêcia.Nela é explicado detalhadamente cada um dos objetos GTK bem como osmétodos e sinais que podem ser atribuídos à eles. Na terceira e últimaparte, há uma seção nomeada Tutoriais, onde você poderá obter algunsexemplos de aplicações prontas feitas em PHP-GTK.

Somente a seção de Referência está incluída no sistema de busca (nasversões em PHP).

Page 2: Apostila PHP GTK

O manual é produzido usando uma versão modificada do Docbook DTD. Asmodificações que foram feitas permitem à documentação dos objetosusados pelo sistema do PHP-GTK. Os XML básicos para cada uma dasclasses e seus métodos são gerados automaticamente à partir do códigofonte do PHP-GTK. Note que não é possível gerarl informações sobre ossinais desta maneira, ex: se não há uma descrição textual sobre osinal para uma classe, então ela é considerada incompleta e não éincluída.

O gerador XML foi escrito por Andrei Zmievski, o autor original doPHP-GTK. A documentação é transformada à partir de um código-fonte emXML para vários outros formados usando folhas de estilos XSL bem comouma série de outras ferramentas.

O sistema de geração do manual foi criado por James Moore e é mantidopor James Moore e Steph Fox.

O manual está atualmente disponível em formato texto puro, múltiplosarquivos HTML ou em um único arquivo HTML e também em formatos quepodem ser usados em sistemas de busca do PHP, todos eles podem serbaixados em PHP-GTK website.

Guia do Usuário_________________________________________________________________

Índice

Introdução oa PHP-GTKComeçando...Elementos Básicos

Introdução oa PHP-GTK

Esta seção do manual fala sobre as idéias e tecnologias por trás doPHP-GTK.

Índice

O que é PHP-GTK?O que é PHP?O que é GTK+?Agradecimentos

O que é PHP-GTK?

PHP-GTK é uma extensão do PHP que permite à você escrever nolado-cliente, aplicações multi-plataforma. Esta é a primeira extensãopara o PHP deste tipo, e foi escrita em parte para provar que o PHP écapaz de ser uma linguagem de uso-geral que pode ser usado para muitomais do que somente escrever aplicações no ambiente web.

Esta extensão não irá permitir à você mostrar aplicações GTK+ em umnavegador-web. A intenção dela é criar aplicações GUI autônomas

Page 3: Apostila PHP GTK

(standalone).

O que é PHP?

Índice

A História do PHPO que o PHP faz?

A História do PHP

O PHP começou e ainda é usado principalmente como uma linguagem descripting do lado-servidor embutida no HTML.

PHP, conhecido originalmente como Personal Home Pages, foiprimeiramente concebido no outono de 1994 por Rasmus Lerdorf. Ele aescreveu como um modo de rastrear os visitantes de seu CV online. Aprimeira versão foi realizada no início de 1995, época na qual Rasmusdecidiu tornar seu projeto open-soruce, sendo assim, as pessoascorrigiriam seus bugs. A primeira versão era muito direta e tinha umparser simples que reconhecia algumas macros especiais e continhaalgumas utilidades que eram comumente usadas em hompages daquelaépoca.

O parser foi reescrito em meados de 1995 e renomeado para PHP/FIversion 2. O "FI" desta versão significava Form Interpreter, Rasmusentão adicionou ao PHP mais uma série de funções que cobriam asnecessidades das webpages daquela época. PHP/FI então começou a ter umcrescimento massivo, e outras pessoas começaram a contribuir com ocódigo regularmente.

Em meados de 1997 Zeev Suraski e Andi Gutmans reescreveram o parserprincipal, e o PHP deixou de estar sob a tutela de Rasmus' para estarsob a orientação de um grupo. Com isto a formou-se base para o PHP3,agora chamado de PHP: Hypertext Preprocessor - um acrônimo recursivo.

A última versão, o PHP4, é outra reescrita feita por Suraski e Gutmanse é baseada no mecanismo (tecnologia) Zend. O PHP agora tem mais deduzentos contribuintes regulares trabalhando em várias partes doprojeto. Tem uma quantidade gigantesca de extensões de terceiros,módulos, suporte à todos tipo de servidores populares nativamente, etem suporte para MySql e ODBC embutido.

A última estatística mostra que o PHP agora é usado por mais de 5,5milhões de domínios, e tem tido uma taxa de uso crescente ano pós ano.Isto está longe de ser simplesmente o módulo mais popular do Apache;Para se ter uma idéia, o Apache atualmente está perto de 60% dosservidores de internet do mercado, enquanto que servidores IIS (quenativamente suportam ASP) estão presente em menos que a metade destaproporção. (Figuras obtidas em http://www.securityspace.com/ Março2001.)

O que o PHP faz?

Page 4: Apostila PHP GTK

PHP é uma linguagem para propósitos gerais. É normalmente usada comolinguagem de scripting embutida em html para se usar na web, mastambém pode ser usada como linguagem de scripting shell ou mesmo comouma linguagem para escrever aplicações "windowned", no formatoPHP-GTK.

Devido a natureza open-source do PHP, se há algo atualmente que vocênão consegue fazer em PHP, não há nada que impessa você de escrever ummódulo ou extensão em código C para estender suas funcionalidades,sendo assim, você pode fazer o que você quiser com usando somente oPHP. Isto é possível através da documentação da API que é muito bemfeita e está disponível para todos.

O PHP4 tem duas partes principais:* O mecanismo (tecnologia) Zend é parte do pacote PHP que mantém o registro de requisições,processa arquivos de scripting, e manipula variáveis e recursos.Sua homepage pode ser acessada em http://www.zend.com/.* PHPimplementa 90% das funcionalidades vistas pelo usuário final.Provê um extenso conjunto de módulos tais como: MySQL, ODBC esuporte ao XML.

O que é GTK+?

Índice

A história do GTK+O que o GTK+ faz?

A história do GTK+

GTK+ foi originalmente desenvolvido para o GIMP, o GNU ImageManipulation Program. GTK+ faz parte do GIMP Tool Kit. GTK+ surgiudestes proprósitos iniciais e agora é parte central do Gnome, e noprojeto de ambiente para Desktop do GNU. GTK+ também tem sido portadopara o BeOS e Win32, fazendo da linguagem a escolha perfeita para seusar como base para a extensão do PHP, mantendo o PHP multi-plataformadentro do possível e permitindo a criação de aplicações "windowned" emPHP para Linux, BeOS e Windows.

O que o GTK+ faz?

GTK+ é um conjunto de bibliotecas escritas em C para criar interfacesgráficas. Tem uma arquitetura orientada a objetos desenvolvida em trêsbibliotecas:

* GLibprovê várias ferramentas para se usar quando se programa com GTK+.* GDKfunções para construção de janelas em baixo nível.* GTKprovê um conjunto de widgets para se usar quando se cria uma GUI.

Page 5: Apostila PHP GTK

Agradecimentos

A pessoa que Eu gostaria de agradecer muito é James Henstridge, oautor do PyGTK (Python GTK+ Bindings). Os conselhos e ajuda dele foramde grande valia durante o desenvolvimento desta extensão, e uma grandequantidade do código fonte é baseada ou inspirada no código que eledesenvolveu para o PyGTK.

Eu também gostaria de agradecer à Equipe do PHP por fazerem estamaravilhosa linguagem, e a Equipe do GTK+ por desenvolver o que temsido a melhor ferramenta GUI baseada em C.

Andrei Zmievski - Fev 2001

Começando...

Esta parte do manual explica o processo de instalação do PHP-GTK.

Índice

Obtendo a Última VersãoInstalando o PHP-GTK no WindowsInstalando o PHP-GTK no UnixComo usar o PHP-GTK?

Obtendo a Última Versão

O código fonte e os binários do PHP-GTK 1.0.0 para Windows podem serencontrados em http://gtk.php.net/. Usuários do fonte precisarãotambém verificar a última versão do PHP usando o CVS - vejahttp://www.php.net/anoncvs.php.

Instalando o PHP-GTK no Windows

Índice

Baixando o PHP-GTKLayout da Distribuição dos BináriosComo instalar

Baixando o PHP-GTK

Baixe os binários do PHP-GTK 1.0.0 para win32 em http://gtk.php.net/.Você talvez queira verificar se tem tem a última versão dos fontes doservidor CVS do php.net. Veja http://www.php.net/anoncvs.php para maisinformações.

Layout da Distribuição dos Binários

A distribuição binária do PHP-GTK contém a seguinte estrutura:* \php4 » arquivos binários do PHP e do PHP-GTK 1.0.0* \winnt » o arquivo padrão php.ini* \winnt\system32 » binários do GTK+ usados pela extensão* \test » alguns exemplos demonstrando o uso do PHP-GTK

Page 6: Apostila PHP GTK

* README.TXT

Como instalar

1. Se esta é uma nova instalação você deve criar um diretório chamadoC:\php4 e copiar os arquivos da pasta \php4 para este diretório.Se você já tem uma instalação do PHP (por exemplo, com Apache) oupretende ter uma, você irá precisar por seu arquivo php.ini látambém. Os arquivos que estão nesta pasta pasta, por padrão, sãorelacionados ao PHP ou PHP-GTK e irão todos precisar seratualizads de tempos em tempos. Note que C:\php4 é o diretóriopadrão e se você instalar o PHP-GTK em outro lugar, você precisaráespecificar o caminho completo na diretiva "extension_dir" nacópia do arquivo php.ini que será usado pelo PHP.2. Copie o conteúdo da pasta \winnt\system32 para o seu diretóriosystem32. No Windows NT e Windows 2000 o diretório éC:\winnt\system32. No Windows 95/98 ele pode ser C:\Windows\systemou C:\Windows\system32, escolha o seu. Este grupo de arquivos érelacionado ao GTK e não é estritamente necessária atualizá-losaté que o PHP-GTK2 seja lançado.3. Copie o conteúdo de \test para o local onde você quer rodar seusscripts (ex: C:\php4\test).

Instalando o PHP-GTK no Unix

Usuários do Debian podem fazer download do binário do PHP-GTK emhttp://www.debian.org/.

O PHP-GTK depende do número de pacotes, que precisam ser instaladosantes de começar a instalação do PHP-GTK:* PHP versão 4.3.4 ou maior* As bibliotecas GTK+, disponíveis em http://www.gtk.org/download/,ou você pode usar a versão que vem nos pacotes do seu sistema, ex:gtk e gtk-devel.* libtool, automake e autoconf. A combinação da libtool 1.4.2, doautomake 1.4 e do autoconf 2.13 são as melhores para se trabalhar;isto pode variar dependendo das versões e combinações que foremfeitas.* Para opções extras, baixe as bibliotecas GtkHTML, as bibliotecasGtkScintilla e bibliotecas Gdk-Pixbuf. Novamente, você pode pegaros pacotes disponíveis para seu sistema, só tenha certeza de quevocê instalou o pacote de desenvolvedor. A GtkHTML, tem um grandenúmero de sub-depedências, ex: GAL, que pode ser obtida em Gnomeftp site.

Nós sugerimos que você baixe a última versão do fonte emhttp://gtk.php.net/ ou à partir do CVS (anonimamente)http://www.php.net/anoncvs.php.

Rode o script ./buildconf que está dentro da distribuição. Ele iráconfigurar os arquivos necessários e criar o script configure. Eletambém irá verificar se você tem uma versão correta do GTK+ 1.2.x(1.2.6 ou superior, disponível em http://www.gtk.org/download/) eoutros arquivos obrigatórios para a compilação, após isto, ele criará

Page 7: Apostila PHP GTK

os arquivos Makefiles necessários.

O comando ./configure pode também ser usado para adicionar widgetsadicionais, ex: ./configure --enable-scintilla --enable-gtkhtml. Paralistar todas as opções disponíveis use: ./configure --help. Lembre-seque cada widget adicional pode ter um número de depedênciasnecessárias que você irá precisar para que o PHP-GTK compile comsucesso.

Fincalmente, rode o comando make para compilar a extensão. Algunsarquivos fontes são gerados à partir de arquivos .def pelo gerador decódigo. Se você ver mensagens como "Could not write...", istosignifica que os objetos ou característidas listadas no GTK+ não sãosuportados ainda. Se a compilação for bem sucedida, rode o comandomake install para instalar a extensão em seu diretório padrão deextensões do PHP (geralmente /usr/local/lib/php/extensions).

Solução de problemas: problemas comuns com os comandos ./configure oumake* ./ltconfig: ltconfig : No such file or directory, configure:error: libtool configure failed ocorre quando não se tem um doscomponentes da libtool, automake ou autoconf instalado.* ./aclocal.m4:813: error: m4_defn: undefined: _m4_divert_diversionocorre quando há incompatibilidade de versões do autoconf, veja arecomendação das versões acima.* php_gtk+.c:33: parse error before `TSRMLS_DC' ocorre quando umaversão antiga do PHP é encontrada pelo sistema de geração ouquando se está tentando compilar o php-gtk com uma versão antigado PHP - por favor atualize a sua versão do PHP para 4.3.4 paraconsertar este problema.* gen_gtk.c:1: parse error before '<' é causada por um erro nogerador de código. Geralmente este problema é solucionadoadicionando-se a linha ini_set("memory_limit", "32M"); na primeiralinha do arquivo generator/generator.php. Você irá precisarremover todos os arquivos gen_* de todos os diretórios após fazeresta alteração.* checking for gnome-config... Unknown library `gtkhtml' (from./configure) ocorre devido ao uso de um arquivo de cabeçalhoantigo ou não disponível - se você instalou o PHP-GTK usando viarpm ou pacotes simalres do seu sistema você precisará dos pacotes-devel.* Unable to find -lgal ou mensagens simalres à esta, são causadaspela falta da biblioteca gal-devel ou alguma biblioteca simular àesta. Geralmente ela é uma sub-dependência de alguns widgets maiscomplexos, como o gtkhtml.

Para testar se a extensão foi instalada com sucesso, tente rodar umdos scripts de exemplo do diretório test/ directory. Estes scriptstambém demonstram alguns modos nos quais o PHP-GTK e suas extensõespodem ser usadas.

Como usar o PHP-GTK?

Aplicações em PHP-GTK podem ser iniciadas à partir da linha de comando

Page 8: Apostila PHP GTK

(ou um arquivo batch) usando esta sintaxe: C:\php4\php -qC:\caminho\para\o\script\php-gtk.php

Elementos Básicos

Esta parte do manual fala sobre os elementos essênciais do PHP-GTK emostra exemplos básicos sobre seu uso.

Índice

Widgets e ContainersSinais e Callbacks

Widgets e Containers

Índice

O que são Widgets?O que são Containers?

O que são Widgets?

widget é qualquer interface com o usuário, e é muito usado no mundo X.Um widget pode ser uma caixa de texto, rótulo, quadro, janela ouqualquer outro componente GUI. GTK widgets são todos derivados daclasse GtkWidget, e herdam os métodos, sinais e propriedadesimplementados nela.

Do ponto de vista da programação um widget tem cinco partes duranteseu ciclo de vida:

1. CriaçãoNo PHP-GTK isto é feito criando um objeto, ex: $janela = &newGtkWindow();2. ColocaçãoNesta etapa o widget é adicional à um container. Isto é feito noPHP-GTK usando a sintaxe $container->add($widget);.3. Conexão com o SinalNesta etapa as funções de callback são configuradas. Um exemplodisto seria: $widget->connect("evento", "minha_func_focus"); ,onde "evento" é um estado pré-definido tal como "clicked" e"minha_func_focus" é uma subrotina que é chamada quando este"evento" ocorre.4. ExposiçãoNesta etapa é definidoo se o widget está visível ou não para ousuário. Para mostrar o widget ao usuário usa-se: $widget->show();e para escondê-lo usa-se: $widget->hide();.5. DestruiçãoA destruição ocorre quando a função gtk::main_quit() é chamada.Todas as ações que são necessárias aqui são tratadas internamente.

O que são Containers?

Um container é simplesmente um widget que é capaz de conter outro

Page 9: Apostila PHP GTK

widget. A maioria dos wigets caem dentro desta classe; exemplos óbviosdisso são as classes GtkWindow, GtkTable e GtkBox. Exceto por estapropriedade eles são exatamente como qualquer outro widget, e podemser adicionados outros containers, bem como filhos dos widgets do seupróprio tipo. Eles são derivados da classe base GtkContainer, que éderivada da classe GtkWidget.

Sinais e Callbacks

Índice

O que são Signals?O que são Callbacks?Herança dos sinaisConectando SinaisUsando Parâmetros PersonalizadosSinais e Eventos

O que são Signals?

Sinais são notificações emitidas pelos widgets.

Quando programando Graphical User Interfaces (GUI), é freqüentementenecessário responder às ações realizadas pelo usuário ou iniciadaspelo programa. GNOME e GTK+ fazem isto através do uso de sinais.Sinais são usados para informar ao programa que alguma coisaaconteceu. Um sinal pode ser, por exemplo, um usuário clicando em umGtkButton, ou uma alteração sendo feito nos valores de GtkAdjustment.

Um programa pode, por exemplo, fazer com que a clase GtkAdjustmentemita seu sinal "value-changed" quando um dos wigets alterar um deseus valores. Este sinal em particular é usado tanto internamentequanto externamente na classe GtkAdjustment, para que não seja semprenecessário escrever este sinal em seu código, digamos, para que aclasse GtkProgressBar poder usá-lo. Uma situação bem óbvia podeocorrer quando um usuário clica em uma instância da classe GtkButton,causando a emição do sinal "clicked" pelo botão. Como programdor, vocêpode configurar uma callbacks para reagir à qualquer sinal emitido porum widget.

O que são Callbacks?

Callbacks são funções que são invocadas quando sinais são emitidos porum widgets.

Callbacks são funções que são pré-definidas pelo programador parareagir à sinais emitidos por widgets. Você especifica a função quedeve ser chamada conectando-a ao sinal.

Uma callback é também conhecida como um método do sinal da função. Elapode ser o evento padrão dos widgets ou um evento definido pelousuário, isto é, uma função escrita pelo programador.

Herança dos sinais

Page 10: Apostila PHP GTK

O sinais são herdados dos objetos, bem como seus métodos também. Umwidget pode emitir qualquer um dos sinais que seu objeto (anterior)tenha definido, bem como seus próprios sinais específicos.

Nos casos onde o sinal não é relevante para o widget mas é herdado porele, não será emitida nenhuma mensagem de erro quando o sinal échamado - mas igualmente, não haverá nenhuma necessidade do widgetemitir este sinal em particular.

Conectando Sinais

Conexões Simples

Para reagir à um sinal você deve conectá-lo especificando a função decallback que o PHP-GTK terá de chamar quando este sinal for emitido.

Conectar uma função ao sinal é feito chamando-se o método connect() doobjeto.

A função que você registra como sendo callback para o sinal deve ter oprotótipo (prototype) correto. Para saber qual prototype você de usarveja ele na seção de reference do manual.

Por exemplo, se você quiser conectar o sinal "clicked" você devedefinir uma função que aceita um parâmetro, que será o botão que foiclicado.

O código abaixo mostra como você deve criar uma janela, adicionar umbotão à ela, esperar que ele seja clicado, e então, quando o botão forclicado, abrir uma GtkWindow contendo uma mensagem.

Exemplo 2.1. Sinais e Callbacks<?phpdl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')) ||die("Não foi possível carregar o módulo!\n");function desligar(){print("Desligando...\n");gtk::main_quit();}

function voce_clicou($botao){$janela = &new GtkWindow();$rotulo = &new GtkLabel("Você clicou no botão");$janela->add($rotulo);$janela->connect("destroy","desligar");$janela->show_all();return false;}

$janela = &new GtkWindow();$janela->connect("destroy", "desligar");

Page 11: Apostila PHP GTK

$janela->set_border_width(10);

$botao = &new GtkButton("Clique Me!!");$botao->connect("clicked", "voce_clicou");$janela->add($botao);

$janela->show_all();

gtk::main();

?>

A parte importante aqui é onde nós chamamos $botao->connect();. Ométodo "connect" aqui é registrado à função de callback voce_clicou()que irá ser invocada quando o sinal "clicked" é emitido pelo widgetGtkButton. Nós também registramos a função desligar() como sendo umevento para o sinal "destroy" para ambas as janelas para que assim nóspossamos finalizar o programa corretamente.

Múltpiplas Conexões

Com o PHP-GTK você pode registrar mais de uma função para ser chamadaquando um sinal é emitido por um widget. Ito permite à você configuraruma série de funções para serem chamadas em respsta à uma açãoexperada.

Quando mais de uma função é conectada à um sinal, as funções sãochamadas na ordem em que foram registradas quando aquele sinal éemitido.

Exemplo 2.2. Ordem do Sinal da Callback<?phpdl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')) ||die("Não foi possível carregar o módulo!\n");

function primeira($botao){print "Primeira função foi chamada.\n";}

function segunda($botao){print "Segunda função foi chamada.\n";}

$janela = &new GtkWindow();$janela->connect_object("destroy", array("gtk","main_quit"));

$botao = &new GtkButton("Clique Me!!");$botao->connect("clicked","primeira");$botao->connect("clicked","segunda");$janela->add($botao);

Page 12: Apostila PHP GTK

$janela->show_all();

gtk::main();

?>

No exemplo acima nós conectamos duas funções para o sinal "clicked" deum botão. À primeira chamada ao método connect() conecta o sinal"clicked" à função primeira(), a segunda chamada ao sinal "clicked"conecta-se à função segunda().

A saída para este programa seria:Primeira funþÒo foi chamada.Segunda funþÒo foi chamada.

Usando Parâmetros Personalizados

Passando dados personalizadso como parâmetro

Quando se está conectando sinais, é possível adicionar um parâmetropersonalizado adicional para à callback. Isto é útil quando se querpassar um objeto que você quer usar para executar uma ação, para a suafunção de callback.

Por eemplo, quando um botão é pressionado nós podemos destruir ainstância pai da GtkWindow à qual uma instância de GtkButton podeadicionada.

Você pode fazer isto incluindo um terceiro parâmetro adicional àchamada do método connect() . Este terceiro parâmetro será passadopara o seu manipulador de sinal de sua função como sendo o últimoparâmetro da callback.

Exemplo 2.3. Usando parâmetros personalizados com o método connect() .<?phpdl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')) ||die("Não foi possível carregar o módulo!\n");

function botao_clicado($botao, $janela){$janela->destroy();gtk::main_quit();}

$janela = &new GtkWindow();

$botao = &new GtkButton("sair");$botao->connect("clicked","botao_clicado", $janela);

$janela->add($botao);$janela->show_all();

gtk::main();

Page 13: Apostila PHP GTK

?>

No código acima você pode ver que nós passamos não somente a variável$botao, uma instância da classe GtkButton, para o sinal "clicked" mastambém passamos a variável $janela, uma instância da classe GtkWindow.Isto permite à nós chamar o método da janela destroy() .

Você pode ter quantos parâmetros personalizados desejar.

Ao passar a variável $botao como parâmetro objeto da chamada e avariável $janela como sendo nosso parâmetro personalizado, nós podemosusar a mesma callback para mais de um GtkButton em mais de umaGtkWindow. Note que os nomes dados aos parâmetros junto com a callbacksão irrelevantes fora da função de callback; o PHP-GTk escolhe asposições dos parâmetros nas chamadas ao método connect* e passa estasvariáveis listadas na declaração da callback como sendo arrays, paraque qualquer instância da conexão usando a mesmo estrutura deparâmetro possam usar a mesma callback. Isto é demonstrado no códigoabaixo usando um único parâmetro personalizado, mas é igualmenteválido para mais de um.

Exemplo 2.4. Usando a mesma callback para mais de uma janela<?phpdl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')) ||die("Não foi possível carregar o módulo!\n");

function botao_clicado($botao, $janela){$janela->set_title("entitulada");}

$janela1 = &new GtkWindow();$janela1->connect_object("destroy", array("gtk", "main_quit"));$janela2 = &new GtkWindow();$janela2->connect_object("destroy", array("gtk", "main_quit"));

$botao1 = &new GtkButton("clique em mim");$botao2 = &new GtkButton("ou em mim");

$botao1->connect("clicked", "botao_clicado", $janela1);$botao2->connect("clicked", "botao_clicado", $janela2);

$janela1->add($botao1);$janela2->add($botao2);

$janela1->show_all();$janela2->show_all();

gtk::main();

?>

Usando o método connect_object*

Page 14: Apostila PHP GTK

Ambos connect_object() e connect_object_after() permitem à você passarum objeto diferente do objeto que está sendo chamado como primeiroparâmetro da sua função callback. Isto é muito usado para chamarfunções estáticas do PHP-GTK, como (por exemplo) a funçãogtk::main_quit() :

Exemplo 2.5. Usando o método connect_object() para especificiar umafunção embitida como sendo uma função de callback. <?phpdl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')) ||die("Não foi possível carregar o módulo!\n");

$janela = &new GtkWindow();$janela->connect_object("destroy", array("gtk", "main_quit"));$janela->show();

gtk::main();

?>

Isto também poderia ser feito chamando qualquer função estática oumétodo usando a sintaxe de expressão (array) gtkobject::method.

Isto também significa que você pode ter uma callback para múltiplossinais. Por exemplo; você pode criar uma janela contendo (desde quecontenha os widgets e containers necessários) um GtkMenuBar, umaGtkToolbar e um GtkButton. Quando Sair é escolhido pelo usuário dentreum desses widgets, uma função de "desligamento" pode ser invocadapassando uma instância de GtkWindow como primeiro parâmetro,permitindo que a janela possa ser destruída de qualquer uma dasconexões. A função de callback e as conexões nesta instância podem serparecidas com esta:

Exemplo 2.6. Usando o método connect_object() para passar outro objetocomo primeiro parâmetro. <?phpdl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')) ||die("Não foi possível carregar o módulo!\n");

function destruir_janela($janela){$janela->destroy();gtk::main_quit();}

$janela = &new GtkWindow();$botao_sair = &new GtkButton("Sair");$botao_sair->connect_object("clicked", "destruir_janela", $janela);$janela->add($botao_sair);$janela->show_all();

gtk::main();?>

Page 15: Apostila PHP GTK

O método connect_after* permite que os callbacks "rodem após" o eventodo sinal padrão. Isto pode ser muito útil em algumas situações; porexemplo, onde você quer destriuir somente uma das muitas janelas emuma dada circunstância. Entretanto, o método connect_after* somenteirão funcionar quando o sinal for criado no código fonte GTK usando aflag GTK_RUN_LAST. O sinal "destroy" e todos os sinais 'evento' temesta flag; além dela o único jeito de fazer esta verificação é testaro sinal usando o PHP-GTK ou lendo o código fonte do GTK.

Exemplo 2.7. Usando o método connect_after() . <?phpdl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')) ||die("Não foi possível carregar o módulo!\n");

function rotina_sair($janela){print("Desligando...\n");gtk::main_quit();}

$janela1 = &new GtkWindow();$janela1->set_title("Sair do loop principal");$janela1->connect("destroy", "rotina_sair");

$janela2 = &new GtkWindow();$janela2->set_title("Destruir esta janela");$janela2->connect_after("destroy", "rotina_sair");

$janela1->show();$janela2->show();

gtk::main();

?>

Veja também: GtkObject, connect_after() connect_object() econnect_object_after() .

Sinais e Eventos

Sinais GTK, Eventos GDK.

Sinais não são eventos, e eventos não são sinais. Um sinal é umamensagem emitida pela instância de um GtkObject em resposta à algumelemento pré-determinado em seu ambiente (programa), ex: uma açãofeita pelo usuário final, ou uma instrução de um método ou função.Sinais são sempre programados no código, internamente dentro do GTK ouexternamento pelo programador PHP-GTK.

Eventos, por outro lado, são um circuito continuo dos impulsos queenviam mensagens a respeito das mudanças no ambiente (programa) nossistemas de janelas. O loop principal do GTK é feito através destecircuito de evnetos, e uma série de outras coisas.

Page 16: Apostila PHP GTK

não é possível conectar uma função de callback à um GdkEventdiretamente.

Qualquer widget que tenha sua própria GdkWindow pode capturar eventosque são relevantes à ela. Widgets falham na GdkWindow - aquelascriados com a flag GTK_NO_WINDOW - não podem fazer isso, à não ser queeles tenham um GtkEventBox - um widget criado para este propósitoespecífico. Há ocasiões quando é útil poder capturar eventos; umexemplo óbvio seria a criação de um GtkToolTips que é provocado quandoo widget captura o evento GDK_ENTER_NOTIFY e destruído quando o mesmowidget captura o evento GDK_LEAVE_NOTIFY.

Entretanto não é possível usar um evento para chamar uma callback domesmo modo como é feito com o sinal, há uma série de sinais derivadosda classe GtkWidget conhecidos como sinais 'evento'. Estas sãomaneiras eficientes de descriar um evento em termos de sinal,permitindo que callbacks sejam provocados diretamente através dacaptura de ocorrências da maioria dos GdkEventTypes. O objetoGtkTooltips usa o método connect_object e o sinal genérico (evento) afim de monitorar o widget.

O conceito de eventos não é muito fácil. Por favor copie, cole e rodeo script a seguir a fim de ter uma idéia do que são eventos em umwiget quando estão em ação.

Exemplo 2.8. Demonstração do fluxo de eventos usando a classeGtkButton <?phpdl("php_gtk." . (strstr(PHP_OS, "WIN") ? "dll" :"so")) ||die("Não foi possível carregar o módulo!\n");

function mostrar_tipo_de_evento($botao, $evento, $texto){$tipo_de_evento = $evento->type;$texto_a_inserir = $texto->get_length();$texto->freeze();switch($tipo_de_evento) {case 2:$texto->insert_text("GDK_EXPOSE\n", $texto_a_inserir);break;case 3:$texto->insert_text("GDK_MOTION_NOTIFY\n", $texto_a_inserir);break;case 4:$texto->insert_text("GDK_BUTTON_PRESS\n", $texto_a_inserir);break;case 5:$texto->insert_text("GDK_2BUTTON_PRESS\n", $texto_a_inserir);$botao->hide();break;case 7:$texto->insert_text("GDK_BUTTON_RELEASE\n", $texto_a_inserir);break;

Page 17: Apostila PHP GTK

case 8:$texto->insert_text("GDK_KEY_PRESS\n", $texto_a_inserir);break;case 9:$texto->insert_text("GDK_KEY_RELEASE\n", $texto_a_inserir);break;case 10:$texto->insert_text("GDK_ENTER_NOTIFY\n", $texto_a_inserir);break;case 11:$texto->insert_text("GDK_LEAVE_NOTIFY\n", $texto_a_inserir);break;case 12:$texto->insert_text("GDK_FOCUS_CHANGE\n", $texto_a_inserir);break;case 14:$texto->insert_text("GDK_MAP\n", $texto_a_inserir);break;case 15:$texto->insert_text("GDK_UNMAP\n", $texto_a_inserir);$botao->destroy();$amarelo = &new GdkColor("#FFFFFF");$preto = &new GdkColor("#000000");$texto->insert(NULL, $amarelo, $preto,"\n* EVENTOS DO GDK E SINAIS DO GTK - stream de fundo vs mensagens de primeiro plano *\n* A maioria dos GdkEventTypes fazem parte dos sinais do GTK, conhecidos como sinais do 'evento', implementados na GtkWidget. Os tipos que aparecem na tela estão lá porque o GtkButton foi programado para emitir o sinal genérico 'evento' cada vez que ele capturar um dos eventos stream do GDK que são feitos no loop principal do GTK. Em qualquer um dos casos, o GdkEvent foi passado como sendo umparâmetro de callback sendo assim que ele pode ser ter os valores dos seus tipos numerado para que a função possa tratá-los. Veja acima uma série de valores de eventos que foram capturados durante sua recente interação com o widget GtkButton. *\n* Por favor, note que a maioria dos sinais do GTK NÃO correspondem aos eventosGDK nem aqui nem em nenhuma outra maneira! Por exemplo, o sinal de conexão \$botao->connect('pressed', 'qualquer_coisa'); não tem relação com o evento GDK_BUTTON_PRESS que é gerado, que no caso, refere-se ao botão do mouse ativiado e nãoao sinal 'pressed' do GtkButton. *\n");break;}$texto->thaw();return false;}

$janela = &new GtkWindow();$janela->set_position(GTK_WIN_POS_CENTER);$janela->set_default_size((gdk::screen_width()/1.5), (gdk::screen_height()-20))

Page 18: Apostila PHP GTK

;$janela->connect_object("destroy", array("gtk", "main_quit"));$janela->realize();

$caixa = &new GtkVBox(false, 5);$janela->add($caixa);$scrljan = &new GtkScrolledWindow();$caixa->pack_start($scrljan, true, true, 0);$texto = &new GtkText();$scrljan->add($texto);

$botao = &new GtkButton("Clique aqui duas vezes para obter informações..");$botao->add_events(GDK_ALL_EVENTS_MASK);$botao->connect("event", "mostrar_tipo_de_evento", $texto);$caixa->pack_end($botao, false, false, 5);

$janela->show_all();

gtk::main();

?>

Tutoriais sobre PHP-GTK_________________________________________________________________

Índice

Tutorial do Olá MundoPixmapsTranslation of PHP-Gtk applicationsDrag'n'drop with files

Tutorial do Olá Mundo

Quando você está começando à aprender uma linguage de programação, oprimeiro programa que você escreve é o famoso 'olá mundo'. Então,apenas para não sermos do contra, o primeiro tutorial neste manualserá um tutorial do 'olá mundo'!

Durante todos os tutorials nós esperamos que você sinta-se como seestive-se programando em PHP. Os tutoriais são projetados para dar aousuário uma idéia de como usar o PHP-GTK, e as idéias e técnicas portrás dele.

Neste tutorial você irá criar uma simples janela com o texto "OláMundo!" dentro dela.

Nós começaremos mostrando o programa e depois iremos explicar cadalinha do programa, dando uma idéia geral sobre uma aplicação bembásica em PHP-GTK.

Exemplo 1.1. Código do programa Olá Mundo em PHP-GTK<?php

Page 19: Apostila PHP GTK

if (!class_exists('gtk')) {if (strtoupper(substr(PHP_OS, 0,3) == 'WIN'))dl('php_gtk.dll');elsedl('php_gtk.so');}

function deletar_evento(){return false;}

function desligar(){print("Desligando...\n");gtk::main_quit();}

function ola(){global $janela;print "Olá Mundo";$janela->destroy();}

$janela = &new GtkWindow();$janela->connect('destroy', 'desligar');$janela->connect('delete-event', 'deletar_evento');$janela->set_border_width(10);

$botao = &new GtkButton('Olá Mundo!');$botao->connect('clicked', 'hello');$janela->add($botao);

$janela->show_all();

gtk::main();

?>

Exemplo 1.2. Carregando o PHP-GTK<?php

if (!class_exists('gtk')) {if (strtoupper(substr(PHP_OS, 0,3) == 'WIN'))dl('php_gtk.dll');elsedl('php_gtk.so');}

?>

Estas primeiras linhas fazem a checagem para ver se a extensão doPHP-GTK já está disponível para uso, caso não ela é carregada. Isto é

Page 20: Apostila PHP GTK

feito usando os comandos dl('php_gtk.dll'); ou dl('php_gtk.so'); noWindows e Linux respectivamente.

Exemplo 1.3. A função deletar_evento()<?php

function deletar_evento(){return false;}

?>

A função deletar_evento() é registrada como sendo um evento (vejaabaixo) do sinal "delete-event". Ela retorna false, dizendo ao PHP-GTKpara disparar o alimentador para os eventos padrões de sinais, o quenesse caso é o método destroy() . Se a função retornar true, o PHP-GTKpararia o alimentador padrão para os eventos de sinais que estive-serodando no momento. É bom saber isto se você precisa escrever umafunção definida pelo usuário para substituir a função destroy() - porexemplo, para produzir uma caixa de diálogo de confirmação onde ousuário pretende fechar um aplicativo.

Não é estritamente necessário que o retorno seja false para conectar osinal "delete-event" ao método destroy() . É possível não especificarnenhum comportamento para os sinais "delete-event" de todas asjanelas, desde que o evento de sinal do "destroy" seja tratadocorretamente, como está sendo feito aqui.

Exemplo 1.4. A função desligar()<?php

function desligar(){print("Desligando...\n");gtk::main_quit();}

?>

A função desligar() é registrada como sendo um evento para o sinal"destroy". A função imprime o texto "Desligando...\n" para o console edepois chama a função estática gtk::main_quit() .

Exemplo 1.5. A função ola()<?php

function ola(){global $janela;print "Olá Mundo!\n";$janela->destroy();}

Page 21: Apostila PHP GTK

?>

A função ola() é registrada como sendo um evento para o sinal"clicked" do botão. Ela torna global a variável $janela sendo assimela pode ser acessada como sendo uma instância da classe GtkWindowcriada mais abaixo no script. Ela então imprime o texto "Olá Mundo!"para o console antes de chamar o método destroy() da janela, o qualdispara o sinal "destroy", que depois chama a função shutdown().

Uma outra maneira da função ola() acessar a variável $janela é se avariável fosse passada como um parâmetro personalizado.

Exemplo 1.6. Configurando a Janela<?php

$janela = &new GtkWindow();$janela->connect('destroy', 'desligar');$janela->connect('delete-event', 'deletar_evento');$janela->set_border_width(10);

?>

As quatro linhas seguintes configuram a janela. Primeiramente n´socriamos uma instânica da classe GtkWindow. Uma vez criada com sucesso,nós chamamos o método connect() da janela para que possamos registrara função desligar() como sendo um evento do sinal "destroy" e a afunção deletar_evento() como sendo um evento do sinal "delete-event".Finalmente, nós chamamos o método set_border_width() para configurar ajanela com uma bordar de 10-pixels na instância da classe GtkWindowque nós havíamos criamos.

Exemplo 1.7. Configurando o Botão<?php

$botao = &new GtkButton('Olá Mundo!');$botao->connect('clicked', 'ola');$janela->add($botao);

$janela->show_all();

?>

Estas três linhas criam e configuram um botão. A primeira linha docódigo acima faz com que criemos uma instância da classe GtkButton. Oargumento passado para o construtor é o texto que queremos mostrar natela - no caso "Olá Mundo!". Nós então chamamos o método connect()para registrar a função ola() que definimos anteriormente, como sendoum evento do sinal "clicked". Finalmente nós adicionamos o botão paraa janela que nós criamos anteriormente chamando o método add() daclasse GtkContainer que está em $janela, e depois mostramos tudo queestá em $janela chamando o método show_all() , que também é umainstância de nossa classe GtkWindow.

Exemplo 1.8. A chamada ao gtk::main

Page 22: Apostila PHP GTK

<?php

gtk::main();

?>

A última linha do script chama a função estática gtk::main. Isto dizao PHP-GTK que nós finalizamos nossa interface, e que o loop principalpode ser iniciado para que os eventos disparados pelo usuáriointerajam com as nossas funções callback (ola(), desligar(), etc.) quedefinimos no script, e também com que várias ações sejam realizadas.

Pixmaps

Índice

How To Use Pixmaps in PHP-GTKAbout XPMImage related php-gtk functionsExamplesOther things you can do with pixmaps

How To Use Pixmaps in PHP-GTK

Many applications are using graphical images: A nice splash screenindicating that the program is loading; the toolbar with new, open andother well-known icons or the nifty about dialog. This HowTo describeswhat you need to use images in your own php-gtk applications.

About XPM

The standard way to deal with images and mainly icons in php-gtk isusing XPMs. XPM is short for XPixMap and describes an ASCII imageformat as well as a C library for dealing with the images. Originallythe format was developed because the X libraries just had support for1 bit depth images, the XBM (X BitMap) which is just not enough forapplications on a graphical system. Although it is has not beenstandardized by the X Consortium, it is the de facto standard foricons in X. In this tutorial we will omit the library because we'reprogramming in php and not in C.

The XPM format was designed to fit the special need for icons:* Icons are usually small* Icons may need to be drawn differently depending on whether theyare being displayed on color or monochrome screen* Icons may want to define symbolic colors, such as "Foreground" and"Background", that can be changed depending on the context inwhich the icons are used.* Icons can be of any shape, not just rectangular.

The XPM image format

An icon in XPM format is just an ASCII file which can be edited with anormal text editor. As it was designed to be included in C sources,

Page 23: Apostila PHP GTK

the only content is a C styled array with the image information. Youcan even have comments in the file - it's C source.

The basic format of a XPM is an array composed as follows:/* XPM */static char * <pixmap name>[] = {"Values-string","Colors-strings","Pixel-strings"};

Note that the header comment with only the word XPM in it is required.I leave out the Extension strings as we don't need them here.

The Values-string has to contain four integer values:1. Width of the image in pixels2. Height of the image in pixels3. Number of colors in the image4. Number of characters per pixel

Example: "16 16 8 1" defines an icon of size 16x16 pixels with 8colors and 1 char for defining one pixel.

First it may be strange that one has to define the number ofcharacters per pixel, but this becomes clear if you consider thefollowing: Each pixel is represented by a char, e.g. "b", with "b"having the color blue. Now you want another pixel in red, so you giveit the char "r" and define "r" being the red color. The ASCII standarddefines 128 chars, and with an extended codepage of 255 you wouldstill be limited to somewhat of 250 colors (you can't use quotes andsome other chars). To avoid this limitation you can use more than onechar to describe a pixel and a color: If you use 2 chars per pixel itis possible to use about 250x250 = 62500 colors by defining pairs ofchars to be one color, e.g. "mr" being a medium red and 'db' being adark blue.

The Colors-strings contains as many strings as there are colors. Eachstring has the following format:"chars key value [key value]*"

The chars value is one or more chars (depending on the number ofcharacters setting) which define the "pixel name" of the color. A keycan have one of the following values:* m for a monochrome visual* c for a color visual* g4 for 4-level grayscale* g for grayscale with more than 4 levels* s for a symbolic name

The color value itself can be the following:* A color name, e.g. "blue"* A hexadecimal RGB code like in HTML, e.h. '#FF8000'* The string "None" which means the transparent color

Page 24: Apostila PHP GTK

Different key-value pairs can be concatenated to optimize the imagefor several visuals"r m white c red","b m black c blue"

The example would define two colors: A color named "r" which isdisplayed white on a monochrome display and red on a color display.The second is named "b" and is displayed black on a monochrome visualand blue on a color one.

The Pixel-strings are height string of which each is width * chars perpixel wide.

Exemplo 2.1. A small sample XPM/* XPM */static char * dot[] = {"5 5 2 1",". c None","X c Red"," X "," XXX ","XXXXX"," XXX "," X ",};

As you probably don't want to create these images by hand, here is alist of programs which support the creation of XPMs:* The GIMP which should be on every linux system; it is alsoavailable for Windows.* ImageMagick is a command line tool which can be used tobatch-convert other image formats to xpm. Available for unix andWindows.

Image related php-gtk functions

Images are displayed using the GtkPixmap widget which has to beinvoked with two parameters; a map of type GdkPixmap and a mask oftype GdkBitmap. The map defines all the pixels with its colors, and asthe map is not able to contain transparent color information, the maskis a map of 1's and 0's telling which pixel is transparent and whichnot.

There are two functions dedicated to reading of XPM images:* gdk::pixmap_create_from_xpm which creates a pixmap and a maskdirectly from a file.* gdk::pixmap_create_from_xpm_d which creates the pixmap and maskfrom an array.

As both functions are identical in usage, I will describepixmap_create_from_xpm_d only.list( $pixmap, $mask) = gdk::pixmap_create_from_xpm_d( $objWindow->window, $colTransparent, $arImage);

Page 25: Apostila PHP GTK

The function returns an array of size 2: the first is the map with allthe pixels and colors, and the second is the mask with transparencyinformation. We store them in two different variables here, althoughyou can just use an array.

The first parameter, $objWindow->window is the GdkWindow of yourapplication's window. Please make sure that the GdkWindow exists byshowing the GtkWindow or by calling the realize() function.

The second parameter, $colTransparent defines which color thetransparent color (color None) will get if the pixmask is not usedwhen creating e.g. the GtkPixmap.

The third parameter is the name of the image file(pixmap_create_from_xpm), or a normal php array with the structure asdescribed in the XPM standard (pixmap_create_from_xpm_d).

Examples

The following example shows how to create a pixmap from an array,creating a button and attaching the pixmap along with the label to thebutton. It also uses the enter and leave signals to change the pixmapwhen the button is hovered by the mouse. The icon of the window isset, too - but this won't work on Windows.

Exemplo 2.2. Pixmap button & highlighting example<?phpif (!extension_loaded('gtk')) {dl('php_gtk.' . PHP_SHLIB_SUFFIX);}

$arXPMs['ok'] = array("32 32 7 1"," c None",". c #005F00", "+ c #008A00", "@ c #00BB00","# c #00E000", "$ c #00F709", "% c #4BE24A"," "," "," "," "," @@"," +@++","+@ +@+@+ ","+++ @+@++. ","+@++ ++@%++. "," +%++ +++%%@+ "," +%@++ +++%%%++ "," +@##++ +++%$$%++ "," +$$%++ +++@$$$$++ "," +#$$@+. +++@$$$$%++ "," +@$$$#+.+.+@$$$$$#+. "," .+$$$$@+.@#$$$$$@+. "," +##$$$####$$$$++. "," .@$#####$$###@.. ",

Page 26: Apostila PHP GTK

" .+##########+.. "," .#########+.. "," .@##@#@#@.. "," .+@##@#@+. "," ..#@@#@.. "," .@@@@.. "," .+@+.. "," .++.. "," ... "," .. "," "," "," "," ");

$arXPMs['inbox'] = array("16 16 6 1"," c None" , ". c #028800", "+ c #995700","@ c #82E61D", "# c #FFBE58", "$ c #FCEF8E"," "," .... "," .$$$$. "," .@@@@. "," .@@@@. "," ..@@@@.. "," .@@@@@@@@. "," .@@@@@@. "," .@.@@. "," ..@. ","+++ .. +++","+$$+ +$$+","+$$++++++++++$$+","+$#$$$$$$$$$$$#+","+$#############+","++++++++++++++++");

$window =& new GtkWindow();$window->set_title('pixmaps');$window->set_default_size(200, 100);$window->connect_object('destroy', array('gtk', 'main_quit'));$window->realize();

$clTransparentTest =& new GdkColor('#000000');

$arPxTest = gdk::pixmap_create_from_xpm_d($window->window, $clTransparentTest,$arXPMs['ok']);

$btnTest =& new GtkButton();$pxmTest =& new GtkPixmap($arPxTest[0], $arPxTest[1]);$lblTest =& new GtkLabel('Button with icon');$hboxTest =& new GtkHBox();$hboxTest->pack_start($pxmTest);

Page 27: Apostila PHP GTK

$hboxTest->pack_end($lblTest);$btnTest->add($hboxTest);

// hovering the button changes the image// to a highlighted version of itselffunction changePixmap( $btnTest, $strAction, &$pixmap){$hbox = $btnTest->child;$arChildren = $hbox->children();$hbox->remove($arChildren[0]);$hbox->pack_start($pixmap);$pixmap->show();

// underline the label$lblTest = $arChildren[1];$strPattern = '';if ($strAction == 'enter') {$strPattern = '________________';}

$lblTest->set_pattern($strPattern);}

// generate a highlighted picture from the original$arXPMs['high'] = $arXPMs['ok'];$arData = explode(' ', $arXPMs['high'][0]);$nColors = $arData[2];

// change all colors | we know the first color is transparentfor ($nA = 2; $nA < $nColors + 1; $nA++) {$arData = explode(' #', $arXPMs['high'][$nA]);// the following code is taken from PEAR::Image_Color$degree = 40;$color[] = hexdec(substr($arData[1], 0, 2));$color[] = hexdec(substr($arData[1], 2, 2));$color[] = hexdec(substr($arData[1], 4, 2));for ($x = 0; $x < 3; $x++) {if (($color[$x] + $degree) < 256) {if (($color1[$x] + $degree) > -1) {$color[$x] += $degree;} else {$color[$x] = 0;}} else {$color[$x] = 255;}}$arData[1] = sprintf('%02X%02X%02X', $color[0], $color[1], $color[2]);$arXPMs['high'][$nA] = implode(' #', $arData);}

$arPxTestH = gdk::pixmap_create_from_xpm_d($window->window, null, $arXPMs['high']);$pxmTestHigh =& new GtkPixmap($arPxTestH[0], $arPxTestH[1]);

Page 28: Apostila PHP GTK

$btnTest->connect('enter', 'changePixmap', 'enter', $pxmTestHigh);$btnTest->connect('leave', 'changePixmap', 'leave', $pxmTest);

$alBtn =& new GtkAlignment(0.5, 0.5, 0, 0);$alBtn->add($btnTest);

list($pxWindow, $maskWindow) = gdk::pixmap_create_from_xpm_d($window->window, null, $arXPMs['inbox']);$gdkwindow = $window->window;$gdkwindow->set_icon($gdkwindow, $pxWindow, $maskWindow);

$window->add($alBtn);$window->show_all();

gtk::main();

?>

Other things you can do with pixmaps

Shaping widgets

Another nice thing you can do with a pixmap or better a pixmask isdefining your own shape for widgets or whole windows. This means youcan have can have a button with rounded corners or a window with"holes" in it by using the shape_combine_mask method of GtkWidget.

Symbolic names

The XPM specification allows the use of symbolic color names in thexpm. For example, if your pixmap should display a symbol of a button,the button could have the real button colors: light shadow, darkshadow and the normal flat surface color. The only thing you wouldhave to do is writing something like this:/* XPM */static char * button[] = {"16 16 3 1",". s foreground","X s lightshadow","X s darkshadow","...pixels here"};

Unfortunately, the Gtk, unlike CDE, does not support symbolic colornames. So you cannot use them unless you define your own names andwrite a function which replaces the symbolic names by real colors.

Other graphics formats

Pixmaps are nice, but what if you want to display a jpg or png image?As the gtk libraries don't support this, you could use the gd or gd2to transform the image to xpm format and go on with the normal xpmfunctions.

Page 29: Apostila PHP GTK

Translation of PHP-Gtk applications

Índice

What it's all aboutGettextUsing gettext in PHPTranslating glade filesSome additional notes

What it's all about

You want to distribute your PHP-Gtk application on your webpage andmake it reach a large number of people. The only problem between yourapplication and all the people is not the functionality; your app isperfect in this way: It is the language.

Even if some people don't or don't want to realize: There are lots ofpeople out there which would use your program but don't speak yourlanguage or the language in which your program is. It would benonsense to ignore them. The solution is easy: Translate the program.Just find a person who speaks the target language and who is willingto translate all the things your program contains.

But the next step: How do you - technically - translate your program?.There are many ideas how to do this:* Take the program sources (and glade files), make a copy andtranslate them. This is the worst method: If you want to extendyour program you will have to change every single file of the 20translated versions. Even worse: The translator does not have tobe a programmer, and requiring him to change the sources can causeserious problems with the code: Does the translator know how todeal with escape sequences? What if the translator accidentlyremoves a end-quote? The program just won't run, and you will havea nice time searching bugs in all the translated versions.* Using a big array which contains all the texts. Put it in atranslation file for each language, and include the right one whenthe program starts. This has the advantage that translation andcode are segregated strictly, and the translator will have an easyjob. Just what if you are using glade files for your GUIdefinitions? You would have to make a copy of each glade file andtranslate it; causing the same problems as the first option. Oryou load every single widget and change the text of it. This wouldrequire a function in your application which knew every singlewidget and the string in the big translation array it shouldapply.* Using the text as normal in the sources, but having it and theglade files translated automatically. Impossible? No, the gettextextension of php makes this scenario real.

This tutorial shows how to translate your apps the most easy way usingthe gettext extension of php. It covers normal string translation aswell as the translation of glade files and shows a solution if the

Page 30: Apostila PHP GTK

gettext extension is not available on the user's system.

Exemplo 3.1. The first and worst translation method//file: cart.en.php//...echo '<title>Shopping cart</title>';//...echo 'Copying file ' . $strFile1 . ' to ' . $strFile2;//...

//file: cart.de.php//...echo '<title>Einkaufswagen</title>';//...echo 'Kopiere Datei ' . $strFile1 . ' nach ' . $strFile2;//...

Exemplo 3.2. The second method//file: translationl.en.inc$arTranslation = array('title' => 'Shopping cart','copy_1' => 'Copying file ','copy_2' => ' to ');

//file: translationl.de.inc$arTranslation = array('title' => 'Einkaufswagen','copy_1' => 'Kopiere Datei ','copy_2' => ' nach ');

//file: cart.phpinclude_once( 'translation.en.inc');//...echo '<title>' . $arTranslation['title'] . '</title>';//...echo $arTranslation['copy_1'] . $strFile1 . $arTranslation['copy_2'] . $strFile2;//...

Exemplo 3.3. Using gettext//file: cart.php//...echo '<title>' . _('Shopping cart') . '</title>';//...echo sprintf( _('Copying file %s to %s'), $strFile1, $strFile2);//...

Gettext

Gettext is a set of tools, guidelines, directory naming conventionsand a runtime library. Together, they are the standard way totranslate applications in the *nix environment. Don't be scared, you

Page 31: Apostila PHP GTK

can use it on Windows as well. I don't want to describe the wholesystem here, just the things you need to translate your application -you can read the manual if you want more information.

The gettext system translates replaces whole strings with thetranslated equivalent in the target language. This means that youdon't have to invent array keys but can keep the original string inthe code, which makes it a lot more readable. The translations arewritten down in so-called .po-files, where "po" stands for "portableobject". They contain the human-readable and human-editabletranslation of the strings to the target language. To speed up thelive-translation process when the application is running, they arecompiled to .mo-files, "machine object" files. These files arerequired to be in a certain directory structure:locale-language-LC_MESSAGES-applicationname-.po-applicationname-.modeLC_MESSAGESappwizard.poappwizard.motuxracer.moesLC_MESSAGESappwizard.motuxracer.mo

Here you see, that there are 2 languages: german (de) and spanish(es). They contain both the machine object files for the applicationsAppWizard and TuxRacer. The original translation files are notrequired for running the program, and so only the german translationfile for AppWizard is here. If you are on *nix, have a look at/usr/share/locale/. You will find the translations for many programsthere.

A .mo translation file looks the following way:# SOME DESCRIPTIVE TITLE.# Copyright (C) YEAR Free Software Foundation, Inc.# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.##, fuzzymsgid ""msgstr """Project-Id-Version: PACKAGE VERSION\n""POT-Creation-Date: 2002-04-06 21:44-0500\n""PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n""Last-Translator: FULL NAME <EMAIL@ADDRESS>\n""Language-Team: LANGUAGE <[email protected]>\n""MIME-Version: 1.0\n""Content-Type: text/plain; charset=CHARSET\n""Content-Transfer-Encoding: 8bit\n"#: gettext_example.php:12

Page 32: Apostila PHP GTK

msgid "A string to be translated would go here"msgstr "Ein string der übersetzt werden soll steht hier"

msgid "Really quit?"msgstr "Wirklich beenden?"

msgid "This is a glade language test script"msgstr "Dies ist ein Glade Sprach-test script"

The first 15 lines are a sort of header, which can be customized withdates and authors. After the header the translation begins: msgidtells what shall be translated, and msgstr is the translation. Specialchars in strings can be escaped as usually with a backslash \.

After translating your strings, you have to compiles the .po to .mofiles which is done by using the msgfmt tool. On *nix, you should haveit somewhere; on Windows you can get it with mingw32. Go to theLC_MESSAGES directory and just call the compiler:# msgfmt messages.po

which will result in a messages.mo file.

Using gettext in PHP

Our sample application is the following:

Exemplo 3.4. Basic sample application<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

$window = &new GtkWindow();$window->set_default_size( 300, 200);$window->set_title( 'window title');

$vbox = &new GtkVBox();$label = &new GtkLabel( 'Translation test');$button = &new GtkButton( 'Close window');

$vbox->pack_start( $label);$vbox->pack_start( $button);

$window->connect_object('destroy', array('gtk', 'main_quit'));$button->connect_object( 'clicked', array( 'gtk', 'main_quit'));

$window->add( $vbox);$window->show_all();gtk::main();?>

We would like to have the "window title", "Translation test" and"Close window".

Page 33: Apostila PHP GTK

The first thing you need to do is loading the gettext extension, thesame way you load php-gtk. This can be done by doing aif( !extension_loaded( 'gettext')) {if( !@dl( 'php_gettext.' . PHP_SHLIB_SUFFIX)) {die( 'gettext is not available');}}

The next step is to set the location of the translation file; this canbe done withbindtextdomain( 'testapp', './locale');

which would assume that the .mo file would be in{CURRENT_DIR}/locale/{LANGUAGE}/LC_MESSAGES/testapp.mo. Language couldbe de_DE, depending on your system setting - this can be overriddenwithputenv( "LANG=" . 'de_DE'); //required on windows, because setlocale doesn't really worksetlocale( LC_ALL, 'de_DE');

. You should always use the language identifier together with thecountry code as there have been problems on some systems when usingonly de or DE. The {CURRENT_DIR} assumes that the application isstarted with the working directory in the application directory; butthis can't always be expected. It would be better to do abindtextdomain( 'testapp', dirname( __FILE __) . '/locale');

which uses the real location of the current file as base.

After setting the file location, you have to tell gettext which"domain" (part of the translation files) you want to use, in our caseit would be "testapp":textdomain( 'testapp');

This allows you to use multiple domains in the same program, and youcan switch between them everytime.

The translation of strings if an ease: There is the function gettextwhich takes a string as parameter and returns the translated version.To make the code more readable, there is an alias of the function: _(underscore). Now we change our code and get the following:

Exemplo 3.5. Basic example with translation<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}putenv( "LANG=" . 'de_DE'); //required on windows, because setlocale doesn't really worksetlocale( LC_ALL, 'de_DE');

if( !function_exists( 'gettext')) {//gettext not automatically loadedif( !@dl( 'php_gettext.' . PHP_SHLIB_SUFFIX)) {

Page 34: Apostila PHP GTK

die( 'gettext extension is not available!');}}bindtextdomain( 'testapp', dirname( __FILE__) . '/locale');textdomain( 'testapp');

$window = &new GtkWindow();$window->set_default_size( 300, 200);$window->set_title( _('window title'));

$vbox = &new GtkVBox();$label = &new GtkLabel( _('Translation test'));$button = &new GtkButton( gettext('Close window'));

$vbox->pack_start( $label);$vbox->pack_start( $button);

$window->connect_object('destroy', array('gtk', 'main_quit'));$button->connect_object( 'clicked', array( 'gtk', 'main_quit'));

$window->add( $vbox);$window->show_all();gtk::main();?>

When you start your application, you will see nothing translated: Weforgot the translation file. Just copy the following intolocale/de/LC_MESSAGES/testapp.po:# PHP-Gtk translation tutorial# Copyright (C) 2004 PHP-Gtk documentation team# Christian Weiske <[email protected]>, 2004.##, fuzzymsgid ""msgstr """Project-Id-Version: 0.1N\n""POT-Creation-Date: 2004-09-15 07:12+0100\n""PO-Revision-Date: 2004-09-15 07:12+0100\n""Last-Translator: Christian Weiske <[email protected]>\n""Language-Team: PHP-Gtk doc team germany <[email protected]>\n""MIME-Version: 1.0\n""Content-Type: text/plain; charset=iso-8859-1\n""Content-Transfer-Encoding: 8bit\n"#: gettext_example.php:20msgid "window title"msgstr "Fenstertitel"

msgid "Translation test"msgstr "UEbersetzungstest"

msgid "Close window"msgstr "Fenster schliessen"

After doing this, compile it with msgfmt testapp.po and move the

Page 35: Apostila PHP GTK

created messages.mo to testapp.mo. Start the application again - youwill see the app in the german language.

Translating glade files

Translating the strings in a glade file is really easy: If gettext isavailable and loaded and the textdomain is set, it automatically looksfor translations - you just have to provide the translated .mo file inthe right directory.

Here is the example application, but with glade:

Exemplo 3.6. Basic example with glade<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}putenv( "LANG=" . 'de_DE'); //required on windows, because setlocale doesn't worksetlocale( LC_ALL, 'de_DE');

if( !function_exists( 'gettext')) {//gettext not automatically loadedif( !@dl( 'php_gettext.' . PHP_SHLIB_SUFFIX)) {die( 'gettext extension is not available!');}}

bindtextdomain( 'testapp', dirname( __FILE__) . '/locale');textdomain( 'testapp');

$glade =& new GladeXML( dirname( __FILE__) . "/example-tutorial-translation.glade");

$window = $glade->get_widget( 'window');$button = $glade->get_widget( 'button');

$window->connect_object('destroy', array('gtk', 'main_quit'));$button->connect_object( 'clicked', array( 'gtk', 'main_quit'));

gtk::main();?>

and here the glade file:<?xml version="1.0"?><GTK-Interface><project><name>example-tutorial-translation</name><program_name>example-tutorial-translation</program_name><directory></directory><source_directory>src</source_directory><pixmaps_directory>pixmaps</pixmaps_directory><language>C</language>

Page 36: Apostila PHP GTK

<gnome_support>False</gnome_support><gettext_support>False</gettext_support><output_translatable_strings>True</output_translatable_strings><translatable_strings_file>example-tutorial-translation.strings</translatable_strings_file></project><widget><class>GtkWindow</class><name>window</name><title>window title</title><type>GTK_WINDOW_TOPLEVEL</type><position>GTK_WIN_POS_NONE</position><modal>False</modal><default_width>300</default_width><default_height>200</default_height><allow_shrink>False</allow_shrink><allow_grow>True</allow_grow><auto_shrink>False</auto_shrink>

<widget><class>GtkVBox</class><name>vbox</name><homogeneous>False</homogeneous><spacing>0</spacing>

<widget><class>GtkLabel</class><name>label</name><label>Translation test</label><justify>GTK_JUSTIFY_CENTER</justify><wrap>False</wrap><xalign>0.5</xalign><yalign>0.5</yalign><xpad>0</xpad><ypad>0</ypad><child><padding>0</padding><expand>True</expand><fill>True</fill></child></widget>

<widget><class>GtkButton</class><name>button</name><can_focus>True</can_focus><label>Close window</label><relief>GTK_RELIEF_NORMAL</relief><child><padding>0</padding><expand>False</expand><fill>False</fill></child></widget>

Page 37: Apostila PHP GTK

</widget></widget></GTK-Interface>

Just start the script, and you will see a translated application asthe string contents are already in testapp.mo.

It can be quite boring to collect all the strings which shall betranslated in a .glade file. Glade has the option "save translatablestrings" which creates a file containing all the strings from a gladefile - it's easy to convert them to a .po file.

Some additional notes

What to do if gettext is not available?

As you can't assume that gettext is available and you want your app towork in all environments, you should provide a gettext "emulation":function _( $strString){return $strString;}function bindtextdomain( $strString){return $strString;}function dcgettext( $strDomain, $strString, $nCategory){ return $strString;}function dgettext( $strDomain, $strMessage) { return $strString;}function gettext( $strString){return $strString;}function textdomain( $strString){return $strString;}

Replace the linedie( 'gettext extension is not available!');

with the code above, and the gettext functions will be available evenif gettext is not installed. They just return the original text, sothat the apps will be in the original language.

Dynamic sentences

In message boxes you ask the user "There is a file "{FILENAME}". Whatshall I do with it?". The {FILENAME} could be on a totally differentposition in one of the target languages, so splitting the string isnot an option.

The solution is to replace the "{FILENAME}" with "%s" and use thesprintf() php function with the string. That way your strings are asportable as possible.

Strings with multiple lines

Sometimes you need to translate strings which are on multiple lines:They are noted in .po files on multiple lines as well, with quotes atthe beginning and the end of a line. The first line is just a "".msgid """this is a""multiline string"msgstr """Dies ist ein""mehrzeiliger String"

Page 38: Apostila PHP GTK

Drag'n'drop with files

Índice

About this tutorialThe application frameReceiving dropsThe text/uri-list formatDragging files to other applicationsThe final programFurther ideas

About this tutorial

This tutorial will show you how to use the drag'n'drop functions ofPHP-Gtk and go deep into the topic "Files and DnD", as this is not astrivial as it might look.

In the tutorial we will exemplarily build an application which hasonly one widget, a tree. This tree can be filled with branches andleaves by dropping files over it. You will be able to drag those filesback to different programs, at least if you are not on Windows. Short:We build a bookmark manager for files.

The application frame

As the creation of the application's frame is not our topic, here isit:

Exemplo 4.1. A working application skeleton<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

$fdnd = new FileDragNDrop();$fdnd->buildDialog();$fdnd->display();

class FileDragNDrop{function buildDialog() {$this->window =& new GtkWindow();$this->window->set_title('FileDropper');$this->window->set_default_size(200, 200);$this->window->connect_object('destroy', array('gtk', 'main_quit'));

$scrolledwindow =& new GtkScrolledWindow();$scrolledwindow->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);$this->window->add($scrolledwindow);

$this->tree =& new GtkCTree(3, 0, array('title', 'url', 'local path'));

Page 39: Apostila PHP GTK

$scrolledwindow->add($this->tree);

$this->ndToplevel = $this->tree->insert_node(null, null, array('Files','', ''), 0, null, null, null, null, false, true);

$this->tree->connect('key-press-event', array(&$this, 'keyPressedTree'));}

function display() {$this->window->show_all();gtk::main();}

function keyPressedTree($tree, $objEvent) {if ($objEvent->keyval == GDK_KEY_Delete) {$ar = $tree->selection;foreach ($ar as $objNode) {$tree->remove_node($objNode);}}}}?>

The code creates a window with a GtkCTree containing the root node. Itis possible to delete nodes from the tree by pressing the "delete"key.

Receiving drops

After you have decided which type of data you want your application orwidget to accept, you tell everyone about this decision by calling thedrag_dest_set() function on the target widget. Since we want to acceptfiles, we need the text/uri-list target type:

Exemplo 4.2. Accepting files//at the end of buildDialog()$this->targets = array( array( 'text/uri-list', 0, 0));$this->tree->drag_dest_set( GTK_DEST_DEFAULT_ALL, $this->targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);

Let's analyze the code:* We want to accept files, and files indicated by the text/uri-listtarget type.* Drags shall be accepted from everywhere, so we give the secondparameter a 0 and the third the same, as we don't have todistinguish between different target types.* The tree shall accept both copy and move requests. The move isvery important, as all KDE applications (including Konqueror) seemto give their files to targets only which accept the move action.

The Gtk knows now that we accept files, but we didn't say what to do

Page 40: Apostila PHP GTK

with them. The plan is to add all the dropped files to the tree, aschildren of the currently selected item.

Exemplo 4.3. Handling the files//at the end of buildDialog()$this->tree->connect( 'drag-data-received', array( &$this, 'dragDataReceived'));

// a new functionfunction dragDataReceived($tree, $context , $x, $y, $data , $info, $time) {if (count($tree->selection) != 1) {$parent = $this->ndToplevel;} else {$parent = $tree->selection[0];}

$strData = $data->data;$arData = explode("\n", $strData);foreach ($arData as $strLine) {$strFile = trim($strLine);if ($strFile == '') { continue; }$tree->insert_node($parent, null, array(basename(urldecode($strFile)),$strFile, ''), 0, null, null, null, null, false, true);}$tree->columns_autosize();}

If you drop some files from your favorite file manager, you will seethat they are added to the list.

The text/uri-list format

text/uri-list is the standard file listing format for drag and drop.It is specified as follows:* A list of files, each file per line.* Each line ends with a \r\n, carriage return and newline.* File names have to be valid, url-encoded URIs (Unique resourceidentifier).

Exemplo 4.4. Example text/uri-list stringfile://localhost/usr/bin/opera[\r\n]file://localhost/c:/programs/myfile.txt[\r\n]file://server/data/software.xml[\r\n]http://gtk.php.net/apps/[\r\n]

Now the world would not be the world we know if everyone followed thespecs. As written on freedesktop.org, there are plenty ofimplementations, and most cook their own soup.

Let it be the \r\n at the end of the line; most programs do that rightbut some just forget the \r. Some forget the terminating characters onthe last line. That is easy to catch when implementing the routine inphp.

Page 41: Apostila PHP GTK

The real problem are the URIs, or what the programmers think URIs are.

URIs of some programs* Remember the correct URI: file://host/path/to/file* KDE programs like Konqueror, Kate and so pass the following:file:/path/to/file. Only one "/", totally incorrect.* Nautilus, gnome's file manager, passes file:///path/to/file.Correct protocol (file://), hostname left out (not really correct,but nearly), and the full path with a leading "/".* The Opera browser gives you a file://path/to/file. What is that? Arelative filename?* When dragging links from Firefox, you get the same as withNautilus: file:///path/to/file, nearly correct. The crux: Firefoxdoesn't drop files to targets accepting text/uri-list, only totext/plain ones.* The Windows' explorer is nearly correct like Nautilus and Firefox,giving a file:///c:/path/to/file.

And beside files, there can be real URLs like http://gtk.php.net inthe list. What does that tell us? We will have a hard time finding outwhere the file really is.

We need a solution which accepts URIs that follow the standard AND isable to guess what files the source applications mean if the URI doesnot conform to the standard. The resulting code seems to be awkward,but that's the price for compatibility:

Exemplo 4.5. Convert a (misformed) URI to a local path/*** converts a file path gotten from a text/uri-list* drop to a usable local filepath* @param string The line from the uri-list* @return string The usable local filepath*/function getPathFromUrilistEntry( $strUriFile){$strUriFile = urldecode($strUriFile);//should be URL-encoded$bUrl = false;if (substr($strUriFile, 0, 5) == 'file:'){ //(maybe buggy) file protocolif (substr($strUriFile, 0, 17) == 'file://localhost/') {//correct implementation$strFile = substr($strUriFile, 16);} else if (substr($strUriFile, 0, 8) == 'file:///') {//no hostname, but three slashes - nearly correct$strFile = substr($strUriFile, 7);} else if ($strUriFile[5] == '/') {//theoretically, the hostname should be the first//but no one implements it$strUriFile = substr($strUriFile, 5);for( $n = 1; $n < 5; $n++) {if ($strUriFile[$n] != '/') { break; }}$strUriFile = substr($strUriFile, $n - 1);

Page 42: Apostila PHP GTK

if (!file_exists($strUriFile)) {//perhaps a correct implementation with hostname???$strUriFileNoHost = strstr(substr($strUriFile, 1), '/');if (file_exists($strUriFileNoHost)) {//seems so$strUriFile = $strUriFileNoHost;}}$strFile = $strUriFile;} else {//NO slash after "file:" - what is that for a crappy program?$strFile = substr ($strUriFile, 5);}} else if (strstr($strUriFile, '://')) {//real protocol, but not file$strFile = $strUriFile;$bUrl = true;} else {//local file?$strFile = $strUriFile;}if (!$bUrl && $strFile[2] == ':' && $strFile[0] == '/') {//windows file path$strFile = str_replace('/', '\\', substr($strFile, 1));}return $strFile;}

Now that we have a nice conversion routine, we can extend our sourceto display the local path in the file tree:

Exemplo 4.6. Displaying the local file path in the tree$tree->insert_node($parent, null, array(basename(urldecode($strFile)), $strFile, $this->getPathFromUrilistEntry($strFile)), 0, null, null, null, null, false,true);

Dragging files to other applications

It seems that Gtk 1.x on windows allows you to receive drops fromother windows programs, but not to drag outside the application. Thismeans you can use DnD inside your PHP-Gtk application, but use droponly when communicating with other programs.

The good news: Unlike the drop problems, all tested programs(Konqueror, Kate, Firefox, Opera, Nautilus) seem to be able to handlecorrect URIs dragged to them in the right way. Even Firefox acceptstext/uri-list data.

The first step is again to tell the widget that it has the ability toact as a source for drag data. Furthermore, we need to provide thedata we want to drag, which can be done by connecting the widget tothe "drag-data-get" signal.

Exemplo 4.7. Setting up the drag source

Page 43: Apostila PHP GTK

//at the end of buildDialog()$this->tree->drag_source_set(GDK_BUTTON1_MASK, $this->targets, GDK_ACTION_COPY);$this->tree->connect('drag-data-get', array(&$this, 'dragDataGet'));

We told the widget the following:* Act as a drag source when the user uses the first (mostly left)mouse button* Provide one format for the dragging data, namely text/uri-list* Require the drop target to copy the file, not to move it.* When the target widget demands for the data, call the dragDataGetfunction of our class.

Next is to provide the data for the drop target in the dragDataGetfunction:

Exemplo 4.8. Setting the data to dragfunction dragDataGet( $tree, $context, $selection_data, $info, $time) {if( count( $tree->selection) < 1) { return false; }$node = $tree->selection[0];$file = $tree->node_get_text( $node, 2);if( $file == '') { return false; }$selection_data->set($selection_data->target, 8, urlencode($this->getUriFromFile($file)) . "\r\n");}

/*** converts a file name to a URI* useful to convert a file to the text/uri-list compatible format* @param string The file* @return string The URI*/function getUriFromFile( $strFile) {if (strstr($strFile, '://')) {//real URL$strUri = $strFile;} else {//normal fileif (substr($strFile, 1, 2) == ':\\') {//windows path c:\programs\bla\blu\file.bli$strUri = 'file://localhost/' . str_replace('\\', '/', $strFile);} else {//should be nice unix file//@fixme: convert relative names to absolute ones?$strUri = 'file://localhost' . realpath($strFile);}}return $strUri;}

The data are passed by overwriting the selection data via the set()method of the selection_data. As we want to follow the standards, thefile name has to be converted to a full-flagged url-encoded URI, withthe terminating \r\n at the end of the line. When nothing is selected

Page 44: Apostila PHP GTK

in the tree, we don't change the selection data.

When trying to drag a file to your favorite application, you will notethat nothing happens. Why? The URI passed to the program looks likethat: file%3A%2F%2Flocalhost%2Fdata%2Fphp-gtk. Yes, urlencode doesn'ttake care of the character's meaning in the URI. Now it would costsome effort to make a function which does a correct encoding whiletaking care of special characters, as http URIs can contain slashes ina parameter which would have to be encoded, but slashes in thefilename not. For that reason, only a simple back-translation of somechars is done after urlencoding the string:

Exemplo 4.9. urlencode replacementfunction pathurlencode($uri) {$uri = urlencode($uri);$uri = str_replace('%3A', ':', $uri);$uri = str_replace('%2F', '/', $uri);$uri = str_replace('%26', '&', $uri);$uri = str_replace('%40', '@', $uri);$uri = str_replace('%3A', ':', $uri);$uri = str_replace('%3F', '?', $uri);return $uri;}

With that, we can change our dragDataGet function:$selection_data->set($selection_data->target, 8, $this->pathurlencode($this->getUriFromFile($file)) . "\r\n");

The final program

<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

$fdnd = new FileDragNDrop();$fdnd->buildDialog();$fdnd->display();

class FileDragNDrop{function buildDialog() {$this->window =& new GtkWindow();$this->window->set_title('FileDropper');$this->window->set_default_size(200, 200);$this->window->connect_object('destroy', array('gtk', 'main_quit'));

$scrolledwindow =& new GtkScrolledWindow();$scrolledwindow->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);$this->window->add($scrolledwindow);

$this->tree =& new GtkCTree(3, 0, array('title', 'url', 'local path'));$scrolledwindow->add($this->tree);

Page 45: Apostila PHP GTK

$this->ndToplevel = $this->tree->insert_node(null, null, array('Files','', ''), 0, null, null, null, null, false, true);

$this->tree->connect('key-press-event', array(&$this, 'keyPressedTree'));$this->tree->connect( 'drag-data-received', array( &$this, 'dragDataReceived'));

$this->targets = array( array( 'text/uri-list', 0, 0));$this->tree->drag_dest_set( GTK_DEST_DEFAULT_ALL, $this->targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);

$this->tree->drag_source_set(GDK_BUTTON1_MASK, $this->targets, GDK_ACTION_COPY);$this->tree->connect('drag-data-get', array(&$this, 'dragDataGet'));}

function display() {$this->window->show_all();gtk::main();}

function keyPressedTree($tree, $objEvent) {if ($objEvent->keyval == GDK_KEY_Delete) {$ar = $tree->selection;foreach ($ar as $objNode) {$tree->remove_node($objNode);}}}

function dragDataReceived($tree, $context , $x, $y, $data , $info, $time) {if (count($tree->selection) != 1) {$parent = $this->ndToplevel;} else {$parent = $tree->selection[0];}

$strData = $data->data;$arData = explode("\n", $strData);foreach ($arData as $strLine) {$strFile = trim($strLine);if ($strFile == '') { continue; }$tree->insert_node($parent, null, array(basename(urldecode($strFile)), $strFile, $this->getPathFromUrilistEntry($strFile)), 0, null, null, null, null, false, true);}$tree->columns_autosize();}

/*** converts a file path gotten from a text/uri-list

Page 46: Apostila PHP GTK

* drop to a usable local filepath* @param string The line from the uri-list* @return string The usable local filepath*/function getPathFromUrilistEntry($strUriFile){$strUriFile = urldecode($strUriFile);//should be URL-encoded$bUrl = false;if (substr($strUriFile, 0, 5) == 'file:'){ //(maybe buggy) file protocolif (substr($strUriFile, 0, 17) == 'file://localhost/') {//correct implementation$strFile = substr($strUriFile, 16);} else if (substr($strUriFile, 0, 8) == 'file:///') {//no hostname, but three slashes - nearly correct$strFile = substr($strUriFile, 7);} else if ($strUriFile[5] == '/') {//theoretically, the hostname should be the first//but no one implements it$strUriFile = substr($strUriFile, 5);for( $n = 1; $n < 5; $n++) {if ($strUriFile[$n] != '/') { break; }}$strUriFile = substr($strUriFile, $n - 1);if (!file_exists($strUriFile)) {//perhaps a correct implementation with hostname???$strUriFileNoHost = strstr(substr($strUriFile, 1), '/');if (file_exists($strUriFileNoHost)) {//seems so$strUriFile = $strUriFileNoHost;}}$strFile = $strUriFile;} else {//NO slash after "file:" - what is that for a crappy program?$strFile = substr ($strUriFile, 5);}} else if (strstr($strUriFile, '://')) {//real protocol, but not file$strFile = $strUriFile;$bUrl = true;} else {//local file?$strFile = $strUriFile;}if (!$bUrl && $strFile[2] == ':' && $strFile[0] == '/') {//windows file path$strFile = str_replace('/', '\\', substr($strFile, 1));}return $strFile;}

function dragDataGet($tree, $context, $selection_data, $info, $time) {if( count( $tree->selection) < 1) { return false; }

Page 47: Apostila PHP GTK

$node = $tree->selection[0];$file = $tree->node_get_text( $node, 2);if( $file == '') { return false; }$selection_data->set($selection_data->target, 8, $this->pathurlencode($this->getUriFromFile($file)) . "\r\n");}

/*** converts a file name to a URI* useful to convert a file to the text/uri-list compatible format* @param string The file* @return string The URI*/function getUriFromFile($strFile) {if (strstr($strFile, '://')) {//real URL$strUri = $strFile;} else {//normal fileif (substr($strFile, 1, 2) == ':\\') {//windows path c:\programs\bla\blu\file.bli$strUri = 'file://localhost/' . str_replace('\\', '/', $strFile);} else {//should be nice unix file//@fixme: convert relative names to absolute ones?$strUri = 'file://localhost' . realpath($strFile);}}return $strUri;}

function pathurlencode($uri) {$uri = urlencode($uri);$uri = str_replace('%3A', ':', $uri);$uri = str_replace('%2F', '/', $uri);$uri = str_replace('%26', '&', $uri);$uri = str_replace('%40', '@', $uri);$uri = str_replace('%3A', ':', $uri);$uri = str_replace('%3F', '?', $uri);return $uri;}}?>

Further ideas

There is a PEAR package which solves exactly this problem:Gtk_FileDrop.

One could extend the application to save and load the tree's contents.The XBEL (XML Bookmark Exchange Language) would be very ideal forthis.

Page 48: Apostila PHP GTK

Make your applications user-friendly: Every text field which requiresa filename or a path should accept drops from file managers.

Guia de Referêcia_________________________________________________________________

Índice

Classes do GTKClasses do GDKGTK Extra ClassesGTK EnumsGDK EnumsGtkExtra EnumsClasses do GladeClasses do ScintillaClasses do Sqpane

Classes do GTK

Classes derivadas da Biblioteca GTK

Índice

GtkAccelGroupUma estrutura que contém dados da chave do acelerador.

GtkAccelLabelA label that can display an accelerator key next to the text.

GtkAdjustmentRepresents an adjustable bounded value.

GtkAlignmentA container that controls the alignment and scale of itschild.

GtkArrowAn arrow pointing in one of the four cardinal directions.

GtkAspectFrameA frame that constrains its child to a particular aspectratio.

GtkBinBase class for containers with just one child.

GtkBoxBase class for box containers.

GtkButtonA container widget that emits a signal when clicked on.

Page 49: Apostila PHP GTK

GtkButtonBoxBase class for GtkHButtonBox and GtkVButtonBox.

GtkCalendarA calendar offering dates that can be selected and marked.

GtkCheckButtonButton that displays a discrete toggle indicator.

GtkCheckMenuItemMenu item with a toggle indicator.

GtkCListA multi-columned scrolling list widget.

GtkColorSelectionWidget that allows for selection of a color.

GtkColorSelectionDialogStandard dialog box for selecting a color.

GtkComboText entry field with a dropdown list.

GtkContainerBase class for all container widgets.

GtkCTreeWidget that displays a hierarchical tree.

GtkCurveWidget that allows editing of a curve.

GtkDataAbstract base class for objects containing data.

GtkDialogWidget that eases creation of popup dialogs.

GtkDrawingAreaWidget for custom user interface elements.

GtkEditableBase class for text-editing widgets.

GtkEntryA single line text entry field.

GtkEventBoxWidget used to capture events for widgets with no GdkWindow.

GtkFileSelectionWidget for selecting a file or a directory.

Page 50: Apostila PHP GTK

GtkFixedContainer that retains the sizes and positions of itschildren.

GtkFontSelectionWidget for selecting fonts.

GtkFontSelectionDialogStandard dialog box for selecting fonts.

GtkFrameContainer with a decorative frame and an optional label.

GtkGammaCurveA subclass of GtkCurve for editing gamma curves.

GtkHandleBoxWidget for detachable window portions.

GtkHBoxHorizontal box container.

GtkHButtonBoxContainer for arranging a group of buttons horizontally.

GtkHPanedContainer with two panes arranged horizontally.

GtkHRulerHorizontal ruler.

GtkHScaleHorizontal slider widget for selecting a value from a range.

GtkHScrollbarHorizontal scrollbar.

GtkHSeparatorHorizontal separator.

GtkImageWidget for displaying a graphical image.

GtkInputDialogStandard dialog for configuring input devices.

GtkInvisibleInternally used widget which is not displayed.

GtkItemAbstract base class for GtkMenuItem, GtkListItem, andGtkTreeItem.

GtkItemFactory

Page 51: Apostila PHP GTK

A factory class for simplified menu creation.

GtkLabelWidget that displays a small amount of text.

GtkLayoutScrollable widget allowing multiple children in fixedpositions.

GtkListWidget displaying a list of selectable items.

GtkListItemA single element in a GtkList.

GtkMenuPopup container for menu items.

GtkMenuBarHorizontal container for menu items.

GtkMenuItemWidget used for item in menus.

GtkMenuShellAbstract base class for menu objects.

GtkMiscBase class for widgets having their own alignment andpadding.

GtkNotebookWidget that displays a set of pages with tabs.

GtkObjectThe base class of the PHP-GTK class hierarchy.

GtkOptionMenuWidget used to choose from a list of valid choices.

GtkPacker

GtkPanedBase class for widgets with two adjustable panes.

GtkPixmapWidget displaying a graphical image or icon.

GtkPlugToplevel widget for embedding into other processes.

GtkPreviewWidget to display RGB or grayscale data.

Page 52: Apostila PHP GTK

GtkProgressBase class for GtkProgressBar.

GtkProgressBarWidget that provides a visual indication of an operation'sprogress.

GtkRadioButtonButton that is part of a group, only one of which may beselected.

GtkRadioMenuItemMenu item that is part of a group, only one of which may beselected.

GtkRangeBase class for widgets that manipulate the value of aGtkAdjustment.

GtkRulerBase class for horizontal and vertical rulers.

GtkScaleBase class for GtkHScale and GtkVScale.

GtkScrollbarBase class for GtkHScrollbar and GtkVScrollbar.

GtkScrolledWindowAdds scrollbars to its child widget.

GtkSeparatorBase class for GtkHSeparator and GtkVSeparator.

GtkSocketContainer for widgets from other processes.

GtkSpinButtonWidget offering masked numerical entry and/or selection.

GtkStatusbarWidget that provides a way to report messages of minorimportance.

GtkStyleA class that determines the appearance of widgets.

GtkTableContainer that provides a flexible grid for packing itschildren.

GtkTearoffMenuItemMenu item used to tear off and reattach its menu.

Page 53: Apostila PHP GTK

GtkTextEditable text-display widget.

GtkTipsQueryDisplays help about widgets in the user interface.

GtkToggleButtonButton that retains its state.

GtkToolbarContainer that creates bars of buttons and other widgets.

GtkTooltipsAdds tooltips to other widgets.

GtkTreeWidget for displaying hierarchical information.

GtkTreeItemOne node of a GtkTree widget.

GtkVBoxVertical box container.

GtkVButtonBoxContainer for arranging a group of buttons vertically.

GtkViewportProvides scrolling capability for non-scrolling awarewidgets.

GtkVPanedContainer with two panes arranged vertically.

GtkVRulerVertical ruler.

GtkVScaleVertical slider widget for selecting a value from a range.

GtkVScrollbarVertical scrollbar.

GtkVSeparatorVertical separator.

GtkWidgetBase class for user interface elements.

GtkWindowWidget that provides windows for an application.

GTK Functions

Page 54: Apostila PHP GTK

GTK functions not belonging to any class.

GtkAccelGroup

Uma estrutura que contém dados da chave do acelerador.

Hierarquia do Objeto

GtkAccelGroup

Direct subclasses

None.

Descrição

GtkAccelGroup é uma classe que guarda os dados da chave doacelerador para todos os menus em uma GtkWindow. Ela é geralmentecolocada na janela para evitar confusões no aplicativo. Ainformação é guardada em uma tabela hash das entradasGtkAccelEntry, cada uma delas precisa ser criada para cadaacelerador. No PHP-GTK não há acesso direto à essas entradas.

Uma chave do acelerador é o mesmo que um atalho do teclado para umGtkMenuItem.

Veja também: add_accel_group() , add_accelerator() , GtkAccelLabel,GtkMenuItem.

Construtor

GtkAccelGroup ();

-- Fornece a estrutura necessária para guardar informações sobreuma tabela hash da chave do acelerador.

Métodos

lock()Trava a informação do grupo do accelerator.

unlock()Destrava a informação do grupo do accelerator.

GtkAccelGroup Construtor

GtkAccelGroup ();

Embora não faça parte da hierarquia dos objetos do GTK, a classeGtkAccelGroup pode ser construída da mesma maneira que a maioria dasclasses GTK, ex:$accelgroup = &new GtkAccelGroup();

Na maioria dos casos, GtkAccelGroup contruído poderia ser usado por

Page 55: Apostila PHP GTK

todos os menus pertencentes à janela de primeir nível(toplevel), epoderia ser adicionado usando a função add_accel_group() .

Não é sempre necessário criar um grupo de aceleradores desta menira. Ométodo GtkMenu chama a função ensure_uline_accel_group() da classeGtkAccelGroup usado internamente pelo menu para sublinhar osaceleradores (atalhos) pelo período de duração no qual o menu aparece.Se nenhum acelerador (atalho) for designiado, um novo grupo deaceleradores é criado e usado.

GtkAccelGroup::lock

void lock(void);

lock() impede futuras alterações nas entradas dos aceleradores naschamadas à classe GtkAccelGroup.

Para impedir que as chaves sejam alteradas, adicionadas ou removidasde uma única entrada GtkAccelEntry, use a função lock_accelerators() .

GtkAccelGroup::unlock

void unlock(void);

A função unlock() permite que as entradas dos aceleradores sejamalteradas, adicionadas ou removidas de um GtkAccelGroup previamentetravado.

Para permitir que uma chave secundária em uma lista GtkAccelEntry sejadesignada pelo usuário, use unlock_accelerators() .

GtkAccelLabel

A label that can display an accelerator key next to the text.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkMisc`-- GtkLabel`-- GtkAccelLabel

Direct subclasses

None.

Descrição

A GtkAccelLabel is a label capable of displaying any accelerator,modifier keys and signal set on a GtkMenuItem or similar widget.

In PHP-GTK this is effectively an internal widget, as anaccelerator label is created the moment a text string is passed to

Page 56: Apostila PHP GTK

a menu item. It is therefore unlikely that you will ever need touse the constructor, or any of the methods that this class directlyprovides. However, you may need to access it, for instance to parsean underline in a label's text string or to retrieve a menu'stextual content.

To access the GtkAccelLabel within an existing menu item, use thefollowing code:

$accel_label = $menu_item->child;

You will then be able to call most of the methods available to anew instance of a GtkAccelLabel.

Construtor

GtkAccelLabel (string string);

-- Constructs a label for displaying accelerator information.

Métodos

get_accel_width()Sets width to accommodate accelerator information.

set_accel_widget()Associates accelerator label with specified widget.

refetch()Recreates accelerator information.

GtkAccelLabel Construtor

GtkAccelLabel (string string);

This is effectively an internal construct in PHP-GTK, and there shouldbe no reason to use it unless you are writing an original widget.

See instead: GtkAccelLabel description, GtkLabel, add_accelerator() ,parse_uline() .

GtkAccelLabel::get_accel_width

int get_accel_width(void);

get_accel_width() is used within GTK+ in order to find the widthneeded by the target menu item to accommodate any acceleratorinformation displayed on the label.

There should be no reason to call this method unless you are writingan original widget.

GtkAccelLabel::set_accel_widget

Page 57: Apostila PHP GTK

void set_accel_widget( GtkWidget accel_widget );

set_accel_widget() is called within GTK+ at the point where aGtkAccelLabel is added to a menu item.

There should be no reason to call this method unless you are writingan original widget.

GtkAccelLabel::refetch

bool refetch(void);

refetch() is called within GTK+ in order to create new acceleratorinformation on a GtkAccelLabel following changes made to thatinformation.

There should be no reason to call this method unless you are writingan original widget.

GtkAdjustment

Represents an adjustable bounded value.

Hierarquia do Objeto

GtkObject`-- GtkData`-- GtkAdjustment

Direct subclasses

None.

Descrição

Any widget with a moving part has a GtkAdjustment at work behind itsomewhere. The adjustment object is used to limit the range ofvalues used by that moving part and also, in some widgets, todetermine the size of the steps by which the value may be increasedor decreased.

Construtor

GtkAdjustment (double value, double lower, double upper, doublestep_increment, double page_increment, double page_size);

-- Creates the basis for an adjustable widget.

Métodos

changed()Emits "changed" signal.

value_changed()

Page 58: Apostila PHP GTK

Emits "value-changed" signal.

clamp_page()Prevents bounds being exceeded.

set_value()Sets adjustment value.

Sinais

"changed"Emitted when a property other than value changes.

"value-changed"Emitted when the value of any property is changed.

Propriedades

value:Current value.

lower:Lower bound.

upper:Upper bound.

step_increment:Smaller incremental step value.

page_increment:Larger incremental step value.

page_size:Displayed area.

GtkAdjustment Construtor

GtkAdjustment (double value, double lower, double upper, doublestep_increment, double page_increment, double page_size);

Not every widget with an underlying adjustment object uses all six ofthe properties available. Where this occurs, null is not a validparameter option; all the adjustment parameters take double values,and you will need to set them as 0.0 where they are not needed.

The first parameter, value, is used by every widget with an adjustablepart. It represents the current value, and should be set to the valuethat you want to see displayed on opening. That setting will mostoften be 0.0 for percentage-based values (e.g. in a GtkProgressBar orin a GtkScrollbar), or 1.0 for literal values (e.g. in aGtkSpinButton).

lower and upper are the next two parameters. These represent the

Page 59: Apostila PHP GTK

limitations on the changing value; what is the lowest possible value,and what is the highest? Very often, the opening value is at the startof the rising scale, and will in that case be equal in value to thelower parameter setting. The way you choose to express the upper boundmay depend on the step_increment, which is defined in the fourthparameter when it is used at all. For instance, you could set theupper bound at 100.0 and increment the value in steps of 1.0, or setit at 1.0 and increment the value in steps of 0.01, depending on whatit is you are measuring or on your mood. Either goes the samedistance.

The final two parameters are page_increment and page_size. Where theseare used, the page_increment should have roughly 90% of the page_sizevalue. If you set the page size to the same value as the upper bound,a GtkScrollbar using these values will be extended so that it cannotbe scrolled. This can be a way to test whether your values are beingset. In some widgets - GtkCList, GtkLayout, GtkText and GtkViewport -the adjustment values can be set internally by scrolling-awarecontainer widgets, and these will override settings that are mademanually. A GtkScrollbar, conversely, has no adjustment values untilyou set them. Caveat: if a scrollbar shares a GtkAdjustment objectwith a widget that has overriding pre-set values, the scrollbar willshare the widget's adjustment settings as part of the process ofbecoming associated with that widget.

See also: GtkCList, GtkLayout, GtkProgressBar, GtkRange, GtkScale,GtkScrollbar, GtkScrolledWindow, GtkSpinButton, GtkText, GtkViewport,set_focus_hadjustment() , set_focus_vadjustment() .

GtkAdjustment::changed

void changed(void);

The changed() method makes the adjustment object fire the "changed"signal. This method is called internally whenever there is a change toany of the GtkAdjustment's properties.

GtkAdjustment::value_changed

void value_changed(void);

The value_changed() method is called internally whereever a signalemission is needed. It causes the "value-changed" signal to beemitted.

GtkAdjustment::clamp_page

void clamp_page(double lower, double upper);

clamp_page() is used internally to ensure that, if a page is beingscrolled down, the incremental value is not added to the end of thepage in terms of extra space at the bottom. It compares the set boundsand the page size with the current adjustment value and prevents themfrom adding up to more than the sum of their parts.

Page 60: Apostila PHP GTK

GtkAdjustment::set_value

void set_value(double value);

This method sets the adjustment value to a new level. It doesn't workwhere that value has already been set by a widget or widgets; widgetsettings always take precedence over manual settings. Where it isallowed, it causes a "value-changed" signal to be emitted, if thevalue is within the adjustment range.

Adjustable widgets generally have their own wrapper method for settingthe adjustment value, which should be used in preference where itexists.

changed

The "changed" signal is emitted when any of the properties other thanthe value is altered in a GtkAdjustment. This happens when theadjustment object has its values initialised or unset, or when awidget-owned scrollable object is resized, or when the adjustablewidget has a configure() method and calls it.

Note that a "value-changed" signal is also emitted under the samecircumstances, regardless of whether the value itself has beenchanged.

Função Callback

void callback(GtkAdjustment button);

value-changed

The "value-changed" signal is emitted when there is a change to any ofthe values in a GtkAdjustment. If the signal is accompanied by a"changed" emission, the altered property was something other thanvalue.

Função Callback

void callback(GtkAdjustment button);

GtkAdjustment::value

Access: Read OnlyType: double

The value property represents the current value of a GtkAdjustment.This may be initialized manually or, in some instances, by ascrolling-aware parent widget. Anything descended from GtkContainerfalls into the latter category.

In most cases, the value does not need any more attention after it hasbeen set, and will be incremented or decremented purely through

Page 61: Apostila PHP GTK

GdkEvents initiated by the user and controlled by the other adjustmentsettings. This property gives a means of accessing that informationacross all adjustable widgets.

GtkAdjustment::lower

Access: Read OnlyType: double

lower is the lowest value that will be accepted by the GtkAdjustment.

GtkAdjustment::upper

Access: Read OnlyType: double

upper is the highest value that will be accepted by the GtkAdjustment.

GtkAdjustment::step_increment

Access: Read OnlyType: double

The step_increment is the smaller of the two incremental values, mademanifest as a left click on a GtkSpinButton or GtkScrollbar arrow.This property is not used across the full range of adjustable widgets,and should return 0 when queried where this is the case.

GtkAdjustment::page_increment

Access: Read OnlyType: double

The page_increment is the larger of the two incremental values,responding to a right click on a GtkSpinButton arrow or as a click inthe trough belonging to a GtkScrollbar. This property is not usedacross the full range of adjustable widgets, and should return 0 whenqueried where this is the case.

GtkAdjustment::page_size

Access: Read OnlyType: double

The page_size is the area of (for instance) text that is displayed atany given time. This property is not used across the full range ofadjustable widgets, and should return 0 when queried where this is thecase.

GtkAlignment

A container that controls the alignment and scale of its child.

Hierarquia do Objeto

Page 62: Apostila PHP GTK

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkAlignment

Direct subclasses

None.

Descrição

GtkAlignment is a container class that controls the alignment andscale of its child widget, relative to its own dimensions.

Where the child widget has sizing responsibilites to a child orchildren of its own, these are fulfilled as a priority. Forexample, a GtkButton with a label will never be scaled down to theminimal size that the same widget with no label can; the label isthe button's child, and the button must honour its size request.

See also: GtkAspectFrame, GtkContainer, set_uposition() ,set_usize() .

Construtor

GtkAlignment (double xalign, double yalign, double xscale, doubleyscale);

-- Creates a container that determines its child's alignment andscale.

Métodos

set()Sets new parameter values for an existing GtkAlignment.

GtkAlignment Construtor

GtkAlignment (double xalign, double yalign, double xscale, doubleyscale);

A GtkAlignment object has control over its child widget's relativeposition and size. Each parameter is a double, with the minimum valuebeing 0.0 and the maximum value being 1.0.

The first two parameters describe the positioning of the child widget,with 0.0 being the left or top of the containing GtkAlignment and 1.0being the right or bottom. A child with the setting 0.5, 0.5 as thefirst two parameters is fully centred, with scale being taken intoconsideration throughout.

The second pair of parameters determine the scale of the child widget,

Page 63: Apostila PHP GTK

with the setting 1.0, 1.0 having the child widget fill the availablearea and the setting 0.0, 0.0 shrinking the child to its minimumpossible size. If the widget has no children of its own, that can bejust a couple of pixels in each direction - but it must obey the sizerequests made by any such children.

GtkAlignment::set

void set(double xalign, double yalign, double xscale, double yscale);

This method sets new values for a GtkAlignment's parameters.

Exemplo 1. Resetting GtkAlignment parameters. <?php

dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

function change_it($align, &$i) {if($i%2) $align->set(1.0, 1.0, 0.4, 0.3);elseif($i%3) $align->set(0.0, 0.0, 0.6, 0.2);else $align->set(0.0, 1.0, 0.1, 0.2);$i++;}

$window = &new GtkWindow();$window->set_position(GTK_WIN_POS_CENTER);$window->set_default_size((gdk::screen_width()-10),(gdk::screen_height()-30));$window->connect_object('destroy', array('gtk', 'main_quit'));

$align = &new GtkAlignment(0.5, 0.5, 1.0, 1.0);$button = &new GtkButton("Click Here");$i = 0;$button->connect_object('enter', 'change_it', $align, &$i);$align->add($button);$align->show_all();

$window->add($align);$window->show_all();

gtk::main();

?>

GtkArrow

An arrow pointing in one of the four cardinal directions.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkMisc`-- GtkArrow

Page 64: Apostila PHP GTK

Direct subclasses

None.

Descrição

The GtkArrow widget is a drawn triangle that has its "nose"pointing in the direction specified during construction. The lookof the arrow is varied through the choice of GtkShadowType, and itinherits from the GtkMisc class the ability to have its own paddingand alignment properties altered directly, both of which can alsohave a surprisingly big impact on the arrow's appearance.

Construtor

GtkArrow ( GtkArrowType arrow_type , GtkShadowType shadow_type );

-- Displays an arrow pointing in one of the four cardinaldirections.

Métodos

set()Sets new parameter values for an existing GtkArrow.

Propriedades

arrow_type:Direction of arrow's nose.

shadow_type:Appearance of arrow.

GtkArrow Construtor

GtkArrow ( GtkArrowType arrow_type , GtkShadowType shadow_type );

For a simple widget, there are a lot of options in the construction ofthe GtkArrow - twenty different combinations in all.

It may not be immediately obvious that the GtkArrow is made upentirely of lines of shadow. As a result of this, the GtkShadowTypeoption GTK_SHADOW_NONE actually creates an invisible arrow - apotentially useful option to have, given that the parameters of thearrow can be redefined at any point using the set() method.

The syntax to create a right-pointing, etched arrow would be:$arrow = &new GtkArrow(GTK_ARROW_RIGHT, GTK_SHADOW_ETCHED_IN);

Exemplo 2. A list of GtkArrows<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);

Page 65: Apostila PHP GTK

}

$window = &new GtkWindow();$window->set_default_size( 600, 500);$window->connect_object('destroy', array('gtk', 'main_quit'));

$table = &new GtkTable( 5, 6);

$color = &new GdkColor( '#FF0000');

$arTxtArrowTypes = array( 'GTK_ARROW_UP', 'GTK_ARROW_DOWN', 'GTK_ARROW_LEFT', 'GTK_ARROW_RIGHT');$arTxtShadowTypes = array( '', 'GTK_SHADOW_NONE', 'GTK_SHADOW_IN', 'GTK_SHADOW_OUT', 'GTK_SHADOW_ETCHED_IN', 'GTK_SHADOW_ETCHED_OUT');for( $nA = 0; $nA < 6; $nA++) {$label = &new GtkLabel( $arTxtShadowTypes[$nA]);$table->attach( $label, 0, 1, $nA, $nA+1);

for( $nB = 0; $nB < 5; $nB++) {if( $nA == 0) {$widget = &new GtkLabel( $arTxtArrowTypes[$nB]);} else {$widget = &new GtkArrow( $nB, $nA-1);$style = $widget->style;$style->bg[GTK_STATE_NORMAL] = $color;// $widget->set_style( $style);}$table->attach( $widget, $nB+1, $nB+2, $nA, $nA+1, GTK_EXPAND|GTK_FILL, GTK_EXPAND|GTK_FILL);}}

$window->add( $table);$window->show_all();gtk::main();?>

GtkArrow::set

void set( GtkArrowType arrow_type , GtkShadowType shadow_type );

This method redefines the parameters for an existing GtkArrow. Itwould typically be used within a callback function where the arrow wasrequired to point in another direction, change its appearance and/orvanish.

Exemplo 3. Setting the direction of a GtkArrow dynamically<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

$window = &new GtkWindow();

Page 66: Apostila PHP GTK

$window->set_default_size( 150, 150);$window->connect_object('destroy', array('gtk', 'main_quit'));

$table = &new GtkTable( 3, 3);

$arButtons = array(array( 'Up', GTK_ARROW_UP, 1, 0),array( 'Left', GTK_ARROW_LEFT, 0, 1),array( 'Right', GTK_ARROW_RIGHT, 2, 1),array( 'Down', GTK_ARROW_DOWN, 1, 2),);

$color = &new GdkColor( '#FF0000');

$arrow = &new GtkArrow( GTK_ARROW_UP, GTK_SHADOW_NONE);$table->attach( $arrow, 1, 2, 1, 2, GTK_EXPAND|GTK_FILL, GTK_EXPAND|GTK_FILL);

$style = $arrow->style;$style->bg[GTK_STATE_NORMAL] = $color;//$arrow->set_style( $style);

function setArrow( $objButton, $objArrow, $nDirection){$objArrow->set( $nDirection, GTK_SHADOW_OUT);}

foreach( $arButtons as $arButtonDesc) {$button = &new GtkButton( $arButtonDesc[0]);$table->attach( $button, $arButtonDesc[2], $arButtonDesc[2]+1, $arButtonDesc[3], $arButtonDesc[3]+1);$button->connect( 'clicked', 'setArrow', $arrow, $arButtonDesc[1]);}

$window->add( $table);$window->show_all();gtk::main();?>

GtkArrow::arrow_type

Access: Read OnlyType: GtkArrowType

The arrow_type property is a GtkArrowType enumerated value which canbe queried to test in which direction the arrow is currently pointing.

GtkArrow::shadow_type

Access: Read OnlyType: GtkShadowType

The shadow_type property is a GtkShadowType enumerated value which canbe queried to test the current style of the arrow's appearance.

Page 67: Apostila PHP GTK

GtkAspectFrame

A frame that constrains its child to a particular aspect ratio.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkFrame`-- GtkAspectFrame

Direct subclasses

None.

Descrição

Construtor

GtkAspectFrame ([string label = NULL , [double xalign = 0.5 , [doubleyalign = 0.5 , [double ratio = 1.0 , [bool obey_child = TRUE ]]]]]);

--

Métodos

set()

GtkAspectFrame Construtor

GtkAspectFrame ([string label = NULL , [double xalign = 0.5 , [doubleyalign = 0.5 , [double ratio = 1.0 , [bool obey_child = TRUE ]]]]]);

GtkAspectFrame::set

void set(double xalign, double yalign, double ratio, bool obey_child);

GtkBin

Base class for containers with just one child.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin

Direct subclasses

GtkAlignment, GtkButton, GtkEventBox, GtkFrame, GtkHandleBox,

Page 68: Apostila PHP GTK

GtkInvisible, GtkItem, GtkScrolledWindow, GtkViewport, GtkWindow

Descrição

GtkBin is a container widget that is capable of holding only onechild. All widgets derived from GtkBin therefore also can onlycontain one immediate child, although this child may itself containmultiple widgets.

Note that GtkBin is an abstract base class and cannot beconstructed directly.

See also: GtkBox, GtkContainer.

Propriedades

child:

The child widget.

GtkBin::child

Access: Read OnlyType: GtkWidget

This property allows access to the child widget contained by theGtkBin object. It can be treated like any other GtkWidget. If thevalue of this property is NULL, then GtkBin object does not contain achild widget.

$button->remove($button->child);

GtkBox

Base class for box containers.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBox

Direct subclasses

GtkButtonBox, GtkHBox, GtkVBox

Descrição

GtkBox is a base class providing box containers GtkHBox and GtkVBoxwith properties and methods for packing any number of childwidgets.

Note that GtkBox is an abstract class and cannot be constructed

Page 69: Apostila PHP GTK

directly.

See also: GtkBin, GtkBoxChild, GtkContainer, GtkTable.

Métodos

pack_start()Packs from top or left of box container.

pack_end()Packs from bottom or right of box container.

pack_start_defaults()Packs from top or right using default settings.

pack_end_defaults()Packs from bottom or left using default settings.

set_homogeneous()Toggles equality of child sizing.

set_spacing()Sets spacing between children.

reorder_child()Sets new position for child.

set_child_packing()Sets packing parameters for child.

query_child_packing()Queries packing parameters for child.

Propriedades

children:Array of child packing information.

spacing:Universal spacing policy.

homogeneous:Universal sizing policy.

GtkBox::pack_start

void pack_start( GtkWidget child , [bool expand = true , [bool fill =true , [int padding = 0 ]]]);

pack_start() packs the child widget from the top or left of the boxcontainer. The expand parameter is a boolean value that determineswhether the child can expand when the parent container is resized. Thesecond parameter fill is also a boolean value, and determines whetherthe child should fill the space available to it. The third parameter

Page 70: Apostila PHP GTK

padding is an integer describing the padding around the child widget,in pixels. The default values are true, true, 0.

Calls to pack_start() can be mixed with calls to pack_end() or evenadd() , within the same box container.

GtkBox::pack_end

void pack_end( GtkWidget child , [bool expand = true , [bool fill =true , [int padding = 0 ]]]);

pack_end() packs the child widget from the bottom or right of the boxcontainer. The expand parameter is a boolean value that determineswhether the child can expand when the parent container is resized. Thesecond parameter fill is also a boolean value, and determines whetherthe child should fill the space available to it. The third parameterpadding is an integer descrbing the padding around the child widget,in pixels. The default values are true, true, 0.

pack_end() calls may be interspersed with pack_start() calls withinthe same box container widget.

GtkBox::pack_start_defaults

void pack_start_defaults( GtkWidget widget );

pack_start_defaults() packs the given child widget from the top orfrom the left of the box container using the default parameter valuestrue, true, 0.

The same result can be achieved by using$box->pack_start($child);

without specifying any further parameters.

GtkBox::pack_end_defaults

void pack_end_defaults( GtkWidget widget );

pack_end_defaults() packs the given child widget from the bottom orfrom the right of the box container using the default parameter valuestrue, true, 0.

The same result can be achieved by using$box->pack_end($child);

without specifying any further parameters.

GtkBox::set_homogeneous

void set_homogeneous(bool homogeneous);

set_homogeneous() sizes all the child widgets in the container to thedimensions of the largest child widget if set to true. The default

Page 71: Apostila PHP GTK

setting is false.

Note that the homogeneous property corresponding to this functionrefers to the child sizing in only one dimension, that is, the heightin a row or the width in a column.

GtkBox::set_spacing

void set_spacing(int spacing);

set_spacing() is used to set the universal minimum spacing between thechild widgets, in pixels.

The default setting is 0.

GtkBox::reorder_child

void reorder_child( GtkWidget child , int position);

reorder_child() moves the child's position in the children array tothe position given as the second parameter.

GtkBox::set_child_packing

void set_child_packing( GtkWidget child , bool expand, bool fill, intpadding, GtkPackType pack_type );

set_child_packing() sets the GtkBoxChild parameters for the childwidget.

GtkBox::query_child_packing

array query_child_packing( GtkWidget child );

query_child_packing() is a way to query the GtkBoxChild parametersexpand, fill, padding and pack_type for an individual child widget.

GtkBox::children

Access: Read OnlyType: array

The packing information for the individual child widgets is stored inchildren as an array of GtkBoxChild objects.

GtkBox::spacing

Access: Read OnlyType: int

The spacing property represents the minimum amount of space betweenthe child widgets, in pixels. This setting is universal across the boxcontainer.

Page 72: Apostila PHP GTK

To set the spacing for an individual child widget, use pack_start() ,pack_end() , set_child_packing() , or the padding property inGtkBoxChild.

GtkBox::homogeneous

Access: Read OnlyType: bool

The homogeneous property is a boolean value which, when set to true,will make all child widgets in the container the same size as thelargest child.

Use set_homogeneous() to set the value.

Note that the value of this property only affects one dimension, asthe children will always fit the height of a row, or the width of acolumn, regardless of settings.

GtkBoxChild

Helper class for GtkBox.

Hierarquia do Objeto

GtkBoxChild

Direct subclasses

None.

Descrição

GtkBox is a base class providing box container widgets withproperties and methods related to packing multiple child widgets.

GtkBoxChild is a helper class that allows access to the widget andpacking information for each individual child. The childrenproperty in GtkBox is an array of GtkBoxChild objects correspondingto packed child widgets.

Note that neither GtkBox nor GtkBoxChild can be constructeddirectly.

Propriedades

widget:

Child widget.

padding:Child padding.

expand:

Page 73: Apostila PHP GTK

Child expand toggle.

fill:Child fill toggle.

pack:Child packing type.

GtkBoxChild::widget

Access: Read OnlyType: GtkWidget

The widget property provides access to the child widget object.

It is possible to access methods, properties and signals belonging towidget as with any GtkWidget of the same type.<?php

$button = $vbox->children[5]->widget;$label = $button->child;$label->set_text("New Button Label");

?>

GtkBoxChild::padding

Access: Read OnlyType: int

The padding property is an integer showing the padding around thewidget, in pixels.

The default setting for padding is 0.

GtkBoxChild::expand

Access: Read OnlyType: bool

The expand property is a boolean value describing whether or not thespace around the widget should be allowed to expand when the parentcontainer is resized.

The child widget is centered within its available space.

The default setting for expand is true.

GtkBoxChild::fill

Access: Read OnlyType: bool

The fill property is a boolean value describing whether or not the

Page 74: Apostila PHP GTK

widget should be allowed to fill the space available to it.

Where the expand property is false and the fill property is true, thechild widget is positioned as close as its padding will allow to thatedge of its available space determined by its pack value.

GtkBoxChild::pack

Access: Read OnlyType: GtkPackType

The pack property is a GtkPackType enum indicating where the childwidget is packed in reference to the parent widget - start or end.

GtkButton

A container widget that emits a signal when clicked on.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkButton

Direct subclasses

GtkOptionMenu, GtkToggleButton

Descrição

The GtkButton widget is a container widget that can hold any validchild widget derived from GtkWidget. The most commonly used childwidget is a GtkLabel. This is therefore built into the constructoras an optional parameter.

The GtkButton widget is mainly used to call some function when thebutton is pressed.

To change the label after the button is created, you can use thechildren() function of the container class:

//$obj is the button object$childs = $obj->children();$childs[0]->set_text('new button title');

Construtor

GtkButton ([string label ]);

-- Creates a button.

Métodos

Page 75: Apostila PHP GTK

pressed()Emits "pressed" signal.

released()Emits "released" signal.

clicked()Emits "clicked" signal.

enter()Emits "enter" signal.

leave()Emits "leave" signal.

set_relief()Sets the button relief style.

get_relief()Gets the button relief style.

Sinais

"enter"Emitted when the cursor is over the button.

"pressed"Emitted when the button is initially pressed.

"clicked"Emitted when the button is clicked.

"released"Emitted when the button is released.

"leave"Emitted when the cursor leaves the button area.

GtkButton Construtor

GtkButton ([string label ]);

This function creates and returns a GtkButton widget. If the optionallabel is passed, the button will contain a GtkLabel widget with thegiven text. If the parameter is left empty, there will be no childwidget.

Note that, as GtkButton is descended from GtkBin, it may contain onlyone child.

Exemplo 4. Adding more than one widget to a GtkButton<?php

Page 76: Apostila PHP GTK

dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

$window = &new GtkWindow(GTK_WINDOW_DIALOG);$window->set_position(GTK_WIN_POS_MOUSE);$window->connect_object('destroy', array('gtk', 'main_quit'));$window->realize();

list ($gdkpixmap, $mask) = gdk::pixmap_create_from_xpm($window->window,null, "test.xpm");$pixmap = &new GtkPixmap($gdkpixmap, $mask);

$label = &new GtkLabel("Open");

$vbox = &new GtkVBox();$vbox->pack_start($pixmap);$vbox->pack_start($label);

$button = &new GtkButton();$button->add($vbox);$vbox->show_all();

$window->add($button);$window->show_all();

gtk::main();

?>

GtkButton::pressed

void pressed(void);

Makes the button emit the "pressed" signal.

GtkButton::released

void released(void);

Makes the button emit the "released" signal.

GtkButton::clicked

void clicked(void);

Makes the button emit the "clicked" signal.

GtkButton::enter

void enter(void);

Makes the button emit the "enter" signal.

GtkButton::leave

Page 77: Apostila PHP GTK

void leave(void);

Makes the button emit the "leave" signal.

GtkButton::set_relief

void set_relief( GtkReliefStyle newstyle );

Sets the relief style of the button widget edges using one of thethree GtkReliefStyle settings. The default relief style isGTK_RELIEF_NORMAL.

GtkButton::get_relief

GtkReliefStyle get_relief (void);

Returns the current GtkReliefStyle setting for the button.

enter

The "enter" signal is emitted when the cursor enters the area of thescreen where the button is positioned.

Função Callback

void callback(GtkButton button);

pressed

The "pressed" signal is emitted when the user presses down themouse-button and the cursor is over the widget.

Função Callback

void callback(GtkButton button);

clicked

The "clicked" signal is emitted at the midpoint between pressing andreleasing the mouse-button. This is the most commonly used GtkButtonsignal, and holds an advantage over the other signals listed here inthat it also responds to enter or spacebar keypresses as though theywere mouse-clicks. Signals that have this property are wrappers for aninternal GtkWidget signal named 'activate_signal'; all interactivewidgets contain one such method/signal pair, with appropriate keyboardbindings.

Note that the "clicked" signal will not fire when the mouse-button isreleased after the cursor has left the widget's region. The activatetype of signals are by nature region-specific.

Use one of the connect() methods in order to emit the signal andconnect it to your function. The connected function is known as thecallback or signal-handler function:

Page 78: Apostila PHP GTK

Exemplo 5. Making a simple connection<?php

dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

function my_function() {echo "The button was clicked\n";}

$window = &new GtkWindow();$window->set_position(GTK_WIN_POS_MOUSE);$window->connect_object('destroy', array('gtk', 'main_quit'));

$button = &new GtkButton("Click Me");$button->connect('clicked', 'my_function');$window->add($button);

$window->show_all();

gtk::main();

?>

For further information about connecting signals, refer to the Signalsand Callbacks chapter in the PHP-GTK Userguide.

Função Callback

void callback(GtkButton button);

released

The "released" signal is emitted when the user releases themouse-button, regardless of the cursor position.

Função Callback

void callback(GtkButton button);

leave

The "leave" signal is emitted when the cursor leaves the area of thescreen where the button is positioned.

Função Callback

void callback(GtkButton button);

GtkButtonBox

Base class for GtkHButtonBox and GtkVButtonBox.

Hierarquia do Objeto

Page 79: Apostila PHP GTK

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBox`-- GtkButtonBox

Direct subclasses

GtkHButtonBox, GtkVButtonBox

Descrição

GtkButtonBox is a base class providing a series of layout optionsfor buttons packed into GtkHButtonBox and GtkVButtonBox containerwidgets.

Please note that in GTK+ 2.0 all reference to spacing will becompletely removed; this is because these values are always relativein GtkButtonBox classes, and should be adjusted internally.

Métodos

get_spacing()Returns spacing between buttons. *deprecated in GTK2*

get_layout()Retrieves the layout style setting.

set_spacing()Sets spacing between buttons. *deprecated in GTK2*

set_layout()Sets the button layout style.

set_child_size()Sets minimum child size. *deprecated in GTK2*

set_child_ipadding()Sets child's internal padding. *deprecated in GTK2*

GtkButtonBox::get_spacing

int get_spacing(void);

get_spacing() returns the integer value representing the spacing inpixels between the buttons contained in a GtkButtonBox.

Note that this method is deprecated in GTK+ 2.0 and should not be usedwhere forward compatibility is an issue.

GtkButtonBox::get_layout

GtkButtonBoxStyle get_layout (void);

Page 80: Apostila PHP GTK

get_layout() retrieves the current GtkButtonBoxStyle setting.

GtkButtonBox::set_spacing

void set_spacing(int spacing);

set_spacing() sets the spacing between the buttons, in pixels. Seealso gtk::hbutton_box_set_spacing_default() orgtk::vbutton_box_set_spacing_default() to set the spacing defaultacross an entire application. If you don't change it, the defaultsetting is currently 10 pixels for GtkVButtonBox, or 30 forGtkHButtonBox.

Note that this method is deprecated in GTK+ 2.0. Where forwardcompatibility is an issue, use set_layout() instead.

GtkButtonBox::set_layout

void set_layout( GtkButtonBoxStyle layout_style );

set_layout() sets the spacing arrangement of the buttons in accordancewith one of the five GtkButtonBoxStyle settings.

The default setting is always the GTK_BUTTONBOX_DEFAULT_STYLE, whichis itself pre-set to GTK_BUTTONBOX_EDGE. This can be reset for anentire application by using gtk::hbutton_box_set_layout_default() orgtk::vbutton_box_set_layout_default() .

GtkButtonBox::set_child_size

void set_child_size(int min_width, int min_height);

set_child_size() sets the minimum size for any child in theGtkButtonBox widget, in pixels.

The default setting is (85, 27).

Note that this method is deprecated, and that minimum sizing will beset internally in future versions of GTK+.

GtkButtonBox::set_child_ipadding

void set_child_ipadding(int ipad_x, int ipad_y);

set_child_ipadding() sets the amount to increase the width and heightof the space requested by the buttons.

The default settings are currently (7, 0).

Note that this method is deprecated, and that internal padding will beset by the widget itself in future versions of GTK+.

GtkCalendar

Page 81: Apostila PHP GTK

A calendar offering dates that can be selected and marked.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkCalendar

Direct subclasses

None.

Descrição

A GtkCalendar is a widget consisting of a grid container displayinga calendar, with an optional label allowing month/year navigationand an optional header giving abbreviated day names.

Both the day and the month names are supplied by the system locale,and cannot be overwritten. Unfortunately, under win32 there aresevere problems with internationalization in the GDK sourcecurrently used by PHP-GTK. Non-standard ISO8859-1/2 characterscannot be drawn in this widget as a result of a wide characterconversion failure under Windows. Multibyte characters are notrecognised, and as they are supplied directly by the system to thewidget there is no option to convert them using PHP. This issue isgradually being addressed by the PHP-GTK development team on awidget-by-widget basis.

Assuming that your locale and your operating system will allow youto use this widget's headers, the only other point to keep in mindis that a marked date is differentiated from the other dates bybeing drawn on a slightly bigger base rectangle, making it appearbold while actually using the same font as the rest of the widget.This is less effective in some fonts than in others, and can becomea very negligable distinction.

Construtor

GtkCalendar (void);

-- Creates a calendar widget.

Métodos

select_month()Determines the month and year displayed.

select_day()Determines the selected day.

mark_day()Marks the given day.

Page 82: Apostila PHP GTK

unmark_day()Unmarks the given day, if marked.

clear_marks()Clears all marked dates.

display_options()Sets flags determining the appearance of the calendar.

get_date()Returns currently selected date.

freeze()Freezes the display to allow updates.

thaw()Thaws the display following updates.

Sinais

"month-changed"Emitted whenever the displayed month is changed.

"day-selected"Emitted when a day is selected.

"day-selected-double-click"Emitted when the mouse is clicked twice on a day.

"prev-month"Emitted when user chooses to go back one month.

"next-month"Emitted when user chooses to go forward one month.

"prev-year"Emitted when user chooses to go back one year.

"next-year"Emitted when user chooses to go forward one year.

Propriedades

month:Currently selected month.

year:Currently selected year.

selected_day:Currently selected day.

num_marked_dates:

Page 83: Apostila PHP GTK

Number of marked dates held.

marked_date:Array of marked dates.

GtkCalendar Construtor

GtkCalendar (void);

Creates a calendar widget, set to display the current month and year.

Exemplo 6. Changing the style of a GtkCalendar<?php

dl("php_gtk." . (strstr(PHP_OS, "WIN") ? "dll" :"so"));

$window = &new GtkWindow();$window->set_position(GTK_WIN_POS_CENTER);$window->connect_object("destroy", array("gtk","main_quit"));

/* create the calendar and add it to the window. */$calendar = &new GtkCalendar();$window->add($calendar);

/* create a new style for the calendar, based on the old one */$oldstyle = $calendar->style;$newstyle = $oldstyle->copy();$font =gdk::font_load('-unknown-Arial-normal-r-normal--*-160-*-*-p-0-iso8859-1');$red = &new GdkColor(255*255, 0, 0);$newstyle->font = $font;$newstyle->fg[GTK_STATE_SELECTED] = $red;$calendar->set_style($newstyle);

/* have today's date highlighted on opening */$calendar->select_day(date('d'));

$window->show_all();

gtk::main();

?>

GtkCalendar::select_month

int select_month(int month, int year);

This method determines the month and year displayed on opening. Thedefault setting is the current month and year, taken from theoperating system.

If the display option flag GTK_CALENDAR_NO_MONTH_CHANGE is set, the

Page 84: Apostila PHP GTK

user will be unable to switch from the month and year passed asparameters.

Note that the month must be in the range 0 to 11, similar to PHP'sdate('m'). The year is in 4-digit format, as in 2002 the formatreturned by date('Y').

GtkCalendar::select_day

void select_day(int day);

select_day() specifies the day number that will be selected (i.e.highlighted).

Note that if there are no further instructions, the same day will behighlighted throughout the months and years in the calendar.

The default selected day is 1, with the range being 1 to 31. Selectingan impossible day within that range - e.g. February 30th - does notreturn an error message, as the day number is not associated with themonth and year information in this method.

GtkCalendar::mark_day

int mark_day(int day);

Switches the appropriate marked_date to true and marks the day numberby making it appear bold. If no further instructions are given, thesame day number will be marked throughout the calendar.

There is no limit to the number of marked days in a month. There isalso no limit to the range.

GtkCalendar::unmark_day

int unmark_day(int day);

Switches the appropriate marked_date to false, if it is true, andunmarks the day.

If the day was not marked, this method has no effect whatever.

GtkCalendar::clear_marks

void clear_marks(void);

Given that marked dates are identical on every calendar page, you willprobably need to clear them and set a new bunch of marked dates whenthe month is changed. These are best stored in a file or files, e.g.<?php

function new_month($calendar) {$calendar->clear_marks();$selected = $calendar->get_date();

Page 85: Apostila PHP GTK

$month = ($selected[1]+1);$year = $selected[0];

if(file_exists("diary/$year/marked_dates_$month.txt")) {$dates = fopen("diary/$year/marked_dates_$month.txt", 'r');$string = explode(',', fgets($dates));$calendar->freeze();for($i = 0; $i < 31; $i++) {if($string[$i]==true) $calendar->mark_day($i+1);}

$calendar->thaw();fclose($dates);}}

$calendar->connect('month-changed', 'new_month');

?>

GtkCalendar::display_options

void display_options( GtkCalendarDisplayOptions flags );

Use display_options() to choose which elements of the calendar shouldbe displayed via GtkCalendarDisplayOptions.

The default setting is GTK_CALENDAR_SHOW_HEADING |GTK_CALENDAR_SHOW_DAY_NAMES.

GtkCalendar::get_date

array get_date(void);

get_date() returns the currently selected calendar date as an array.The contents are the year (e.g. 2002), the month (1 - 12), and the day(1 - 31), in that order.

The range for the month is 1 - 12 here, but 0 - 11 in theselect_month() method. Marked dates also run from 0. Beware!

GtkCalendar::freeze

void freeze(void);

freeze() is used to prevent the screen flickering during an update aseach string in the monthly array is evaluated and redrawn. Place itbefore an update loop.

See also: thaw() .

GtkCalendar::thaw

void thaw(void);

Page 86: Apostila PHP GTK

thaw() is the corollary to freeze() , and is placed after an updateroutine.

month-changed

The "month-changed" signal is emitted whenever the month on displaychanges, regardless of the way in which this is achieved. As the monthand year information are tied, January 2002 is not the same month asJanuary 2003 - the signal will be fired for a year change, too.

Função Callback

void callback(GtkCalendar calendar);

day-selected

The "day-selected" signal is emitted when a day has been selected,regardless of the way in which this is achieved.

Função Callback

void callback(GtkCalendar calendar);

day-selected-double-click

The "day-selected-double-click" signal is fired when the user clicksthe mouse on a day number twice in quick succession.

Função Callback

void callback(GtkCalendar calendar);

prev-month

The "prev-month" signal is emitted when the user either clicks on themonth arrow back, or when the user selects a greyed-out day from theprevious month. It cannot be emitted through the program itself; use"month-changed" if you need to do this.

Função Callback

void callback(GtkCalendar calendar);

next-month

The "next-month" signal is emitted when the user either clicks on themonth arrow forward, or when the user selects a greyed-out day fromthe following month. It cannot be emitted through the program itself;use "month-changed" if you need to do this.

Função Callback

void callback(GtkCalendar calendar);

Page 87: Apostila PHP GTK

prev-year

The "prev-year" signal is emitted when the user either clicks on theyear arrow back, or when the user selects a greyed-out day from theprevious December when January is currently displayed. It cannot beemitted through the program itself; use "month-changed" if you need todo this.

Função Callback

void callback(GtkCalendar calendar);

next-year

The "next-year" signal is emitted when the user either clicks on theyear arrow forward, or when the user selects a greyed-out day from thefollowing January when December is currently displayed. It cannot beemitted through the program itself; use "month-changed" if you need todo this.

Função Callback

void callback(GtkCalendar calendar);

GtkCalendar::month

Access: Read OnlyType: int

The month property is an integer representing the currently selectedmonth. This will be in the range 0 - 11.

GtkCalendar::year

Access: Read OnlyType: int

The year property is an integer representing the currently selectedyear. This is in the 4-digit format, i.e. 2002.

GtkCalendar::selected_day

Access: Read OnlyType: int

The selected_day property is an integer representing the currentlyselected day. This will be in the range 1 - 31.

GtkCalendar::num_marked_dates

Access: Read OnlyType: int

Page 88: Apostila PHP GTK

The num_marked_dates property is an integer representing the number ofmarked dates set to true in the current marked_date array. If you areusing GtkCalendar fully, you are likely to have several of thesearrays - one for each month, at a minimum. This property is tied tothe array.

GtkCalendar::marked_date

Access: Read OnlyType: array

The marked_date property is an array of 31 comma-separated values, allof which are either the default false or, if marked, true.

The array count begins at zero, whereas the days in the calendarbegins at 1. You will need to add 1 to an integer representing theposition of a marked date, to compensate for this mismatch.

GtkCheckButton

Button that displays a discrete toggle indicator.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkButton`-- GtkToggleButton`-- GtkCheckButton

Direct subclasses

GtkRadioButton

Descrição

The GtkCheckButton widget is basically a different style ofGtkToggleButton. Instead of the entire button acting as the toggleindicator, a small button to the left of the text position appears'pressed in' when the toggle is in the GTK_STATE_ACTIVE state.

See also: GtkRadioButton, GtkStateType, GtkToggleButton.

Construtor

GtkCheckButton ([string label ]);

-- Creates a button with a small toggle indicator.

GtkCheckButton Construtor

GtkCheckButton ([string label ]);

Page 89: Apostila PHP GTK

$checkbutton = &new GtkCheckButton("GtkCheckButton label");

instantiates a normal-sized GtkButton with a small draw_indicatortoggle to the left of the button's label area. The indicator displaysthe GtkShadowType GTK_SHADOW_IN when the check button's GtkStateTypeis set as GTK_STATE_ACTIVE.

See also: GtkButton, GtkCheckMenuItem, GtkToggleButton.

GtkCheckMenuItem

Menu item with a toggle indicator.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkItem`-- GtkMenuItem`-- GtkCheckMenuItem

Direct subclasses

GtkRadioMenuItem

Descrição

A GtkCheckMenuItem is a normal GtkMenuItem that contains a toggleindicator positioned to the left of any GtkAccelLabel text. Theindicator does not necessarily have to be displayed during the timethat the menu item is set to its inactive state, but is alwaysdisplayed when the state is set as active.

Construtor

GtkCheckMenuItem ([string label ]);

-- Creates a GtkMenuItem with a toggle indicator.

Métodos

set_active()Toggles the active state.

set_show_toggle()Determines whether toggle indicator should be displayed.

toggled()Emits the "toggled" signal.

Sinais

Page 90: Apostila PHP GTK

"toggled"Emitted when the toggled() method is called.

Propriedades

active:'Active' toggle.

GtkCheckMenuItem Construtor

GtkCheckMenuItem ([string label ]);

$checkmenuitem = &new GtkCheckMenuItem("CheckMenuItem's Label");

is the syntax that will create a new menu item with an indigenoustoggle indicator placed to the left of any existing text. TheGtkCheckMenuItem may be set to the active state - GtkStateTypeGTK_STATE_ACTIVE - or to the inactive state, GTK_STATE_NORMAL. When itis in the inactive state, the toggle indicator need not be displayed.

GtkCheckMenuItem::set_active

void set_active(bool is_active);

set_active() sets the state of the calling GtkCheckMenuItem to eitherthe GTK_STATE_ACTIVE or the GTK_STATE_NORMAL GtkStateType. When themenu item is in its active state, the toggle indicator is alwaysdisplayed.

$checkmenuitem->set_active(true); will set the GtkCheckMenuItem'sstate to active.

The default setting is false.

GtkCheckMenuItem::set_show_toggle

void set_show_toggle(bool always);

set_show_toggle() determines whether the toggle indicator should bevisible at all times, or only when the menu item is active.

The default setting is false.

GtkCheckMenuItem::toggled

void toggled(void);

toggled() causes the calling GtkCheckMenuItem to emit the "toggled"signal.

toggled

The "toggled" signal is emitted when the toggled() method is called.

Page 91: Apostila PHP GTK

This is called internally when the GtkCheckMenuItem's "activate"signal is emitted - that is, when a user clicks on the menu item orpresses the Enter or Space key while the item is selected. The signalis also emitted when calling the set_active() method.

Note that the state-switching triggered by activation is not directlyrelated to the "toggled" signal.

Função Callback

void callback( GtkCheckMenuItem checkmenuitem );

GtkCheckMenuItem::active

Access: Read OnlyType: bool

The active property provides a means of testing whether theGtkCheckMenuItem is currently in the active state - in which case thereturned value will be true - or otherwise.

<?php

$active_state = $checkmenuitem->active;if($active_state == 1) echo "This GtkCheckMenuItem is active\n";

?>

GtkCList

A multi-columned scrolling list widget.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkCList

Direct subclasses

GtkCTree

Descrição

A GtkCList allows you to display tabular data in rows, divided intomultiple columns.

Note that is it not possible to create new columns after the widgethas been instantiated. A workaround is to create a number ofcolumns and hide the ones you don't need.

GtkCList has been deprecated since GTK+ 2.0 and should not be used innewly written code.

Page 92: Apostila PHP GTK

Construtor

GtkCList (int columns, Array titles]);

-- Creates a new GtkCList object

Métodos

set_hadjustment()Allows you to set the GtkAdjustment to be used for the horizontalaspect of the GtkCList widget.

set_vadjustment()Allows you to set the GtkAdjustment to be used for the verticalaspect of the GtkCList widget.

get_hadjustment()Gets the GtkAdjustment currently being used for the horizontalaspect.

get_vadjustment()Gets the GtkAdjustment currently being used for the vertical aspect.

set_shadow_type()Set the outer border (shadow) of the widget

set_selection_mode()Sets the selection mode for the specified CList.

set_reorderable()Sets whether the CList's rows are re-orderable using drag-and-drop.

set_use_drag_icons()Determines whether the GtkCList should use icons when doingdrag-and-drop operations.

set_button_actions()Sets the action(s) that the specified mouse button will have on thelist.

freeze()Causes the GtkCList to stop updating its visuals.

thaw()Causes the specified GtkCList to allow visual updates.

column_titles_show()Makes the column titles visible.

column_titles_hide()Hides the column titles.

column_title_active()

Page 93: Apostila PHP GTK

Sets the specified column to become selectable.

column_title_passive()Causes the specified column title button to not respond to events.

column_titles_active()Causes all column title buttons to become active.

column_titles_passive()Causes all column title buttons to become passive.

set_column_title()Set the title of the specified column.

get_column_title()Returns the title of the specified column.

set_column_widget()Sets a widget to be used as the specified column's title.

get_column_widget()Returns the custom widget for the given column.

set_column_justification()Sets the justification to be used for all text in the specifiedcolumn.

set_column_visibility()Allows you to set whether a specified column in the GtkCList shouldbe hidden or shown.

set_column_resizeable()Lets you specify whether a specified column should be resizeable bythe user.

set_column_auto_resize()Lets you specify whether a column should be automatically resized bythe widget when data is added or removed.

columns_autosize()Auto-sizes all columns in the CList and returns the total width ofthe CList.

optimal_column_width()Gets the required width in pixels that is needed to show everythingin the specified column.

set_column_width()Causes the column specified to be set to a specified width.

set_column_min_width()Causes the column specified to have a minimum width.

set_column_max_width()

Page 94: Apostila PHP GTK

Causes the column specified to have a maximum width.

set_row_height()Causes the GtkCList to have a specified height for its rows.

moveto()Tells the CList widget to visually move to the specified row andcolumn.

row_is_visible()Checks how the specified row is visible.

get_cell_type()Checks the type of cell at the location specified.

set_text()Sets the displayed text in the specified cell.

get_text()Gets the text for the specified cell.

set_pixmap()Sets a pixmap for the specified cell.

set_pixtext()Sets text and a pixmap/bitmap on the specified cell.

set_foreground()Sets the foreground color for the specified row.

set_background()Sets the background color for the specified row.

set_cell_style()Sets the style for the specified cell.

get_cell_style()Gets the current style of the specified cell.

set_row_style()Sets the style for all cells in the specified row.

get_row_style()Gets the style set for the specified row.

set_shift()Sets the vertical and horizontal shift of the specified cell.

set_selectable()Sets whether the specified row is selectable or not.

get_selectable()Gets whether the specified row is selectable or not.

Page 95: Apostila PHP GTK

prepend()Adds a row to the list at the top.

append()Adds a row to the list at the bottom.

insert()Adds a row of text to the list at the specified position.

remove()Removes the specified row from the list.

select_row()Selects the specified row.

unselect_row()Unselects the specified row.

undo_selection()Undoes the last selection for an "extended selection mode" list.

clear()Removes all the rows.

select_all()Selects all rows in the CList.

unselect_all()Unselects all rows in the list.

swap_rows()Swaps the two specified rows with each other.

row_move()Allows you to move a row from one position to another in the list.

set_sort_column()Sets the sort column of the clist.

set_sort_type()Sets the sort type of the GtkClist.

sort()Sorts the list.

set_auto_sort()Turns on or off auto sort of the GtkCList.

Sinais

"select-row"This signal is emitted when the user selects a row in the list.

"unselect-row"

Page 96: Apostila PHP GTK

This signal is emitted when the user unselects a row in the list.

"row-move"This signal is emitted when a row is moved.

"click-column"This signal is emitted when a column title is clicked.

"resize-column"This signal is emitted when a column is resized.

Propriedades

focus_row:Number of the row having the focus.

rows:Returns the number of rows.

row_list:Returns all rows in the list.

selection:Array of selected rows.

selection_mode:Returns the current selection mode.

sort_column:The current row after which the list shall be sorted.

sort_type:The current sort type (order).

GtkCList Construtor

GtkCList (int columns, Array titles]);

Creates a new GtkCList object with the given number of columns. Theoptional second parameter is an array of strings which are uses ascolumn titles.

The columns can be resized with the set_column_width function.<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

$win = &new GtkWindow();$win->set_default_size(200,300);$win->connect('destroy', 'destroy');

function destroy() {Gtk::main_quit();

Page 97: Apostila PHP GTK

}

$arStatistics = array(array( 'Paris', 9.1),array( 'Moscow', 9.0),array( 'London', 6.8),array( 'Rome', 3.8),array( 'Berlin', 3.4),array( 'Athena', 3.0));

$scrolled_win = &new GtkScrolledWindow();$scrolled_win->set_policy( GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

$list = &new GtkCList( 2, array( "City", "Inhabitants (M)"));

foreach( $arStatistics as $arStat) {$list->insert( 0, $arStat);}

$list->set_column_width( 0, 90);

$scrolled_win->add( $list);$win->add( $scrolled_win);$win->show_all();GTK::main();?>

The numbering of a position parameter for a column or row starts at 0.

GtkCList::set_hadjustment

void set_hadjustment(GtkAdjustment adjustment);

Allows you to set the GtkAdjustment to be used for the horizontalaspect of the GtkCList widget.

GtkCList::set_vadjustment

void set_vadjustment(GtkAdjustment adjustment);

Allows you to set the GtkAdjustment to be used for the vertical aspectof the GtkCList widget.

GtkCList::get_hadjustment

GtkAdjustment get_hadjustment(void);

Gets the GtkAdjustment currently being used for the horizontal aspect.

GtkCList::get_vadjustment

GtkAdjustment get_vadjustment(void);

Page 98: Apostila PHP GTK

Gets the GtkAdjustment currently being used for the vertical aspect.

GtkCList::set_shadow_type

void set_shadow_type(GtkShadowType type);

Set the outer border (shadow) of the widget. The whole widget issurrounded with a special border, which can look flat, inset oroutset.

You can best see the effect when you add the following lines to theexample given in the constructor:$scrolled_win->set_border_width( 10);$list->set_shadow_type( GTK_SHADOW_ETCHED_OUT);

GtkCList::set_selection_mode

void set_selection_mode(GtkSelectionMode mode);

Sets the selection mode for the specified CList. This allows you toset whether only one or more than one item can be selected at a timein the widget. Note that setting the widget's selection mode to one ofGTK_SELECTION_BROWSE or GTK_SELECTION_SINGLE will cause all the itemsin the GtkCList to become deselected.

GtkCList::set_reorderable

void set_reorderable(bool reorderable);

Sets whether the CList's rows are re-orderable using drag-and-drop. Ifit is set to true, the user can select one with the mouse, hold theleft mouse button and move it to another position in the list. Therow-move signal is emmited when the user did so.

GtkCList::set_use_drag_icons

void set_use_drag_icons(bool use_icons);

Determines whether the GtkCList should use icons when doingdrag-and-drop operations.

In every case the cursor is changed when moving a selected row. Thedifference is, that a standard cursor is used when the value is set tofalse, and an icon if it is true. The icon looks nicer, but causesugly effects sometimes (UI not fully redrawn).

GtkCList::set_button_actions

void set_button_actions(int button, GtkButtonAction button_actions);

Sets the action(s) that the specified mouse button will have on thelist. The button_actions can be one or several, logically OR'edactions.

Page 99: Apostila PHP GTK

GtkCList::freeze

void freeze(void);

Causes the GtkCList to stop updating its visuals until a matching callto thaw is made. This function is useful if a lot of changes will bemade to the widget that may cause a lot of visual updating to occur.

Note that calls to gtk_clist_freeze() can be nested.

GtkCList::thaw

void thaw(void);

Causes the specified GtkCList to allow visual updates which werestopped with freeze.

GtkCList::column_titles_show

void column_titles_show(void);

Makes the column titles visible.

GtkCList::column_titles_hide

void column_titles_hide(void);

Hides the column titles.

GtkCList::column_title_active

void column_title_active(int column);

Sets the specified column in the GtkCList to become selectable. Youcan then respond to events from the user clicking on a title button,and take appropriate action.

You can make all columns titles active by using column_titles_active.

GtkCList::column_title_passive

void column_title_passive(int column);

Causes the specified column title button to become passive, i.e., doesnot respond to events, such as the user clicking on it.

You can make all columns titles passive by usingcolumn_titles_passive.

GtkCList::column_titles_active

void column_titles_active(void);

Causes all column title buttons to become active. The same as calling

Page 100: Apostila PHP GTK

column_title_active for each single column.

GtkCList::column_titles_passive

void column_titles_passive(void);

Causes all column title buttons to become passive. The same as callingcolumn_title_passive for each single column.

GtkCList::set_column_title

void set_column_title(int column, string title);

Set the title of the specified column.

GtkCList::get_column_title

string get_column_title(int column);

Returns the title of the specified column.

GtkCList::set_column_widget

void set_column_widget(int column, GtkWidget widget);

Sets a widget to be used as the specified column's title. This can beused to place a pixmap or something else as the column title, insteadof the standard text.

Exemplo 7. Using a custom widget in title of a GtkCList<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

$win = &new GtkWindow();$win->set_default_size(250,250);$win->connect('destroy', 'destroy');

function destroy() {Gtk::main_quit();}

$arStatistics = array(array( 'Paris', 9.1),array( 'Moscow', 9.0),array( 'London', 6.8),array( 'Rome', 3.8),array( 'Berlin', 3.4),array( 'Athena', 3.0));

$scrolled_win = &new GtkScrolledWindow();$scrolled_win->set_policy( GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);

Page 101: Apostila PHP GTK

$list = &new GtkCList( 2, array( "City", "Inhabitants"));

foreach( $arStatistics as $arStat) {$list->insert( 0, $arStat);}

$list->set_column_width( 0, 90);

$list->set_selection_mode( GTK_SELECTION_MULTIPLE);

function mnuActivated( $mnuItem, $strLabel) {global $list;$chShow = $strLabel[0];for( $nA = 0; $nA < count( $list->row_list); $nA++) {$nSize = $list->get_text( $nA, 1);if( $chShow == 'A' || ( $chShow == '<' && $nSize < 5)|| ( $chShow == '>' && $nSize >= 5)) {$list->select_row( $nA, 0);} else {$list->unselect_row( $nA, 0);}}}

$arMenus = array( 'All', '> 5 million', '< 5 million', 'none');

$mnuSizes = &new GtkMenu();foreach( $arMenus as $strLabel) {$mnu = &new GtkMenuItem( $strLabel);$mnu->connect( 'activate', 'mnuactivated', $strLabel);$mnuSizes->append( $mnu);}$mnuSizes->show_all();

$om = &new GtkOptionMenu();$om->set_menu( $mnuSizes);

$list->set_column_widget( 1, $om);

$scrolled_win->add( $list);$win->add( $scrolled_win);$win->show_all();GTK::main();?>

GtkCList::get_column_widget

GtkWidget get_column_widget(int column);

Returns the custom widget for the given column.

GtkCList::set_column_justification

Page 102: Apostila PHP GTK

void set_column_justification(int column, GtkJustificationjustification);

Sets the justification to be used for all text in the specifiedcolumn.

GtkCList::set_column_visibility

void set_column_visibility(int column, bool visible);

Allows you to set whether a specified column in the GtkCList should behidden or shown.At least one column must always be showing, so attempting to hide thelast visible column will be ignored.

GtkCList::set_column_resizeable

void set_column_resizeable(int column, bool resizeable);

Lets you specify whether a specified column should be resizeable bythe user. Note that turning on resizeability for the column willautomatically shut off auto-resizing, but turning off resizeabilitywill NOT turn on auto-resizing. This must be done manually via a callto set_column_auto_resize.

GtkCList::set_column_auto_resize

void set_column_auto_resize(int column, bool auto_resize);

Lets you specify whether a column should be automatically resized bythe widget when data is added or removed. Enabling auto-resize on acolumn explicity disallows user-resizing of the column.

GtkCList::columns_autosize

int columns_autosize(void);

Auto-sizes all columns in the GtkCList and returns the total width ofthe CList.

GtkCList::optimal_column_width

int optimal_column_width(int column);

Gets the required width in pixels that is needed to show everything inthe specified column.

GtkCList::set_column_width

void set_column_width(int column, int width);

Causes the column specified for the GtkCList to be set to a specifiedwidth.

Page 103: Apostila PHP GTK

GtkCList::set_column_min_width

void set_column_min_width(int column, int min_width);

Causes the column specified to have a minimum width, preventing theuser from resizing it smaller than that specified.

GtkCList::set_column_max_width

void set_column_max_width(int column, int max_width);

Causes the column specified to have a maximum width, preventing theuser from resizing it larger than that specified.

GtkCList::set_row_height

void set_row_height(int height);

Causes the GtkCList to have a specified height for its rows. Settingthe row height to 0 allows the GtkCList to adjust automatically todata in the row.

GtkCList::moveto

void moveto(int row, int column, double row_align, double col_align);

Tells the CList widget to visually move to the specified row andcolumn.

FIXME: Example

GtkCList::row_is_visible

GtkVisibility row_is_visible(int row);

Checks how the specified row is visible.

GtkCList::get_cell_type

GtkCellType get_cell_type(int row, int column);

Checks the type of cell at the location specified.

GtkCList::set_text

void set_text(int row, int column, string text);

Sets the displayed text in the specified cell.

GtkCList::get_text

String get_text(int row, int column);

Page 104: Apostila PHP GTK

Gets the text for the specified cell.

GtkCList::set_pixmap

void set_pixmap(int row, int column, GdkPixmap pixmap, GdkBitmapmask);

Sets a pixmap for the specified cell.

Note that the normal text is not visible anymore, you have to useset_pixtext instead.

GtkCList::set_pixtext

void set_pixtext(int row, int column, string text, int spacing,GdkPixmap pixmap, GdkBitmap mask);

Sets text and a pixmap/bitmap on the specified cell. The spacingparameter is the space between the picture and the pixtext.

GtkCList::set_foreground

void set_foreground(int row, GdkColor color);

Sets the foreground color for the specified row.

GtkCList::set_background

void set_background(int row, GdkColor color);

Sets the background color for the specified row.

GtkCList::set_cell_style

void set_cell_style(int row, int column, GtkStyle style);

Sets the style for the specified cell.

GtkCList::get_cell_style

GtkStyle get_cell_style(int row, int column);

Gets the current style of the specified cell.

GtkCList::set_row_style

void set_row_style(int row, GtkStyle style);

Sets the style for all cells in the specified row.

GtkCList::get_row_style

GtkStyle get_row_style(int row);

Page 105: Apostila PHP GTK

Gets the style set for the specified row.

GtkCList::set_shift

void set_shift(int row, int column, int vertical, int horizontal);

Sets the vertical and horizontal shift of the specified cell.

GtkCList::set_selectable

void set_selectable(int row, bool selectable);

Sets whether the specified row is selectable or not. This is useful ifyou want to separate rows from each other to e.g. categorize them. Youshould also set the background color so that the user can distinguishbetween selectable and not selectable cells.

GtkCList::get_selectable

bool get_selectable(int row);

Gets whether the specified row is selectable or not.

GtkCList::prepend

void prepend(Array text);

Adds a row to the list at the top. The parameter is an array ofstrings, one for each column.

GtkCList::append

int append(Array text);

Adds a row to the list at the bottom. The parameter is an array ofstrings, one for each column.

GtkCList::insert

void insert(int row, Array text);

Adds a row of text to the list at the specified position. Theparameter is an array of strings, one for each column.

GtkCList::remove

void remove(int row);

Removes the specified row from the list.

GtkCList::select_row

void select_row(int row, int column);

Page 106: Apostila PHP GTK

Selects the specified row. Causes the "select-row" signal to beemitted for the specified row and column.

GtkCList::unselect_row

void unselect_row(int row, int column);

Unselects the specified row. Causes the "unselect-row" signal to beemitted for the specified row and column.

GtkCList::undo_selection

void undo_selection(void);

Undoes the last selection for an "extended selection mode" list.

GtkCList::clear

void clear(void);

Removes all the rows from the list.

GtkCList::select_all

void select_all(void);

Selects all rows in the CList. This function has no affect for a listin "single" or "browse" selection mode.

GtkCList::unselect_all

void unselect_all(void);

Unselects all rows in the list.

GtkCList::swap_rows

void swap_rows(int row1, int row2);

Swaps the two specified rows with each other.

GtkCList::row_move

void row_move(int source_row, int dest_row);

Allows you to move a row from one position to another in the list.

GtkCList::set_sort_column

void set_sort_column(int column);

Sets the sort column of the clist. The sort column is used by thedefault compare function to determine which column to sortby.

Page 107: Apostila PHP GTK

GtkCList::set_sort_type

void set_sort_type(GtkSortType sort_type);

Sets the sort type (direction) of the GtkClist. This is eitherGTK_SORT_ASCENDING for ascening sort or GTK_SORT_DESCENDING fordescending sort.

It can be read via the sort_type property.

GtkCList::sort

void sort(void);

Sorts the GtkClist according to the settings of sort column and sorttype. The sort function knows to distinguish between normal text andpixtext, so that a mixture of normal and pixtext will be sorted right.

The items are handled as text when being compared, so numbers will benot in a "natural" order.

Here is an example how to let the user sort the list by columns whenhe clicks on a column title. The sort order (type) is changedeverytime he clicks on the same column title.

Exemplo 8. Sorting GtkCList rows by clicking the titlefunction sortList( $objList, $nColumn){if( $nColumn != $objList->sort_column ) {$objList->set_sort_column( $nColumn);$objList->set_sort_type( GTK_SORT_ASCENDING);} else {if( $objList->sort_type == GTK_SORT_ASCENDING) {$objList->set_sort_type( GTK_SORT_DESCENDING);} else {$objList->set_sort_type( GTK_SORT_ASCENDING);}}$objList->sort();}$objList->connect( 'click-column', 'sortList');

GtkCList::set_auto_sort

void set_auto_sort(bool auto_sort);

Turns on or off auto sort of the GtkCList. If auto sort is on, thenthe list will be resorted when a row is inserted into the list.

select-row

This signal is emitted when the user selects a row in the list. It isemitted for every row that is selected in a multi-selection or bycalling select_all.

Page 108: Apostila PHP GTK

Função Callback

void callback(GtkCList widget, int row, int column, GdkEvent event);

unselect-row

This signal is emitted when the user unselects a row in the list. Itis emitted for every row that is unselected in a multi-selection or bycalling unselect_all. It is also emitted for the previously selectedrow in a "single" or "browse" mode GtkCList.

Função Callback

void callback(GtkCList widget, int row, int column, GdkEvent event);

row-move

This signal is emitted when a row is moved.

Função Callback

void callback(GtkCList widget, int source_row, int destination_row);

click-column

This signal is emitted when a column title is clicked. Here would be agood starting point if you want to make the list sortable by the user.

Função Callback

void callback(GtkCList widget, int column);

resize-column

This signal is emitted when a column is resized. It is also emitted ifthe size has not changed (but the user tried to).

Função Callback

void callback(GtkCList widget, int column, int size);

GtkCList::focus_row

Access: Read OnlyType: int

Returns the number of the row which currently has the focus. Note thatthe focus doesn't mean the row is selected - see GtkSelectionMode fora detailed explanation.

GtkCList::rows

Access: Read Only

Page 109: Apostila PHP GTK

Type: int

Returns the number of rows/entries in the list.

GtkCList::row_list

Access: Read OnlyType: array

Returns an array of GtkCListRows containing all the rows of the list.

GtkCList::selection

Access: Read OnlyType: array

Returns an array of int values which describe the row number of theselected row. This is independent of the selection_mode - it is alwaysan array.

GtkCList::selection_mode

Access: Read OnlyType: GtkSelectionMode

Returns the current selection mode set with set_selection_mode() .

GtkCList::sort_column

Access: Read OnlyType: int

The current row after which the list shall be sorted.

GtkCList::sort_type

Access: Read OnlyType: GtkSortType

The current sort type (order) after which the list shall be sorted.Can be GTK_SORT_ASCENDING or GTK_SORT_DESCENDING.

GtkCListRow

Hierarquia do Objeto

GtkCListRow

Direct subclasses

None.

Descrição

Page 110: Apostila PHP GTK

Propriedades

state:

foreground:

background:

style:

fg_set:

bg_set:

selectable:

GtkCListRow::state

Access: Read OnlyType: int

GtkCListRow::foreground

Access: Read OnlyType: GdkColor

GtkCListRow::background

Access: Read OnlyType: GdkColor

GtkCListRow::style

Access: Read OnlyType: GtkStyle

GtkCListRow::fg_set

Access: Read OnlyType: bool

GtkCListRow::bg_set

Access: Read OnlyType: bool

GtkCListRow::selectable

Page 111: Apostila PHP GTK

Access: Read OnlyType: bool

GtkColorSelection

Widget that allows for selection of a color.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBox`-- GtkVBox`-- GtkColorSelection

Direct subclasses

None.

Descrição

Construtor

GtkColorSelection (void);

--

Métodos

set_update_policy()

set_opacity()

set_color()

get_color()

GtkColorSelection Construtor

GtkColorSelection (void);

GtkColorSelection::set_update_policy

void set_update_policy(GtkUpdateType policy);

GtkColorSelection::set_opacity

void set_opacity(int use_opacity);

Page 112: Apostila PHP GTK

GtkColorSelection::set_color

XXX set_color(XXX);

GtkColorSelection::get_color

XXX get_color(XXX);

GtkColorSelectionDialog

Standard dialog box for selecting a color.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkWindow`-- GtkColorSelectionDialog

Direct subclasses

None.

Descrição

Construtor

GtkColorSelectionDialog (string title);

--

GtkColorSelectionDialog Construtor

GtkColorSelectionDialog (string title);

GtkCombo

Text entry field with a dropdown list.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBox`-- GtkHBox`-- GtkCombo

Direct subclasses

None.

Page 113: Apostila PHP GTK

Descrição

A GtkCombo appears to be the equivalent of the select element inHTML. This can be misleading if you're coming directly from a webdevelopment background; a GUI widget is largely about appearance,and carrying hidden values is not something this one will dowithout a little programming. Luckily, there are a trio ofinvaluable GtkObject methods that will do just that, with anyobject and with any form of data. These are get_data() , set_data()and remove_data() . See the sample under GtkCombo's constructor toget an idea of their usage.

There are a few key bindings in the combo widget. Most of them havesome bearing on searches.

Tabela 1. Key bindings in GtkComboKey combination FunctionReturn (from the entry box) Opens up the list. If the entry containstext that fully matches a list item's content, that list item will beselected on opening.Tab + MOD_1 mask (from the entry box) The MOD_1 modifier is usuallyAlt. This key combination auto-completes a partial entry.Arrow up (from the entry box) If use_arrows has been set to true,scrolls up through the list without opening the list window. Can alsobe achieved with keypad arrow or Alt + p.Arrow down (from the entry box) If use_arrows has been set to true,scrolls down through the list without opening the list window. Canalso be achieved with keypad arrow or Alt + n.Return (from the list box) Toggles the list item that has currentfocus.Spacebar (from the list box) Selects the list item that has currentfocus.Up arrow (from the list box) Scrolls up through the list items.Down arrow (from the list box) Scrolls down through the list items.Esc (from the list box) Removes grab from the list box, which closesit.

The normal but annoying behaviour is that the first entry isselected when you open the dropdown. This can be stopped by doingthe following:

$objList = $objCombobox->list;$objList->set_selection_mode( GTK_SELECTION_SINGLE);

See also: GtkEditable, GtkEntry, GtkItem, GtkList, GtkListItem,GtkOptionMenu.

GtkCombo has been deprecated since GTK+ 2.0 and should not be used innewly written code.

Construtor

GtkCombo (void);

Page 114: Apostila PHP GTK

-- Creates an entry box with a dropdown list.

Métodos

set_value_in_list()Toggles whether entry value must be matched in list.

set_use_arrows()Toggles whether list can be scrolled within entry box.

set_use_arrows_always()Toggles whether entry box list-scrolling should loop.

set_case_sensitive()Toggles whether matching should be case-sensitive.

set_item_string()Sets string associated with list item.

set_popdown_strings()Simple list construction.

disable_activate()Prevents return key from opening dropdown list.

Propriedades

entry:Text entry field.

list:Dropdown list.

GtkCombo Construtor

GtkCombo (void);

When the GtkListItem has been selected in a GtkCombo, the combo'sentry text is picked up from the item, and the combo's list issearched for a data match. The "unselect-child" signal is fired by thelist during this routine in order to clear previously existing data.If you connect to either that or the "deselect" signal, your callbackfunction will run twice. The same applies to the "select-child" and"select" signals, as the deselection allows the item to be selectedagain - which it is, when select_child() is called immediatelyafterwards.

There are many ways of working around this. One is given in the samplebelow.

Exemplo 9. Associating data with a GtkListItem<?php

if( !extension_loaded('gtk')) {

Page 115: Apostila PHP GTK

dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

function on_click($item, $event, $i) {echo $item->get_data($i)."\n";flush();}

function on_key($item, $i) {echo $item->get_data($i)."\n";flush();}

$window = &new GtkWindow();$window->set_position(GTK_WIN_POS_CENTER);$window->connect_object("destroy", array("gtk","main_quit"));

$combo = &new GtkCombo();/* The GtkEntry and GtkList are accessible through the combo's properties */$entry = $combo->entry;$entry->set_text('Choose some fruit');$list = $combo->list;$list->set_selection_mode(GTK_SELECTION_SINGLE);

$fruit = array('apples', 'bananas', 'cherries', 'damsons', 'eggplants','figs', 'grapes');

for($i = 0; $i < count($fruit); $i++) {$item = &new GtkListItem();/* You can put pretty much anything into a GtkListItem */$box = &new GtkHBox();$arrow = &new GtkArrow(GTK_ARROW_RIGHT, GTK_SHADOW_OUT);$box->pack_start($arrow, false, false, 5);$label = &new GtkLabel('Item '.($i+1));$box->pack_start($label, false, false, 10);$item->add($box);$combo->set_item_string($item, "You chose $fruit[$i]");$data = $fruit[$i];/* This data will be carried with the $item. The key here is $i. */$item->set_data($i, $data);/* Two separate signals to get around the 'select' problem. */$item->connect('button-press-event', 'on_click', $i);$item->connect('toggle', 'on_key', $i);$list->add($item);$item->show_all();}

$window->add($combo);$window->show_all();

gtk::main();

?>

Page 116: Apostila PHP GTK

GtkCombo::set_value_in_list

void set_value_in_list(bool val, bool ok_if_empty);

This method used to make the combo emit a beep if the entry valuecould not be matched in the list. It no longer does this, and nor doesit print an error message when the search string is invalid.Effectively broken.

GtkCombo::set_use_arrows

void set_use_arrows(bool val);

set_use_arrows() , when set to false prevents the Up and Down arrowkeys from being used to scroll the list within the combo's entry box.

The default value is true, which allows such scrolling where there isa match between the entry text and one of the list item strings.

GtkCombo::set_use_arrows_always

void set_use_arrows_always(bool val);

This method is the adult version of set_use_arrows() . The chiefdifference is that the entry box text does not need to match the textstring in a list item in order for the arrows to be used. Thesecondary difference is that the scrolling loops back to the start ofthe list when the final item is reached, and vice versa.

GtkCombo::set_case_sensitive

void set_case_sensitive(bool val);

set_case_sensitve, if set to true, will not match items that aredissimilar with regard to case -in other words, Cat is not the samething as cat.

The default behaviour is that a string in the combo's entry box thatis accurate in all the ways other than case will be altered to matchthe list version of that string.

GtkCombo::set_item_string

void set_item_string( GtkItem item , string item_value);

As you may have noticed in the GtkCombo constructor example, it is notby any means essential that the items in a GtkList are GtkListItems.This method is intended to provide a way to give an alternative to theentry box, where only the string data type is allowed.

set_item_string() can be set regardless of whether there is alreadytext in the list item, and in either case will provide the string thatis compared against the entry's text content during search routines.

Page 117: Apostila PHP GTK

This method determines the string that will be displayed in the entryfield after the list item has been selected.

GtkCombo::set_popdown_strings

array set_popdown_strings(array item_labels);

Use this method to create the GtkListItems to populate the list, whereonly the labels themselves are necessary data.

Exemplo 10. The easy way to fill a GtkCombo's list<?php

dl("php_gtk." . (strstr(PHP_OS, "WIN") ? "dll" :"so"));

function print_this($list, $item) {$label = $item->child;echo $label->get()."\n";flush();}

$window = &new GtkWindow();$window->set_position(GTK_WIN_POS_CENTER);$window->connect_object("destroy", array("gtk","main_quit"));

$combo = &new GtkCombo();$fruit = array('apples', 'bananas', 'cherries', 'damsons', 'eggplants','figs', 'grapes');$combo->set_popdown_strings($fruit);/* We don't have handles for these list items, so we connect them through theGtkList. The child is passed to the callback with the select-child signal. */$list = $combo->list;$list->connect('select-child', 'print_this');

$window->add($combo);$window->show_all();

gtk::main();

?>

GtkCombo::disable_activate

void disable_activate(void);

Normally the "activate" signal is emitted when the return key ispressed and the GtkEntry has keyboard grab. This signal emissionresults in the dropdown list being exposed.

disable_activate() simply disconnects the "activate" signal when it isset.

Page 118: Apostila PHP GTK

GtkCombo::entry

Access: Read OnlyType: GtkEntry

The entry property provides a way of retrieving information directlyfrom the GtkEntry part of the combo widget.

GtkCombo::list

Access: Read OnlyType: GtkList

The list property provides a way of retrieving information directlyfrom the GtkList part of the combo widget.

GtkContainer

Base class for all container widgets.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer

Direct subclasses

GtkBin, GtkBox, GtkCList, GtkFixed, GtkLayout, GtkList, GtkMenuShell,GtkNotebook, GtkPacker, GtkPaned, GtkSocket, GtkTable, GtkToolbar,GtkTree, GtkSheet, GtkSQPane

Descrição

GtkContainer is an abstract base class providing all widgetsderived from it with the ability to contain child widgets.

It also endows those child widgets with a resizing mechanism.

Métodos

set_border_width()Sets border width.

add()Adds child widget to container.

remove()Removes child widget from container.

set_resize_mode()Sets priority of resize requests.

Page 119: Apostila PHP GTK

check_resize()Emits check_resize signal.

children()Returns array of container's child widgets.

focus()Queues child focus in a given direction.

set_reallocate_redraws()Toggles whether redraws are necessary.

set_focus_child()Sets initial child focus.

set_focus_vadjustment()Sets focus on a vertical GtkAdjustment.

set_focus_hadjustment()Sets focus on a horizontal GtkAdjustment.

register_toplevel()Registers container as toplevel.

unregister_toplevel()Unregisters a toplevel container.

resize_children()Resizes child widgets.

child_type()Describes expected child type.

Sinais

"add"Emitted when the add() method is called.

"remove"Emitted when the remove() method is called.

"check-resize"Emitted when the check_resize() method is called.

"focus"Emitted when the focus() method is called.

"set-focus-child"Emitted when the set_focus_child() method is called.

GtkContainer::set_border_width

void set_border_width(int border_width);

Page 120: Apostila PHP GTK

set_border_width() sets the width of the container's border, inpixels.

The default setting is 0.

GtkContainer::add

void add( GtkWidget widget );

add() adds the child widget passed as the parameter to the container.

See also: GtkBin, GtkBox, pack_start() , pack_end() .

GtkContainer::remove

void remove( GtkWidget widget );

remove() removes the child widget passed as the parameter from thecontainer, regardless of the method used to pack that child.

GtkContainer::set_resize_mode

void set_resize_mode( GtkResizeMode resize_mode );

set_resize_mode() sets the priority of any resize requests for thecontainer widget calling the method. The standard behaviour is to haveany such requests added to a queue; setting the resize mode toGTK_RESIZE_IMMEDIATE bypasses that queue.

GtkContainer::check_resize

void check_resize(void);

check_resize() emits the "check-resize" signal, which triggers aseries of functions to check exactly what needs to be resized beforeeither resetting the container's size allocation or calling theresize_children() method.

This method is mostly used internally.

GtkContainer::children

array children(void);

children() provides an alternative means of accessing a container'schild widgets, the other being through the container's properties.

The chief and potentially useful difference is that the array returnedby this method consists of the child widget itself rather than asub-array of information related to the child's packing dimensions.Note that the array returned by either method is reversed, so that thelast item added to the container has the position [0].

GtkContainer::focus

Page 121: Apostila PHP GTK

int focus( GtkDirectionType direction );

focus() creates an internal array of the child widgets able to havefocus, and sorts it according to the direction given. The first childin the array will receive focus on opening.

To be included in this array, child can be taken as any widget havingthe container in its ancestry; it need not be a direct child of thecontainer.

GtkContainer::set_reallocate_redraws

void set_reallocate_redraws(bool needs_redraws);

set_reallocate_redraws() toggles whether redraws are necessary for thecontainer, and if set to true will initiate the GtkWidget methodqueue_draw() as appropriate, allowing the content of the container tobe re-set on the fly.

The default setting is false.

GtkContainer::set_focus_child

void set_focus_child( GtkWidget child );

set_focus_child() is used to denote which child widget should receivefocus on opening.

GtkContainer::set_focus_vadjustment

void set_focus_vadjustment( GtkAdjustment adjustment );

set_focus_vadjustment() sets a vertical instance of a GtkAdjustment tohave focus. In practice, this means that the adjustment will respondto changes made by the user, e.g. the position of a verticalscrollbar's handle in a GtkScrolledWindow will reflect the currentfocus within the scrolled window, when called from the scrolledwindow's container.

There is a method named get_vadjustment() which is implemented in allthe classes where this method is likely to be utilised. Use it toprovide the parameter.

GtkContainer::set_focus_hadjustment

void set_focus_hadjustment( GtkAdjustment adjustment );

set_focus_hadjustment() sets a horizontal instance of a GtkAdjustmentto have focus, allowing it to act in synchronicity with the movementof the adjusted widget.

See also: set_focus_vadjustment() , GtkAdjustment.

Page 122: Apostila PHP GTK

GtkContainer::register_toplevel

void register_toplevel(void);

register_toplevel() adds the calling container to an internal array ofwidgets having toplevel status within that application.

Registering a container as toplevel can speed up some of theprocessing involved in resizing.

GtkContainer::unregister_toplevel

void unregister_toplevel(void);

unregister_toplevel() removes the calling container from an internalarray of widgets having toplevel status. Note that the container mustfirst have been prepended to this array using register_toplevel() ;simply declaring a container as toplevel does not add it to theregistry.

GtkContainer::resize_children

void resize_children(void);

resize_children() resizes child widgets following an alteration intheir size requests.

GtkContainer::child_type

int child_type(void);

child_type() returns an integer describing the type of child thecontainer is expecting to be packed into it. This is mostly forinternal use, but could perhaps be useful for diagnosis.

The return values are as follows from most containers:

GTK_TYPE_NONE = 1 (generated where no widget can be added, e.g. by adescendant of GtkBin already containing a child, or a GtkPaned alreadycontaining both children, or a GtkOptionMenu)

GTK_TYPE_WIDGET = 39701 (generated where non-specific widgets may beadded, e.g. by GtkBox descendants, GtkNotebook, GtkFixed, GtkPacker orGtkTable)

The exceptions are GTK_TYPE_LIST_ITEM, GTK_MENU_ITEM andGTK_TREE_ITEM, all of which can be any of a variety of widget typesdepending on how the items are produced.

add

The "add" signal is emitted when the add() method is called.

It is generally used internally.

Page 123: Apostila PHP GTK

Função Callback

void callback(GtkContainer container, GtkWidget child);

remove

The "remove" signal is emitted when the remove() method is called.

It is generally used internally.

Função Callback

void callback(GtkContainer container, GtkWidget child);

check-resize

The "check-resize" signal is emitted when the check_resize() method iscalled.

It is generally used internally.

Função Callback

void callback(GtkContainer container);

focus

The "focus" signal is emitted when the focus() method is called.

It is generally used internally.

Função Callback

void callback(GtkContainer container, GtkDirectionType direction);

set-focus-child

The "set-focus-child" signal is emitted when the set_focus_child()method is called.

It is generally used internally.

Função Callback

void callback(GtkContainer container, GtkWidget child);

GtkCTree

Widget that displays a hierarchical tree.

Hierarquia do Objeto

GtkObject

Page 124: Apostila PHP GTK

`-- GtkWidget`-- GtkContainer`-- GtkCList`-- GtkCTree

Direct subclasses

None.

Descrição

GtkCTree has been deprecated since GTK+ 2.0 and should not be used innewly written code.

Construtor

GtkCTree (int nColumns, int nTreeGraphicCol, array arColTitles]);

-- Creates a new CtkCTree object.

Métodos

insert_node()Inserts a new node in the tree.

remove_node()Removes the given node from the tree

post_recursive()Recursively apply a function to all nodes of the tree at or below acertain node.

post_recursive_to_depth()Recursively apply a function to nodes up to a certain depth

pre_recursive()Recursively apply a function to all nodes of the tree at or below acertain node.

pre_recursive_to_depth()Recursively apply a function to nodes up to a certain depth.

is_viewable()This function checks whether the given node is viewable i.e. so thatall of its parent nodes are expanded.

last()Returns the last child of the last child of the last child... of thegiven node.

node_nth()Returns the node in row X

find()

Page 125: Apostila PHP GTK

Checks if child is on some level a child (grandchild...) of thenode.

find_by_row_data()FIXME

find_by_row_data()FIXME

is_ancestor()Checks if node is an ancestor of child.

is_hot_spot()Checks if the given coordinates lie on an expander button.

move()Move a node in the tree to another location.

expand()Expand one node.

expand_recursive()Expand one node and all nodes underneath.

expand_to_depth()Expand a node and its children up to the depth given.

collapse()Collapse one node.

collapse_recursive()Collapse one node and all its subnodes.

collapse_to_depth()Collapse a node and its children up to the depth given.

toggle_expansion()Toggle a node, i.e. if it is collapsed, expand it and vice versa.

toggle_expansion_recursive()Toggle the expansion of a node and all its children.

select()Cause the given node to be selected and emit the appropriate signal.

select_recursive()Cause the given node and its subnodes to be selected and emit theappropriate signal(s).

unselect()Unselect the given node and emit the appropriate signal.

unselect_recursive()Unselect the given node and its subnodes and emit the appropriate

Page 126: Apostila PHP GTK

signal(s).

node_set_text()Set the column text of the specific row.

node_set_pixmap()Sets an icon into a column of the node.

node_set_pixtext()Sets the pixmap and the corresponding text of a column of a row.

set_node_info()Changes all the values set by the insert_node function.

node_set_shift()Shift the column of the given cell the given amounts in pixels.

node_set_selectable()Sets whether this node can be selected by the user.

node_get_selectable()Whether this node can be selected by the user.

node_get_cell_type()Returns the type of the given cell.

node_get_text()Returns the column text of a given row.

node_get_pixtext()Returns the column pixtext of a given row.

get_node_info()GGet information corresponding to a node.

node_set_row_style()Set the style of a row.

node_get_row_style()Get the style of a row.

node_set_cell_style()Set the style of an individual cell.

node_get_cell_style()Get the style of an individual cell.

node_set_foreground()Set the foreground color of a row.

node_set_background()Set the background color of a row.

node_set_row_data()

Page 127: Apostila PHP GTK

Associate a custom object with the row.

node_get_row_data()Returns the custom object associated with the node.

node_moveto()This function makes the given column of the given node visible byscrolling.

node_is_visible()True if the node is currently inside the bounds of the window.

set_indent()Sets the number of pixels to shift the levels of the tree.

set_spacing()Sets the spacing between the tree graphic and the actual nodecontent.

set_show_stub()FIXME

set_line_style()Set the line style of the tree.

set_expander_style()Set the expander style of the tree.

sort_node()Sort the children of a node.

sort_recursive()Sort the descendants of a node.

Sinais

"tree-select-row"Emitted when a row is selected.

"tree-unselect-row"Emitted when a node is unselected.

"tree-expand"Emitted when a node is expanded.

"tree-collapse"Emitted when a node is collapsed.

"tree-move"Emitted when a node is moved.

Propriedades

clist:

Page 128: Apostila PHP GTK

FIXME

row_list:Array of viewable nodes.

selection:Array of selected rows (nodes).

GtkCTree Construtor

GtkCTree (int nColumns, int nTreeGraphicCol, array arColTitles]);

Create a new CtkCTree object with a number of columns. The secondparameter contains the index of the column in which the tree linesshall be visible (indent and +/-) and the third parameter can be anarray with the column titles.

Notice how much of the code here is actually the arrays of data neededto populate the GtkCTree. It would probably be cleaner to keep yourdata generation in an include file.

Exemplo 11. Setting up a GtkCTree<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

/* start of data generation arrays */$widgets_ = array(/*level 0*/array('Object'),/*level 1*/array('Widget', 'Data', 'ItemFactory'),/*level 2*/array('Misc', 'Container', 'Calendar', 'DrawingArea', 'Editable', 'Ruler','Range', 'Separator', 'Preview', 'Progress'),array('Adjustment', 'Tooltips'),/*level 3*/array('Label', 'Arrow', 'Image', 'Pixmap'),array('Bin', 'Box', 'CList', 'Fixed', 'Notebook', 'Paned', 'Layout', 'List','MenuShell', 'Packer', 'Socket', 'Table', 'Toolbar', 'Tree'),array('Curve'),array('Entry', 'Text'),array('HRuler', 'VRuler'),array('Scale', 'Scrollbar'),array('HSeparator', 'VSeparator'),array('ProgressBar'),/*level 4*/array('AccelLabel', 'TipsQuery'),array('Alignment', 'Frame', 'Button', 'Item', 'Window', 'EventBox','HandleBox', 'ScrolledWindow', 'Viewport', 'Invisible'),array('ButtonBox', 'HBox', 'VBox'),array('CTree'),array('FontSelection'),

Page 129: Apostila PHP GTK

array('HPaned', 'VPaned'),array('MenuBar', 'Menu'),array('SpinButton'),array('HScale', 'VScale'),array('HScrollbar', 'VScrollbar'),/*level 5*/array('AspectFrame'),array('ToggleButton', 'OptionMenu'),array('ListItem', 'MenuItem', 'TreeItem'),array('ColorSelectionDialog', 'Dialog', 'FileSelection','FontSelectionDialog', 'Plug'),array('HButtonBox', 'VButtonBox'),array('Combo', 'Statusbar'),array('ColorSelection', 'GammaCurve'),/*level 6*/array('CheckButton'),array('CheckMenuItem', 'TearoffMenuItem'),array('InputDialog'),/*level 7*/array('RadioButton'),array('RadioMenuItem'));

$row = array(0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 4, 5, 5, 5, 5, 5, 5, 7, 9, 9,13, 13, 13, 13, 14, 14, 14, 23, 24, 25, 29, 30);

$class = array(0, 0, 1, 0, 1, 3, 4, 5, 6, 7, 9, 0, 0, 1, 2, 4, 5, 8, 0, 0, 1,1, 2, 3, 4, 0, 1, 2, 0, 1, 1, 0, 0);/* end of data generation arrays */

$window = &new GtkWindow();$window->set_title('The GTK Class Hierarchy');$window->set_position(GTK_WIN_POS_CENTER);$window->set_default_size(300, (gdk::screen_height()-30));$window->connect_object('destroy', array('gtk', 'main_quit'));

$scrolledwindow = &new GtkScrolledWindow();$scrolledwindow->set_policy(GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);$window->add($scrolledwindow);

$ctree = &new GtkCTree(1, 0);$ctree->set_line_style(GTK_CTREE_LINES_SOLID);

for($x = 0; $x < count($widgets_); $x++) {$sibling[$x] = array();switch($x) {case 0:$parent = null;break;default:$parent = $sibling[$row[$x-1]][$class[$x-1]];break;}for ($i = 0; $i < count($widgets_[$x]); $i++) {

Page 130: Apostila PHP GTK

$widgets[0] = "Gtk".$widgets_[$x][$i];$sibling[$x][$i] = $ctree->insert_node($parent, $sibling[$x][],$widgets, 5, null, null, null, null, false, true);}}

$scrolledwindow->add($ctree);$ctree->show();

$window->show_all();gtk::main();

?>

GtkCTree::insert_node

GtkCTreeNode insert_node(GtkCTreeNode parent, GtkCTreeNode sibling,Array labels, int pixmap_spacing, GdkPixmap pixmap_closed, GdkBitmapmask_closed, GdkPixmap pixmap_open, GdkBitmap mask_open, booleanis_leaf, boolean is_expanded);

This function creates a new node and inserts it into the tree. Thefirst parameter is the parent node; if it's NULL the node will be theroot. The "labels" parameter is an array of strings which are shown inthe tree, for each column one. pixmap_spacing is the spacing betweenthe pixmap and the text.

The sibling parameter determines the position of the new node. If itis NULL, it will be appended to the parents childen as the lastelement. If the sibling is given, the new node will be inserted justbefore it.

GtkCTree::remove_node

void remove_node( GtkCTreeNode node );

Removes the given node from the tree. Children nodes are removedrecursively.

GtkCTree::post_recursive

void post_recursive(GtkCTreeNode node, String callback, ???own_parameter]);

Recursively apply a function to all nodes of the tree at or below acertain node. The function is called for each node after it has beencalled for that node's children.

The callback parameter can be a function name as a string; thisfunction will be called. If you want to use the function of an object,just usearray( &$obj, "function")

The third parameter is optional, it will be passed to the called

Page 131: Apostila PHP GTK

function. You can have as many own parameters as you like.

The calling function needs to implement at least 2 parameters: Thefirst is the tree object, the second the specific node.

GtkCTree::post_recursive_to_depth

void post_recursive_to_depth(GtkCTreeNode node, int depth, Stringcallback, mixed own_parameter]);

Recursively apply a function to nodes up to a certain depth. Thefunction is called for each node after it has been called for thatnode's children.

The depth parameter determines, how many levels below the given nodethe function shall be applied. Note that a depth of "0" does nothing,the depth of "1" will apply the function just to the given node. Only"2" will apply the given function to the first level below the node.If depth is negative, this function just calls post_recursive.

The callback parameter can be a function name as a string; thisfunction will be called. If you want to use the function of an object,just usearray( &$obj, "function")

The fourth parameter is optional, it will be passed to the calledfunction. You can have as many own parameters as you like.

The calling function needs to implement at least 3 parameters: Thefirst is the tree object, the second the specific node and the thirdcontains the callback itself (String or array).

GtkCTree::pre_recursive

void pre_recursive(GtkCTreeNode node, String callback, ???own_parameter]);

Recursively apply a function to all nodes of the tree at or below acertain node. The function is called for each node after it has beencalled for its parent.

For a in-detail description, see post_recursive.

GtkCTree::pre_recursive_to_depth

void pre_recursive_to_depth(GtkCTreeNode node, int depth, Stringcallback, ??? own_parameter]);

Recursively apply a function to nodes up to a certain depth. Thefunction is called for each node after it has been called for thatnode's children.

For a in-detail description, see post_recursive_to_depth.

Page 132: Apostila PHP GTK

GtkCTree::is_viewable

bool is_viewable( GtkCTreeNode node );

This function checks whether the given node is viewable i.e. so thatall of its parent nodes are expanded. This is different from beingactually visible: the node can be viewable but outside the scrollingarea of the window.

GtkCTree::last

GtkCTreeNode last ( GtkCTreeNode node );

Returns the last child of the last child of the last child... of thegiven node.

GtkCTree::node_nth

GtkCTreeNode node_nth (int row);

Returns the node which is in the given row. Count begins with 0 asusual.Only expanded, means viewable nodes are counted!

GtkCTree::find

bool find( GtkCTreeNode node , GtkCTreeNode child );

Checks if child is on some level a child (grandchild...) of the node.

GtkCTree::find_by_row_data

GtkCTreeNode find_by_row_data( GtkCTreeNode node , ??? ???);

GtkCTree::find_by_row_data

Array find_by_row_data( GtkCTreeNode node , ??? ???);

GtkCTree::is_ancestor

bool is_ancestor( GtkCTreeNode node , GtkCTreeNode child );

Checks if node is an ancestor (parent, grandparent, grand...parent) ofchild.

GtkCTree::is_hot_spot

bool is_hot_spot(int x, int y);

Returns true if the given coordinates lie on an expander button.

GtkCTree::move

void move( GtkCTreeNode node , GtkCTreeNode new_parent , GtkCTreeNode

Page 133: Apostila PHP GTK

new_sibling );

Move a node in the tree to another location.

The parent node and the sibling are handled the same way as ininsert_node

GtkCTree::expand

void expand( GtkCTreeNode node );

Expand one node.

GtkCTree::expand_recursive

void expand_recursive([ GtkCTreeNode node = NULL ]);

Expand one node and all nodes underneath.

GtkCTree::expand_to_depth

void expand_to_depth( GtkCTreeNode node , int depth);

Expand a node and its children up to the depth given.

GtkCTree::collapse

void collapse( GtkCTreeNode node );

Collapse one node.

GtkCTree::collapse_recursive

void collapse_recursive([ GtkCTreeNode node = NULL ]);

Collapse one node and all its subnodes.

GtkCTree::collapse_to_depth

void collapse_to_depth( GtkCTreeNode node , int depth);

Collapse a node and its children up to the depth given.

GtkCTree::toggle_expansion

void toggle_expansion( GtkCTreeNode node );

Toggle a node, i.e. if it is collapsed, expand it and vice versa.

GtkCTree::toggle_expansion_recursive

void toggle_expansion_recursive( GtkCTreeNode node );

Toggle the expansion of a node and all its children.

Page 134: Apostila PHP GTK

GtkCTree::select

void select( GtkCTreeNode node );

Cause the given node to be selected and emit the appropriate signal.

GtkCTree::select_recursive

void select_recursive([ GtkCTreeNode node = NULL ]);

Cause the given node and its subnodes to be selected and emit theappropriate signal(s).

GtkCTree::unselect

void unselect( GtkCTreeNode node );

Unselect the given node and emit the appropriate signal.

GtkCTree::unselect_recursive

void unselect_recursive([ GtkCTreeNode node = NULL ]);

Unselect the given node and its subnodes and emit the appropriatesignal(s).

GtkCTree::node_set_text

void node_set_text(int row, int column, string text);

Set the column text of the specific row. The row number begins with 0and counts only viewable rows.

GtkCTree::node_set_pixmap

void node_set_pixmap( GtkCTreeNode node , int column, GdkPixmap pixmap, GdkBitmap mask );

Sets an icon into a column of the node. The normal text in that columnis replaced by the icon and not visible anymore. Use thenode_set_pixtext function to add an extra text after that icon.

If you once expand/collapse the node, the icon is gone because theopen/closed icons you set at the insert_node are used then. To preventthis, use the set_node_info function.

GtkCTree::node_set_pixtext

void node_set_pixtext( GtkCTreeNode node , int column, string text,int spacing, GdkPixmap pixmap , GdkBitmap mask );

Sets the pixmap and the corresponding text of a column of a row. Thepixmap and mask parameters may not be NULL.

Page 135: Apostila PHP GTK

If you once expand/collapse the node, the icon is gone because theopen/closed icons you set at the insert_node are used then. To preventthis, use the set_node_info function. The text stays visible.

GtkCTree::set_node_info

void set_node_info( GtkCTreeNode node , string text, int spacing,GdkPixmap pixmap_closed , GdkBitmap mask_closed , GdkPixmappixmap_opened , GdkBitmap mask_opened , bool is_leaf, bool expanded);

Changes all the values set by the insert_node function.

GtkCTree::node_set_shift

void node_set_shift( GtkCTreeNode node , int column, int vertical, inthorizontal);

Shift the column of the given cell the given amounts in pixels.

Moves the column display inside the area reserved for the display.E.g. when you set the vertical to 20 and the height of the row is just10, then the cell won't be visible any more.

This function can be used to move the icon or the text a given amountleft/right from the +/- symbols (horizontal).

GtkCTree::node_set_selectable

void node_set_selectable( GtkCTreeNode node , bool selectable);

Sets whether this node can be selected by the user. This is useful ifyou have separators in the tree which have no function except thatthey separate something and shall not be selectable by the user.

GtkCTree::node_get_selectable

bool node_get_selectable( GtkCTreeNode node );

Whether this node can be selected by the user.

GtkCTree::node_get_cell_type

GtkCellType node_get_cell_type ( GtkCTreeNode node , int column);

Returns the type of the given cell.

GtkCTree::node_get_text

String node_get_text( GtkCTreeNode node , int column);

Returns the column text of a given row.

The column in which the expanders/lines are visible cannot use this

Page 136: Apostila PHP GTK

function (nTreeGraphic in the Constructor). You have to usenode_get_pixtext in this case.

Note that this function can also not be used if you used the functionsnode_set_pixtext or node_set_pixmap to that column. You should usenode_get_pixtext instead.

GtkCTree::node_get_pixtext

Array node_get_pixtext( GtkCTreeNode node , int column);

Returns the column pixtext of a given row. The array has a length of 4and contains the following values:* 0 - String - Pixtext* 1 - int - Spacing between icon and text* 2 - GdkPixmap Pixmap* 3 - GdkBitmap Pixmask

GtkCTree::get_node_info

Array get_node_info( GtkCTreeNode node );

Get information corresponding to a node. Any of the return parameterscan be null.

The array has a size of 8 and contains the same values in the sameorder as you set them with insert_node or set_node_info.

GtkCTree::node_set_row_style

void node_set_row_style( GtkCTreeNode node , GtkStyle style );

Set the style of a row.

GtkCTree::node_get_row_style

GtkStyle node_get_row_style ( GtkCTreeNode node );

Get the style of a row.

GtkCTree::node_set_cell_style

void node_set_cell_style( GtkCTreeNode node , int column, GtkStylestyle );

Set the style of an individual cell.

GtkCTree::node_get_cell_style

GtkStyle node_get_cell_style ( GtkCTreeNode node , int column);

Get the style of an individual cell.

GtkCTree::node_set_foreground

Page 137: Apostila PHP GTK

void node_set_foreground( GtkCTreeNode node , GdkColor color );

Set the foreground (text) color of a row.

GtkCTree::node_set_background

void node_set_background( GtkCTreeNode node , GdkColor color );

Set the background color of a row. This is useful in connection withnode_set_selectable so that the user can distinguish betweenselectable and not selectable rows. But then don't forget to changethe foreground color to a contrast color.

GtkCTree::node_set_row_data

void node_set_row_data( GtkCTreeNode node , Object custom);

Associate a custom object with the row.

If you have e.g. a file tree, then you could add the open file handlesto the corresponding node.

GtkCTree::node_get_row_data

Object node_get_row_data( GtkCTreeNode node );

Returns the custom object associated with the node.

GtkCTree::node_moveto

void node_moveto( GtkCTreeNode node , int column, double row_align,double col_align);

This function makes the given column of the given node visible byscrolling.

GtkCTree::node_is_visible

GtkVisibility node_is_visible ( GtkCTreeNode node );

True if the node is currently inside the bounds of the window. Notethat this function can return true even if the node is not viewable,if the node's ancestor is visible.

GtkCTree::set_indent

void set_indent(int indent);

Sets the number of pixels to shift the levels of the tree.

GtkCTree::set_spacing

void set_spacing(int spacing);

Page 138: Apostila PHP GTK

Sets the spacing between the tree graphic and the actual node content.

GtkCTree::set_show_stub

void set_show_stub(bool show_stub);

GtkCTree::set_line_style

void set_line_style( GtkCTreeLineStyle line_style );

Set the line style of the tree.

GtkCTree::set_expander_style

void set_expander_style( GtkCTreeExpanderStyle expander_style );

Set the expander style of the tree.

GtkCTree::sort_node

void sort_node( GtkCTreeNode node );

Sort the children of a node. The details of sorting can be set withthe GtkCList functions set_sort_column and set_sort_type.

GtkCTree::sort_recursive

void sort_recursive([ GtkCTreeNode node = NULL ]);

Sort the descendants of a node. The details of sorting can be set withthe GtkCList functions set_sort_colum and set_sort_type.

tree-select-row

Emitted when a row is selected.

The use of the third parameter is not known, only that is hassomething to do with the selection mode.

Função Callback

void callback(GtkCTree widget, GtkCTreeNode node, int unknown, ???userparam1]);

tree-unselect-row

Emitted when a node is unselected.

The use of the third parameter is not known, only that is hassomething to do with the selection mode.

Função Callback

Page 139: Apostila PHP GTK

void callback(GtkCTree widget, GtkCTreeNode node, int unknown, ???userparam1]);

tree-expand

Emitted when a node is expanded.

Função Callback

void callback(GtkCTree widget, GtkCTreeNode node, ??? userparam1]);

tree-collapse

Emitted when a node is collapsed.

Função Callback

void callback(GtkCTree widget, GtkCTreeNode node, ??? userparam1]);

tree-move

Emitted when a node is moved.

Função Callback

void callback(GtkCTree widget, GtkCTreeNode node, GtkCTree new_parent,GtkCTreeNode new_sibling, ??? userparam1]);

GtkCTree::clist

Access: Read OnlyType: GtkCTree

GtkCTree::row_list

Access: Read OnlyType: Array

Array of viewable nodes. This means that if a node is not expanded,its children won't occur on that list.

GtkCTree::selection

Access: Read OnlyType: Array

Array of selected rows (nodes).

GtkCTreeNode

Represents one row in a GtkCTree

Hierarquia do Objeto

Page 140: Apostila PHP GTK

GtkCTreeNode

Direct subclasses

None.

Descrição

Represents a row in a GtkCTree. To obtain information like the textof the row, you have to use the get_node_info function of the treeobject.

Propriedades

parent:

sibling:

children:

pixmap_closed:

pixmap_opened:

mask_closed:

mask_opened:

level:

is_leaf:

expanded:

row:

GtkCTreeNode::parent

Access: Read OnlyType: GtkCTreeNode

GtkCTreeNode::sibling

Page 141: Apostila PHP GTK

Access: Read OnlyType: GtkCTreeNode

GtkCTreeNode::children

Access: Read OnlyType: array

GtkCTreeNode::pixmap_closed

Access: Read OnlyType: GdkPixmap

GtkCTreeNode::pixmap_opened

Access: Read OnlyType: GdkPixmap

GtkCTreeNode::mask_closed

Access: Read OnlyType: GdkBitmap

GtkCTreeNode::mask_opened

Access: Read OnlyType: GdkBitmap

GtkCTreeNode::level

Access: Read OnlyType: int

GtkCTreeNode::is_leaf

Access: Read OnlyType: bool

GtkCTreeNode::expanded

Access: Read OnlyType: bool

GtkCTreeNode::row

Access: Read OnlyType: GtkCListRow

GtkCurve

Widget that allows editing of a curve.

Hierarquia do Objeto

Page 142: Apostila PHP GTK

GtkObject`-- GtkWidget`-- GtkDrawingArea`-- GtkCurve

Direct subclasses

None.

Descrição

Construtor

GtkCurve (void);

--

Métodos

reset()

set_gamma()

set_range()

get_vector()

set_vector()

set_curve_type()

GtkCurve Construtor

GtkCurve (void);

GtkCurve::reset

void reset(void);

GtkCurve::set_gamma

void set_gamma(double gamma);

GtkCurve::set_range

void set_range(double min_x, double max_x, double min_y, doublemax_y);

GtkCurve::get_vector

Page 143: Apostila PHP GTK

XXX get_vector(XXX);

GtkCurve::set_vector

XXX set_vector(XXX);

GtkCurve::set_curve_type

void set_curve_type(GtkCurveType type);

GtkData

Abstract base class for objects containing data.

Hierarquia do Objeto

GtkObject`-- GtkData

Direct subclasses

GtkAdjustment, GtkTooltips, GladeXML

Descrição

GtkData is a legacy abstract base class providing inheritingobjects with a single signal - which no longer operates.

Objects that are descendants of this class are not widgets, and donot take up screen space. They purely carry data.

In GTK 2, GtkData will cease to exist entirely, and the objectsthat currently are derived from it will be derived directly fromGtkObject instead.

Sinais

"disconnect"

Never emitted.

disconnect

This is a legacy signal which has been implemented in GtkData butnowhere else. You won't get an error message by setting up aconnection for it, but there is no longer any way to make an objectemit it - so don't bother.

Função Callback

void callback(GtkData object);

GtkDialog

Page 144: Apostila PHP GTK

Widget that eases creation of popup dialogs.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkWindow`-- GtkDialog

Direct subclasses

GtkInputDialog

Descrição

GtkDialog is used to create a popup window for presenting orrequesting small amounts of information. It is composed of twocontainers separated by a GtkHSeparator. The top container is aGtkVBox, and would typically contain GtkLabel and GtkEntry widgetsto present the user with information and allow input. The bottomcontainer is a GtkHBox and would usually contain dialog buttons,e.g. OK, Cancel, Help and so on.

Note that widgets should not be added to the GtkDialog itself butto the containers, which can be accessed as vbox and action_arearespectively.

Dialogs can be made modal (in effect freezing input to the rest ofthe application) by calling the GtkWindow method set_modal() on theGtkDialog object.

Note that making a GtkDialog modal does not stop execution of thecode that calls it. In the example below, the call to 'echo' willstill get executed even though the main application may not respondto user input. To stop execution of the code the GtkDialog mustcontain a call to a nested gtk::main() function. Execution willthen continue when the corresponding gtk::main_quit() function iscalled.

Exemplo 12. Using set_modal() <?php

$dialog = &new GtkDialog();$dialog->set_modal(TRUE);echo "This message will still be printed \n";

?>

Construtor

GtkDialog (void);

Page 145: Apostila PHP GTK

-- Creates the basis for a popup dialog window.

Propriedades

vbox:

Upper container.

action_area:Lower container.

GtkDialog Construtor

GtkDialog (void);

Creates the basis for a dialog window.

Exemplo 13. Creating a dialog window<?php

$dialog = &new GtkDialog();$dialog->set_policy(true, false, false);$dialog->set_position(GTK_WIN_POS_CENTER);$dialog->connect_object("destroy", array("gtk","main_quit"));

$dialog_vbox = $dialog->vbox;$dialog_action_area = $dialog->action_area;

$user_info_label = &new GtkLabel("Some Important Information");$dialog_vbox->pack_start($user_info_label);

$ok_button = &new GtkButton("OK");$dialog_action_area->pack_start($ok_button);

gtk::main();

?>

GtkDialog::vbox

Access: Read OnlyType: GtkWidget

vbox is the GtkVBox at the top of the GtkDialog widget. The programmerwould typically add widgets such as GtkLabel and GtkEntry here for thepurpose of exchanging information with the end user.

GtkDialog::action_area

Access: Read OnlyType: GtkWidget

Page 146: Apostila PHP GTK

action_area is the GtkHBox at the bottom of the GtkDialog widget,below the GtkHSeparator. This is where the programmer would usuallyadd one or two GtkButtons, connecting these to functions thatterminate the dialog and/or act upon the information gathered throughit.

GtkDrawingArea

Widget for custom user interface elements.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkDrawingArea

Direct subclasses

GtkCurve

Descrição

A GtkDrawingArea is a widget whose GdkWindow can be drawn to. Youcould use it to create a new user interface element, or anupdateable graph, or pretty much anything, using the GDK and GTKdraw and paint functions.

Because it is in itself so featureless, everything has to be addedto a GtkDrawingArea. It will not respond to key or button pressevents, unless you give it the ability to do so using set_events()or add_events() . It cannot have keyboard focus, unless you set theGTK_CAN_FOCUS flag. It does not regard what is drawn upon it as aclue to sizing, so you have to size it. If you want it to react toresizing, you will need to connect it to an appropriate callbackvia the "configure-event" signal in order to do so. It has nodefining behaviour, beyond the ability to manufacture configureevents when it is allocated a new size. It's basically a completelyempty widget.

Redraws should be created through an "expose-event" handler.

Construtor

GtkDrawingArea (void);

-- Constructs a blank, drawable widget.

Métodos

size()Sets the size of the drawing area.

GtkDrawingArea Construtor

Page 147: Apostila PHP GTK

GtkDrawingArea (void);

Exemplo 14. Drawing to a GtkDrawingArea<?php

dl('php_gtk.'.(strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

function draw_it($drawingarea, $event, $style, $gdkwindow) {/* access the GdkWindow's colormap to associate a color with a GdkGC */$colormap = $gdkwindow->colormap;$yellow = $gdkwindow->new_gc();$yellow->foreground = $colormap->alloc('yellow');$red = $gdkwindow->new_gc();$red->foreground = $colormap->alloc('red');$red->line_width = 7;

/* set up fonts. The first font here is set as part of the drawingarea'sstyle property so that it will be used in gtk::draw_string(). */$font =gdk::font_load('-unknown-Arial-bold-r-normal--*-120-*-*-p-0-iso8859-1');$style->font = $font;$font2 =gdk::font_load('-unknown-Arial-bold-r-normal--*-720-*-*-p-0-iso8859-1');

/* call the appropriate drawing functions */gdk::draw_rectangle($gdkwindow, $style->white_gc, true, 0, 0, 200, 220);gdk::draw_rectangle($gdkwindow, $yellow, true, 50, 50, 100, 100);gdk::draw_string($gdkwindow, $font2, $style->white_gc, 75, 130, '?');gdk::draw_line($gdkwindow, $red, 20, 20, 180, 180);gdk::draw_line($gdkwindow, $red, 20, 180, 180, 20);gtk::draw_string($style, $gdkwindow, GTK_STATE_NORMAL, 12, 210,'SAY TO SQUARE EGGS!');gdk::draw_string($gdkwindow, $font, $red, 42, 210, 'NO');}

function press_it($drawingarea, $event, $style, $gdkwindow) {/* make the drawingarea look like it has been pressed down */$rectangle = &new GdkRectangle(0, 0, 200, 220);gtk::paint_focus($style, $gdkwindow, $rectangle, $drawingarea, null, 0, 0,200, 220);}

function redraw_it($drawingarea, $event) {/* trigger a new expose event */$drawingarea->queue_draw();}

/* set up the main window that will hold the drawing area */$window = &new GtkWindow();$window->set_position(GTK_WIN_POS_CENTER);$window->connect_object('destroy', array('gtk', 'main_quit'));

/* set up the drawing area. Sizing is taken from the parent, unless set.We need to add events so that the drawingarea is sensitive to the mouse,

Page 148: Apostila PHP GTK

using set_events() to do this because the widget is not realized yet. */$drawingarea = &new GtkDrawingArea();$drawingarea->size(200, 220);$drawingarea->set_events(GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);$window->add($drawingarea);

/* once the drawing area has been added to the window we can realize() it,which means that we can now access its properties */$drawingarea->realize();$style = $drawingarea->style;$gdkwindow = $drawingarea->window;

/* drawing should always follow an expose event */$drawingarea->connect('expose-event', 'draw_it', $style, $gdkwindow);$drawingarea->connect('button-press-event', 'press_it', $style,$gdkwindow);$drawingarea->connect('button-release-event', 'redraw_it');

$window->show_all();gtk::main();

?>

GtkDrawingArea::size

void size(int width, int height);

A GtkDrawingArea has no default size set. If none is given, it willdefault to the size allocated to it by its parent window. Note thatthe size set using this method is treated as the drawingarea's sizerequest, and may be overridden in some situations.

GtkEditable

Base class for text-editing widgets.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkEditable

Direct subclasses

GtkEntry, GtkText

Descrição

GtkEditable is an abstract base class providing GtkEntry andGtkText with several methods, signals and properties, and also aset of keybindings that can be used for editing.

Tabela 2. Key bindings for editingKey combination Editing function

Page 149: Apostila PHP GTK

Control + a Move to the beginning of the lineControl + b Move back one characterControl + c Copy currently selected textControl + d Delete forward characterControl + e Move to the end of the lineControl + f Move forward one characterControl + h Delete backward characterControl + k Delete to line endControl + n Move to the next line (GtkText only)Control + p Move to the previous line (GtkText only)Control + u Delete current lineControl + v Paste clipboard textControl + w Delete backward wordControl + x Cut currently selected textAlt + b Move back one wordAlt + d Delete forward wordAlt + f Move forward one word

There are also a host of signals that are used internally to enablethese editing functions to work. These signals have not beendocumented here.

Métodos

select_region()Selects designated area of text.

insert_text()Inserts a string of text.

delete_text()Deletes designated area of text.

get_chars()Returns designated string.

cut_clipboard()Copies and deletes selected string.

copy_clipboard()Copies selected string.

paste_clipboard()Pastes current clipboard contents.

claim_selection()Provides selection data.

delete_selection()Deletes selected text and accompanying selection data.

changed()Causes "changed" signal to be emitted.

Page 150: Apostila PHP GTK

set_position()Sets the cursor position.

get_position()Returns the current cursor position.

set_editable()Toggles whether the text is editable.

Sinais

"changed"Emitted when there is a change to the text string.

"insert-text"Emitted when insert_text() is called.

"delete-text"Emitted when text is deleted.

"activate"Emitted when designated key is pressed.

"set-editable"Emitted when the set_editable() method is called.

"cut-clipboard"Emitted when cut_clipboard() is called.

"copy-clipboard"Emitted when copy_clipboard() is called.

"paste-clipboard"Emitted when paste_clipboard() is called.

Propriedades

selection_start_pos:Selection start position.

selection_end_pos:Selection end position.

has_selection:Indicates whether there is currently a selection.

GtkEditable::select_region

void select_region(int start, int end);

select_region() selects an area of text programmatically. The startand end parameters can be 0, -1 if the full text string is required.

Note that the editable widget needs to be realized prior to this

Page 151: Apostila PHP GTK

method being called on it. See claim_selection() .

GtkEditable::insert_text

void insert_text(string text_string, int position);

insert_text() is the simplest way of putting text into an editablewidget. GtkText has an alternative method, insert() , which givesgreater control over the appearance of the text, amongst other things.

This method does not support internationalization under win32. Useinsert() .

The insert_text() method also causes the signal of the same name to beemitted.

GtkEditable::delete_text

void delete_text(int start_pos, int end_pos);

Deletes the designated area of text.

As with all editing functions, 0 denotes the beginning of the string,and -1 the end position.

delete_text() also causes the signal of the same name to be emitted.

GtkEditable::get_chars

string get_chars(int start_pos, int end_pos);

This method is used to return the specified contents of a string. Toreturn the complete string, pass 0, -1 as the parameters.

GtkEditable::cut_clipboard

void cut_clipboard(void);

cut_clipboard() copies the current selection to the clipboard. It thendeletes the original text using the position parameters of theselection.

It also causes the "cut-clipboard" signal to be emitted.

GtkEditable::copy_clipboard

void copy_clipboard(void);

copy_clipboard() copies the current selection to the clipboard.

It also causes the "copy-clipboard" signal to be emitted.

GtkEditable::paste_clipboard

Page 152: Apostila PHP GTK

void paste_clipboard(void);

paste_clipboard() pastes the current clipboard contents at the cursorposition.

It also causes the "paste-clipboard" signal to be emitted.

GtkEditable::claim_selection

void claim_selection(bool claim, int time);

This method is used internally as a way to provide select_region()with all the data it needs in order to work, including the underlyingGdkWindow that the GtkSelectionData requires. It's not very usefulelsewhere.

GtkEditable::delete_selection

void delete_selection(void);

This method deletes the information held in the clipboard as well asthe text to which it relates. It is used internally to differentiatebetween a full text delete and the deletion used in cut_clipboard() .

Generally, use delete_text() instead.

GtkEditable::changed

void changed(void);

This method causes the GtkEditable widget to emit the "changed"signal.

It is called internally every time there is a change made to the textstring.

GtkEditable::set_position

void set_position(int position);

Sets the cursor position within the string of existing text. Note thatthe calling editable widget must have keyboard focus in order for thecursor position to be valid.

GtkEditable::get_position

int get_position(void);

This method returns the current cursor position.

GtkEditable::set_editable

void set_editable(bool is_editable);

Page 153: Apostila PHP GTK

set_editable() , when set to true, sets the widget to be editable bythe user.

The default setting is false.

changed

Effectively, the only difference between this and the"key-press-event" signal is that the key press event is not passed tothe callback function.

Função Callback

void callback(GtkEditable widget);

insert-text

This signal is emitted when the insert_text() method is called, whichhappens internally every time the text is added to by the end user, atevery key press.

The string_length that is passed is the length of the string that isbeing inserted, and not the length of the string that makes up thecontent of the text widget.

Note that there is a fourth parameter here that the signal cannotcarry in PHP-GTK because it is a GTK_TYPE_POINTER, which is anunsupported type. Depending on the E-NOTICES settings in your php.inifile, you may get an error message when you connect this signal. Thisdoes not affect the signal's functionality.

Função Callback

void callback(GtkEditable widget, string text_string, intstring_length);

delete-text

This signal is emitted when the delete_text() method is called, whichhappens internally when the user presses the delete button and text iscurrently selected.

The data that is passed with this signal consists of the calling classand the start and end positions of the selection.

Função Callback

void callback(GtkEditable widget, int start_pos, int end_pos);

activate

The "activate" signal is usually fired when the user presses Return.However, note that in GtkText both the Return key and the arrow keysneed to be combined with the Control key in order to have their usual

Page 154: Apostila PHP GTK

effect.

Função Callback

void callback(GtkEditable widget);

set-editable

This signal is emitted when the set_editable() is called. It carries aboolean value which determines in which direction the switch has beenmade.

Função Callback

void callback(GtkEditable widget, bool is_editable);

cut-clipboard

This signal is emitted when the cut_clipboard() method is called. Thishappens internally when the user presses the Control and x keyssilmultaneously.

Função Callback

void callback(GtkEditable widget);

copy-clipboard

This signal is emitted when the copy_clipboard() method is called.This happens internally when the user presses the Control and c keyssilmultaneously.

Função Callback

void callback(GtkEditable widget);

paste-clipboard

This signal is emitted when the paste_clipboard() method is called.This happens internally when the user presses the Control and v keyssilmultaneously.

Função Callback

void callback(GtkEditable widget);

GtkEditable::selection_start_pos

Access: Read OnlyType: int

The position in the text index that the current selection starts from,if there is one.

Page 155: Apostila PHP GTK

GtkEditable::selection_end_pos

Access: Read OnlyType: int

The position in the text index that the current selection ends at, ifthere is one.

GtkEditable::has_selection

Access: Read OnlyType: bool

Indicates whether there is currently a selection.

GtkEntry

A single line text entry field.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkEditable`-- GtkEntry

Direct subclasses

GtkSpinButton

Descrição

GtkEntry is a single line text field generally used where input isrequired from the user. The minimum length of the entry field isset internally at 150 pixels; the maximum length is determined bythe size of the container. If the text entered is longer than theentry field, the widget will scroll so that the cursor position isvisible.

Both GtkEntry and GtkText have the potential to be edited by theuser, and share a fairly large number of key bindings to that end.These are listed under GtkEditable for the sake of completeness;however, note that they are replaced by a more intuitive set inGTK+ 2.0.

It will be immediately obvious that quite a few GtkEntry methods aremarked here as being deprecated in later GTK+ releases. Please beaware that all editable classes are undergoing radical changes, andthat deprecated methods may or may not be supportable in the future.It would therefore be wise to avoid methods marked as deprecated, asfar as is possible.

See also: GtkEditable, GtkCombo, GtkList, GtkCheckButton,GtkToggleButton, GtkRadioButton.

Page 156: Apostila PHP GTK

Construtor

GtkEntry (void);

-- Creates a single-line text entry widget.

Métodos

set_text()Sets text content.

append_text()Adds text to the end of entered text. *Deprecated in GTK2*

prepend_text()Adds text to the start of entered text. *Deprecated in GTK2*

set_position()Sets cursor position. *Deprecated in GTK2*

get_text()Retrieves entered text.

select_region()Selects text region. *Deprecated in GTK2*

set_visibility()Toggles text visibility.

set_editable()Toggles text editability. *Deprecated in GTK2*

set_max_length()Sets the maximum text length.

GtkEntry Construtor

GtkEntry (void);

Creates a widget that will hold a single line of text, either setprogrammatically through set_text() or entered by the user.

Exemplo 15. Retrieving text from a GtkEntry widget <?php

dl('php_gtk.'.(strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

/* set up a function to collect the input from the entry and print it */function get_input($entry) {$input=$entry->get_text();echo "$input\n";$entry->grab_focus();$entry->set_text("");

Page 157: Apostila PHP GTK

}

/* set up the window */$window = &new GtkWindow();$window->set_position(GTK_WIN_POS_MOUSE);$window->connect_object('destroy', array('gtk', 'main_quit'));

/* add a box container to the window to allow more than one child widget */$box = &new GtkVBox();$window->add($box);

/* add a GtkEntry to the box and connect it to the callback function */$entry = &new GtkEntry();$entry->connect('activate', 'get_input');$box->add($entry);

/* add a GtkButton to the box and use connect_object() so that itwill pass the GtkEntry to the callback when it is clicked */$button = &new GtkButton('Return or click me to echo input');$button->connect_object('clicked', 'get_input', $entry);$box->add($button);

/* display everything and set the main loop running */$box->show_all();$window->show_all();gtk::main();

?>

GtkEntry::set_text

void set_text(string text);

set_text() sets a string of given text in the entry field.

$entry-gt;set_text("Programmed text entry");

GtkEntry::append_text

void append_text(string text);

append_text() adds the given string to the end of any entered text.

$entry->append_text("</END>");

GtkEntry::prepend_text

void prepend_text(string text);

prepend_text() adds the given string to the start of any entered text.

$entry->prepend_text("<START>");

GtkEntry::set_position

Page 158: Apostila PHP GTK

void set_position(int position);

set_position() sets the cursor at the given character position withinexisting text in the entry field. Use 0 to set the cursor at thebeginning of the text, and -1 to set it at the end.

GtkEntry::get_text

string get_text(void);

get_text() retrieves the text entered into the GtkEntry widget, andalso any appended or prepended text that may have been set but notdisplayed.

Contrary to rumour, this function is *not* marked as deprecated,either in the versions of GTK+ currently used by PHP-GTK or in recentdevelopment releases of GTK+.

GtkEntry::select_region

void select_region(int start, int end);

select_region() is used to select a region of existing text, generallyfor using with the cut, copy and paste methods found in GtkEditable.

If you need to select the entire text entry, use the setting (0, -1).

GtkEntry::set_visibility

void set_visibility(bool visible);

set_visibility() , when set to false, provides a means of hidingsensitive input information on screen. It replaces each character witha star.

This function is mainly used for password entry.

GtkEntry::set_editable

void set_editable(bool editable);

set_editable() sets the entry field to be editable by the user, orotherwise.

The default setting is true.

Note that setting set_editable() to true on top of the default settingcan lead to some unexpected effects.

GtkEntry::set_max_length

void set_max_length(int max);

Page 159: Apostila PHP GTK

set_max_length() sets the maximum number of characters that will beaccepted in a text entry. Any further characters entered will not bedisplayed in the entry field, nor will they be capable of beingretrieved with the get_text() function.

GtkEventBox

Widget used to capture events for widgets with no GdkWindow.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkEventBox

Direct subclasses

None.

Descrição

The GtkEventBox is used to capture events for widgets that do nothave their own window.

Most widgets inherit the window property from GtkWidget, whichmakes it possible to use those widgets interactively. However, somewidgets are flagged as GTK_NO_WINDOW at source, because there israrely a need to capture events crossing those widgets.

The following widgets and their descendants fall into this categoryand need to be packed into an event box before they can be made torespond to user activity:

GtkAlignmentGtkArrowGtkBoxGtkCheckButtonGtkFrameGtkImageGtkItemGtkLabelGtkPackerGtkPixmapGtkScaleGtkScrolledWindowGtkSeparatorGtkTableGtkToggleButton - alters according to its draw indicator status!

Construtor

GtkEventBox (void);

Page 160: Apostila PHP GTK

-- Creates a means of capturing events where there is none.

GtkEventBox Construtor

GtkEventBox (void);

The most common need for a GtkEventBox arises when a tooltip isrequired for a non-windowed widget.

Exemplo 16. Giving a GtkLabel a tooltip.<?php

dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

$window = &new GtkWindow();$window->set_position(GTK_WIN_POS_CENTER);$window->connect_object('destroy', array('gtk', 'main_quit'));

$eventbox = &new GtkEventBox();$label = &new GtkLabel("This is a normal label. It cannot captureevents.");$eventbox->add($label);$label->show();$window->add($eventbox);

$tooltip = &new GtkTooltips();$tooltip->set_tip($eventbox, "So how did this get here?", null);$tooltip->enable();

$window->show_all();

gtk::main();

?>

GtkFileSelection

Widget for selecting a file or a directory.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkWindow`-- GtkFileSelection

Direct subclasses

None.

Descrição

Page 161: Apostila PHP GTK

GtkFileSelection is used to retrieve files or directories requestedby the end user. The widget contains a directory list and a filelist which will correspond to the default directory, that is,either the current working directory or one determined usingset_filename() .

The filesystem can be navigated using either the directory tree orthe dropdown history menu. Alternatively it is possible to type thedirectory or file path into the selection_entry field, and also touse the TAB key to autocomplete either the directory name or filename entered in this way.

Construtor

GtkFileSelection ([string title ]);

-- Creates a new GtkFileSelection widget.

Métodos

set_filename()Sets the default path.

get_filename()Returns the current selected path.

complete()Matches a given pattern to a valid file name.

show_fileop_buttons()Shows the file operation buttons.

hide_fileop_buttons()Hides the file operation buttons.

Propriedades

dir_list:Directory list.

file_list:File list.

selection_entry:Entry field.

selection_text:Directory selection status.

main_vbox:Main container.

ok_button:

Page 162: Apostila PHP GTK

Standard button.

cancel_button:Standard button.

action_area:Container for custom additions.

GtkFileSelection Construtor

GtkFileSelection ([string title ]);

The syntax to create a GtkFileSelection widget is:$fs = &new GtkFileSelection("My File Selection");

Note that if the title parameter is not supplied or is NULL the titlewill be set to the name of the file in which the PHP code resides.

GtkFileSelection::set_filename

void set_filename(string filename);

Sets the default path for the directory and/or file name.

$fs->set_filename("/home/user/php/");

GtkFileSelection::get_filename

string get_filename(void);

Returns a string representing the current value in the file selector.If no directory or file has been selected then the current path isreturned.

$filename = $fs->get_filename();

GtkFileSelection::complete

void complete(string pattern);

complete() will try to match the pattern given by the programmer to avalid file name in the current directory, or to a valid directory nameon the current drive. This is useful when, for example, wishing tohard-code a search for a specific extension into an application. Wherea full match is made, the matched file name will appear in both thefile list and the text entry field of the file selection dialog. Ifonly partial matches can be found, the file list will contain theresulting file names and the text entry field will contain the closestmatched string (not the full file name).

Note that only a single wildcard field is effective here.

$fs->complete("*.php");

Page 163: Apostila PHP GTK

GtkFileSelection::show_fileop_buttons

void show_fileop_buttons(void);

Shows the file operation buttons Create Dir, Delete File and RenameFile. This is their default state, so that show_fileop_buttons() wouldonly be used following a call to hide_fileop_buttons() . The rest ofthe widgets in the dialog will be automatically resized to accommodatethe status of the file operation buttons. These buttons do not needany programming in order to carry out their respective functions, asthese are already hard-coded into GTK+.

$fs->show_fileop_buttons();

GtkFileSelection::hide_fileop_buttons

void hide_fileop_buttons(void);

Hides the file operation buttons Create Dir, Delete File and RenameFile which by default appear at the top of a GtkFileSelection.hide_fileop_buttons() is useful where the programmer would prefer theend user not to have easy access to these file operations.

$fs->hide_fileop_buttons();

GtkFileSelection::dir_list

Access: Read OnlyType: GtkWidget

dir_list is a GtkCList widget embedded in the GtkFileSelection objectthat displays the subdirectories available in the current directory.

GtkFileSelection::file_list

Access: Read OnlyType: GtkWidget

file_list is a GtkCList widget embedded in the GtkFileSelection objectthat displays the list of files available in the current directory.

GtkFileSelection::selection_entry

Access: Read OnlyType: GtkWidget

selection_entry is a GtkEntry widget placed at the bottom of theGtkFileSelection object for use in navigation and searching. Itdisplays the current enquiry or the current selected item.

GtkFileSelection::selection_text

Access: Read OnlyType: GtkWidget

Page 164: Apostila PHP GTK

selection_text is a GtkLabel that by default contains the string"Selection: " followed by the full path of the current selecteddirectory.

GtkFileSelection::main_vbox

Access: Read OnlyType: GtkWidget

main_vbox is the container holding all the other elements of theGtkFileSelection widget.

GtkFileSelection::ok_button

Access: Read OnlyType: GtkWidget

ok_button is a GtkButton placed at the bottom of the GtkFileSelectionobject. Note that this button is not initially connected and has nodefault callback function.

GtkFileSelection::cancel_button

Access: Read OnlyType: GtkWidget

cancal_button is a GtkButton placed at the bottom of theGtkFileSelection object. As with the ok_button, it is the programmer'sresponsibility to listen for signals from this button and take theappropriate action.

GtkFileSelection::action_area

Access: Read OnlyType: GtkWidget

action_area is a GtkHBox which is positioned directly below thefile_list and dir_list.

It would generally be used for displaying custom items such asadditional buttons, labels or text entry boxes.

GtkFixed

Container that retains the sizes and positions of its children.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkFixed

Page 165: Apostila PHP GTK

Direct subclasses

None.

Descrição

GtkFixed is a container widget that retains the original sizes andpositions of its children regardless of any top-level resizing.

Note that there is no padding or spacing implicit in this method ofcontainer packing. The arrangement of the children is based purelyon the co-ordinate values given in the put() and move() methodparameters. For this reason it is inadvisable to use add() whenutilising GtkFixed, as widgets that have been added in this way canand will be overwritten by any fixed-position widgets.

Construtor

GtkFixed (void);

-- Creates a GtkFixed container.

Métodos

put()Sets initial position of child.

move()Moves child to new position.

Propriedades

children:Array of child positioning information.

GtkFixed Construtor

GtkFixed (void);

This function creates and returns a GtkFixed widget.

GtkFixed::put

void put( GtkWidget widget , int x, int y);

put() sets the initial position of the child widget(s) in a GtkFixedcontainer. This information is held in the children property as anarray of GtkFixedChild objects.

The parameters are the x and y co-ordinates of the top left-handcorner of the child widget, measured in pixels from the top left-handcorner of the container.

GtkFixed::move

Page 166: Apostila PHP GTK

void move( GtkWidget widget , int x, int y);

move() sets a new position for a child widget in a GtkFixed container.

The parameters are the x and y co-ordinates of the top left-handcorner of the child widget, measured in pixels from the top left-handcorner of the container.

GtkFixed::children

Access: Read OnlyType: array

The positioning information for the individual child widgets is storedin children as an array of GtkFixedChild objects.

GtkFixedChild

Helper class for GtkFixed.

Hierarquia do Objeto

GtkFixedChild

Direct subclasses

None.

Descrição

GtkFixed is a widget that fixes its children at their given sizesand positions.

GtkFixedChild is a helper class that allows access to thepositioning information for each individual child. The childrenproperty in GtkFixed is an array of GtkFixedChild objectscorresponding to the child widgets that have been put() into aGtkFixed object.

Note that GtkFixedChild cannot be constructed directly.

Propriedades

widget:

Child widget.

x:Child position x co-ordinate.

y:Child position y co-ordinate.

Page 167: Apostila PHP GTK

GtkFixedChild::widget

Access: Read OnlyType: GtkWidget

The widget property provides access to the child widget object.

It is possible to access methods, properties and signals belonging towidget as with any GtkWidget of the same type.<?php

$button = $fixed->children[5]->widget;$label = $button->child;$label->set_text("New Button Label");

?>

GtkFixedChild::x

Access: Read OnlyType: int

x is the measurement in pixels of the distance between the topleft-hand corner of the child widget and the left edge of the GtkFixedcontainer.

GtkFixedChild::y

Access: Read OnlyType: bool

y is the measurement in pixels of the distance between the topleft-hand corner of the child widget and the top edge of the GtkFixedcontainer.

GtkFontSelection

Widget for selecting fonts.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkNotebook`-- GtkFontSelection

Direct subclasses

None.

Descrição

Construtor

Page 168: Apostila PHP GTK

GtkFontSelection (void);

--

Métodos

get_font_name()

get_font()

set_font_name()

get_preview_text()

set_preview_text()

GtkFontSelection Construtor

GtkFontSelection (void);

GtkFontSelection::get_font_name

string get_font_name(void);

GtkFontSelection::get_font

GdkFont get_font(void);

GtkFontSelection::set_font_name

bool set_font_name(string fontname);

GtkFontSelection::get_preview_text

string get_preview_text(void);

GtkFontSelection::set_preview_text

void set_preview_text(string text);

GtkFontSelectionDialog

Standard dialog box for selecting fonts.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer

Page 169: Apostila PHP GTK

`-- GtkBin`-- GtkWindow`-- GtkFontSelectionDialog

Direct subclasses

None.

Descrição

Construtor

GtkFontSelectionDialog (string title);

--

Métodos

get_font_name()

get_font()

set_font_name()

get_preview_text()

set_preview_text()

GtkFontSelectionDialog Construtor

GtkFontSelectionDialog (string title);

GtkFontSelectionDialog::get_font_name

string get_font_name(void);

GtkFontSelectionDialog::get_font

GdkFont get_font(void);

GtkFontSelectionDialog::set_font_name

bool set_font_name(string fontname);

GtkFontSelectionDialog::get_preview_text

string get_preview_text(void);

GtkFontSelectionDialog::set_preview_text

Page 170: Apostila PHP GTK

void set_preview_text(string text);

GtkFrame

Container with a decorative frame and an optional label.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkFrame

Direct subclasses

GtkAspectFrame, GtkScintilla

Descrição

GtkFrame is a container for a single child widget that provides aconfigurable shadowed border around the child's allocated area.

Construtor

GtkFrame ([string label = NULL ]);

-- Creates a decorative container.

Métodos

set_label()Sets label text.

set_label_align()Sets label position.

set_shadow_type()Sets angle and depth of shadow.

GtkFrame Construtor

GtkFrame ([string label = NULL ]);

The label in the GtkFrame is only given physical space if a textstring is passed to it. The NULL default setting does not refer to thevalue of the text string, but to its absence.

Note that the internal label exists in this widget regardless ofwhether it has text set during construction.

GtkFrame::set_label

void set_label(string label);

Page 171: Apostila PHP GTK

set_label() sets the label text programmatically.

$frame->set_label("Alternative text string");

GtkFrame::set_label_align

void set_label_align(double xalign, double yalign);

set_label_align() sets the position of the label along the top edge ofthe frame. The position is given as a double, so that an xalignsetting of 0.0 would hold the label against the top left edge of theframe and a setting of 1.0 against the top right edge. The defaultxalign setting is 0.0.

Note that although the yalign setting is currently ignored by GTK, itis not possible to omit the parameter completely. The default settingfor yalign is 0.5 both currently and in development releases of GTK+,so it would seem advisable to use that value.

$frame->set_label_align(0.7, 0.5);

GtkFrame::set_shadow_type

void set_shadow_type( GtkShadowType type );

set_shadow_type() sets the angle and depth of the line of shadow thatdecorates the GtkFrame border, according to the specifiedGtkShadowType option.

The default setting is GTK_SHADOW_ETCHED_IN.

GtkGammaCurve

A subclass of GtkCurve for editing gamma curves.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBox`-- GtkVBox`-- GtkGammaCurve

Direct subclasses

None.

Descrição

Construtor

GtkGammaCurve (void);

Page 172: Apostila PHP GTK

--

GtkGammaCurve Construtor

GtkGammaCurve (void);

GtkHandleBox

Widget for detachable window portions.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkHandleBox

Direct subclasses

None.

Descrição

GtkHandleBox allows for widgets to be "torn out" of a window and tobecome their own floating window. The GtkHandleBox displays itschild along with a handle that the user can drag to tear the widgetout of its containing window and into its own float window. Whenthe widget is torn out of the original window, its place is held bya thin ghost widget. By draging the float window back to the ghostwidget and aligning the snap edge, the float window can bereattached.

GtkHandleBox is a decendant of GtkBin, which means that it maycontainer only one child. If you would like to have more than onewidget in the same float window, you must first add those widgetsto a container capable of holding more than one child, such as aGtkVBox.

Construtor

GtkHandleBox (void);

-- Create a widget capable of being "torn out" of a window.

Métodos

set_shadow_type()Set the shadow type that the float window will cast.

set_handle_position()Set the edge on which the handle will be shown.

Page 173: Apostila PHP GTK

set_snap_edge()Set the edge which must be aligned to reattach the float window.

GtkHandleBox Construtor

GtkHandleBox (void);

GtkHandleBox::set_shadow_type

void set_shadow_type(GtkShadowType type);

GtkHandleBox::set_handle_position

void set_handle_position(GtkPositionType position);

GtkHandleBox::set_snap_edge

void set_snap_edge(GtkPositionType edge);

Sets the edge which must be aligned to reattach the float window. Whenedge on both the float window and the ghost widget are aligned thefloat window will be reattached to its original window.

If the snap edge is not explicitly set using set_snap_edge() , thesnap edge will be determined automatically by the placement of thehandle.

To make detaching and reattaching the handlebox as minimally confusingas possible to the user, it is important to set the snap edge so thatthe snap edge does not move when the handlebox is deattached. Forinstance, if the handlebox is packed at the bottom of a GtkVBox, thenwhen the handlebox is detached, the bottom edge of the handlebox'sallocation will remain fixed as the height of the handlebox shrinks,so the snap edge should be set to GTK_POS_BOTTOM.

See also: set_handle_position()

GtkHBox

Horizontal box container.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBox`-- GtkHBox

Direct subclasses

GtkCombo, GtkStatusbar

Descrição

Page 174: Apostila PHP GTK

GtkHBox is a box container that packs child widgets in a singlerow, using the packing methods inherited from GtkBox, such aspack_start() , as well as the less flexible add() method availableto most container widgets. GtkHBox and GtkVBox in combination arethe most commonly used packing widgets. See the GtkVBox constructorfor a working example using both.

Note that all children in a GtkHBox are allocated the same height,regardless of settings and child requisition size. Widgets takingup less than the allocated height are by default centered withinthe available area in that dimension.

See also: GtkContainer, GtkBox, GtkVBox, GtkButtonBox, GtkTable.

Construtor

GtkHBox ([bool homogeneous = false , [int spacing = 0 ]]);

-- Creates a container for a single row of child widgets.

GtkHBox Construtor

GtkHBox ([bool homogeneous = false , [int spacing = 0 ]]);

Creates a new horizontal box container designed for packing a singlerow of child widgets.

The first parameter, homogeneous, is a boolean value which, if set totrue, will set each child widget in the GtkHBox to the same width asthat of the largest child widget. The second parameter, spacing, setsthe minimum spacing between the child widgets along the width of thecontainer, in pixels. Leaving both parameters empty, e.g.$hbox = &new GtkHBox();

will set the default behaviour of individual sizing and zero spacing.

GtkHButtonBox

Container for arranging a group of buttons horizontally.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBox`-- GtkButtonBox`-- GtkHButtonBox

Direct subclasses

None.

Page 175: Apostila PHP GTK

Descrição

GtkHButtonBox is a container widget designed for arranging a row ofbuttons in accordance with a specified GtkButtonBoxStyle setting.

See also: GtkButtonBox, GtkVButtonBox.

Construtor

GtkHButtonBox (void);

-- Creates the basis for a horizontal button container.

GtkHButtonBox Construtor

GtkHButtonBox (void);

The syntax for creating a horizontal buttonbox is:$hbuttonbox = &new GtkHButtonBox();

There are no parameters.

As with all container widgets, no physical space is taken by aGtkHButtonBox until its child widgets are in place.

GtkHPaned

Container with two panes arranged horizontally.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkPaned`-- GtkHPaned

Direct subclasses

None.

Descrição

GtkHPaned is a widget derived from GtkPaned, consisting of twopanes arranged horizontally and separated by a dividing handle. Thehandle can be adjusted by the end user to alter the relative sizesof the pane contents.

See also: GtkPaned, GtkVPaned.

Construtor

GtkHPaned (void);

Page 176: Apostila PHP GTK

-- Creates the basis for a horizontal dual-paned container.

GtkHPaned Construtor

GtkHPaned (void);

The GtkHPaned widget should be thought of in terms of an arrangementof two child widgets, rather than as an object in its own right. Theconstruct$hpaned = &new GtkHPaned();

needs to be within a containing GtkWindow and to contain two childwidgets of its own in order to work.

Exemplo 17. Constructing a GtkHPaned widget<?php

$window = &new GtkWindow();$window->set_title("GtkHPaned");$window->connect_object("destroy", array("gtk","main_quit"));

$hpaned = &new GtkHPaned();$window->add($hpaned);$hpaned->show();

$button = &new GtkButton("Widget child1");$hpaned->pack1($button, false, false);$button->show();

$label = &new GtkLabel();$label->set_text("Widget child2");$hpaned->pack2($label, true, true);$label->show();

$window->show_all();

gtk::main();

?>

Note that setting the resize parameter when packing GtkHPaned childwidgets will not prevent them from resizing vertically when thetop-level window is maximised.

GtkHRuler

Horizontal ruler.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkRuler

Page 177: Apostila PHP GTK

`-- GtkHRuler

Direct subclasses

None.

Descrição

Construtor

GtkHRuler (void);

--

GtkHRuler Construtor

GtkHRuler (void);

GtkHScale

Horizontal slider widget for selecting a value from a range.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkRange`-- GtkScale`-- GtkHScale

Direct subclasses

None.

Descrição

A GtkHScale is a horizontal scrollbar-like widget that is able todisplay its adjustment value as text.

There are some configuration issues with this widget when it isused in such a way; please refer to GtkScale for furtherinformation.

Construtor

GtkHScale ( GtkAdjustment adjustment );

-- Creates a horizontal slider.

GtkHScale Construtor

GtkHScale ( GtkAdjustment adjustment );

A GtkHScale that can be given its own GtkAdjustment settings or simply

Page 178: Apostila PHP GTK

not display the text value has no configuration issues whatever.However, please note that even a GtkHScale with no displayed value isnot able to scroll a GtkText widget.

GtkHScrollbar

Horizontal scrollbar.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkRange`-- GtkScrollbar`-- GtkHScrollbar

Direct subclasses

None.

Descrição

A GtkHScrollbar is a horizontal scrollbar.

Tabela 3. Key bindings for GtkHScrollbarKey combination Scroll functionLeft arrow Move left one step incrementRight arrow Move right one step incrementHome Move left one page incrementEnd Move right one page incrementControl + Home Move to left of scrollControl + End Move to right of scroll

Construtor

GtkHScrollbar ( GtkAdjustment adjustment );

-- Creates a horizontal scrollbar.

GtkHScrollbar Construtor

GtkHScrollbar ( GtkAdjustment adjustment );

A scrollbar needs a GtkAdjustment in order to operate. The values thatyou give to the adjustment object will depend on the situation wherethe scrollbar is intended to be used.

All scrollable widgets have their own adjustment object(s), and inmost instances where you are most likely to need a horizontalscrollbar it is possible to create a handle for the widget'shorizontal GtkAdjustment and assign that as the new scrollbar'sadjustment object.

There is no working horizontal adjustment object in GtkText.

Page 179: Apostila PHP GTK

See also: GtkAdjustment, GtkVScrollbar.

GtkHSeparator

Horizontal separator.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkSeparator`-- GtkHSeparator

Direct subclasses

None.

Descrição

A GtkHSeparator is a widget that consists of a horizontal line. Itis used to separate widgets that are laid out vertically.

Separators cannot be added to menu widgets. See GtkMenuItem fordetails.

See also: GtkVSeparator, gtk::paint_hline() .

Construtor

GtkHSeparator (void);

-- Draws a horizontal line.

GtkHSeparator Construtor

GtkHSeparator (void);

Constructing a GtkHSeparator and adding it to a widget amounts to thesame thing as drawing a horizontal line across that widget. Use thecontainer's packing methods to organise spacing around the separator.

GtkImage

Widget for displaying a graphical image.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkMisc`-- GtkImage

Direct subclasses

Page 180: Apostila PHP GTK

None.

Descrição

The GtkImage class is not implemented in PHP-GTK. Use GtkPixmapinstead.

GtkInputDialog

Standard dialog for configuring input devices.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkWindow`-- GtkDialog`-- GtkInputDialog

Direct subclasses

None.

Descrição

Construtor

GtkInputDialog (void);

--

GtkInputDialog Construtor

GtkInputDialog (void);

GtkInvisible

Internally used widget which is not displayed.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkInvisible

Direct subclasses

None.

Page 181: Apostila PHP GTK

Descrição

Construtor

GtkInvisible (void);

--

GtkInvisible Construtor

GtkInvisible (void);

GtkItem

Abstract base class for GtkMenuItem, GtkListItem, and GtkTreeItem.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkItem

Direct subclasses

GtkListItem, GtkMenuItem, GtkTreeItem

Descrição

GtkItem provides the toggle() method and "select", "deselect" and"toggle" signal prototypes for GtkMenuItem, GtkListItem, andGtkTreeItem.

Note that GtkItem is an abstract base class and cannot beconstructed directly.

Métodos

select()Emits "select" signal.

deselect()Emits "deselect" signal.

toggle()Emits "toggle" signal.

Sinais

"select"Emitted when user selects item using mouse-click.

"deselect"

Page 182: Apostila PHP GTK

Emitted when user deselects item using mouse-click.

"toggle"Emitted when user selects or deselects item using Enter key.

GtkItem::select

void select(void);

select() is part of a function/signal pair serving as a basis formethods of the same name lower in the hierarchy.

It enables the relevant implementation of the select signal to beemitted programmatically.

GtkItem::deselect

void deselect(void);

deselect() is part of a function/signal pair serving as a basis formethods of the same name lower in the hierarchy.

It enables the relevant implementation of the deselect signal to beemitted programmatically.

GtkItem::toggle

void toggle(void);

toggle() enables the relevant implementation of the toggle signal tobe emitted programmatically.

select

The "select" signal is emitted when the select() is called within theprogram, or when the cursor enters the item's screen area. There is nobehaviour defined at base level for this signal, please refer to thedescription in the deselect method in the non-abstract class you areusing.

Função Callback

void callback(GtkItem item);

deselect

The "deselect" signal is emitted when the deselect() is called withinthe program, or when the cursor leaves the screen area of the GtkItem.There is no behaviour defined at base level for this signal, pleaserefer to the description in the deselect method in the non-abstractclass you are using.

Função Callback

Page 183: Apostila PHP GTK

void callback(GtkItem item);

toggle

The "toggle" signal is emitted when the toggle() is called within theprogram, or when the user presses the enter or spacebar key while theconnected GtkItem has focus.

Beyond that, this signal also has no behaviour defined at base level.In GtkListItem and GtkTreeItem, the "toggle" signal switches statesbetween GTK_STATE_SELECTED and GTK_STATE_NORMAL; these GtkStateTypeenumerations are by default colour-coded, providing visual cues forthe end user as well as a value within the program.

GtkMenuItem inherits the "toggle" signal without adding to it, i.e. itis there in theory but has no functionality in practice.

It is worth noting that both GtkListItem and GtkTreeItem aredeprecated in future versions of GTK+, so that it would seemreasonable to expect the "toggle" signal to disappear too over time.

Função Callback

void callback(GtkItem item);

GtkItemFactory

A factory class for simplified menu creation.

Hierarquia do Objeto

GtkObject`-- GtkItemFactory

Direct subclasses

None.

Descrição

The GtkItemFactory is a class which makes it very easy to create alot of menu items at once. It supports nested menus, shortcuts anddifferent menu item types as well.

GtkItemFactory has been deprecated since GTK+ 2.0 and should not beused in newly written code.

Construtor

GtkItemFactory (GtkType container_type, String path, GtkAccelGroupaccel_group);

-- Creates a new instance of this class.

Page 184: Apostila PHP GTK

Métodos

create_items()Creates the whole menu.

get_item()Obtains the menu item which corresponds to path.

get_widget()Obtains the widget item which corresponds to path.

get_widget_by_action()Obtains the widget which was constructed from theGtkItemFactoryEntry with the given action.

get_item_by_action()Obtains the menu item which was constructed from the firstGtkItemFactoryEntry with the given action.

delete_item()Deletes the menu item which was created for path by the given itemfactory.

popup()Pops up the menu at (x, y).

GtkItemFactory Construtor

GtkItemFactory (GtkType container_type, String path, GtkAccelGroupaccel_group);

Creates a new instance of the GtkItemFactory class. One factory can beused for one menu, and not more. This means that if you want to have astandard GtkMenuBar at the top of a window and an additionalright-click popup menu, you have to use 2 item factories.

The container_type determines, which type the root menu will have:GtkMenu, GtkMenuBar or GtkOptionMenu. To get the GtkType you want,just use the the get_type() function of this class:$type = GtkMenuBar::get_type();

The path is a unique name for this menu, enclosed in < and >, e.g.<mainmenu>. This path has to be unique in the whole application.

The accel_group is the accelerator group belonging to this window andis responsible for the menu shortcuts. It can be NULL, but then themenu shortcuts won't work.

Exemplo 18. Using a GtkItemFactory<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

Page 185: Apostila PHP GTK

$window = &new GtkWindow();$window->set_default_size( 300, 20);$window->connect_object('destroy', array('gtk', 'main_quit'));

$accelgroup = &new GtkAccelGroup();$window->add_accel_group( $accelgroup);

$fac = &new GtkItemFactory( GtkMenuBar::get_type(), "<mainmenu>", $accelgroup);

function quit( $number, $item) {gtk::main_quit();}$arItems = array(array( "/_File/_Open", null, null, 0, null ),array( "/_File/_Save", null, null, 0, null ),array( "/_File/_Quit", "<CTRL>Q", 'quit', 0, null ));

$fac->create_items( $arItems);

$window->add( $fac->get_widget( "<mainmenu>"));$window->show_all();gtk::main();?>

A more sophisticated example can be found at the create_items()function.

GtkItemFactory::create_items

boolean create_items(Array items);

You usually create your menu by calling this method with an array fullof menu item definitions. Such a item definition is an array itselfand has the following structure: String path, String accelerator,Mixed callback, int callback_action, String type

The function can be called several times, causing the new items to beappended to the existing ones.If you add a first-level menu item on a second create_items call, anexisting <LastBranch> will lose its right alignment.

The path is the name describing the path form the top down to thisitem. The levels are separated with a slash /, and underscores _ canbe used to create in-menu accelerators."/_File/_Recent files/_1 test.xml""/_File/O_pen"

It is not necessary to explicitly create the parent items if youcreate a submenu item; this is done automatically.

The accelerator sets the shortcut for the menu item; it can be NULL ora combination of modifiers and chars.

Page 186: Apostila PHP GTK

Tabela 4. Accelerator modifiers<ALT><CTL> or <CTRL> or <CONTROL><MOD1> to <MOD5><SHFT> or <SHIFT>

As usually, the callback accepts the String of the function to call,or an array with the reference to an object as first, and the name ofthe object's function as the second parameter. This parameter can beNULL.

Unlike many other callback registering functions, this one doesn'tsupport own parameters as callback_option. Instead, you can give anumber (int) only to describe the function of the menu item. So youcan use 1 for opening and 2 for saving to distinguish both when theyuse the same callback. The callback function needs to implement 2parameters:int callback_option, GtkMenuItem item. The parameter has tobe of type int, so a NULL cause an error.

The type is a string from this list:

Tabela 5. GtkItemFactory item typesType DescriptionNULL or '' or <Item> Simple item<Title> Title item which can't be clicked.<CheckItem> Check item<ToggleItem> Toggle item<RadioItem> (Root) radio itemPath Sister radio item for another radio item<Tearoff> Tearoff<Separator> Separator<Branch> Item to hold submenus (optional)<LastBranch> Right justified branch. This is only useful for onesubmenu of a menubar.

Exemplo 19. Extensive GtkItemFactory::create_items example<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

$window = &new GtkWindow();$window->set_default_size( 300, 20);$window->connect_object('destroy', array('gtk', 'main_quit'));

$accelgroup = &new GtkAccelGroup();$window->add_accel_group( $accelgroup);

$fac = &new GtkItemFactory( GtkMenuBar::get_type(), '<mainmenu>', $accelgroup);

function menucall( $number, $item) {switch( $number) {

Page 187: Apostila PHP GTK

case 1: echo 'New file'; break;case 15: echo 'This is a small GtkItemFactory example'; break;case 20: gtk::main_quit(); break;default: echo 'Unknown action ' . $number;}echo "\r\n";}$arItems = array(array( '/_File/_New', '<CTRL>N', 'menucall', 1, null ),array( '/_File/_Open', '<CTRL>O', 'menucall', 2, '' ),array( '/_File/sep1', null, null, 0, '<Separator>' ),array( '/_File/_Save', '<CTRL>S', 'menucall', 0, null ),array( '/_File/Save _as', null, 'menucall', 0, null ),array( '/_File/sep2', null, null, 0, '<Separator>' ),array( '/_File/_Quit', '<CTRL>Q', 'menucall', 20, null ),

array( '/_View', null, null, 0, '<Branch>' ),array( '/_View/tearoff', null, null, 0, '<Tearoff>' ),array( '/_View/_Toolbar', null, null, 0, '<CheckItem>' ),array( '/_View/_Preview', null, null, 0, '<CheckItem>' ),

array( '/_Colors/tearoff', null, null, 0, '<Tearoff>' ),array( '/_Colors/Foreground', null, null, 0, '<Title>' ),array( '/_Colors/White', null, null, 0, '<RadioItem>' ),array( '/_Colors/Yellow', null, null, 0, '/Colors/White' ),array( '/_Colors/Orange', null, null, 0, '/Colors/White' ),

array( '/_Colors/sep1', null, null, 0, '<Separator>' ),array( '/_Colors/Background', null, null, 0, '<Title>' ),array( '/_Colors/Black', null, null, 0, '<RadioItem>' ),array( '/_Colors/Blue', null, null, 0, '/Colors/Black' ),array( '/_Colors/Red', null, null, 0, '/Colors/Black' ),

array( '/_Help', null, null, 0, '<LastBranch>' ),array( '/_Help/_About', 'F1', 'menucall', 15, '<Item>' ));

$fac->create_items( $arItems);

//By default, the first item of a radio group is selected. We change this$mnuColorRed = $fac->get_widget( '/Colors/Red');$mnuColorRed->set_active( true);

$arMoreItems = array(array( '/_View/sep1', null, null, 0, '<Separator>' ),array( '/_View/more/items/are/appended/here', null, null, 0, null));$fac->create_items( $arMoreItems);

$window->add( $fac->get_widget( "<mainmenu>"));$window->show_all();gtk::main();?>

Page 188: Apostila PHP GTK

GtkItemFactory::get_item

GtkWidget get_item(String path);

If the widget corresponding to path is a menu item which opens asubmenu, then the item is returned. If you are interested in thesubmenu, use get_widget() instead.

GtkItemFactory::get_widget

GtkWidget get_widget(String path);

If the widget corresponding to path is a menu item which opens asubmenu, then the submenu is returned. If you are interested in themenu item, use get_item() instead.

GtkItemFactory::get_widget_by_action

GtkWidget get_widget_by_action(int action);

Obtains the widget which was constructed from the GtkItemFactoryEntrywith the given action. If there are multiple items with the sameaction, the result is undefined. It is NOT an array as you may haveassumed - it is probably one of the items found.

GtkItemFactory::get_item_by_action

GtkWidget get_item_by_action(int action);

Obtains the item which was constructed from the GtkItemFactoryEntrywith the given action. If there are multiple items with the sameaction, the result is undefined. It is NOT an array as you may haveassumed - it is probably one of the items found.

The difference between item and widget is explained in get_item() .

GtkItemFactory::delete_item

void delete_item(string path);

Deletes the menu item which was created for path by the given itemfactory.

GtkItemFactory::popup

void popup(int x, int y, int mouse_button, int time);

Pops up the complete menu at (x, y).

The mouse_button parameter should be the mouse button pressed toinitiate the menu popup. If the menu popup was initiated by somethingother than a mouse button press, such as a mouse button release or akeypress, mouse_button should be 0.

Page 189: Apostila PHP GTK

GtkLabel

Widget that displays a small amount of text.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkMisc`-- GtkLabel

Direct subclasses

GtkAccelLabel, GtkTipsQuery

Descrição

A very common use of GtkLabel is to display text that describes ormakes some comment about the use of an adjacent widget. If you needto display a great deal of text, use GtkText instead.

Note that labels do not generate events. If you want to catchevents (e.g. from a mouse click) you will need to put the label ina GtkEventBox.

See also: GtkEditable, GtkEventBox, GtkText.

Construtor

GtkLabel ([string label_text ]);

-- Creates a new label with the given text inside it. If no text isspecified, an empty label is created.

Métodos

set_text()Sets the label text.

set_justify()Sets label justification.

set_pattern()Underlines text in the label.

set_line_wrap()Toggles line wrapping.

get()Gets label text. *deprecated in GTK2*

parse_uline()Parses underscores into underlines. *deprecated in GTK2*

Page 190: Apostila PHP GTK

GtkLabel Construtor

GtkLabel ([string label_text ]);

Exemplo 20. Aligning the text in a GtkLabel<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

$window = &new GtkWindow();$window->set_default_size(300, 70);$window->connect_object('destroy', array('gtk', 'main_quit'));

$label = &new GtkLabel("This is my label");//move it to the lower right$label->set_alignment(1.0, 1.0);

//give it a nice font and color$style = $label->get_style();$style->font = gdk::font_load( '-*-Arial-bold-r-normal-*-24-*-*-*-*-*-*-*');$orange = &new GdkColor( '#FF8000');;$style->fg[GTK_STATE_NORMAL] = $orange;$label->set_style( $style);

//you can't set the background color of a label, use the parent widget instead$wstyle = $window->get_style();$wstyle->bg[GTK_STATE_NORMAL] = $wstyle->black;$window->set_style( $wstyle);

$window->add($label);$window->show_all();

gtk::main();?>

The set_alignment() method is inherited from GtkMisc.

GtkLabel::set_text

void set_text(string label_text );

Sets the text for the label widget. Previous text in the label is notstored.

Note that any existing underlines are not overwritten in the same waythat text is; use set_pattern() with no parameters to erase these.

$label->set_text("Whatever text you wish to pass");

GtkLabel::set_justify

void set_justify( GtkJustification justification );

Page 191: Apostila PHP GTK

set_justify() is the method for justifying text in GtkLabel. Theoptions are GtkJustification enumerated flags, the default settingbeing GTK_JUSTIFY_CENTER.

Justification is relative to existing lines of text, and should beused in combination with set_line_wrap() . It is irrelevant wherethere is only one line. If you need to set the text alignment in asingle-line label, use set_alignment() . There is a working example ofthis method on the constructor page.

<?php

$label->set_line_wrap(true);$label->set_justify(GTK_JUSTIFY_FILL);

?>

GtkLabel::set_pattern

void set_pattern([string pattern = NULL ]);

set_pattern() is the method for underlining text in GtkLabel. It needsto be defined as a pattern, e.g. if your text consists of A B C, then"_ _" will underline A and C but not B, as that is where the spacefalls. Each underscore or space in the pattern maps directly to thecharacter position in the label text.

$label->set_pattern("_ _");

Call this method with no parameters to erase existing underlines.

GtkLabel::set_line_wrap

void set_line_wrap(bool wrap);

Toggles line wrapping in the label. If wrap is true, the linesexceeding the size of the widget will be automatically wrapped. Wherewrap is false, those lines will be cut off at the widget's edge.

$label->set_line_wrap(true);

GtkLabel::get

string get(void );

Returns the current text content of the label.

Note that this method is deprecated in GTK 2.0, and will be replacedby get_text().

$label->get();

GtkLabel::parse_uline

Page 192: Apostila PHP GTK

int parse_uline(string string);

parse_uline() checks the string passed as the parameter forunderscores, and then underlines the characters following theunderscores. It will take the first underlined character in a labeland return it as a lower-case accelerator key, e.g. _Save will returnthe accelerator key value for "s".

This method is used internally by Gtk+ for menu items.

Note that this method is deprecated in GTK+ 2.0.

$label->parse_uline("_File");

GtkLayout

Scrollable widget allowing multiple children in fixed positions.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkLayout

Direct subclasses

None.

Descrição

A GtkLayout is a scrollable widget that provides a scrolling-awarebackdrop for a child or children having fixed positions. It shouldbe added directly to a GtkScrolledWindow.

Note that the scrolling does not work on win32 unless you programit to do so. There have been no such problems reported on othersystems. The workaround under win32 is to connect theGtkScrolledWindow scrollbar adjustments' "value-changed" signals toa function that will force the GtkLayout to be redrawn. This can bequeue_draw() in most situations, but the more complex child widgetswill not respond to this alone and will need to have hide() andthen show() called on the GtkLayout during the callback.

Note that GtkHtml is based on the GtkLayout class, and that similarredraw issues are seen with that widget.

Construtor

GtkLayout ( GtkAdjustment hadjustment , GtkAdjustment vadjustment );

-- Creates a scrollable backdrop whose children retain theirpositions.

Page 193: Apostila PHP GTK

Métodos

put()Fixes a child widget at the given position.

move()Moves a child widget to a new position.

set_size()Sets the size of the layout.

get_hadjustment()Returns the horizontal adjustment object.

get_vadjustment()Returns the vertical adjustment object.

freeze()Freezes the display during an update.

thaw()Allows the display to be updated.

GtkLayout Construtor

GtkLayout ( GtkAdjustment hadjustment , GtkAdjustment vadjustment );

The following example is based on the GTK+ test file testgtk.c. Unixusers will not need to use the callback function in order to achievescrolling, but it shouldn't do any harm to run it as it stands. Win32users will find that the labels are redrawn and the buttons are not,giving a somewhat psychedelic effect. To redraw both types of objectunder win32, replace the callback function with:<?php

function exposure($adj, $layout) {$layout->hide();$layout->show();}

?>

Exemplo 21. Forcing a GtkLayout to redraw<?php

dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

/* callback that forces a redraw of simple child widgets */function exposure($adj, $layout) {$layout->queue_draw();}

/* set up a window and size it to be smaller than the intended layout */$window = &new GtkWindow();

Page 194: Apostila PHP GTK

$window->set_position(GTK_WIN_POS_CENTER);$window->set_title('Layout');$window->set_usize(200, 200);$window->connect_object('destroy', array('gtk', 'main_quit'));

/* create and add the scrolled window to the main window */$scrolledwindow = &new GtkScrolledWindow();$window->add($scrolledwindow);

/* create and add the layout widget to the scrolled window */$layout = &new GtkLayout(null, null);$scrolledwindow->add($layout);

/* set the layout to be bigger than the windows that contain it */$x = gdk::screen_width();$y = gdk::screen_height();$layout->set_size($x, $y);

/* get the adjustment objects and connect them to the callback. Thispart should not be necessary under *nix systems */$hadj = $scrolledwindow->get_hadjustment();$vadj = $scrolledwindow->get_vadjustment();$hadj->connect('value-changed', 'exposure', $layout);$vadj->connect('value-changed', 'exposure', $layout);

/* populate the layout with a mixture of buttons and labels */for ($i=0 ; $i < round($y/100); $i++) {for ($j=0 ; $j < round($x/100); $j++) {$buf =sprintf('Button %d, %d', $i, $j);if (($i + $j) % 2) $button = &new GtkButton($buf);else $button = &new GtkLabel($buf);$layout->put($button, $j*100, $i*100);}}

/* display everything and run the main loop */$layout->show_all();$window->show_all();

gtk::main();

?>

add is not implemented for GtkLayout. You must use put to add childrento the layout.

GtkLayout::put

void put( GtkWidget widget , int x, int y);

This method adds a child widget to the layout. The top left corner ofthe child widget will be positioned at the co-ordinates passed in thex, y parameters.

Page 195: Apostila PHP GTK

GtkLayout::move

void move( GtkWidget widget , int x, int y);

This method takes a child widget that has already been added to theGtkLayout and moves it to a new position reflecting the co-ordinatespassed in the parameters.

GtkLayout::set_size

void set_size(int width, int height);

Sets the size of the GtkLayout. If you do not call this method thelayout will size itself according to the size allocation given it bythe parent window, rather than the size requisition of the layout'schild widgets.

GtkLayout::get_hadjustment

GtkAdjustment get_hadjustment (void);

This method is used internally to set the horizontal scrollbaradjustment in the GtkScrolledWindow holding the GtkLayout. These setsof adjustment objects are interchangeable, i.e. they share the samevalues.

GtkLayout::get_vadjustment

GtkAdjustment get_vadjustment (void);

This method is used internally to set the vertical scrollbaradjustment in the GtkScrolledWindow holding the GtkLayout. These setsof adjustment objects are interchangeable, i.e. they share the samevalues.

GtkLayout::freeze

void freeze(void);

Use freeze() when you are updating a large amount of data, e.g. alarge pixmap or series of pixmaps. Calling this method prior to theupdate will speed up the process and reduce flicker.

See also: thaw() .

GtkLayout::thaw

void thaw(void);

thaw() is the corollary of freeze() . It allows the display to beredrawn after the new data is fully assimilated.

GtkList

Page 196: Apostila PHP GTK

Widget displaying a list of selectable items.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkList

Direct subclasses

None.

Descrição

A GtkList is a container widget that is designed to hold a simplelist, the full range of which is displayed. The items held in thelist are selectable, with the default selection mode set asGTK_SELECTION_SINGLE. Each item in the list must be a GtkListItemwidget. Glade users will find that they need to code these manuallyin order to populate a list or combo box.

The signal part of the function/signal pair for most of the methodsgiven here is private in GtkList, but is also implemented inGtkListItem. As this secondary implementation is also private,these signals are not covered in this manual. Although thosesignals that have GTK keybindings will cause the appropriate signalto be publicly fired when their key combinations are used, there isno other way to emit this range of signals. The keybindings arelisted under GtkListItem; the signal prototypes share the relevantGtkList method's parameters, should you need to connect to them.

If you need a list with multiple columns and/or titles with sortingsupport, GtkCList is the right class for you.

See also: GtkCList, GtkCombo, GtkListItem.

GtkList has been deprecated since GTK+ 2.0 and should not be used innewly written code.

Construtor

GtkList (void);

-- Creates a container for a simple list.

Métodos

append_items()Appends an array of list items to a list.

clear_items()Clears designated list items from list.

Page 197: Apostila PHP GTK

select_item()Causes the "select-child" signal to be emitted.

unselect_item()Causes the "unselect-child" signal to be emitted.

select_child()Causes the "select-child" signal to be emitted.

unselect_child()Causes the "unselect-child" signal to be emitted.

child_position()Returns item specified by list position.

set_selection_mode()Sets the selection mode.

extend_selection()Extends selected area to position given.

start_selection()Selects range from anchor to currently selected item.

end_selection()Curtails selection set with start_selection() .

select_all()Selects all list items.

unselect_all()Deselects all list items.

scroll_horizontal()Sets associated horizontal scrollbar to a predetermined position.

scroll_vertical()Sets associated vertical scrollbar to a predetermined position.

toggle_add_mode()Toggles whether further selections may be added in extended mode.

toggle_focus_row()Toggles selection status of row with focus.

toggle_row()Toggles selection status of specified row.

undo_selection()In extended mode, returns selection to its previous state.

end_drag_selection()Ends drag selection.

Page 198: Apostila PHP GTK

Sinais

"selection-changed"Emitted when the selection property is changed.

"select-child"Emitted when a list item is selected.

"unselect-child"Emitted when a list item is deselected.

Propriedades

selection:Array containing current selection information.

GtkList Construtor

GtkList (void);

Creating a GtkList widget is straightforward, populating it slightlyless so. Each item added to the list container must itself becontained in a GtkListItem. In its simplest and most common form, allthat means is that the GtkListItem is created with a label, the textcontent of which will be displayed in the list.

Exemplo 22. Constructing a GtkList<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

function echo_it($list, $listitem) {/* collect the text from the selected list item's label */$listlabel = $listitem->child;/* filter list items according to child object type */if($listlabel->get_name() == 'GtkLabel') {$name = $listlabel->get();$label = &new GtkLabel("You chose $name just now");/* create a popup window and display a message relevant to selected item */$popup = &new GtkWindow(GTK_WINDOW_POPUP);$popup->set_uposition((gdk::screen_width()/2)+50,(gdk::screen_height()/3));$popup->add($label);$popup->show_all();/* connect the list item's own deselect signal (not the list's) */$listitem->connect_object('deselect', create_function('$popup','$popup->destroy();'), $popup);}else gtk::main_quit();}

$window = &new GtkWindow(GTK_WINDOW_DIALOG);$window->set_position(GTK_WIN_POS_CENTER);

Page 199: Apostila PHP GTK

$window->connect_object('destroy', array('gtk', 'main_quit'));

$list = &new GtkList();/* the contents of this array will populate the list */$fill = array('Angela', 'Belinda', 'Carolyn', 'Danike', 'Etha', 'Fiona','Gertraud', 'Heidi', 'Jessica', 'Kirstin', 'Lorinda', 'Marianne');

foreach(range(0, count($fill)-1) as $i)$listitem[] = &new GtkListItem($fill[$i]);

$list->append_items($listitem);

$enditem = &new GtkListItem();/* a list item is also a container */$button = &new GtkButton('Close');$enditem->add($button);/* there is no way to append() a single item - but GtkList is a containerwidget, so it's okay to use add() */$list->add($enditem);$list->connect('select-child', 'echo_it');$list->show_all();

$window->add($list);$window->show_all();

gtk::main();?>

GtkList::append_items

void append_items(Array listItems);

This is a widget-specific method for adding an array of GtkListItemsto a GtkList.

GtkList::clear_items

void clear_items(int start, int end);

Removes the list items between the positions given in the parameters,from a GtkList. The remaining items close up the gap, always movingcloser to the top as there is no way to fix a child's list position.Note that the list container itself is not resized to reflect thesechanges.

GtkList::select_item

void select_item(int row);

The only difference between select_item() and select_child() is thatthe former takes the item's list position as a parameter rather thanthe GtkListItem object itself. In either case, the signal that isactually emitted is the list item's "select" signal - these are justdifferent ways of describing the same thing, providing alternative

Page 200: Apostila PHP GTK

means of selection and connection.

GtkList::unselect_item

void unselect_item(int row);

The only difference between unselect_item() and unselect_child() isthat the former takes the item's list position as a parameter ratherthan the GtkListItem object itself. In either case, the signal that isactually emitted is the list item's "deselect" signal - these are justdifferent ways of describing the same thing, providing alternativemeans of de-selection and connection.

GtkList::select_child

void select_child( GtkWidget child );

The only difference between select_item() and select_child() is thatthe former takes the item's list position as a parameter rather thanthe GtkListItem object itself. In either case, the signal that isactually emitted is the list item's "select" signal - these are justdifferent ways of describing the same thing, providing alternativemeans of selection and connection.

GtkList::unselect_child

void unselect_child( GtkWidget child );

The only difference between unselect_item() and unselect_child() isthat the former takes the item's list position as a parameter ratherthan the GtkListItem object itself. In either case, the signal that isactually emitted is the list item's "deselect" signal - these are justdifferent ways of describing the same thing, providing alternativemeans of de-selection and connection.

GtkList::child_position

int child_position( GtkWidget child );

child_position() returns the list position currently holding thewidget that was passed as the argument. The widget needs to be passedby reference, i.e. using the form $widget.

GtkList::set_selection_mode

void set_selection_mode( GtkSelectionMode mode );

Sets one of the four possible GtkSelectionMode enumerated values.

The default setting is GTK_SELECTION_SINGLE.

GtkList::extend_selection

void extend_selection( GtkScrollType scroll_type , double position,

Page 201: Apostila PHP GTK

bool auto_start_selection);

This is quite a complex method that can only be used when theselection mode is set to GTK_SELECTION_EXTENDED. It duplicates andresets the focus row (i.e. the row that is marked as selected) andhighlights all the items between that and the anchor item. It hasdifferent behaviours depending on whether or not the list has keyboardgrab, so that putting it into a callback function does not have thesame results as calling it from the main loop.

Selection of all the items in the highlighted range requires thatscroll_vertical() is also set appropriately.

In general, calling the extend_selection() method will only select thelast row with focus. It needs to have toggle_add_mode() set in orderto do this when scroll_vertical() is set after the list widget hasgrab.

As with scroll_vertical() , this method's position parameter is usedonly when the GtkScrollType value is set to GTK_SCROLL_JUMP, andrepresents a percentage of the area covered by the scroll. The finalparameter negates the method's functionality completely if set tofalse.

GtkList::start_selection

void start_selection(void);

start_selection() selects the range between the anchor item - 0 onfirst opening or the most recent selection thereafter - and the nextselection that is made. For instance, if you were to select item 4 onopening, the selection range would run as 4, 0, 1, 2, 3. If you thenselected item 7 the new range would be 7, 4, 5, 6. Further items canbe included in the selection by dragging while the mouse button isstill pressed down from selecting the original item.

Note that this method can only be used if the list's selection mode isset to GTK_SELECTION_EXTENDED.

See also: end_selection() , end_drag_selection() .

GtkList::end_selection

void end_selection(void);

end_selection() ends a selection as it would be if made usingstart_selection() . It curtails the selection so that only the anchorand the item selected return a "select" signal.

Note that this method can only be used if the list's selection mode isset to GTK_SELECTION_EXTENDED.

GtkList::select_all

Page 202: Apostila PHP GTK

void select_all(void);

select_all() selects all the list items in a GtkList. Note that thereneeds to be the possibility of multiple selection for this method towork; see set_selection_mode() .

GtkList::unselect_all

void unselect_all(void);

The corollary to select_all() , this method can also be used to clearthe initial focus when the selection mode has been set toGTK_SELECTION_BROWSE.

GtkList::scroll_horizontal

void scroll_horizontal( GtkScrollType scroll_type , double position);

This method needs set_focus_hadjustment() to be called on theappropriate scrollbar from the GtkList in order for it to work. Itscrolls the list horizontally to a predetermined position according tothe GtkScrollType.

The position parameter is only used where the enumerated value isGTK_SCROLL_JUMP, when 0.0 sets the scroll to the (default) leftmostpoint and 1.0 to the rightmost. Values between 0.0 and 1.0 describethe percentage of the distance scrolled, i.e. 0.5 would set thebeginning of the scroll slider halfway across the area.

Where any other GtkScrollType is set, the position is required but isthen ignored.

GtkList::scroll_vertical

void scroll_vertical( GtkScrollType scroll_type , double position);

This method needs set_focus_vadjustment() to be called on theappropriate scrollbar from the GtkList in order for it to work. Itscrolls the list to a predetermined position according to theGtkScrollType setting and, if a selection has been made and the list'sselection mode allows it, will automatically select the child nearestto the new scroll position.

The position parameter is only used where the enumerated value isGTK_SCROLL_JUMP, when 0.0 sets the scroll to the topmost item and 1.0to the final item. Values between 0.0 and 1.0 describe the percentageof the distance scrolled, i.e. 0.5 would set the scroll so that thelast visible item is the one holding the halfway position in the list.

Where any other GtkScrollType is set, the position is required but isthen ignored.

GtkList::toggle_add_mode

Page 203: Apostila PHP GTK

void toggle_add_mode(void);

When toggle_add_mode() has been called, the grab in aGTK_SELECTION_EXTENDED mode list will remain with the anchor item atthe start of the selection, regardless of where the focus falls, untilanother item is actually selected. Effectively it switches the list tosomething very like GTK_SELECTION_BROWSE mode.

The item that currently has grab has a dashed line around it tosignify its status, as well as the usual GTK_STATE_SELECTED style.

GtkList::toggle_focus_row

void toggle_focus_row(void);

If the row having current focus is marked as selected, callingtoggle_focus_row() will unselect it, and vice versa. In both cases theappropriate signal is fired.

This method would be pointless in a list set to GTK_SELECTION_BROWSE,and so is not implemented there.

GtkList::toggle_row

void toggle_row( GtkWidget item );

If the item specified in the parameter is marked as selected, callingtoggle_row() will unselect it, and vice versa. In both cases theappropriate signal is fired.

If the selection mode is GTK_SELECTION_BROWSE, the item will always beselected.

GtkList::undo_selection

void undo_selection(void);

This method returns selection to its previous state if the list modeis set to GTK_SELECTION_EXTENDED. It is not implemented in any othermode.

GtkList::end_drag_selection

void end_drag_selection(void);

This method is used extensively within GTK to complete a selection. Itremoves the grab from the list, and also the internal timer associatedwith the drag action. It is unlikely to be very useful at this level.

selection-changed

The "selection-changed" signal is emitted whenever there is a changein the list's selection property, regardless of whether that changeempties the array.

Page 204: Apostila PHP GTK

As there is no way to track back which particular item has beenselected or unselected, you should use the "select-child" if you needthat piece of information.

Função Callback

void callback(GtkList list);

select-child

The "select-child" signal is emitted when a child is selected. Itcarries the selected child as an argument.

This signal is basically a wrapper for the "select" signal emitted bythe GtkListItem that is currently selected. If you mix the two, thesame item will emit the same signal twice in response to selection.

Função Callback

void callback(GtkList list, GtkWidget child);

unselect-child

The "unselect-child" signal is emitted when a child is deselected. Itcarries the deselected child as an argument.

This signal is basically a wrapper for the "deselect" signal emittedby the GtkListItem that has just been deselected. If you mix the two,the same item will emit the same signal twice in response todeselection.

Função Callback

void callback(GtkList list, GtkWidget child);

GtkList::selection

Access: Read OnlyType: array

The selection property is an array that contains any currentlyselected items. If there is no current selection, the array will beempty. If the selection mode does not allow multiple selection,$list->selection[0];

will return the selected item. If the selection mode allows multipleselection, there will be as many elements in the array as there arecurrently-selected objects.

See also: children() .

GtkListItem

Page 205: Apostila PHP GTK

A single element in a GtkList.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkItem`-- GtkListItem

Direct subclasses

None.

Descrição

A GtkListItem is one of the elements that makes up a GtkList. Itcan consist of many things - see the constructor page - beingbasically a container with a specialised set of methods andsignals.

GtkListItems are not equipped to carry data, unless you make it so.Using the GtkObject methods get_data() , remove_data() andset_data() is the usual way to achieve this. See GtkCombo for aworking example.

The GtkListItem class supplies a multitude of signals to the listwidget recursively, where they are treated as private signals andused internally. Several of these signals have keybindings,implemented here rather than in GtkList of necessity, which aredescribed below.

Tabela 6. Key bindings used in GtkListKey combination Effect Equivalent GtkList methodUp arrow Scrolls up one step scroll_vertical(GTK_SCROLL_STEP_BACKWARD,0.0)Down arrow Scrolls down one stepscroll_vertical(GTK_SCROLL_STEP_FORWARD, 0.0)Page Up Scrolls up one page scroll_vertical(GTK_SCROLL_PAGE_BACKWARD,0.0)Page Down Scrolls down one pagescroll_vertical(GTK_SCROLL_PAGE_FORWARD, 0.0)Control + Home Scrolls to the top of the listscroll_vertical(GTK_SCROLL_JUMP, 0.0)Control + End Scrolls to the end of the listscroll_vertical(GTK_SCROLL_JUMP, 1.0)Shift + Up arrow Selects up one stepextend_selection(GTK_SCROLL_STEP_BACKWARD, 0.0, true)Shift + Down arrow Selects down one stepextend_selection(GTK_SCROLL_STEP_FORWARD, 0.0, true)Shift + Page Up Selects up one pageextend_selection(GTK_SCROLL_PAGE_BACKWARD, 0.0, true)Shift + Page Down Selects down one page

Page 206: Apostila PHP GTK

extend_selection(GTK_SCROLL_PAGE_FORWARD, 0.0, true)Shift | Control + Home Selects to the top of the listextend_selection(GTK_SCROLL_JUMP, 0.0, true)Shift | Control + End Selects to the end of the listextend_selection(GTK_SCROLL_JUMP, 1.0)Left arrow Scrolls one step to the leftscroll_horizontal(GTK_SCROLL_STEP_BACKWARD, 0.0)Right arrow Scrolls one step to the rightscroll_horizontal(GTK_SCROLL_STEP_FORWARD, 0.0)Home Scrolls to the left of the listscroll_horizontal(GTK_SCROLL_JUMP, 0.0)End Scrolls to the right of the listscroll_horizontal(GTK_SCROLL_JUMP, 1.0)Escape Returns to previous selection undo_selection()Space Toggles state of row with current focus toggle_focus_row()Control + Space Toggles whether further items can be selectedtoggle_add_mode()Control + / Selects all items select_all()Control + \\ Deselects all items unselect_all()Shift_L + Release | Shift Completes selection end_selection()Shift_R + Release | Shift Completes selection end_selection()Shift_R + Release | Shift | Control Completes selectionend_selection()

GtkListItem has been deprecated since GTK+ 2.0 and should not be usedin newly written code.

Construtor

GtkListItem ([string label ]);

-- Creates a list element.

Métodos

select()Causes the "select" signal to be emitted.

deselect()Causes the "deselect" signal to be emitted.

GtkListItem Construtor

GtkListItem ([string label ]);

A GtkListItem is a container widget, derived indirectly from GtkBinand so only able to hold one direct child. Most of the time, the childyou will want the list item to contain will be a GtkLabel - and so, incommon with all objects that have an alternative '-with-label'constructor available in GTK, we have the option in PHP-GTK to passthe label's text as a parameter during construction, e.g.<?php

$listitem = &new GtkListItem("This list item now has a label");

Page 207: Apostila PHP GTK

?>

If you wanted something other than a label in the list item, yousimply omit the parameter and add the required widget:<?php

$arrow = &new GtkArrow(GTK_ARROW_RIGHT, GTK_SHADOW_ETCHED_IN);$listitem = &new GtkListItem();$listitem->add($arrow);

?>

or, if you wanted perhaps a label plus some other item:<?php

$box = &new GtkHBox();$label = &new GtkLabel("Here we have multiple objects in aGtkListItem");$arrow = &new GtkArrow(GTK_ARROW_RIGHT, GTK_SHADOW_ETCHED_IN);

$box->pack_start($label);$box->pack_end($arrow);$box->show_all();

$listitem = &new GtkListItem();$listitem->add($box);

?>

Whatever your list item consists of, the GtkList will only respond toit as a GtkListItem. If you have different kinds of list item contentsin the same list, you will need to exercise a great deal of caution ifyou are connecting callbacks to any form of select signal.

See also: GtkList, which has a working example under the constructor.

GtkListItem::select

void select(void);

The GtkListItem method select() causes the list item to emit theGtkItem signal "select". This is then bound recursively to theGtkListItem implementation of that signal.

The same sequence of events is produced by calling the GtkList methodselect_child() .

The easy part: it sets the GtkStateType of the calling list item toGTK_STATE_SELECTED.

Note that this state can also be achieved programmatically by callingtoggle() from a list item that is currently unselected.

Page 208: Apostila PHP GTK

GtkListItem::deselect

void deselect(void);

The GtkListItem method deselect() causes the list item to emit theGtkItem signal "deselect". This is then bound recursively to theGtkListItem implementation of that signal.

The same sequence of events is produced by calling the GtkList methodunselect_child() .

The easy part: it sets the GtkStateType of the calling list item toGTK_STATE_NORMAL.

Note that this state can also be achieved programmatically by callingtoggle() from a list item that is currently selected.

GtkMenu

Popup container for menu items.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkMenuShell`-- GtkMenu

Direct subclasses

None.

Descrição

GtkMenu is a menushell widget, designed to exclusively holdGtkMenuItems. It may be a standalone popup widget, or may beassociated either with a higher-level GtkMenuItem within aGtkMenuBar, or with a GtkOptionMenu.

Note that a GtkMenu in any form is effectively a modal popupwidget. There are keybindings in place here specifically tocounteract this apparent isolation, by allowing the Up, Down, Leftand Right arrow keys to navigate multiple menus with regard to therelationships between those menus (i.e. parent and child, next andprevious). These are fairly rudimentary in the current version ofGTK+ used in PHP-GTK, but have been improved recently.

See also: GtkCombo, GtkCTree, GtkItemFactory, GtkList,GtkRadioButton, GtkToolbar.

Construtor

GtkMenu (void);

Page 209: Apostila PHP GTK

-- Creates the structure to hold a menu's content.

Métodos

popup()Pops up a menu.

reposition()Repositions menu.

popdown()Pops down menu.

get_active()Gets currently selected GtkMenuItem.

set_active()Sets active menu item.

set_accel_group()Sets the GtkAccelGroup holding global accelerators.

get_accel_group()Gets the GtkAccelGroup holding global accelerators.

get_uline_accel_group()Gets the internally-used GtkAccelGroup, if there is one.

ensure_uline_accel_group()Creates a GtkAccelGroup for internal menu use if one does not exist.

attach_to_widget()Sets attachment to specified widget.

detach()Detaches menu from associated widget.

get_attach_widget()Returns the widget currently attached.

set_tearoff_state()Toggles whether menu is torn off.

set_title()Sets the title for a torn off menu.

reorder_child()Moves specified item to given position.

GtkMenu Construtor

GtkMenu (void);

Page 210: Apostila PHP GTK

<?php

$menu = &new GtkMenu();

?>

creates an empty popup container widget that will exclusively holdGtkMenuItems. It may be instantiated alone as an event-driven popupmenu (see the example below) or it can be associated with ahigher-level GtkMenuItem as a submenu, or a GtkOptionMenu as a menu.When it is associated with an object in this way, the menu will pop upin response to the object's activation.

Exemplo 23. Creating a right-click popup menu<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

function show_popup($event, $menu) {if($event->button == 3) {$menu->popup(null, null, null, $event->button, $event->time);}}

$window = &new GtkWindow();$window->set_default_size(350, 450);$window->connect_object('destroy', array('gtk', 'main_quit'));

$menu = &new GtkMenu();$accel = $menu->ensure_uline_accel_group();

$open = &new GtkMenuItem("Open");$open->lock_accelerators();$menu->append($open);$save = &new GtkMenuItem("Save as ...");$save->lock_accelerators();$menu->append($save);$separator = &new GtkMenuItem();$separator->set_sensitive(false);$menu->append($separator);

$exit = &new GtkMenuItem("");$accel_label = $exit->child;$accel_key = $accel_label->parse_uline("E_xit");$exit->add_accelerator('activate', $accel, $accel_key, GDK_CONTROL_MASK,GTK_ACCEL_VISIBLE);$exit->lock_accelerators();$exit->connect_object('activate', array('gtk', 'main_quit'));$menu->append($exit);$menu->show_all();

$label = &new GtkLabel( 'Right-click here to see the menu');$window->add( $label);

Page 211: Apostila PHP GTK

$window->add_events(GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);$window->connect_object('button-press-event', 'show_popup', $menu);$window->show_all();

gtk::main();

?>

GtkMenu::popup

void popup([ GtkWidget parent_menu_shell , [ GtkWidgetparent_menu_item , [ GtkMenuPositionFunc pos_function , int button,int activate_time]]]);

The popup() method looks fairly intimidating at the outset, but isactually quite straightforward to use.

The first thing to be aware of is that the parent_menu_shell andparent_menu_item parameters would generally only be used internally,to associate the popped-up menu with a given GtkMenuShell descendant,or GtkMenuItem, or both. In a freestanding popup menu, both parametersshould be passed as null.

The third parameter concerns the positioning of the popup menu, andhas as its default the position of the mouse pointer. In order to seta different position, you will need to set up a function that willreturn an array of the co-ordinates, and call it from the pos_functionparameter.<?php

function position() {$position = array(300, 200);return $position;}

$filemenu->popup(null, null, 'position', $event->button,$event->time);

?>

The fourth parameter refers to the mouse button emitting the"button-release-event" that will be compared with the button emittingthe "button-press-event" in order to set the timer in the finalparameter. This only works if you happen to be triggering the popupfunction with a button press, and the button pressed and buttonreleased are the same - in all other situations, the time element isignored. However, setting the button parameter to 1 or 3 will speed upthe deactivation when the left or right mouse button is releasedrespectively, regardless of the callback event.

The final parameter, activate_time, sets the time conditions for themenu's deactivation. If you have used a button press event and ensuredthat the initial press and later release have the same valid integer

Page 212: Apostila PHP GTK

value, then setting the timer to 0 will make the menu disappear assoon as the user releases the mouse-button that triggered it. Thesafest setting for this parameter is $event->time - this being asetting that all GdkEvent structures share; it causes the popup menuto react as you'd expect it to, and won't spring any surprises if youduplicate or otherwise adapt the original callback event.

GtkMenu::reposition

void reposition(void);

reposition() is used internally to reposition a GtkMenuItem's submenuaccording to the results of the position function called in thepopup() method.

GtkMenu::popdown

void popdown(void);

popdown() is used internally to de-reference a popup menu. It is oneof the methods that is called when a menu emits the "deactivate"signal.

GtkMenu::get_active

GtkWidget get_active (void);

get_active() can be used to retrieve the currently selectedGtkMenuItem object through the menu. Note that this method returns themenu item object itself, and is really only useful for comparisonagainst a set of criteria. In most instances it would be moreefficient to connect the individual menu item's "activate" signal.

The get_active() method is used internally in GtkOptionMenu'sset_history() to compare the menu item currently selected by the useragainst that previously displayed.

GtkMenu::set_active

void set_active(int index);

set_active() sets the 'active' GtkMenuItem in a GtkMenu. Note thatthis is not the same thing as calling the select() from the menu item,but is a way of adding to the given item's reference count from themenu.

The set_active() method is mainly used internally in GTK, as part ofGtkOptionMenu's set_history() method.

GtkMenu::set_accel_group

void set_accel_group( GtkAccelGroup accel_group );

set_accel_group() sets the global accelerator group for a GtkMenu. A

Page 213: Apostila PHP GTK

GtkAccelGroup set in this way should also be designated as toplevel.This is achieved by calling add_accel_group() from the correspondingtoplevel GtkWindow.

Note that there is a bug in the win32 version of GTK+ currently usedin PHP-GTK. The accelerator key appears as it should, but does notconnect to its designated signal where the accel group has been newlycreated and set in this way. Also, much of the accelerator lockingmechanism has been replaced in GTK2. Future-friendly code can becreated by using GtkItemFactory to create your menus; however, thesame limitations in functionality currently apply.

GtkMenu::get_accel_group

GtkAccelGroup get_accel_group (void);

get_accel_group() returns the global accelerator group that is used inthe calling GtkMenu.

Note that this method does not work as it should in the win32 versionof GTK+ currently used by PHP-GTK. Also, much of the accelerator lockmechanism has been replaced in GTK2. Future-friendly code can becreated by using GtkItemFactory to create your menus; however, thesame limitations in functionality currently apply.

GtkMenu::get_uline_accel_group

GtkAccelGroup get_uline_accel_group (void);

get_uline_accel_group() returns the GtkAccelGroup used by GTK duringthe time that the GtkMenu is popped up. It is used internally to allowthe user to modify the key accelerators where they have not beenlocked.

Note that this method does not work as it should in the win32 versionof GTK+ currently used by PHP-GTK. Also, this method has beeneliminated from later versions of GTK+, and much of the acceleratorlock mechanism replaced. Future-friendly code can be created by usingGtkItemFactory to create your menus; however, the same limitations infunctionality currently apply.

GtkMenu::ensure_uline_accel_group

GtkAccelGroup ensure_uline_accel_group (void);

ensure_uline_accel_group() returns the GtkAccelGroup used by GTKduring the time that the calling GtkMenu is popped up, if one exists,and creates one for internal use if there is none.

This is currently the only way to get accelerators working properlyunder win32. It is also used internally for popup menus inGtkItemFactory. However, note that this method has been eliminatedfrom later versions of GTK+. The replacements in GtkItemFactory arepurely internal; the new methods in GtkMenu are not.

Page 214: Apostila PHP GTK

GtkMenu::attach_to_widget

void attach_to_widget( GtkWidget attach_widget );

attach_to_widget() is mostly used internally to set up therelationship between the 'parent' - usually a GtkMenuItem - and theGtkMenu that is calling the method.

This is not the same thing as setting a submenu for a menu item (useset_submenu() for that), but creates an underlying relationship thatsubsumes the reference count on the menu to that of the attach_widget.The GtkWidget method set_parent() has very similar functionality, butis not appropriate here because the menu is itself a toplevel widget.

GtkMenu::detach

void detach(void);

detach() detaches the calling GtkMenu from its current parent widget.This method is used internally when the menu is being destroyed.

Calling the detach() method after the menu has been set as a submenu,unsets that relationship in exactly the same way as remove_submenu()would. The difference is that the attached widget does not necessarilyneed to be a GtkMenuItem for detach() to work.

GtkMenu::get_attach_widget

GtkWidget get_attach_widget (void);

get_attach_widget() returns the object to which the calling GtkMenu iscurrently attached. Use get_name() to further identify the returnedobject, or else compare it with likely candidates.

GtkMenu::set_tearoff_state

void set_tearoff_state(bool torn_off);

set_tearoff_state() when set to true creates a non-resizeable,decorated, top-level window, sized to fit the menu contents andiconized in the task bar. The torn-off menu does not need a furtherparent window, and can act as a standalone widget in its own right.

Where the same menu has also been set as a submenu on an existingGtkMenuItem or as a popup, the menu data is displayed in thecurrently-visible menu shell.

Note that the GtkMenu in this form is not and cannot be made modal. Itcould be described as a persistent popup.

It is not possible to connect directly to the tearoff window housingthe menu, because it has not been exposed as a property in PHP-GTK -with good reason, as the reference counting has been juggled in GTK+

Page 215: Apostila PHP GTK

to make the widget possible in the first place. In order to connectthe window's delete event to something meaningful, you will need to dosomething like this:<?php

dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

function exit_activated($menu) {$menu->destroy();}

$menu = &new GtkMenu();$window = $filemenu->parent;$window->ref();$window->set_flags(GTK_HAS_GRAB);$menu->connect_object('destroy', array('gtk', 'main_quit'));

/* Append and connect your menu items here, but note that any exit itemmust call $menu->destroy() rather than the usual gtk::main_quit(), inorder to avoid the main loop being quitted twice over */

$exit = &new GtkMenuItem("Exit");$exit->connect_object('activate', 'exit_activated', $menu);

$menu->set_title("Tested!");$menu->set_tearoff_state(true);$menu->show_all();

gtk::main();

?>

Notice that the "destroy" signal must be connected in this instance,and not the window's "delete-event" signal. This is because the parentwindow accessed is not the same window as has the window decorations,but is capable of accessing the internal destroy signal triggered bythat window if it is given grab beforehand, and can propagate theevent to all its children.

You will also spot that this means the menu needs to be rebuilt anytime it is called.

GtkMenu::set_title

void set_title(string title);

set_title() sets the window title for a menu that has been detachedfrom its parent through either a GtkTearoffMenuItem widget or theset_tearoff_state() method. As with all window titles, the text willbe truncated to fit the area available.

Note that the title needs to be set prior to the menu's becoming tornoff.

Page 216: Apostila PHP GTK

If the title is not set, the torn off menu will display in its titlebar either the text in the parent GtkMenuItem's label or, where thereis none, the full file path.

GtkMenu::reorder_child

void reorder_child( GtkWidget child , int position);

reorder_child() moves the specified GtkMenuItem from its currentposition in the GtkMenu to the position given. All items prior to thenew position remain unchanged, and the later items all move on one.

The first position is 0, and the final position can always be found bysetting -1.

GtkMenuBar

Horizontal container for menu items.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkMenuShell`-- GtkMenuBar

Direct subclasses

None.

Descrição

A GtkMenuBar is a container that exclusively holds GtkMenuItemwidgets, and displays them from left to right.

It has key bindings which allow the Up, Down, Left and Right arrowkeys to be used for menubar navigation. Note that these do not workin the win32 version of GTK+ used by PHP-GTK.

A menu bar with a number of subitems can be easily created with theGtkItemFactory class.

Construtor

GtkMenuBar (void);

-- Constructs a horizontal menu bar.

Métodos

set_shadow_type()Alters appearance of menu bar.

Page 217: Apostila PHP GTK

GtkMenuBar Construtor

GtkMenuBar (void);

A GtkMenuBar should normally be packed into a GtkVBox, and the parentwindow size and position set as appropriate. As with all containers,the menu bar itself takes up no screen area until its child widgetsare in place.

Exemplo 24. Creating a Menu Bar<?php

dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

$window = &new GtkWindow();$window->set_uposition(10, 10);$window->set_usize((gdk::screen_width()-20), (gdk::screen_height()-30));$window->connect_object('destroy', array('gtk', 'main_quit'));

$box = &new GtkVBox();$window->add($box);

$menubar = &new GtkMenuBar();$box->pack_start($menubar, false, false, 0);

$header1 = &new GtkMenuItem("File");$menubar->append($header1);$header2 = &new GtkMenuItem("Edit");$menubar->append($header2);

$filemenu = &new GtkMenu();$open = &new GtkMenuItem("Open");$filemenu->append($open);$save = &new GtkMenuItem("Save");$filemenu->append($save);$separator = &new GtkMenuItem();$separator->set_sensitive(false);$filemenu->append($separator);$exit = &new GtkMenuItem("Exit");$exit->connect_object("activate", array("gtk","main_quit"));$filemenu->append($exit);

$header1->set_submenu($filemenu);

$window->show_all();gtk::main();

?>

GtkMenuBar::set_shadow_type

void set_shadow_type( GtkShadowType type );

Page 218: Apostila PHP GTK

set_shadow_type() alters the appearance of a GtkMenuBar according tothe GtkShadowType option set.

The default setting is GTK_SHADOW_OUT.

GtkMenuItem

Widget used for item in menus.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkItem`-- GtkMenuItem

Direct subclasses

GtkCheckMenuItem, GtkTearoffMenuItem

Descrição

A GtkMenuItem is a container widget that can be packed into aGtkMenu or GtkMenuBar, containing a GtkAccelLabel and capable ofbeing associated with a submenu.

Construtor

GtkMenuItem ([string label ]);

-- Creates a menu item.

Métodos

set_submenu()Sets a GtkMenu as submenu.

remove_submenu()Removes a pre-existing submenu.

set_placement()Toggles placement of submenu relative to parent.

configure()Toggles indicators.

select()Emits the "select" signal.

deselect()Emits the "deselect" signal.

Page 219: Apostila PHP GTK

activate()Emits the "activate" signal.

right_justify()Sets item to the right of a GtkMenuBar.

Sinais

"activate"Emitted when menu item is chosen.

"activate-item"Fired when activate_item() is called.

GtkMenuItem Construtor

GtkMenuItem ([string label ]);

The syntax<?php

$menuitem = &new GtkMenuItem("Edit");

?>

will create a single item in a menu with the label Edit. However thislabel is really a GtkAccelLabel, and has the ability to display anykeyboard shortcuts - known as accelerators - associated with it.

For more information on setting up accelerator display in this way,see add_accelerator() . There is also a working example in the GtkMenuconstructor section of this manual.

Underlining an accelerator key within the label text is a separateissue, and can be achieved by calling the GtkLabel methodparse_uline() from the accelerator label. A string passed using thismethod will overwrite any existing text in the label.

Much of the above is to some extent automated in the GtkItemFactoryAPI, and different methods may apply when setting up aGtkItemFactory-generated menu.

Note that it is not possible to add a GtkHSeparator object to either aGtkMenuItem or a GtkMenu. The current workaround for this is to createan empty menu item and then toggle its sensitivity so that it cannotbe inadvertently selected by the end user:<?php

$separatoritem = &new GtkMenuItem();$separatoritem->set_sensitive(false);$menu->append($separatoritem);

?>

Page 220: Apostila PHP GTK

GtkMenuItem::set_submenu

void set_submenu( GtkWidget submenu );

set_submenu() sets the instance of GtkMenu passed as the parameter tobe a submenu for the calling GtkMenuItem.

The submenu will be displayed whenever the calling menu item isselected.

GtkMenuItem::remove_submenu

void remove_submenu(void);

remove_submenu() is the GtkMenuItem-specific version of the remove()found in GtkContainer. It is useful where a submenu needs to beremoved or altered under given conditions within a script.

GtkMenuItem::set_placement

void set_placement( GtkSubmenuPlacement placement );

set_placement() toggles the placement of the submenu relative to itsparent. This method is used internally to ensure that the submenu isalways displayed within the visible screen area when it is activated.

GtkMenuItem::configure

void configure(int show_toggle_indicator, int show_submenu_indicator);

configure() is intended to set the visibility of both the toggle andsubmenu indicator. However these are set internally in GTK+ to be truewhen appropriate and cannot be overridden, and although not marked assuch this method has been eliminated from later revisions of GTK+.

GtkMenuItem::select

void select(void);

select() makes the calling GtkMenuItem emit the "select" signalinherited from GtkItem.

In the GtkMenuItem widget, the emission of the "select" signal causesthe widget to display its prelight GtkStateType and pops up itssubmenu, if it has one.

Note that the "select" signal is also emitted whenever a GtkMenuItemis entered by the cursor, and by the first item in a GtkMenu when itis popped up.

GtkMenuItem::deselect

void deselect(void);

Page 221: Apostila PHP GTK

deselect() makes the calling GtkMenuItem emit the "deselect" signalinherited from GtkItem.

In the GtkMenuItem widget, the emission of the "deselect" signalcauses the widget to display its normal GtkStateType and pops down itssubmenu, if it has one.

Note that the "deselect" signal is also emitted whenever the cursorleaves the screen area of a menu item.

GtkMenuItem::activate

void activate(void);

activate() causes the calling GtkMenuItem to emit the "activate"signal as if the user had clicked on it.

GtkMenuItem::right_justify

void right_justify(void);

right_justify() sets a GtkMenuItem to the right of the GtkMenuBar itis appended to. It has no effect in any other situation, and can onlybe used on the menu item taking the final position in the menu bar'sarray of items.

activate

The "activate" signal is emitted when the user presses a mouse buttonwhile the cursor is over the widget, or hits the Enter key or spacebarwhile the widget is selected, or if the activate() method has beencalled from within the program by the widget, or if theactivate_item() method has been called from within the program by thewidget's parent.

It is also defined as the accelerator signal, so that any acceleratorkey associated with the widget will also emit the "activate".whenpressed, whether the widget is currently selected or not.

On activation, all GtkMenu widgets that are a part of the cascadingselection sequence disappear from the screen, regardless of whether ornot the GtkMenuItem has its "activate" signal connected to a functionwithin the program.

Função Callback

void callback(GtkMenuItem menuitem);

activate-item

The "activate-item" signal is fired when activate_item() is calledfrom a GtkMenuShell object. It is used internally in order to providean indirect means of firing the "activate" signal.

Page 222: Apostila PHP GTK

If you have called the activate_item() method, you will need toconnect() the appropriate GtkMenuItem to the "activate" signal.

Função Callback

void callback(GtkMenuItem menuitem);

GtkMenuShell

Abstract base class for menu objects.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkMenuShell

Direct subclasses

GtkMenu, GtkMenuBar

Descrição

GtkMenuShell is a special kind of abstract container that providesits descendants GtkMenu and GtkMenuBar with methods and signalsthat are appropriate to typical menu behaviour.

There are three keybindings set up here which are carried down tothe inheriting classes. These are as follows:

Escape cancels an existing popup menuReturn activates the current selectionSpace also activates the current selected item

The activate-current signal has not been documented here becauseany attempt to harness it beyond these bindings results in abort.The same applies to the move-current signal, implemented here andgiven keybindings in both GtkMenu and GtkMenuBar.

Note that GtkMenuShell is an abstract base class, and can not beconstructed directly.

Métodos

append()Adds item to end of menu.

prepend()Adds item to start of menu.

insert()Inserts item at specified position in menu.

Page 223: Apostila PHP GTK

deactivate()Emits deactivate signal.

select_item()Makes designated item emit the "select" signal.

deselect()Makes designated item emit the "deselect" signal.

activate_item()Makes designated item emit the "activate" signal.

Sinais

"deactivate"Emitted when the menu is no longer active.

"selection-done"Emitted when selection is complete or cancelled.

"cancel"Cancels menu using key bindings.

GtkMenuShell::append

void append( GtkWidget child );

append() adds the item passed as the parameter to the current endposition in the array of child objects within the containing menu.

See also: prepend() , insert() , GtkContainer.

GtkMenuShell::prepend

void prepend( GtkWidget child );

prepend() adds the item passed as the parameter to the currentbeginning position in the array of child objects within the containingmenu, i.e. a second item packed using prepend() will precede the firstitem packed in this way.

GtkMenuShell::insert

void insert( GtkWidget child , int position);

insert() allows the programmer to specify the position of the itemwithin the menu's array of menuitems, regardless of the order ofmethod calls.

If a position given is impossible (e.g. larger than the size of thearray) the positioning of all items will be ignored, with theexception of 0. In this case the ordering of the method calls willtake precedence.

Page 224: Apostila PHP GTK

GtkMenuShell::deactivate

void deactivate(void);

deactivate() causes the calling menu to emit the "deactivate" signal,which has the effect of deselecting any currently selected menu itemand toggling the active status of the menu to false before removingany grabs the menu may currently have. This in turn takes down themenu.

The deactivate() method is largely used internally.

GtkMenuShell::select_item

void select_item( GtkWidget menu_item );

select_item() is largely used internally. A 'selected' item isdisplayed in the prelight state and has its submenu popped up, if ithas one. This is also achieved by using the mouse pointer or arrowkeys in an active GtkMenu, and should not be confused with the"activate" signal, which is triggered by mouse clicks or the Enterkey.

Using this method causes the designated item to emit the "select"signal, which in turn triggers the 'selected' state.

GtkMenuShell::deselect

void deselect(void);

As with the select_item() method, deselect() is mostly usedinternally. A 'deselected' item is displayed in the normal state andhas its submenu popped down, if it has one.

Using this method causes the designated item to emit the "deselect"signal, which in turn triggers the 'deselected' state.

GtkMenuShell::activate_item

void activate_item( GtkWidget menu_item , bool force_deactivate);

activate_item() is used to emit the "activate" signal from theGtkMenuItem passed as the first argument. This has the same effect asa user clicking on an item or pressing the Enter key while that itemis selected.

If the second parameter is set to true, the deactivate() method iscalled on the menu that the GtkMenuItem is a part of, taking the menudown. If set to false, the menu item is hidden on activation.

deactivate

The "deactivate" signal is emitted when either a GtkMenuItem withinthe current menu has been selected or the menu has been cancelled.

Page 225: Apostila PHP GTK

This signal initiates the menu's deactivate routine, which removes thekey and pointer grabs from the menu and deselects any selected itembefore popping the menu down. It is largely used internally, andprobably carries more overhead when called than the "selection-done"signal emitted under similar conditions.

Função Callback

void callback(GtkWidget menu);

selection-done

The "selection-done" signal is emitted when the selection routine iscomplete, that is, when either a GtkMenuItem within the menu has beenselected or when the user has cancelled the menu by using the Escapekey.

This signal is not connected to any internal functions, merelyreporting the selection status. Use it in preference to the"deactivate" signal.

Função Callback

void callback(GtkWidget menu);

cancel

The "cancel" signal is fired when the Escape key is pressed.

The internal functions called when this signal is emitted cancel thecurrent selection, deactivate the menu, and fire the "selection-done"signal.

It is, however, possible to add to the functions that this signalalready invokes.

Função Callback

void callback(GtkWidget menu);

GtkMisc

Base class for widgets having their own alignment and padding.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkMisc

Direct subclasses

GtkArrow, GtkImage, GtkLabel, GtkPixmap

Page 226: Apostila PHP GTK

Descrição

GtkMisc is a base class bequeathing alignment and paddingproperties and related methods to its descendants.

Most widgets do not have such properties on their own account, andonly get them through being packed into a multiple container suchas the GtkBox family members or GtkTable, or else through using theGtkAlignment widget which is designed to lend a facsimile of theseproperties to its child widget.

It is therefore rare in GTK+ to find a widget capable of callingits own alignment and padding properties directly, and only GtkMiscdescendants are able to do so.

This is an abstract base class, and cannot be directly constructed.

Métodos

set_alignment()Sets alignment.

set_padding()Sets padding.

Propriedades

xalign:Relative distance from container's left edge.

yalign:Relative distance from container's top edge.

xpad:Padding along horizontal axis.

ypad:Padding along vertical axis.

GtkMisc::set_alignment

void set_alignment(double xalign, double yalign);

set_alignment() sets the relative positioning of the calling widgetwithin its container. xalign refers to the relative distance from theleft edge, and yalign to the relative distance from the top edge ofthe container, with 0.0 being no distance from those respective edgesand 1.0 being no distance from their opposites.

GtkMisc::set_padding

void set_padding(int xpad, int ypad);

Page 227: Apostila PHP GTK

set_padding() sets the padding around the calling widget to the givennumber of pixels, in both directions.

GtkMisc::xalign

Access: Read OnlyType: double

The xalign property provides the means to query the relative positionof the widget to its container along the horizontal axis.

GtkMisc::yalign

Access: Read OnlyType: double

The yalign property provides the means to query the relative positionof the widget to its container along the vertical axis.

GtkMisc::xpad

Access: Read OnlyType: int

The xpad property provides the means to query the padding around thewidget to the left and right of the area it takes up. The returnedinteger represents pixels.

GtkMisc::ypad

Access: Read OnlyType: int

The ypad property provides the means to query the padding around thewidget to the top and bottom of the area it takes up. The returnedinteger represents pixels.

GtkNotebook

Widget that displays a set of pages with tabs.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkNotebook

Direct subclasses

GtkFontSelection

Descrição

Page 228: Apostila PHP GTK

GtkNotebook is a widget which displays its children widgets in astacked manner. Each child has a tab which is visible no matterwhen in the stack the child is. A child can be brought to the topof the stack by clicking on that child's tab. A text editor whichallows a user to edit multiple documents at once might make gooduse of GtkNotebook.

Construtor

GtkNotebook (void);

-- Creates a new GtkNotebook object.

Métodos

append_page()Add a page to the back of the note book.

append_page_menu()Appends a page to the notebook, specifying the widget to use as thelabel in the popup menu.

prepend_page()Add a page to the begining of the note book.

prepend_page_menu()Prepends a page to the notebook, specifying the widget to use as thelabel in the popup menu.

insert_page()Add a page to the notebook in the given position.

insert_page_menu()Inserts a page into the notebook at the given position, specifyingthe widget to use as the label in the popup menu.

remove_page()Remove the page at the given position from the notebook.

get_current_page()Return the index of the current page.

get_nth_page()Returns the page in the given position.

page_num()Returns the position of the given child widget.

set_page()Sets the page in the given position as the top page in the notebook.

next_page()Moves the next page in the notebook to the top.

Page 229: Apostila PHP GTK

prev_page()Moves the previous page in the notebook to the top.

set_show_border()Set whether a bevel will be drawn around the notebook pages.

set_show_tabs()Set whether or not to show the page tabs.

set_tab_pos()Set the edge on which the notebook tabs will be displayed.

set_homogeneous_tabs()Set whether or not all tabs should be the same width.

set_tab_border()Sets the border around all edges of the notebook's tabs.

set_tab_hborder()Sets the border for the left and right sides of the notebook's tabs.

set_tab_vborder()Sets the border for the top and bottom sides of the notebook's tabs.

set_scrollable()Set whether the tab label area will allow scrolling.

popup_enable()Enable the popup menu.

popup_disable()Disable the popup menu.

get_tab_label()Get the tab's label widget.

set_tab_label()Set the tab widget of the given child.

set_tab_label_text()Create a new label and set it as the tab label for the given child.

get_menu_label()Get the popup menu label for a notebook page.

set_menu_label()Set the popup menu label for a notebook page.

set_menu_label_text()Set the popup menu label text for a notebook page.

set_tab_label_packing()Set how the popup menu label for a page will be packed.

Page 230: Apostila PHP GTK

reorder_child()Move a page to a given position.

Sinais

"clicked"Emitted when a tab is clicked by the user.

"switch-page"Emitted when the top page of the notebook is changed.

GtkNotebook Construtor

GtkNotebook (void);

Creates a new GtkNotebook instance. After creating the notebook, youshould fill its pages with other widgets using append_page() and/orother similar methods.

Because GtkNotebook is a decendant of GtkContainer, it may contain oneor more children. The notebook's children will be displayed as a"page" with a tab. It is most useful when the notebook's children arethemselves containers so that other items may be added.

Exemplo 25. Creating a GtkNotebook<?php$notebook =& new GtkNotebook;

$pages = array('tab one', 'tab two', 'tab three');

foreach ($pages as $page) {$frame =& new GtkFrame($page);$frame->add(new GtkLabel('Sample text for ' . $page);$notebook->append_page($frame, new GtkLabel($page));}

$notebook->show_all();?>

Tabs are automatically connected to the "clicked" signal. When a tabis clicked the "switch-page" signal is emitted which causes that tab'spage to be brought to the foreground.

GtkNotebook::append_page

void append_page ( GtkWidget child , [ GtkWidget tab_label ]);

Adds a new page and tab to the back of the notebook. child is added asthe "page" with tab_label as the tab. child can be any widget but itis most useful when child is descended from GtkContainer. Thetab_label is usually a GtkLabel but may be any widget.

tab_label is optional. If it is not supplied the tab will be set to"page n" where n is the page number.

Page 231: Apostila PHP GTK

Exemplo 26. Appending pages to a notebook<?php$pages = array(1, 2, 3);

$notebook =& new GtkNotebook;

foreach ($pages as $pageNumber) {$frame =& new GtkFrame('Page ' . $pageNumber);$label =& new GtkLabel('Tab ' . $pageNumber);$notebook->append_page($frame, $label);}?>

See also: prepend_page() , insert_page()

GtkNotebook::append_page_menu

void append_page_menu(GtkWidget child, GtkWidget tab_label, GtkWidgetmenu_label);

Adds child as the last page in the notebook with tab_label as thepage's tab. Also adds menu_label as the page's popup menu label.menu_label will only be visible if the popup menu is enabled bycalling popup_enable() .

See also: prepend_page_menu() , insert_page_menu()

GtkNotebook::prepend_page

void prepend_page ( GtkWidget child , [ GtkWidget tab_label ]);

Adds a new page to the begining of the notebook. child is added as the"page" with tab_label as the tab. child can be any widget but it ismost useful when child is descended from GtkContainer. The tab_labelis usually a GtkLabel but may be any widget.

tab_label is optional. If it is not supplied the tab will be set to"page n" where n is the page number.

See also: append_page() , insert_page()

GtkNotebook::prepend_page_menu

void prepend_page_menu(GtkWidget child, GtkWidget tab_label, GtkWidgetmenu_label);

Adds child as the first page in the notebook with tab_label as thepage's tab. Also adds menu_label as the page's popup menu label.menu_label will only be visible if the popup menu is enabled bycalling popup_enable() .

See also: append_page_menu() , insert_page_menu()

Page 232: Apostila PHP GTK

GtkNotebook::insert_page

void insert_page ( GtkWidget child , [ GtkWidget tab_label , [intposition ]]);

Adds a new page to the notebook as the positionth page. child is addedas the "page" with tab_label as the tab. child can be any widget butit is most useful when child is descended from GtkContainer. Thetab_label is usually a GtkLabel but may be any widget. If position is-1 the page will be added as the last page in the notebook. Pagepositions begin with 0.

tab_label is optional. If it is not supplied the tab will be set to"page n" where n is the page number.

position is optional. If it is not supplied it will default to -1which will put the page at the end of the notebook.

See also: append_page() , prepend_page() , remove_page()

GtkNotebook::insert_page_menu

void insert_page_menu ( GtkWidget child , GtkWidget tab_label ,GtkWidget menu_label , int position );

Adds child as the notebook page in position tab_label as the page'stab. Also adds menu_label as the page's popup menu label. menu_labelwill only be visible if the popup menu is enabled by callingpopup_enable() .

See also: append_page_menu() , prepend_page_menu()

GtkNotebook::remove_page

void remove_page (int page_num );

Removes the page with index page_num or the last page if page_num is-1. Pages are indexed begining with 0.

Exemplo 27. Removing the current page<?php// Remove the current page.$notebook->remove_page($notebook->get_current_page());?>

See also: insert_page()

GtkNotebook::get_current_page

int get_current_page (void);

Returns the index of the currently selected page.

Exemplo 28. Set the current page to 0 if not already

Page 233: Apostila PHP GTK

<?php$notebook =& new GtkNotebook;for ($i = 0; $i < 10; ++$i) {$notebook->append_page(new GtkFrame('Page ' . $i), new GtkLabel($i));}

if ($notebook->get_current_page() != 0) {$notebook->set_page(0);}?>

GtkNotebook::get_nth_page

GtkWidget get_nth_page (int page_num );

Returns the child widget with index page_num. If page_num is -1, thelast page is returned. If page_num is greater then the number of pagesminus one (the highest index), NULL is returned.

See also: page_num()

GtkNotebook::page_num

int page_num ( GtkWidget child );

Returns the index of child. If child is not a child of the notebook,-1 is returned.

See also: get_nth_page()

GtkNotebook::set_page

void set_page (int page_num );

Sets the page with index page_num as the top page in the notebook.

GtkNotebook::next_page

void next_page (void);

Sets the page after the current page as the top page in the notebook.If the current page is the last page in the notebook, nothing happens.

See also: next_page()

GtkNotebook::prev_page

void prev_page (void);

Sets the page before the current page as the top page in the notebook.If the current page is the first page in the notebook, nothinghappens.

See also: next_page()

Page 234: Apostila PHP GTK

GtkNotebook::set_show_border

void set_show_border(bool show_border);

Sets whether or not a beveled edge will be drawn around the notebookpages. If show_border is false the border will not be shown. Settingthe border to be shown when the border is already showing or settingit to be hidden when the border is already hidden has no effect. Thisonly has an effect when tabs are not shown.

See also: set_show_tabs()

GtkNotebook::set_show_tabs

void set_show_tabs(bool show_tabs);

Sets whether or not the page tabs will be shown. If show_tab is falsethe tabs will not be visible. Setting the tabs to be visible when theyare already visisble or setting them to be hidden when they arealready hidden has not effect.

See also: set_tab_pos()

GtkNotebook::set_tab_pos

void set_tab_pos(GtkPositionType pos);

Sets the edge on which the page tabs will appear if they are to beshown.

See also: set_show_tabs()

GtkNotebook::set_homogeneous_tabs

void set_homogeneous_tabs(bool homogeneous);

Sets whether or not all tabs should be the same width. If homogeneousis true all tabs will have equal width. If homogeneous is false thewidth of each tab will depend on the size of the label.

GtkNotebook::set_tab_border

void set_tab_border(int border_width);

Sets the border around all edges of the tabs to border_width. This isequivilent to calling set_tab_hborder() and set_tab_vborder() with thesame value.This method is deprecated in GTK+ and should not be used in new code.Instead you should use set_tab_hborder() and set_tab_vborder() .

See also: set_tab_hborder() , set_tab_vborder()

GtkNotebook::set_tab_hborder

Page 235: Apostila PHP GTK

void set_tab_hborder(int tab_hborder);

Sets the left and right borders to be tab_hborder pixels wide for allthe notebook's tabs.

Combined with set_tab_vborder() this is the suggested method forsetting tab borders.

See also: set_tab_border() , set_tab_vborder()

GtkNotebook::set_tab_vborder

void set_tab_vborder(int tab_vborder);

Sets the top and bottom borders to be tab_vborder pixels wide for allthe notebook's tabs.

Combined with set_tab_hborder() this is the suggested method forsetting tab borders.

See also: set_tab_border() , set_tab_hborder()

GtkNotebook::set_scrollable

void set_scrollable(bool scrollable);

Sets whether or not there will be arrows for scrolling if there aremore tabs than can be displayed in the tab label area. If scrollableis set to true scrolling arrows will appear when needed. If scrollableis set to false the tab label area will not be scrollable.

GtkNotebook::popup_enable

void popup_enable(void);

Enables the popup menu allowing the user to change pages by rightclicking on the bookmarks and selecting a page from the menu.

See also: popup_disable()

GtkNotebook::popup_disable

void popup_disable(void);

Disables the popup menu.

See also: popup_enable()

GtkNotebook::get_tab_label

GtkWidget get_tab_label(GtkWidget child);

Returns child's tab label widget. NULL is returned if child is not in

Page 236: Apostila PHP GTK

the notebook or if there was no label set for child.

Tab labels are normally set when the page is added to the notebook.

See also: set_tab_label()

GtkNotebook::set_tab_label

void set_tab_label(GtkWidget child, GtkWidget tab_label);

Sets child's tab label widget to tab_label. If null is given fortab_label, the default label of "page n", where n is the page number,will be used.

See also: get_tab_label()

GtkNotebook::set_tab_label_text

void set_tab_label_text(GtkWidget child, string tab_text);

Creates a new GtkLabel with tab_text as the label and sets it as thetab label widget for child.

See also: set_tab_label()

GtkNotebook::get_menu_label

GtkWidget get_menu_label(GtkWidget child);

Returns the menu label widget for child. If child is not a child ofthe notebook or does not have a menu label other than the default tablabel, NULL is returned.

GtkNotebook::set_menu_label

void set_menu_label(GtkWidget child, GtkWidget menu_label);

Sets menu_label as the popup menu label widget for child.

See also: get_menu_label() , set_menu_label_text()

GtkNotebook::set_menu_label_text

void set_menu_label_text(GtkWidget child, string menu_text);

Creates a new GtkLabel with menu_text as its label text and sets it aschild's popup menu label.

GtkNotebook::set_tab_label_packing

void set_tab_label_packing(GtkWidget child, bool expand, bool fill,GtkPackType pack_type);

Sets the packing parameters for the tab label of the page containing

Page 237: Apostila PHP GTK

child. See pack_start() for the exact meaning of the parameters.

GtkNotebook::reorder_child

void reorder_child ( GtkWidget child , int position );

Moves child to position position. If position is greater than thenumber of pages or is negative, the page will be moved to the end ofthe notebook.

Page positions start from zero. The third page in the notebook is inposition two.

clicked

The "clicked" signal is emitted when a user clicks on a page tab. Bydefault this signal is connected to the set_page() method. This hasthe effect of moving the page associated with the tab to the front ofthe notebook.

Função Callback

void callback(GtkNotebook notebook);

switch-page

The "switch-page" signal is emitted when the top page of the notebookis changed. This can occur when a user clicks on a page's tab or whenthe top page is changed by the program.

See also: set_page() , next_page() , prev_page()

Função Callback

void callback(GtkNotebook notebook);

GtkObject

The base class of the PHP-GTK class hierarchy.

Hierarquia do Objeto

GtkObject

Direct subclasses

GtkData, GtkItemFactory, GtkWidget

Descrição

GtkObject is the base class of the GTK object hierarchy. Itimplements the functionality that every object below it in the treehas. This object cannot be directly constructed from PHP-GTK, butis documented here for reference purposes as its methods and signal

Page 238: Apostila PHP GTK

are generic throughout the hierarchy.

Métodos

flags()Returns an object's current GtkObjectFlags settings.

set_flags()Sets the GtkWidgetFlags on a derived object.

unset_flags()Unsets the GtkWidgetFlags on a derived object

default_construct()The default object constructor.

constructed()Marks an object as constructed.

sink()Removes an object's initial floating reference.

ref()Increases the reference count on an object.

unref()Decreases the reference count on an object.

destroy()Causes the object to be destroyed.

get_arg()Returns current argument set.

set_arg()Sets an argument or arguments on an object.

set_data()Associate data with an object as a key/values pair.

get_data()Return data from the objects data associations.

remove_data()Remove data from the objects data associations.

emit()Emit a signal.

emit_stop()Stop a signal from being emitted.

emit_stop_by_name()Stop a signal with a given name from being emitted.

Page 239: Apostila PHP GTK

connect()Connects a signal and a callback.

connect_after()Connects a signal and a callback to be called after any others.

connect_object()Pass a different object to the callback.

connect_object_after()Pass a different object to the callback, register the callback last.

disconnect()Disconnects a signal from a function.

signal_handler_block()Block a signal handler from being called when a signal is emitted.

signal_handler_unblock()Allow a previously blocked signal hander to be called again.

signal_handler_pending()

signal_handler_pending_by_id()

signal_handlers_destroy()Destroy all signal handlers connected to this object.

Sinais

"destroy"Emitted when an object is destroyed.

GtkObject::flags

int flags(void);

This method returns the object's flags as defined by the enumeratedvalues in GtkObjectFlags. The return value can be used to findinformation about an object's current status, i.e. whether the objecthas been fully constructed, whether the object has a floatingreference or is associated with a parent object, whether the objecthas signals connected to it, and whether the object has beendestroyed.

See also: set_flags() , unset_flags() .

GtkObject::set_flags

void set_flags( GtkWidgetFlags flags );

Page 240: Apostila PHP GTK

This method allows you to set any of the flags defined by theGtkWidgetFlags enumerated values. These flags share the flags space inGtkObject; the first four bits are taken by GtkObjectFlags, andderived objects use the remaining bitfields. The GtkWidgetFlagssettings determine the capabilities of a widget; e.g the flagGTK_NO_WINDOW is set on certain widgets during their creation in theGTK source, reversing the generic widget property of $widget->window;- such widgets are not able to respond unilaterally to GDK events.(Use a GtkEventBox to capture events on windowless widgets.)

You would use set_flags() in a situation where the widget needscapabilities it does not have at base; setting for instanceGTK_CAN_DEFAULT on a GtkButton you want to have keyboard grab bydefault will cause that button to be drawn in such a way that space isallowed for it to be displayed with default status.

Although all the flag bitfields are reversible in this way, it is notalways sane to alter them, given that the chief characteristics of awidget are controlled by them. For example, unsetting theGTK_NO_WINDOW flag on a GtkLabel widget will prevent the label fromdisplaying its current text.

See also: flags() , unset_flags() , and a whole host of GtkWidgetmethods such as set_sensitive() and grab_default() which either act aswrappers for the set_flags() function or need to work in tandem withGtkWidgetFlags values set in this way.

GtkObject::unset_flags

void unset_flags( GtkWidgetFlags flags );

This method allows the programmer to reverse the switch of thebitfield flags on a widget, as defined by the GtkWidgetFlagsenumerated values. These flags reflect a widget's current state orcapabilities. Note that GtkObjectFlags and GtkWidgetFlags share thesame flag space, but are fairly different in nature. The object flagsare public so that they can be queried rather than so that they can bealtered, relating as they do to the basic construction of any object.The widget flags determine the nature of that object.

See also: flags() , set_flags() .

GtkObject::default_construct

void default_construct(void);

This construction method is called internally in GTK+ after thearguments for a new object have been set, if the GtkObjectFlags valueGTK_CONSTRUCTED does not return true. You are unlikely to use it inPHP-GTK programming.

GtkObject::constructed

void constructed(void);

Page 241: Apostila PHP GTK

constructed() is a wrapper method providing a way to switch theGtkObjectFlaga value GTK_CONSTRUCTED. It may be called internally inGTK+ during the construction of a new object, as a fallback whendefault_construct() fails.

It is unlikely (but not impossible) that you will use this method inPHP-GTK programming.

GtkObject::sink

void sink(void);

This method might be used when a newly-created object has not beenassigned a parent. sink() is called internally when the object isassigned a parent. The object is assigned a reference count of 1 atthat point, and is kept alive only through its association with theparent.

sink() would be called by a PHP-GTK programmer in a situation wherethe object needed to be fully referenced, for example after callingref() and prior to calling unref() on an object, where the object hasno reference-giving parent. It's basically a wrapper method thatprovides access to the GtkObjectFlags value GTK_FLOATING.

GtkObject::ref

void ref(void);

Increases the reference count on an object by 1. This method is calledinternally when a newly created object is claimed by its parent widgetand before its floating reference count is sunk, leaving the life ofthe child completely in the hands of the parent's own reference value.

If you are planning to remove() a child from its parent container, youwill therefore need to call ref() on that child first, in order tomaintain its life away from the parent.

GtkObject::unref

void unref(void);

This method decreases the reference count on an object by 1.

If the reference count reaches 1 then destroy() will be called on theobject from source.

GtkObject::destroy

void destroy(void);

destroy() causes an object and all its signal connections to bedestroyed. During this process the "destroy" signal is emitted.

Page 242: Apostila PHP GTK

Note that the object's memory is currently not freed at the point ofdestruction, as the reference count is maintained by both thedestroy() method within GTK, and the Zend registry within PHP. In bothcases, this way of coping with object destruction has either changedor is about to change in the near future.

See also: unref() .

GtkObject::get_arg

mixed get_arg(string arg_name);

In most cases where you are likely to need to know the content of anargument, there will be a get method in place which is basically awrapper for get_arg() . This is good, because there is, unfortunately,no way to know for certain the name of the argument to pass to thisfunction without looking at GTK+ source. A brief tutorial on makingsense of what you see there follows.

An individual widget's arguments are initialized as a set ofenumerated values at the beginning of the c file relating to thatobject. For example, in gtklabel.c in GTK 1.2.10 you will see thisdirectly after the includes:enum {ARG_0,ARG_LABEL,ARG_PATTERN,ARG_JUSTIFY,ARG_WRAP};

Around a hundred lines later, these argument types are defined as theyare added to the widget, in the class_init function:gtk_object_add_arg_type ("GtkLabel::label",GTK_TYPE_STRING,GTK_ARG_READWRITE,ARG_LABEL);gtk_object_add_arg_type ("GtkLabel::pattern",GTK_TYPE_STRING,GTK_ARG_READWRITE,ARG_PATTERN);gtk_object_add_arg_type ("GtkLabel::justify",GTK_TYPE_JUSTIFICATION,GTK_ARG_READWRITE,ARG_JUSTIFY);gtk_object_add_arg_type ("GtkLabel::wrap",GTK_TYPE_BOOL,GTK_ARG_READWRITE,ARG_WRAP);

This gives you the name (in quotes) that you are looking for, the typeof data that the argument will consist of, the fact that it iswriteable (always), and the name of the original enumerated value tobind this information to.

Page 243: Apostila PHP GTK

For get_arg() , all you really need is the part that is in quotes,which can be surmised by looking at the initial enums. The datatypemay, however, be useful information if you need to set an argument andhave no other means of doing so than set_arg() .

The way you would access this is as follows:<?php

$label = &new GtkLabel('This is an argumentative label');$arg = $label->get_arg('GtkLabel::label');echo $arg."\n";

?>

GtkObject::set_arg

void set_arg(array arg_name);

In most cases, you will find that there is a set method in place thatis a wrapper function for set_arg() . In the rare situation where thisis not in place, you will need to refer to the GTK source in order tofind the argument name expected by this method. There is a shorttutorial explaining what to look for, under get_arg() .

The syntax used in this method is as follows:<?php

$label->set_arg(array('GtkLabel::label'=>'RTFS','GtkLabel::pattern'=>'____'));

?>

GtkObject::set_data

void set_data(string key, mixed value);

Associates value with the calling object. value can be retireved bypassing key when calling get_data() .

Exemplo 29. Tagging objects<?php// Create a GtkNotebook with several pages out of order.$notebook =& new GtkNotebook;

for ($i = 0; $i < 6; $i++) {$frame =& new GtkFrame('Page ' . $i);$frame->set_data('intended_position', $i);

// Add the pages out of order.if ($i % 2) {$notebook->prepend_page($frame, new GtkLabel('Tab ' . $i));}}

Page 244: Apostila PHP GTK

// Reorder the pages.$pages =& $notebook->children();// Can't use foreach because it makes a copy.for ($page =& reset($pages); $page !== false; $page =& next($pages)) {$notebook->reorder_child($page, $page->get_data('intended_position');}?>

See also: get_data() , remove_data()

GtkObject::get_data

mixed get_data(string key);

Returns the value assigned to key when set_data() was called.

See also: set_data() , remove_data()

GtkObject::remove_data

void remove_data(string key);

Removes the data association with key key.

See also: set_data() , get_data()

GtkObject::emit

int emit (string signal_type );

Emits the signal signal_type. signal_type is the name of the signal toemit.

This method is called automatically when an event is triggered. Thesignal that is emitted is determined by the event that occured.

See also: emit_stop() , emit_stop_by_name()

GtkObject::emit_stop

void emit_stop (int signal_id );

Stops the signal identified by signal_id from being emitted. Thesignal_id is the return value from emit() .

See also: emit() , emit_stop_by_name()

GtkObject::emit_stop_by_name

void emit_stop_by_name (string signal_name );

Stops the signal signal_name from being emitted. This will prevent thesignal from being emitted and will in turn prevent the methods

Page 245: Apostila PHP GTK

connected to the signal from being executed.

See also: emit() , emit_stop()

GtkObject::connect

int connect(string signal, string function, [mixed custom_data ]);

Connects a function to a signal so it is called when the signal isemitted by a widget.

The function takes two or three arguments. The first parameter, signalis the textual name of the signal, the second parameter, function isthe name of the function that should be used as a callback. The thirdparameter, custom is optional and can be used to pass extra data tothe callback. Please see the Userguide section of the manual for moreinformation on this.

See Also: connect_after() , connect_object() , connect_object_after()

GtkObject::connect_after

int connect_after(string signal, string function, void custom ]);

Connects a function to a signal so it is called when the signal isemitted by a widget. The callback is guaranteed to be called after thenormal and default handlers.

The function takes two or three arguments. The first parameter, signalis the textual name of the signal, the second parameter, function isthe name of the function that should be used as a callback. The thirdparameter, custom is optional and can be used to pass extra data tothe callback. Please see the Userguide section of the manual for moreinformation on this.

See Also: connect() , connect_object() , connect_object_after()

GtkObject::connect_object

int connect_object(string signal, string function, object param);

connect_object() allows the passing of a different object to acallback than the one for emitting the signal in the first place.

The signal parameter is the textual name of the signal we want toconnect to, the function parameter is the textual name of the functionwe want to connect to the signal and the param parameter is the objectwe want to pass as the first parameter to the callback.

The function returns the signal_id.

See Also: connect() , connect_after() , connect_object_after()

GtkObject::connect_object_after

Page 246: Apostila PHP GTK

int connect_object_after(string signal, string function, Objectparam);

connect_object_after() allows the passing of a different object to acallback than the one for emitting the signal in the first place. Byusing the connect_object_after() you can ensure that all normalhandlers, and the default handler are called first.

The signal parameter is the textual name of the signal we want toconnect to, the function parameter is the textual name of the functionwe want to connect to the signal and the param parameter is the objectwe want to pass as the first parameter to the callback.

The function returns the signal_id.

See Also: connect() , connect_after() , connect_object()

GtkObject::disconnect

void disconnect(int handler_id);

Removes the connection identified by handler_id. handler_id is thevalue returned from connect() or one of its sister functions. When theconnection is removed, the function that was passed to connect() willnot be called when the signal that was passed is emitted.

Exemplo 30. Disconnecting a method<?php// Say 'hi' on the terminalfunction sayHi(){echo 'Hi';}

// Make a button shut up.function beQuiet(&$button, $handler){$button->disconnect($handler);}

// Set up the window$window =& new GtkWindow;$hBox =& new GtkHBox;

// Make a button that says hi.$button1 =& new GtkButton('Say Hi');$handler = $button1->connect('clicked', 'sayHi');

// Make the first button shut up when the second is clicked.$button2 =& new GtkButton('Be Quiet!');$button2->connect_object('clicked', 'beQuiet', $button1, $handler);

$hBox->pack_start($button1);

Page 247: Apostila PHP GTK

$hBox->pack_start($button2);

$window->add($hBox);$window->show_all();gtk::main();?>

See also: connect()

GtkObject::signal_handler_block

void signal_handler_block (int handler_id );

Blocks a signal handler from being called when the connected signal isemitted. handler_id is the value returned when connect() or one of itssister methods is called. While handler_id is blocked, the functionpassed to connect() will not be called when the connected signal isemitted. Calling signal_handler_unblock() will reverse this effect andallow the signal to call the function again.

See also: signal_handler_unblock()

GtkObject::signal_handler_unblock

void signal_handler_unblock(int handler_id);

Releases a blocked signal handler allowing the function to be calledwhen the signal is emitted. handler_id is return value from connect()or one of its sister methods. Calling signal_handler_unblock() on asignal handler that was not previously blocked usingsignal_handler_block() has no effect.

See also: signal_handler_block()

GtkObject::signal_handler_pending

int signal_handler_pending (int signal_id , bool may_be_blocked );

GtkObject::signal_handler_pending_by_id

int signal_handler_pending_by_id (int handler_id , bool may_be_blocked);

GtkObject::signal_handlers_destroy

void signal_handlers_destroy(void);

Destroys all signal handlers connected to this object. This methodwill destroy all handlers whether they were connected by default or bycalling connect() or one of its sister methods. This method is calledautomatically when an object is destroyed, it should not normally becalled in code.

destroy

Page 248: Apostila PHP GTK

The "destroy" signal is emitted by an object when it is in the processof being destroyed. This signal is connected tosignal_handlers_desctroy which causes the signal connectionsassociated with the object to be destroyed immediately after thisemission.

Função Callback

void callback(GtkObject object);

GtkOptionMenu

Widget used to choose from a list of valid choices.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkButton`-- GtkOptionMenu

Direct subclasses

None.

Descrição

A GtkOptionMenu consists of a button containing a label, with anindicator tab to the right.

The GtkMenu currently associated with the option menu pops up in asimilar area to that which would be taken up by a dropdown menu.This is, however, a popup menu; if you need a dropdown list widget,take a look at GtkCombo.

GtkOptionMenu has been deprecated since GTK+ 2.0 and should not beused in newly written code.

Construtor

GtkOptionMenu (void);

-- Creates a popup menu linked to a button.

Métodos

get_menu()Retrieves current menu.

set_menu()Sets associated menu.

Page 249: Apostila PHP GTK

remove_menu()Removes existing menu.

set_history()Sets button text to that of designated GtkMenuItem.

GtkOptionMenu Construtor

GtkOptionMenu (void);

Constructing a GtkOptionMenu is less complicated that creating mostother forms of menu.

Exemplo 31. Creating a simple GtkOptionMenu.<?php

dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

function echo_activated($item, $label, $rank, $x) {echo "\$items[$x] ('$label') is the $rank".$item->get_name().".\n";flush();}

$window = &new GtkWindow();$window->set_position(GTK_WIN_POS_CENTER);$window->connect_object('destroy', array('gtk', 'main_quit'));

$menu = &new GtkMenu();$labels = array('File', 'Edit', 'Save', 'Exit');$pos = array('first', 'second', 'third', 'fourth');for($i = 0; $i < 4; $i++) {$items[$i] = &new GtkMenuItem($labels[$i]);$items[$i]->connect('activate', 'echo_activated', $labels[$i], $pos[$i],$i);$menu->append($items[$i]);}$menu->show_all();

$optionmenu = &new GtkOptionMenu();$optionmenu->set_menu($menu);$window->add($optionmenu);

$window->show_all();gtk::main();

?>

GtkOptionMenu::get_menu

GtkWidget get_menu (void);

get_menu() returns the instance of the GtkMenu that is currently

Page 250: Apostila PHP GTK

associated with the calling GtkOptionMenu.

GtkOptionMenu::set_menu

void set_menu( GtkWidget menu );

set_menu() sets the GtkMenu specified in the parameter to beassociated with the calling GtkOptionMenu.

GtkOptionMenu::remove_menu

void remove_menu(void);

remove_menu() removes the GtkMenu currently associated with theGtkOptionMenu.

In order to avoid an error message the next time that the user clickson the GtkOptionMenu after menu removal, it is necessary to eitherreplace it with a new GtkMenu or to call set_sensitive(false) from theGtkOptionMenu. Either call will avert an error message regards themenu not existing.

GtkOptionMenu::set_history

void set_history(int index);

set_history() is used internally in GTK to display the text of theGtkMenuItem most recently activated by the user.

This method can also be used by the PHP-GTK programmer to overridethis default behaviour or, alternatively, to designate an initialsetting using the index position.

GtkPacker

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkPacker

Direct subclasses

None.

Descrição

Construtor

GtkPacker (void);

--

Page 251: Apostila PHP GTK

Métodos

add_defaults()

add()

set_child_packing()

reorder_child()

set_spacing()

set_default_border_width()

set_default_pad()

set_default_ipad()

GtkPacker Construtor

GtkPacker (void);

GtkPacker::add_defaults

void add_defaults(GtkWidget child, GtkSideType side, GtkAnchorTypeanchor, GtkPackerOptions options);

GtkPacker::add

void add(GtkWidget child, GtkSideType side, GtkAnchorType anchor,GtkPackerOptions options, [int border_width = 0, [int pad_x = 0, [intpad_y = 0, [int i_pad_x = 0, [int i_pad_y = 0]]]]]);

GtkPacker::set_child_packing

void set_child_packing(GtkWidget child, GtkSideType side,GtkAnchorType anchor, GtkPackerOptions options, [int border_width = 0,[int pad_x = 0, [int pad_y = 0, [int i_pad_x = 0, [int i_pad_y =0]]]]]);

GtkPacker::reorder_child

void reorder_child(GtkWidget child, int position);

GtkPacker::set_spacing

void set_spacing(int spacing);

Page 252: Apostila PHP GTK

GtkPacker::set_default_border_width

void set_default_border_width(int border);

GtkPacker::set_default_pad

void set_default_pad(int pad_x, int pad_y);

GtkPacker::set_default_ipad

void set_default_ipad(int i_pad_x, int i_pad_y);

GtkPaned

Base class for widgets with two adjustable panes.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkPaned

Direct subclasses

GtkHPaned, GtkVPaned

Descrição

GtkPaned provides methods and properties for container widgets withtwo panes whose relative size can be adjusted by the end user. Thepanes are arranged horizontally in GtkHPaned or vertically inGtkVPaned, and are divided by a handle. By default, the initialposition of the handle is set in accordance with the size requestsof the child widgets.

Note that the panes are defined through their child widgets, i.e.they have an initial size of zero.

GtkPaned is an abstract base class and cannot be constructeddirectly.

Métodos

add1()Adds child to first pane.

add2()Adds child to second pane.

pack1()Adds child to first pane, with options.

Page 253: Apostila PHP GTK

pack2()Adds child to second pane, with options.

set_position()Sets position of dividing handle.

set_handle_size()Sets handle size. *deprecated in GTK2*

set_gutter_size()Sets gutter size. *deprecated in GTK2*

Propriedades

child1:Child widget in first pane.

child2:Child widget in second pane.

handle_size:Size of separating handle. *deprecated in GTK2*

gutter_size:Size of separating gutter. *deprecated in GTK2*

child1_resize:Status of first child's resize setting.

child1_shrink:Status of first child's shrink setting.

child2_resize:Status of second child's resize setting.

child2_shrink:Status of second child's shrink setting.

GtkPaned::add1

void add1( GtkWidget child );

add1() adds the child widget specified to the top or left pane of aGtkPaned-based widget.

The only difference between add1() and pack1() is that the packingparameters are not visible to the programmer where add1() is used, andso cannot easily be altered. The settings are identical to the pack1()defaults.

GtkPaned::add2

void add2( GtkWidget child );

Page 254: Apostila PHP GTK

add2() adds the child widget specified to the bottom or right pane ofa GtkPaned-based widget.

The only difference between add2() and pack2() is that the packingparameters are not visible to the programmer where add2() is used, andso cannot easily be altered. The settings are identical to the pack2()defaults.

GtkPaned::pack1

void pack1( GtkWidget child , [bool resize = false , [bool shrink =true ]]);

pack1() packs the child widget specified into the top or left pane ofa GtkPaned-based widget.

The resize parameter when set to its default false ensures that thepane will not expand beyond its initial size when the top-level windowis maximised, in the direction of the pane arrangement. Note that theresize parameter describes the spatial relationship between the twopanes, so that setting both panes alike will always result in bothpanes resizing when the top-level window is maximised. The userresizing facility offered by the handle is not affected by the resizesetting.

The shrink parameter when set to its default true allows the pane toshrink beyond the size requested by its child widget. Setting theshrink parameter to false prevents it from doing this. Note thatsetting the parameter to false across both panes renders the dividinghandle ineffective where the size of the top-level window is reliantupon the size requests of the child widgets.

GtkPaned::pack2

void pack2( GtkWidget child , [bool resize = true , [bool shrink =true ]]);

pack2() packs the child widget specified into the bottom or right paneof a GtkPaned-based widget.

The resize parameter when set to its default true allows the pane andits child widget to expand to fill the area between the dividinghandle and the edge of the container when the toplevel window ismaximised, in the direction of the pane arrangement. The position ofthe dividing handle can be set using set_position() , or by default isset at the size requested by the child belonging to the opposite pane,where its resize parameter has been set to false.

Note that the resize parameter describes the spatial relationshipbetween the two panes, so that setting both panes alike will alwaysresult in both panes resizing when the top-level window is maximised.The user resizing facility offered by the handle is not affected bythe resize setting.

Page 255: Apostila PHP GTK

The shrink parameter when set to its default true allows the pane toshrink beyond the size requested by its child widget. Setting theshrink parameter to false prevents it from doing this. Note thatsetting the parameter to false across both panes renders the dividinghandle ineffective where the size of the top-level window is reliantupon the size requests of the child widgets.

GtkPaned::set_position

void set_position(int position);

set_position() sets the position of the dividing handle at thespecified number of pixels from the edge of the widget, in thedirection of the pane arrangement, without regard to the size requestsof the child widgets in the panes. It is overridden by the user'srepositioning of the dividing handle.

To unset the position of the dividing handle, use$paned->set_position(-1);</literal>

GtkPaned::set_handle_size

void set_handle_size(int size);

set_handle_size() can currently be used to set the width or height ofthe handle in pixels. The default setting is 5 pixels in the win32binary, or 10 pixels in the 1.2.* series of GTK+. In GTK2 the size ofthe handle will be set at 5 pixels, across both platforms.

Please note that both this function and the handle_size property aredeprecated in GTK2, and so should not be used.

GtkPaned::set_gutter_size

void set_gutter_size(int size);

set_gutter_size() can currently be used to set the width or height inpixels of the gutter where the dividing handle is based, only wherethe 1.2.* series of GTK+ is being used to compile PHP-GTK. It doesnothing in the win32 version.

Please note that this function is more than deprecated in GTK2; thegutter_size property does not exist in later releases. Do not use thisfunction.

GtkPaned::child1

Access: Read OnlyType: GtkWidget

child1 is the internal name for the child widget in the first pane ofa GtkPaned-derived widget.

GtkPaned::child2

Page 256: Apostila PHP GTK

Access: Read OnlyType: GtkWidget

child2 is the internal name for the child widget in the second pane ofa GtkPaned-derived widget.

GtkPaned::handle_size

Access: Read OnlyType: int

handle_size is an integer describing the width or height (asappropriate) of the separating handle in a GtkPaned-derived widget.

Please note that in future releases of GTK+ there is no such property.It will be replaced internally by private fields.

GtkPaned::gutter_size

Access: Read OnlyType: int

gutter_size is an integer describing the width or height (asappropriate) of the gutter which provides the base for the separatinghandle of a GtkPaned-derived widget.

Please note that in later releases of GTK+ - including that currentlyused by the PHP-GTK win32 binary - there is no such property. Thegutter itself has been deprecated.

GtkPaned::child1_resize

Access: Read OnlyType: bool

child1_resize describes the current status of the resize parameterrelating to the child that is packed in the first pane. This is usefulwhere the end user needs to be given control over the resize setting.

GtkPaned::child1_shrink

Access: Read OnlyType: bool

child1_shrink describes the current status of the shrink parameterrelating to the child that is packed in the first pane. This is usefulwhere the end user needs to be given control over the shrink setting.

GtkPaned::child2_resize

Access: Read OnlyType: bool

Page 257: Apostila PHP GTK

child2_resize describes the current status of the resize parameterrelating to the child that is packed in the second pane. This isuseful where the end user needs to be given control over the resizesetting.

GtkPaned::child2_shrink

Access: Read OnlyType: bool

child2_shrink describes the current status of the shrink parameterrelating to the child that is packed in the second pane. This isuseful where the end user needs to be given control over the shrinksetting.

GtkPixmap

Widget displaying a graphical image or icon.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkMisc`-- GtkPixmap

Direct subclasses

None.

Descrição

GtkPixmap has been deprecated since GTK+ 2.0 and should not be used innewly written code.

Construtor

GtkPixmap (GdkPixmap pixmap, GdkBitmap mask);

--

Métodos

set()

set_build_insensitive()

GtkPixmap Construtor

GtkPixmap (GdkPixmap pixmap, GdkBitmap mask);

GtkPixmap::set

Page 258: Apostila PHP GTK

void set(GdkPixmap val, GdkBitmap mask);

GtkPixmap::set_build_insensitive

void set_build_insensitive(int build);

GtkPlug

Toplevel widget for embedding into other processes.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkWindow`-- GtkPlug

Direct subclasses

None.

Descrição

This widget can be used to write plugins for other applications. Ittakes the id of an existing GtkSocket and will embed itself into itand so into the other application. The GtkPlug can be filled withwidgets like any other window, except that it is visible insideanother application.

Please have a look at the GtkSocket documentation, as the plug canonly be used together with a socket.

Note that if the application with the socket is quit, the programwith the plugged-in plug will exit as well.

Construtor

GtkPlug (int socket_id);

-- Creates a new plug instance.

GtkPlug Construtor

GtkPlug (int socket_id);

Creates a new plug which will be connected to the socket specified bythe socket_id.

You should make sure that the socket exists when connecting the plugto it. If it does not, the results are undefined. Probably a newGtkWindow will be created and the plug embedded in this window, butyou shouldn't rely on that behavior.

Page 259: Apostila PHP GTK

The following example creates a plug which connects to the socketcreated in the constructor example of GtkSocket.

Exemplo 32. Plugging into a socket<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

if( $GLOBALS['argc'] != 2) {die( 'Please pass the socket id as parameter!' . "\r\n");}

$socketid = $GLOBALS['argv'][1];

$plug = &new GtkPlug( $socketid);$plug->set_default_size( 300, 300);$plug->connect_object('destroy', array('gtk', 'main_quit'));$plug->set_title( 'plug');

$label = &new GtkLabel( 'hello from outer space');$plug->add( $label);$plug->show_all();

function changeLabel( $objButton, $objLabel, $strLabel) {$objLabel->set_text( $strLabel);}

$window = &new GtkWindow();$window->set_title( 'plug controller');$window->set_default_size( 200, 300);$window->connect_object('destroy', array('gtk', 'main_quit'));$vbox = &new GtkVBox();

$arLabels = array( 'Hello!', 'Yes, I can control you', 'Don\'t believe it, heh?');foreach( $arLabels as $strLabel) {$btn = &new GtkButton( $strLabel);$btn->connect( 'clicked', 'changeLabel', $label, $strLabel);$vbox->pack_start_defaults( $btn);}$window->add( $vbox);$window->show_all();

gtk::main();?>

GtkPreview

Widget to display RGB or grayscale data.

Hierarquia do Objeto

Page 260: Apostila PHP GTK

GtkObject`-- GtkWidget`-- GtkPreview

Direct subclasses

None.

Descrição

The GtkPreview widget provides a simple interface used to displayimages as RGB or grayscale data.

The use of GtkPreview is deprecated and should not be used in newcode. Use a GdkPixbuf displayed by a GtkImage or a GtkDrawingAreainstead.

Construtor

GtkPreview ( GtkPreviewType type );

-- Create a new GtkPreview.

Métodos

size()Set the size of the preview.

put()Draw a portion of the preview image into the drawable window.

draw_row()Set the data for a portion of one row of the preview.

set_expand()Set the behavior of the preview when the allocated size is largerthan the requested size.

GtkPreview Construtor

GtkPreview ( GtkPreviewType type );

Creates a new GtkPreview of type type. type must be a validGtkPreviewType.

The use of GtkPreview is deprecated and should not be used in newcode. Use a GdkPixbuf displayed by a GtkImage or a GtkDrawingAreainstead.

GtkPreview::size

void size(int width, int height);

Sets the dimensions of the preview to width pixels wide by height

Page 261: Apostila PHP GTK

pixels high.

size() only sets the requested size. The actual size of the previewimage depends on the size and settings of the container that enclosesthe widget. If the preview is allowed to expand to fill the container,it may appear larger than the dimensions requested with the size()method.

See also: set_expand()

GtkPreview::put

void put(GdkWindow window, GdkGC gc, int srcx, int srcy, int destx,int desty, int width, int height);

Draws a portion of the preview image into the drawable window. srcxand srcy represent the upper left corner of the source image to bedrawn. destx and desty represent the location of the upper left cornerof the destination image to be drawn. width and height specify therectangular portion of the image that is to be drawn.

GtkPreview::draw_row

void draw_row(string data, int start, int row, int pixels);

Replaces pixels pixels of data on row row of the preview starting atstart with data. If the preview is of type GTK_PREVIEW_GREYSCALE, datamust be pixels bytes of data. If the preview is of typeGTK_PREVIEW_COLOR, data must be 3*pixels bytes of data.

GtkPreview::set_expand

void set_expand(bool expand);

Sets the behavior of the preview when the allocated size is largetthan the requested size. If expand is false then the preview will notbe larger than the dimensions set with size() . If the containerenclosing the preview is larger than the requested dimensions, thepreview will be centered in the container. If expand is true, thepreview will expand to fill the container. The application isresponsible providing data of the correct dimensions.

See also: size()

GtkProgress

Base class for GtkProgressBar.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkProgress

Page 262: Apostila PHP GTK

Direct subclasses

GtkProgressBar

Descrição

GtkProgress is a base class providing methods for widgetsimplementing progress bar functionality. The only built-in widgetusing GtkProgress is GtkProgressBar.

Note that GtkProgress is an abstract class and cannot beconstructed directly.

GtkProgress has been deprecated since GTK+ 2.0 and should not be usedin newly written code.

Métodos

set_show_text()Toggles progress text display.

set_text_alignment()Sets progress text alignment.

set_format_string()Sets and formats progress text.

set_adjustment()Sets the progress adjustment object.

configure()Sets the progress value parameters.

set_percentage()Sets the current progress percentage.

set_value()Sets the current progress value.

get_value()Gets the current progress value.

set_activity_mode()Toggles progress mode.

get_current_text()Gets the current progress text.

get_text_from_value()Gets progress text based on value.

get_current_percentage()Gets current progress percentage.

Page 263: Apostila PHP GTK

get_percentage_from_value()Gets progress percentage based on value.

GtkProgress::set_show_text

void set_show_text(bool show_text);

The show_text parameter controls whether the progress text is shown.The default setting is false.

See also: set_format_string() .

GtkProgress::set_text_alignment

void set_text_alignment(double x_align, double y_align);

The alignment of the text within the progress area can be modifiedusing this method. The x_align and y_align parameters control thehorizontal and vertical alignment of the text, respectively. Theirrange can be from 0.0 to 1.0 (meaning from one side of the progressarea to another).

The default setting is (0.5, 0.5).

GtkProgress::set_format_string

void set_format_string(string format);

The content of the progress text can be modified with the formatstring. It can contain the following format characters:* %v - the current progress value.* %l - the lower bound of the progress value.* %u - the upper bound of the progress value.* %p - the current progress percentage.

The % character itself can be specified as %%.

The default text string is "%p%%".

See also: GtkAdjustment, where the progress value and bounds are set.

GtkProgress::set_adjustment

void set_adjustment( GtkAdjustment adjustment );

A progress has an associated GtkAdjustment object which specifies thebounds of the value having its progress displayed. This methodassociates the specified adjustment object with the progress.

GtkProgress::configure

void configure(double value, double min, double max);

This method provides a way to directly control the current value and

Page 264: Apostila PHP GTK

the bounds of a GtkProgress.

See also: GtkAdjustment.

GtkProgress::set_percentage

void set_percentage(double percentage);

This method sets the current percentage for a GtkProgress. Its valuemust be between 0.0 and 1.0.

Use this method to update a GtkProgressBar that is in percentage mode.

GtkProgress::set_value

void set_value(double value);

The progress value can be set directly with this method. The valuemust be within the range of the underlying GtkAdjustment in order forthe GtkProgressBar to display it.

Use this method to update a GtkProgressBar that is in activity mode.

GtkProgress::get_value

double get_value(void);

Returns the current progress value.

GtkProgress::set_activity_mode

void set_activity_mode(bool activity_mode);

GtkProgress can be either in percentage mode (when the total amount ofwork is known and progress can be calculated) or activity mode (whenthere is no way to estimate the total amount of work and only activitymust be indicated somehow).

If activity_mode is true, the activity mode is turned on, otherwise -the percentage mode.

See also: set_value, set_percentage() .

GtkProgress::get_current_text

string get_current_text(void);

The text indicating the amount of progress can be retrieved with thismethod. Before the text is returned, it is formatted using the currentprogress format.

See also: set_format_string() ).

GtkProgress::get_text_from_value

Page 265: Apostila PHP GTK

string get_text_from_value(double value);

If you wish to retrieve formatted progress text based on some valueother than current, then this method should be used. The currentprogress value will not be changed.

GtkProgress::get_current_percentage

double get_current_percentage(void);

Returns the current progress percentage as a number between 0.0 and1.0.

GtkProgress::get_percentage_from_value

double get_percentage_from_value(double value);

If you wish to retrieve the progress percentage based on some valueother than the current one, then this method should be used. Itreturns the desired percentage as a number between 0.0 and 1.0.

GtkProgressBar

Widget that provides a visual indication of an operation'sprogress.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkProgress`-- GtkProgressBar

Direct subclasses

None.

Descrição

The purpose of GtkProgressBar is to show the user the progress of along-running operation. It can be used in two modes: a percentagemode or an activity mode.

The percentage mode should be used when the application can inadvance determine the total amount of work that will be done. Asthe operation progresses the application should update the barwidget with the amount of work completed so far. The widget willreflect this by displaying a growing percentage bar.

The activity mode is useful when the application cannot determinethe total amount of work and instead simply wishes to provide anindication that an operation is in progress. In this mode, thewidget will display a block moving back and forth in the progress

Page 266: Apostila PHP GTK

area.

See also: GtkProgress, set_activity_mode() .

Construtor

GtkProgressBar ( GtkAdjustment adjustment );

-- Creates a progress bar widget.

Métodos

set_bar_style()Sets the progress bar style in percentage mode.

set_discrete_blocks()Sets the number of discrete blocks.

set_activity_step()Sets the step value in activity mode.

set_activity_blocks()Sets the number of blocks in activity mode.

set_orientation()Sets the orientation of the bar.

update()Sets progress update value. *deprecated*

GtkProgressBar Construtor

GtkProgressBar ( GtkAdjustment adjustment );

When constructing a progress bar, you need to specify an associatedGtkAdjustment which will be used to configure the progress bar'sinitial value and range.

Exemplo 33. Setting up a Progress Bar<?php

dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

function update_bar() {global $progressbar, $value;$progressbar->set_percentage($value);start_update();}

function start_update() {global $value;if($value <= 1.0) {$value += 0.01;gtk::timeout_add(200, 'update_bar');

Page 267: Apostila PHP GTK

}else gtk::timeout_add(50, array('gtk', 'main_quit'));}

$window = &new GtkWindow();$window->set_uposition(200, 250);$window->set_policy(false, false, true);$window->connect_object('destroy', array('gtk', 'main_quit'));

/* These adjustment settings are on the wild side for demo purposes */$adjustment = &new GtkAdjustment(0.5, 100.0, 200.0, 0.0, 0.0, 0.0);$value = $adjustment->value;

$progressbar = &new GtkProgressBar($adjustment);$progressbar->set_show_text(true);$progressbar->set_text_alignment(0.02, 1.0);$progressbar->set_format_string("%v%% complete");$progressbar->set_usize(gdk::screen_width()/2, 30);$window->add($progressbar);

$window->show_all();

start_update();gtk::main();

?>

To create a progress bar in activity mode, delete the references tothe text string and replace them with$progressbar->set_activity_mode(true);

and any further methods appropriate to an activity indicator. You willalso need to replace$progressbar->set_percentage($value);

in the update_bar() function with$progressbar->set_value($value);

Note that a progress bar in activity mode will not be redrawn when thevalues of the lower and upper bounds in the attached GtkAdjustmenthave been exceeded.

GtkProgressBar::set_bar_style

void set_bar_style( GtkProgressBarStyle style );

The default style of a progress bar upon creation isGTK_PROGRESS_CONTINUOUS. This method may be used to change it to thestyle specified in the style parameter (GTK_PROGRESS_CONTINUOUS orGTK_PROGRESS_DISCRETE) when the progress bar is in percentage mode.

Note that the progress bar will not display text if it is drawn in thediscrete style.

Page 268: Apostila PHP GTK

See also: set_discrete_blocks() .

GtkProgressBar::set_discrete_blocks

void set_discrete_blocks(int blocks);

When the progress bar has discrete style, it is divided into a numberof blocks. This method can be used to change the number of theseblocks.

The default value is 10.

GtkProgressBar::set_activity_step

void set_activity_step(int step);

When the progress bar is in the activity mode, this method can be usedto set the step value by which the progress bar will be updated oneach iteration. Higher values make the progress indicator appear tomove faster.

The default value is 3.

GtkProgressBar::set_activity_blocks

void set_activity_blocks(int blocks);

When the progress bar is in activity mode, this method can be used toset the number of blocks that make up the progress bar. Larger numbersmake the progress indicator smaller.

The default value is 5.

GtkProgressBar::set_orientation

void set_orientation( GtkProgressBarOrientation orientation );

This method can be used to change the orientation of the progress bar.The orientation parameter controls the direction in which the progressindicator grows (in percentage mode) or moves (in activity mode), asthe operation progresses.

The default setting is GTK_PROGRESS_LEFT_TO_RIGHT.

GtkProgressBar::update

void update(double percentage);

This is a deprecated method that has had its usage replaced byset_percentage() when a progress bar is set to the percentage mode, orby set_value() when using the activity mode.

GtkRadioButton

Page 269: Apostila PHP GTK

Button that is part of a group, only one of which may be selected.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkButton`-- GtkToggleButton`-- GtkCheckButton`-- GtkRadioButton

Direct subclasses

None.

Descrição

A GtkRadioButton is one of a group of similar widgets, only one ofwhich may be selected at any one time.

In the version of GTK+ currently used by PHP-GTK there is an issuewith the "activate" signal where it is used alongside toggleswitches in arrays. In this particular widget, the "clicked" signalis the activating signal, and as a result of this feature repeatsitself when another group member is activated.

One way around this is to use the "pressed" signal. Another wouldbe to set up a count for each individual function and test that thecount is not divisible by 2. Or, depending on the kind of functionyou are calling, you could simply allow "clicked" to be firedtwice.

Construtor

GtkRadioButton ( GtkRadioButton group , string label);

-- Creates one of a group of GtkRadioButton widgets.

GtkRadioButton Construtor

GtkRadioButton ( GtkRadioButton group , string label);

The first GtkRadioButton in a group should have the first parameterset to null. This 'group leader' is not attached to anything; there isnot at present such a thing as a GtkGroup widget of any kind.

All subsequent GtkRadioButton widgets belonging to the same groupshould have the variable representing that group leader as the firstparameter.

Exemplo 34. Constructing a group of radio buttons<?php

Page 270: Apostila PHP GTK

dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

function here_goes($button) {$child = $button->child;echo $child->get()."\n";}

$window = &new GtkWindow();$window->connect_object('destroy', array('gtk', 'main_quit'));$window->set_title('GtkRadioButton demo');

$box = &new GtkVBox();$window->add($box);

$button1 = &new GtkRadioButton(null, 'button 1');$button1->connect('pressed', 'here_goes');$box->pack_start($button1);

for ($i = 2; $i <= 4; $i++) {$button = &new GtkRadioButton($button1, 'button ' . $i);$button->connect('pressed', 'here_goes');$box->pack_start($button);}

$button_end = &new GtkButton('Exit');$button_end->connect_object('clicked', array('gtk', 'main_quit'));$box->pack_end($button_end);

$window->show_all();

gtk::main();

?>

GtkRadioMenuItem

Menu item that is part of a group, only one of which may beselected.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkItem`-- GtkMenuItem`-- GtkCheckMenuItem`-- GtkRadioMenuItem

Direct subclasses

None.

Page 271: Apostila PHP GTK

Descrição

A GtkRadioMenuItem is one of a group of similar widgets, only oneof which may be selected at any one time.

When the GtkMenuItem version of the "activate" signal has beenemitted by a GtkRadioMenuItem, there is a second emission as themost recently active item is toggled to inactive. This is dealtwith before the original signal is handled.

One way around this would be to use the "button-press-event"signal. Another would be to set up a count for each individualfunction and test that the count is not divisible by 2. Or,depending on the kind of function you are calling, you could simplyallow "activate" to be emitted twice.

Construtor

GtkRadioMenuItem ( GtkRadioMenuItem group , string label);

-- Creates one of a group of GtkRadioMenuItem widgets.

GtkRadioMenuItem Construtor

GtkRadioMenuItem ( GtkRadioMenuItem group , string label);

The first GtkRadioMenuItem in a group should have the first parameterset to null. This 'group leader' is not attached to anything; there isnot at present such a thing as a GtkGroup widget of any kind.

All subsequent GtkRadioMenuItem widgets belonging to the same groupshould have the variable representing that group leader as the firstparameter.

It is possible to mix different types of menu item within a GtkMenu.

In the following code snippet, Open is the group leader and Save andPrint the other options belonging to the group. Note that Exit is nota part of that group, although it is part of the same menu.<?php

$menu = &new GtkMenu();

$open = &new GtkRadioMenuItem(null, "Open");$open->connect('button-press-event', 'open_routine');$menu->append($open);

$save = &new GtkRadioMenuItem($open, "Save");$save->connect('button-press-event', 'save_routine');$menu->append($save);

$print = &new GtkRadioMenuItem($open, "Print");$print->connect('button-press-event', 'print_routine');

Page 272: Apostila PHP GTK

$menu->append($print);

$separator = &new GtkMenuItem();$menu->append($separator);

$exit = &new GtkRadioMenuItem(null, "Exit");$exit->connect_object('button-press-event','exit_routine', $menu);$menu->append($exit);

?>

GtkRange

Base class for widgets that manipulate the value of aGtkAdjustment.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkRange

Direct subclasses

GtkScale, GtkScrollbar

Descrição

GtkRange is the base class for widgets that allow a user tomanipulate the value of a GtkAdjustment. In PHP-GTK 1.0 thosewidgets are GtkScale and GtkScrollbar.

GtkRange is an abstract class and may not be directly instantiated.

Métodos

get_adjustment()Returns the widget's adjustment child.

set_adjustment()Sets the adjustment child.

set_update_policy()Sets the widgets update policy.

GtkRange::get_adjustment

GtkAdjustment get_adjustment (void);

Returns the widget's adjustment child. The returned value should beassigned by reference if you want method calls and other changes to beshown in the adjustment's parent widget.

Exemplo 35. Change the current value of an HScale

Page 273: Apostila PHP GTK

<?php// Create an hScale object$hScale = &new GtkHScale(new GtkAdjustment(.5, 0, 1, .1, .1, .1));

// Get the adjustment from the hScale$adj =& $hScale->get_adjustment();

// Set the value to zero$adj->set_value(0);?>

See also: set_adjustment()

GtkRange::set_adjustment

void set_adjustment ( GtkAdjustment adjustment );

Sets the adjustment child to adjustment. This allows you to change therange of values that scale or scroll operates on without recreatingthe scale or scroll. For instance, if the user narrows the range ofacceptable values from 0-100 down to 20-30, all you have to do isreplace the GtkAdjustment.

See also: get_adjustment()

GtkRange::set_update_policy

void set_update_policy( GtkUpdateType policy );

Sets the widgets update policy to policy. The update policy describeswhen the value of the adjustment is changed. When policy isGTK_UPDATE_CONTINUOUS, the value of the adjustment is updated whilethe slider is being moved. If policy is GTK_UPDATE_DELAYED, the valueof the adjustment will be updated when the user has stopped moving theslider. When policy is set to GTK_UPDATE_DISCONTINUOUS, the value ofthe adjustment will not be changed until the user has released themouse button and ended the slider drag operation.

Anytime the value of the adjustment is changed, the "value-changed"signal is emitted.

Exemplo 36. Update Policies<?php// A function to see what is happening.function valueChange() {echo "A value was changed!\n";}

// A window and frame for testing.$window = &new GtkWindow;$frame = &new GtkFrame('Test Area');

// Create an hscale.$hScale = &new GtkHScale(new GtkAdjustment(.5, 0, 1, .05, .05, .05));

Page 274: Apostila PHP GTK

// Connect the adjustment signal to the above function.$adj =& $hScale->get_adjustment();$adj->connect('value-changed', 'valueChanged');

// Switch the uncommented line to see what affect the policy has.$hScale->set_update_policy(GTK_UPDATE_CONTINUOUS);//$hScale->set_update_policy(GTK_UPDATE_DELAYED);//$hScale->set_update_policy(GTK_UPDATE_DISCONTINUOUS);

$frame->add($hScale);$window->show_all();gtk::main();?>

GtkRuler

Base class for horizontal and vertical rulers.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkRuler

Direct subclasses

GtkHRuler, GtkVRuler

Descrição

Métodos

set_metric()

set_range()

draw_ticks()

draw_pos()

GtkRuler::set_metric

void set_metric(GtkMetricType metric);

GtkRuler::set_range

void set_range(double lower, double upper, double position, doublemax_size);

GtkRuler::draw_ticks

Page 275: Apostila PHP GTK

void draw_ticks(void);

GtkRuler::draw_pos

void draw_pos(void);

GtkScale

Base class for GtkHScale and GtkVScale.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkRange`-- GtkScale

Direct subclasses

GtkHScale, GtkVScale

Descrição

A GtkScale is a widget that looks very like a GtkScrollbar withoutthe arrow buttons at either end and with the ability to display thecurrent value as text.

There are some issues with the value display, in thatscrolling-aware container widgets will not allow their child'sGtkAdjustment to be overwritten, which means that the GtkScalecannot have focus unless it takes the values given by the containerto the scrollable widget. This in turn misconfigures the displayarea, which is calculated with regard to the upper value of theassociated adjustment object. When a container sets an adjustment,each value is 0 at the start, and the later values are calculatedon the fly after the widgets have been drawn.

Although it is possible to use the GtkWidget method queue_resize()to force the text area to resize according to the width of the newadjustment values, the widget does not fully redraw unless it has aconfigure event - that is, you need to manually resize it and thenrestore it.

For all these reasons, it is unadvisable to use the draw-valuefeature where the GtkScale is associated with a scrollable widget.

Métodos

set_digits()Sets number of decimal places.

set_draw_value()Toggles whether value is displayed.

Page 276: Apostila PHP GTK

set_value_pos()Sets position of numeric text.

get_value_width()Returns string width of numeric text.

GtkScale::set_digits

void set_digits(int digits);

This method sets the number of places to the right of the decimalpoint in the displayed value.

The default number of decimal places is 1.

GtkScale::set_draw_value

void set_draw_value(bool draw_value);

set_draw_value() simply toggles whether the value is displayed as textor not.

The default setting is true.

GtkScale::set_value_pos

void set_value_pos( GtkPositionType pos );

This method determines the position of the text, when it is displayed.The default value is GTK_POS_TOP.

GtkScale::get_value_width

int get_value_width(void);

get_value_width() returns the width of the numeric text string in aGtkScale. The value is given in pixels.

GtkScrollbar

Base class for GtkHScrollbar and GtkVScrollbar.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkRange`-- GtkScrollbar

Direct subclasses

GtkHScrollbar, GtkVScrollbar

Page 277: Apostila PHP GTK

Descrição

GtkScrollbar is a base class providing the object type thatGtkHScrollbar and GtkVScrollbar are derived from.

This is an abstract class, and as such cannot be constructeddirectly.

GtkScrolledWindow

Adds scrollbars to its child widget.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkScrolledWindow

Direct subclasses

None.

Descrição

A GtkScrolledWindow is a window that can supply a scrollable childwidget with scrollbars.

The scrollbars take their adjustment settings from the child widgetand do not need adjustment configuration. Children that are notscrollable therefore need to be packed into a widget that hasscrolling awareness. GtkViewport is one such widget, and can beadded and configured automatically using the convenience methodadd_with_viewport() . The other widget that can be used for thispurpose is GtkLayout, which allows multiple children to be givenfixed positions and provides scrollbars.

The scrolling-aware widgets are: GtkCList, GtkCTree, GtkLayout,GtkScrolledWindow, GtkText and the catch-all GtkViewport.

Note that any scroll key bindings are taken from the child widgetin the GtkScrolledWindow, and not from the scrollbars themselves.

Construtor

GtkScrolledWindow ([ GtkAdjustment hadjustment = NULL , [GtkAdjustment vadjustment = NULL ]]);

-- Creates a scrolling window.

Métodos

get_hadjustment()

Page 278: Apostila PHP GTK

Returns the horizontal adjustment object.

get_vadjustment()Returns the vertical adjustment object.

set_policy()Sets scrollbar visibility policies.

set_placement()Sets scrollbar positions.

add_with_viewport()Convenience method for adding non-scrolling widgets.

GtkScrolledWindow Construtor

GtkScrolledWindow ([ GtkAdjustment hadjustment = NULL , [GtkAdjustment vadjustment = NULL ]]);

The GtkScrolledWindow widget is derived from GtkBin, and is designedto only have one direct child. One way around this is to add thechildren to a parent container, make that parent the only child of thewindow, and bind the container's focus to align with the scrollbars.Alternatively, you could use GtkLayout, which has no such restriction.

You do not need to explicitly add a child widget to a GtkViewport ifyou are using the add_with_viewport() method. You may, however, findthat the scrollbars are unresponsive anyway unless you add the childto a box container first.

Exemplo 37. Setting up a GtkScrolledWindow<?php

dl('php_gtk.'.(strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

/* set up a window */$window = &new GtkWindow();$window->set_position(GTK_WIN_POS_CENTER);$window->connect_object('destroy', array('gtk', 'main_quit'));

/* set up the main scrolled window and add it to the main window,sizing it if necessary. */$scrolledwindow = &new GtkScrolledWindow();$scrolledwindow->set_usize(300, 300);$scrolledwindow->set_policy(GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);$window->add($scrolledwindow);

/* create a box container and add child widgets to it */$box = &new GtkVBox();$calendar = &new GtkCalendar();/* let's add a scrollable to an internal scrolled window */$scrolledwindow2 = &new GtkScrolledWindow();$scrolledwindow2->set_usize(280, 100);$scrolledwindow2->set_policy(GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);

Page 279: Apostila PHP GTK

$text = &new GtkText();$text->set_editable(true);$scrolledwindow2->add($text);$box->pack_start($calendar, false, false, 5);$box->pack_start($scrolledwindow2);

/* add the box container to the main scrolled window and link its focus sothat the cursor position is reflected in the scrollbar's adjustment value.You do not need to do this when adding a scrollable widget directly */$scrolledwindow->add_with_viewport($box);$box->set_focus_vadjustment($scrolledwindow->get_vadjustment());

$scrolledwindow2->show_all();$box->show_all();$window->show_all();

gtk::main();

?>

GtkScrolledWindow::get_hadjustment

GtkAdjustment get_hadjustment (void);

get_hadjustment() returns the GtkAdjustment object that is used in thehorizontal scrollbar. The most likely use for this is in combinationwith set_focus_hadjustment() , where it is needed as a parameter.

GtkScrolledWindow::get_vadjustment

GtkAdjustment get_vadjustment (void);

get_vadjustment() returns the GtkAdjustment object that is used in thevertical scrollbar. The most likely use for this is in combinationwith set_focus_vadjustment() , where it is needed as a parameter.

GtkScrolledWindow::set_policy

void set_policy( GtkPolicyType hscrollbar_policy , GtkPolicyTypevscrollbar_policy );

Sets the visibility policy for the scrollbars in a GtkScrolledWindowto one of three possible GtkPolicyType values.

The default setting is GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS, whichdisplays both scrollbars regardless of the relative size of the childwidget.

GtkScrolledWindow::set_placement

void set_placement( GtkCornerType window_placement );

This method sets the positions of the scrollbars in aGtkScrolledWindow to one of four possible GtkCornerType values.

Page 280: Apostila PHP GTK

These values are a little counter-intuitive because they describe theposition of the child, rather than the position of the scrollbarsthemselves.

The default setting is GTK_CORNER_TOP_LEFT, which causes the child tobe placed above and to the left of the scrollbars - i.e., thescrollbars are at the bottom and to the right of the child.

GtkScrolledWindow::add_with_viewport

void add_with_viewport( GtkWidget child );

add_with_viewport() is a convenience function that invisibly adds thechild widget to a GtkViewport before adding the viewport to theGtkScrolledWindow.

The GtkViewport is a scrolling-aware container that provides its childwidget with that characteristic.

GtkSelectionData

Hierarquia do Objeto

GtkSelectionData

Direct subclasses

None.

Descrição

Métodos

set()

Propriedades

selection:

target:

type:

format:

length:

Page 281: Apostila PHP GTK

data:

GtkSelectionData::set

void set(void);

GtkSelectionData::selection

Access: Read OnlyType: GdkAtom

GtkSelectionData::target

Access: Read OnlyType: GdkAtom

GtkSelectionData::type

Access: Read OnlyType: GdkAtom

GtkSelectionData::format

Access: Read OnlyType: int

GtkSelectionData::length

Access: Read OnlyType: int

GtkSelectionData::data

Access: Read OnlyType: string

GtkSeparator

Base class for GtkHSeparator and GtkVSeparator.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkSeparator

Direct subclasses

GtkHSeparator, GtkVSeparator

Descrição

GtkSeparator is a base class providing the underlying widget typefor GtkHSeparator and GtkVSeparator.

Page 282: Apostila PHP GTK

Note that this is an abstract class, and cannot be constructeddirectly.

GtkSocket

Container for widgets from other processes.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkSocket

Direct subclasses

None.

Descrição

By creating a GtkSocket, an entirely different Gtk application mayembed itself into your application.

GtkSocket has nothing to do with network sockets. You can't use it tocommunicate between different computers.

GtkPlug and GtkSocket don't work on the Windows operating system.

The play between GtkSocket and GtkPlug is the following:

* Create a GtkSocket and attach it to a GtkContainer, e.g. aGtkWindow.* Realize the socket (after adding it to the container). Now you canaccess the socket id via $socket->window->xid.* Create the GtkPlug with the socket id as parameter.* Add whatever you want to the plug - it will appear in the firstcontainer.

Note that when a GtkSocket is destroyed, the plugged-in GtkPlugapplication will be destroyed as well.

As soon the GtkPlug unplugs from the socket, the GtkSocket can'treally be used any more. One could re-realize it, but there will beerrors and the socket won't be visible.

You can catch the unplugging-event by connecting to the "unrealize"signal of the socket. Note that you also will be notified if youapplication is being destroyed. There is no other way to do thissince the plug-added and plug-removed signals exist in gtk2 only.

A use for this widget is that you could write your own editor basedon vim by letting it plug into the socket provided by your app:gvim --socketid <id of your socket> Note that you need to have the

Page 283: Apostila PHP GTK

gtk version of gvim for this purpose.

Construtor

GtkSocket (void);

-- Creates a new socket instance.

Métodos

steal()Re-parents an existing window in the socket

GtkSocket Construtor

GtkSocket (void);

Creates a new socket instance. Note that you have to realize thesocket after you have added the widget to a parent container.

The other part of the example can be found at the constructor of theGtkPlug widget.

Exemplo 38. How to use a GtkSocket<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

function checkSocketState( $objButton, $objSocket, $lblStatus){if( $objSocket->window == null) {$lblStatus->set_text( 'The plug has disconnected');} else if( count( $objSocket->window->children) > 0) {$lblStatus->set_text( 'The plug has plugged in');} else {$lblStatus->set_text( 'Nobody plugged in');}}

$objSocket = &new GtkSocket();

$window = &new GtkWindow();$window->set_title( 'socket window');$window->set_default_size( 300, 300);$window->connect_object('destroy', array('gtk', 'main_quit'));

$vbox = &new GtkVBox();$vbox->pack_start_defaults( $objSocket);

$lblStatus = &new GtkLabel( 'status messages go here');$vbox->pack_start_defaults( $lblStatus);

$btnCheck = &new GtkButton( 'check socket state');

Page 284: Apostila PHP GTK

$btnCheck->connect( 'clicked', 'checkSocketState', $objSocket, $lblStatus);$vbox->pack_start_defaults( $btnCheck);

$window->add( $vbox);$window->show_all();

function unrealized( $objSocket, $btnCheck, $lblStatus) {echo 'The plug has disconnected' . "\r\n";checkSocketState( $btnCheck, $objSocket, $lblStatus);}$objSocket->connect( 'unrealize', 'unrealized', $btnCheck, $lblStatus);

//realize *after* adding it to a box or window$objSocket->realize();

$socketid = $objSocket->window->xid;echo 'socket id to use: ' . $socketid . "\r\n";

if( $GLOBALS['argc'] == 2) {//steal the given window$objSocket->steal( $GLOBALS['argv'][1]);}

checkSocketState( null, $objSocket, $lblStatus);

gtk::main();?>

GtkSocket::steal

void steal(int wid);

This function takes the xid of an existing window and reparents thewindow into itself, so that the former window acts as a child of thesocket.

This method is deprecated and does not fully work. Avoid to use it.

The following example creates a normal GtkWindow and echoes the xid ofits GdkWindow. Pass this id to the example application of theGtkSocket constructor and try to resize this window.

Exemplo 39. Stealing a window<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

$label = &new GtkLabel( 'I\'m an innocent window');

$window = &new GtkWindow();$window->set_title( 'this window will be stolen');$window->set_default_size( 200, 100);$window->connect_object('destroy', array('gtk', 'main_quit'));

Page 285: Apostila PHP GTK

$vbox = &new GtkVBox();

$window->add( $label);$window->show_all();

echo 'window xid: ' . $window->window->xid . "\r\n";

gtk::main();?>

GtkSpinButton

Widget offering masked numerical entry and/or selection.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkEditable`-- GtkEntry`-- GtkSpinButton

Direct subclasses

None.

Descrição

A GtkSpinButton is a widget offering a displayed numerical valuewhich can be incremented or decremented within a pre-set range bythe user's clicking on one of two arrow buttons, or by using the Upand Down arrow keys.

The display area is a GtkEntry; the spinbutton object currentlyprovides the only built-in means of masking input in GTK+. If youwant to restrict the user to the values displayed rather thanallowing keyboard input, call set_editable() from the spinbutton.

See also: GtkAdjustment, GtkCombo.

Construtor

GtkSpinButton ([ GtkAdjustment adjustment = NULL , [double climb_rate= 0.0 , [int digits = 0 ]]]);

-- Creates an editable rotating display of selectable numbers.

Métodos

configure()Configures all elements of a spinbutton.

set_adjustment()Sets adjustment object.

Page 286: Apostila PHP GTK

get_adjustment()Retrieves adjustment object.

set_digits()Sets number of decimal places displayed.

get_value_as_float()Retrieves value as float.

get_value_as_int()Retrieves value as integer.

set_value()Sets value displayed in spinbutton entry field.

set_update_policy()Controls update policy.

set_numeric()Toggles the way non-numeric input is treated in display.

spin()Forces a spin.

set_wrap()Toggles whether the display wraps.

set_shadow_type()Controls appearance of spinbutton.

set_snap_to_ticks()Toggles whether input is aligned with increment.

update()Updates value according to settings.

GtkSpinButton Construtor

GtkSpinButton ([ GtkAdjustment adjustment = NULL , [double climb_rate= 0.0 , [int digits = 0 ]]]);

Although the first parameter adjustment is optional, you will find itimpossible to create a working GtkSpinButton without harnessing it toan appropriately defined GtkAdjustment, as the first five parametersof the adjustment need to be set for the spinbutton widget to operate.You may either associate the adjustment at this point, or use theset_adjustment() or configure() method at a later point in yourscript.

climb_rate refers to the speed of the spin, rather than itsincremental value. Its default setting is 0.0, which runs the internaltimer at 20ms per increment (following a 200ms start from the buttonpress). If you intend using this parameter, the value given needs to

Page 287: Apostila PHP GTK

be fairly high in order for it to make an appreciable difference.

The digits parameter controls the number of decimal places displayed.

Exemplo 40. Creating a GtkSpinButton calendar.<?php

dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

function collect($d, $m, $y) {echo $d->get_value_as_int(). "-" .$m->get_value_as_int()."-" .$y->get_value_as_int()."\n";flush();}

$window = &new GtkWindow();$window->set_position(GTK_WIN_POS_CENTER);$window->connect_object('destroy', array('gtk', 'main_quit'));

$vbox = &new GtkVBox(false, 5);$window->add($vbox);

$hbox = &new GtkHBox(false, 5);$hbox->set_border_width(5);$vbox->add($hbox);

$daylabel = &new GtkLabel("Day:");$hbox->pack_start($daylabel, false);

$day = date("d");$dayadj = &new GtkAdjustment($day, 1.0, 31.0, 1.0, 7.0, 0.0);$dayspin = &new GtkSpinButton($dayadj);$dayspin->set_wrap(true);$hbox->pack_start($dayspin, false);

$monthlabel = &new GtkLabel("Month:");$hbox->pack_start($monthlabel, false);

$month = date("m");$monthadj = &new GtkAdjustment($month, 1.0, 12.0, 1.0, 3.0, 0.0);$monthspin = &new GtkSpinButton($monthadj);$monthspin->set_wrap(true);$hbox->pack_start($monthspin, false);

$yearlabel = &new GtkLabel("Year:");$hbox->pack_start($yearlabel, false);

$year = date("Y");$yearadj = &new GtkAdjustment($year, $year-90, $year+10, 1.0, 5.0, 0.0);$yearspin = &new GtkSpinButton($yearadj);$yearspin->set_usize(55, 0);$hbox->pack_start($yearspin, false);

$button = &new GtkButton("Collect data");

Page 288: Apostila PHP GTK

$button->connect_object('clicked', 'collect', $dayspin, $monthspin,$yearspin);$vbox->add($button);

$vbox->show_all();$hbox->show_all();$window->show_all();

gtk::main();

?>

See also: GtkAdjustment's "value-changed" signal.

GtkSpinButton::configure

void configure( GtkAdjustment adjustment , double climb_rate, intdigits);

This method sets the GtkAdjustment and configures the rate of the spinand number of decimal points displayed in an existing spinbutton.

Configuration settings made in this way will overwrite any existingsettings on the calling GtkSpinButton.

GtkSpinButton::set_adjustment

void set_adjustment( GtkAdjustment adjustment );

Call set_adjustment() when you only need to attach an adjustmentobject to a spinbutton. Otherwise, use configure() .

An adjustment associated with a spinbutton in this way will overwriteany exisiting adjustment object.

GtkSpinButton::get_adjustment

GtkAdjustment get_adjustment (void);

get_adjustment() returns the GtkAdjustment object currently associatedwith the calling spinbutton.

GtkSpinButton::set_digits

void set_digits(int digits);

set_digits() sets the number of digits displayed after the decimalpoint in the spinbutton's entry field. User input is limited to theconstraints of the displayed decimal places.

GtkSpinButton::get_value_as_float

double get_value_as_float(void);

Page 289: Apostila PHP GTK

Retrieves the current value displayed in the spinbutton entry as afloat value. Use this in combination with the PHP function round()where you need to collect the value to a specific number of decimalplaces.

<?php

$adj = &new GtkAdjustment(0.0, 0.0, 1.0, 0.01, 0.1, 0.0);$spin = &new GtkSpinButton($adj, 0.0, 2);

round($spin->get_value_as_float(), 2);

?>

GtkSpinButton::get_value_as_int

int get_value_as_int(void);

Retrieves the current value displayed in the spinbutton entry as aninteger. If the value is a fraction, this method rounds it to thenearest whole number.

GtkSpinButton::set_value

void set_value(double value);

set_value() sets the value displayed in the spinbutton's entry field,which is equivalent to the value field in the spinbutton's associatedGtkAdjustment.

If the lower or upper bounds set in the adjustment are exceeded, thevalue of the appropriate bound will replace the value passed as theparameter in this method.

GtkSpinButton::set_update_policy

void set_update_policy( GtkSpinButtonUpdatePolicy policy );

There are only two possible settings for the spinbutton update policy.Setting it as GTK_UPDATE_IF_VALID prevents the current value frombeing changed where the newly entered value is outside the rangedetermined by the underlying GtkAdjustment.

The default setting is GTK_UPDATE_ALWAYS, which allows the update tocontinue by replacing an invalid value with the value of the nearestrange boundary.

Note that set_value() . overrides the update policy setting.

GtkSpinButton::set_numeric

void set_numeric(bool numeric);

set_numeric() , when set to true, prevents non-numeric characters

Page 290: Apostila PHP GTK

other than the decimal point and positive/negative signs from beingdisplayed in the spinbutton's GtkEntry at the point of being keyed in.

Note that inappropriate characters will not be accepted by theunderlying GtkAdjustment in any case; this is purely a maskingfunction at display level.

GtkSpinButton::spin

void spin( GtkSpinType direction , double increment);

This method resets the displayed value to a new value that isdetermined by the GtkSpinType chosen. It is used internally to set upthe functions associated with mouse button presses over thespinbutton's arrows. These are, a left click spins one step increment,a middle button click spins one page increment, and a right clickspins to the lower or upper bound depending on which arrow is pressed.

GtkSpinButton::set_wrap

void set_wrap(bool wrap);

Where set_wrap() is set to true, the spinbutton having displayed theupper bound of its value range will return to the lower bound on thenext step increment. In other words, if the range is 1 to 10, 1 willfollow 10 in the display area when the up arrow is pressed.

The default setting is false, which greys out the appropriate arrowwhen the lower or upper bound of the range is reached.

GtkSpinButton::set_shadow_type

void set_shadow_type( GtkShadowType shadow_type );

Sets the shadow style of the frame around the arrow buttons on aspinbutton using the GtkShadowType options.

The default setting is GTK_SHADOW_NONE.

GtkSpinButton::set_snap_to_ticks

void set_snap_to_ticks(bool snap_to_ticks);

set_snap_to_ticks() , if set to true, will restrict input values tothe order of the step increment, taking the nearest value to theincrement as the input value. For example, if you have set the stepincrement to 0.5 in a range of 0.0 to 2.5 and the user inputs 1.4, theinput will be reset to 1.5 - the nearest incremental value.

The default setting is false, which allows the user to key in anythingwithin range to the given number of decimal points.

See also: set_digits() .

Page 291: Apostila PHP GTK

GtkSpinButton::update

void update(void);

The update() method is used internally to update the value field inthe underlying GtkAdjustment according to the update policy, digitsand snap settings.

GtkStatusbar

Widget that provides a way to report messages of minor importance.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBox`-- GtkHBox`-- GtkStatusbar

Direct subclasses

None.

Descrição

A GtkStatusbar is a framed label, usually added to the bottom of awindow, that provides a way to report messages of minor importance.It is usually updated fairly frequently.

There are two indices in the structure of a statusbar; one is anassociative array of message information, and the other is a stackof uniquely-indexed message arrays. The message at the top of thestack is the one currently on display.

Where a routine requires a lot of processing, the statusbar may beunable to update during the time taken to do so. You will need to call<?php

while (gtk::events_pending())gtk::main_iteration();

?>

each time the bar has been updated, to allow updating throughout.

Construtor

GtkStatusbar (void);

-- Creates a status bar.

Métodos

Page 292: Apostila PHP GTK

get_context_id()Returns the context id from the description.

push()Adds message to top of stack.

pop()Removes message from top of stack.

remove()Removes designated message from stack.

Sinais

"text-pushed"Emitted when a message is prepended to the stack.

"text-popped"Emitted when a message is popped from the top of the stack.

GtkStatusbar Construtor

GtkStatusbar (void);

Creating a status bar is very straightforward; creating and updatingmessages marginally less so.

Exemplo 41. Setting up a status bar.<?php

dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

/* function to clear the entry field and give it keyboard focus */function focusback($entry) {$entry->set_text('');$entry->grab_focus();}

/* on this occasion, the update function *is* the process */function change_status($entry, $event, $status, $stuff, &$i) {/* pick up the value(s) you are intending to use */$value = $event->keyval;$string = $event->string;/* prevent the message stack building up */$popcontext = $status->get_context_id($stuff[$i]);$status->pop($popcontext);/* sort according to value */switch($value) {case ($value >= GDK_KEY__a && $value <= GDK_KEY__z):$i = 1;break;case ($value >= GDK_KEY_A && $value <= GDK_KEY_Z):$i = 2;

Page 293: Apostila PHP GTK

break;case ($value >= GDK_KEY_0 && $value <= GDK_KEY_9):$i = 3;break;case GDK_KEY_Return:$i = 4;break;case GDK_KEY_space:$i = 5;break;default:$i = 6;}

/* create and push the new message according to the value */$pushcontext = $status->get_context_id($stuff[$i]);if($string && $string!==' ')$status->push($pushcontext, $string.' is a '.$stuff[$i].' character');else $status->push($pushcontext, $stuff[$i]);/* call any other function the value triggers */if($i == 4) focusback($entry);}

/* set up the main window */$window = &new GtkWindow();$window->set_position(GTK_WIN_POS_CENTER);$window->connect_object('destroy', array('gtk', 'main_quit'));

/* if you want anything else besides the statusbar, you'll need a box */$vbox = &new GtkVBox();$window->add($vbox);

/* add the statusbar first, else connecting other widgets to it is messy */$status = &new GtkStatusbar();$stuff = array('Here we go...', 'lower case alpha', 'UPPER CASE ALPHA','numeric', 'return', 'spacebar', 'non-alphanumeric');$status->push($status->get_context_id($stuff[0]), $stuff[0]);$vbox->pack_end($status, false);$status->show();

/* create, connect and pack your other widget(s) */$entry = &new GtkEntry();$entry->set_usize(400,20);/* this will usually be connect_object(). $entry is only passed here becauseit is used as a parameter in a function called from the callback. &$iis passed so that the correct message will get 'popped' from the stack */$i = 1;$entry->connect('key-press-event','change_status', $status, $stuff,&$i);$vbox->pack_start($entry, false);$entry->show();

$window->show_all();

Page 294: Apostila PHP GTK

focusback($entry);gtk::main();

?>

GtkStatusbar::get_context_id

int get_context_id(string context_description);

The GtkStatusbar sets up an internal array of the messages that havebeen used, as they are being called. The context_id is the array indexposition that a given message holds.

As the message array is created on the fly, it is never the same twicerunning. The messages that are displayed most frequently during thestatus bar's lifetime will have low numbers, and a message that isnever called will not be added to the array. It is far more efficientto use get_context_id() to generate a context id for a message than itis to allocate your own integer value.

The context_description is actually the text string used in thestatusbar label.

GtkStatusbar::push

int push(int context_id, string text);

push() prepends the given message to an internal stack in thestatusbar, along with its associated context_id. It is best to allowthe statusbar to generate the context_id for itself, as the value canthen change from one run to another to respond to the user's patternof interaction with the application. Use get_context_id() to do this.

The returned value is a unique message_id, which is needed as aparameter in the remove() method. This is simply an incremented value,beginning at 1.

This method causes the "text-pushed" signal to be emitted.

GtkStatusbar::pop

void pop(int context_id);

pop() removes the message that is currently at the top of thestatusbar's stack, using the context_id to identify the message.

When a message is removed from the stack, the memory that wasallocated to it is freed. Given that all messages are generateduniquely, it is good practice to pop() the current message beforeappending the next. Allowing the stack to build up can addconsiderably to processing time.

This method causes the "text-popped" signal to be emitted.

Page 295: Apostila PHP GTK

GtkStatusbar::remove

void remove(int context_id, int message_id);

This method removes a targeted message from anywhere in the stack.

Both the context_id and the message_id can be generated by thestatusbar comfortably here as elsewhere in the GtkStatusbar methods.

If you use this simply to replace a working pop() function you shouldsee no difference in behaviour; the remove() method even causes the"text-popped" signal to be emitted when it removes a message from thetop of the stack. Note that no signal is emitted when messages aretaken from elsewhere in the stack.

As there is no way to add a message anywhere other than the top of thestatusbar's stack - thereby immediately displaying it - this method isbasically a way of preventing a stack build-up where the pop/pushprocedure has proved inappropriate.

text-pushed

This signal is fired by a GtkStatusbar when the push() method iscalled. It carries with it the context_id and the text content of themessage.

Função Callback

void callback(GtkStatusbar statusbar, int context_id, string text);

text-popped

This signal is fired by a GtkStatusbar when the pop() method iscalled, and also when when the topmost message in the stack is removedusing the remove() method . The signal carries with it the context_idand the text content of the message.

Função Callback

void callback(GtkStatusbar statusbar, int context_id, string text);

GtkStyle

A class that determines the appearance of widgets.

Hierarquia do Objeto

GtkStyle

Direct subclasses

None.

Descrição

Page 296: Apostila PHP GTK

GtkStyle is a structure that is used to define the colors displayedin any widget, or across an application. Being a GtkWidgetproperty, it is accessible through all objects that take up screenspace, using the syntax:

<?php$style = $widget->style;?>

It is also possible to create a new GtkStyle object in the normalway, e.g.

<?php$style = &new GtkStyle();?>

or to take the default application style:

<?php$style = gtk::widget_get_default_style();?>

in order to change the style across an application.

Setting a style across an application can also be achieved by usingrc files. There are two in the PHP-GTK test directory which areused in gtk.php.

The style functions are generally not buggy, the only knownexception being where the text and base properties are intended todescribe text and its normally-white background. In some cases thishas not worked, and you may find that you need to use fg to colorthe text.

In all cases where the property type is given as array, what is beingreferred to is an array consisting of the five GtkStateType states.

Construtor

GtkStyle (void);

-- Creates a new style for a widget.

Métodos

copy()Copies an existing style.

Propriedades

black:The color being used as black.

Page 297: Apostila PHP GTK

white:The color being used as white.

font:The font.

black_gc:Graphics information for the black color.

white_gc:Graphics information for the white color.

colormap:The colormap currently being used.

fg:Foreground colors.

bg:Background colors.

light:

dark:

mid:Midway between light and dark.

text:Colors for a text widget.

base:Text background.

fg_gc:Graphics information for the foreground colors.

bg_gc:Graphics information for the background colors.

light_gc:

dark_gc:

mid_gc:

text_gc:Graphics information for the text foreground colors.

Page 298: Apostila PHP GTK

base_gc:Graphics information for the text background colors.

bg_pixmap:Background pixmaps.

GtkStyle Construtor

GtkStyle (void);

There are several ways to define the style across an application, butonly two ways to directly set the style on a given widget.

Exemplo 42. Writing to a widget's style property.<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

$window = &new GtkWindow();$window->set_position(GTK_WIN_POS_CENTER);$window->connect_object('destroy', array('gtk', 'main_quit'));

/* set up a few buttons just to prove we're only changing one of them */$bbox = &new GtkVButtonBox();$window->add($bbox);

for($i = 0; $i < 8; $i++) {$button[$i] = &new GtkButton("This is Button $i");$bbox->pack_start($button[$i], false);$button[$i]->show();}

/* method 1 : set up a new style and define the parts you want to define.The remaining style elements retain the application's default settings. */$newstyle = &new GtkStyle();$cyan = &new GdkColor('#00FFFF');$newstyle->fg[GTK_STATE_PRELIGHT] = $cyan;$label = $button[5]->child;$label->set_style($newstyle);

/* gdk::color_parse() uses a color that is defined on your system to filla GdkColor structure. It can be more convenient than manually creatinga new GdkColor, particularly if you're only assigning the color once. */$newstyle->bg[GTK_STATE_NORMAL] = gdk::color_parse('ivory');$button[5]->set_style($newstyle);

/* method 2 : copy the existing style from a widget and alter it. Defininga new style would overwrite the existing non-default style settings. */$style2 = $label->style;$newstyle2 = $style2->copy();$font = gdk::font_load('-*-Arial-bold-r-normal--*-160-*-*-p-0-iso8859-1');$newstyle2->font = $font;$label->set_style($newstyle2);

Page 299: Apostila PHP GTK

$window->show_all();

gtk::main();?>

GtkStyle::copy

GtkStyle copy(void);

copy() takes an existing style and copies it wholesale, including anyprior modifications that have been made to it.

GtkStyle::black

Access: Read WriteType: GdkColor

Returns the a GdkColor object representing the black color.$style = &new GtkStyle;$style->bg[GTK_STATE_NORMAL] = $style->black;

You can even overwrite the color with your own:$style = &new GtkStyle;$red = &new GdkColor('#FF0000');$style->white = $red;

GtkStyle::white

Access: Read WriteType: GdkColor

Returns the a GdkColor object representing the white color.$style = &new GtkStyle();$style->fg[GTK_STATE_NORMAL] = $style->white;

GtkStyle::font

Access: Read WriteType: GdkFont

Returns or sets the current font of the style.$style = &new GtkStyle();$style->font = gdk::font_load( '-bitsteam-bitstream vera sans mono-bold-r-normal-*-24-*-*-*-*-*-*-*');

GtkStyle::black_gc

Access: Read WriteType: GdkGC

The GdkGC object for the black color.

GtkStyle::white_gc

Page 300: Apostila PHP GTK

Access: Read WriteType: GdkGC

The GdkGC object for the white color.

GtkStyle::colormap

Access: Read WriteType: GdkColormap

Sets or returns the GdkColormap used by this style.

GtkStyle::fg

Access: Read WriteType: Array

Returns an array of 5 foreground GdkColors used for the differentstates a widget can reach.$newstyle = &new GtkStyle();$cyan = &new GdkColor('#00FFFF');$newstyle->fg[GTK_STATE_PRELIGHT] = $cyan;

GtkStyle::bg

Access: Read WriteType: Array

Returns an array of 5 background GdkColors used for the differentstates a widget can reach.$newstyle = &new GtkStyle();$newstyle->bg[GTK_STATE_PRELIGHT] = $newstyle->white;

Note that GtkLabel does not allow the background color to be changed,so you have to set the background of the parent widget, e.g. theGtkButton.

GtkStyle::light

Access: Read WriteType: Array

GtkStyle::dark

Access: Read WriteType: Array

GtkStyle::mid

Access: Read WriteType: Array

GtkStyle::text

Page 301: Apostila PHP GTK

Access: Read WriteType: Array

Returns an array of 5 text GdkColors used for the different states awidget can reach.

GtkStyle::base

Access: Read WriteType: Array

Returns an array of 5 text background GdkColors used for the differentstates a widget can reach.

GtkStyle::fg_gc

Access: Read WriteType: Array

Returns an array of 5 foreground GdkGC objects, one for each state awidget can reach.

GtkStyle::bg_gc

Access: Read WriteType: Array

Returns an array of 5 background GdkGC objects, one for each state awidget can reach.

GtkStyle::light_gc

Access: Read WriteType: Array

GtkStyle::dark_gc

Access: Read WriteType: Array

GtkStyle::mid_gc

Access: Read WriteType: Array

GtkStyle::text_gc

Access: Read WriteType: Array

Returns an array of 5 text foreground GdkGC objects, one for eachstate a widget can reach.

Page 302: Apostila PHP GTK

GtkStyle::base_gc

Access: Read WriteType: Array

Returns an array of 5 text background GdkGC objects, one for eachstate a widget can reach.

GtkStyle::bg_pixmap

Access: Read WriteType: Array

Returns an array of 5 pixmaps, one for each state a widget can reach.You can set it the following way:$bookicon = array("16 16 6 1"," c None s None",". c black","X c red","o c yellow","Oc #808080","# c white"," "," .. "," ..XX. "," ..XXXXX. "," ..XXXXXXXX. ",".ooXXXXXXXXX. ","..ooXXXXXXXXX. ",".X.ooXXXXXXXXX. ",".XX.ooXXXXXX.. "," .XX.ooXXX..#O "," .XX.oo..##OO. "," .XX..##OO.. "," .X.#OO.. ","..O.. "," .. "," ");$transparent = &new GdkColor(0, 0, 0);list( $pixmap, $mask) = Gdk::pixmap_create_from_xpm_d($window->window, $transparent, $bookicon);

$style = &new GtkStyle;$style->bg_pixmap[GTK_STATE_NORMAL] = $pixmap;

GtkTable

Container that provides a flexible grid for packing its children.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkTable

Direct subclasses

None.

Descrição

A GtkTable is a very adaptable container widget that is capable ofhaving the layout of its children structured in both directions.There is a more simplistic version of a similar container inGtkFixed, but GtkTable offers the advantage that the childpositions can be relative rather than absolute. The table's

Page 303: Apostila PHP GTK

stucturing is similar to that of a GtkBox.

As with the box classes, there is an underlying single-childstructure containing packing information, which consitutes oneelement of the array of child data in a GtkTable. This element isknown as a GtkTableChild, and can be accessed through the childrenproperty inherited from GtkContainer. The child objects themselvescan also be accessed more directly through the children() methodinherited from the same ancestor.

Construtor

GtkTable ([int rows = 1 , [int columns = 1 , [bool homogeneous = FALSE]]]);

-- Creates a container whose children are arranged on a grid.

Métodos

resize()Resizes to accommodate changes.

attach()Means of arranging child widgets in a GtkTable.

attach_defaults()Packing defaults.

set_row_spacing()Determines the space below a given row.

set_col_spacing()Determines the space to the right of a given column.

set_row_spacings()Determines the spacing between all rows.

set_col_spacings()Determines the spacing between all columns.

set_homogeneous()Sets all child allocations to size of largest request.

Propriedades

children:Array of GtkTableChild elements.

nrows:Number of rows.

ncols:Number of columns.

Page 304: Apostila PHP GTK

column_spacing:Spacing between columns.

row_spacing:Spacing between rows.

homogeneous:Determines whether child sizing is homogeneous.

GtkTable Construtor

GtkTable ([int rows = 1 , [int columns = 1 , [bool homogeneous = FALSE]]]);

It is not necessary to give the dimensions of a non-homogeneousGtkTable in the constructor, as the table will pick up the layout fromthe information given as its children are attached to it, and thiswill override the initial integer settings. If homogeneous is set totrue the reverse will be the case, and the table's settings takeprecedence.

You will find that you need to use the attach() method throughout, asthe way in which the add() method generally used in containers isimplemented in GTK+ to always position an added child at 0, 1, 0, 1.Once a grid square has been filled, the widget taking up that spacecannot be overwritten by another widget. The remove() method is fullyoperational.

The child widget sizing in a non-homogeneous GtkTable is relative, andwill alter if one or more children is removed or resized. Again, thisis not true for the child widgets in a homogeneous table.

There are a lot of parameters in the attach() method - nine in total -four of which are optional. Basically, if the homogeneous parameter inthe constructor is set to true, there is very little point most of thetime in using any of the four optional packing parameters. These comeinto their own when the children are not required to take up the sameamount of space.

Exemplo 43. Packing a GtkTable with differently-sized child widgets<?php

dl("php_gtk." . (strstr(PHP_OS, "WIN") ? "dll" :"so"));

$window = &new GtkWindow();$window->set_position(GTK_WIN_POS_CENTER);$window->connect_object("destroy", array("gtk","main_quit"));

$table = &new GtkTable();$table->set_row_spacings(5);$table->set_col_spacings(5);$window->add($table);

Page 305: Apostila PHP GTK

$text = &new GtkText();$table->attach($text, 1, 4, 1, 3);

$label = &new GtkLabel('Expand this window to see the difference betweenthe GtkAttachOptions settings.');$table->attach($label, 1, 4, 4, 5, GTK_SHRINK, GTK_SHRINK);

$button = &new GtkButton('Button ');$table->attach($button, 4, 6, 3, 4, GTK_SHRINK, GTK_SHRINK, 3, 3);

$button = &new GtkButton('Button 2 ');$table->attach($button, 4, 6, 4, 5, GTK_FILL, GTK_FILL, 3, 3);

$button = &new GtkButton('Button 3 ');$table->attach($button, 4, 6, 5, 6, GTK_FILL|GTK_EXPAND,GTK_FILL|GTK_EXPAND, 3, 3);

$window->show_all();

gtk::main();

?>

GtkTable::resize

void resize(int rows, int columns);

This method is used internally to resize the table and rearrange thechild widgets accordingly following a new child's attachment to anon-homogeneous table, or a change in the size of the largest child ina homogeneous table.

It can be used to redraw a homogeneous table with a new number of rowsand columns, all of which will have the same size as existing rows andcolumns. It has no external use in a non-homogeneous table.

GtkTable::attach

void attach( GtkWidget child , int left_attach, int right_attach, inttop_attach, int bottom_attach, [ GtkAttachOptions xoptions =GTK_EXPAND|GTK_FILL , [ GtkAttachOptions yoptions =GTK_EXPAND|GTK_FILL , [int xpadding = 0 , [int ypadding = 0 ]]]]);

attach() is the method used to pack child widgets in a GtkTable. Ofthe nine parameters delineated, five are absolutely needed.

The first parameter refers to the child widget that is to be attached.

The following pair of parameters denote the starting point that thechild will be drawn from, at the left hand side, and the end pointthat the child will be drawn to, to the right. These parameters aregiven in terms of columns, with the start point being 0.

Page 306: Apostila PHP GTK

The pair after this denote the starting point that the child will bedrawn from, at the top, and the end point that the child will be drawnto, at the bottom. These parameters are given in terms of rows, withthe start point again being 0.

It is possible for a single child widget to span several rows orcolumns.

As with all container widgets, the container itself takes up no screenspace until it contains a child widget or child widgets. If you attachonly one child with parameters that should set it in the bottom rightcorner and set homogeneous to false, the resulting effect will not bethat of a table with only one entry in the bottom right corner, but ofa container with a single widget in it - regardless of the number ofcolumns and rows specified in the table's constructor. Child settingsalways take precedence in a non-homogeneous table, and so all tableattachments are relative to the other child widgets. This is in linewith the behaviour of other multiple-child capable containers wherethe child widget can have its own packing parameters set.

The behaviour is very different when a regular grid is in position,which happens when the GtkTable has its homogeneous parameter set totrue. The table can work out the dimensions of the grid from the thelargest child widget's size request, and positions its childrenaccordingly.

The final four optional parameters determine the way in which thechild widget will respond to the area available to it (expand, shrink,fill) in each direction, and the padding between the child and itsnearest border, in each direction.

GtkTable::attach_defaults

void attach_defaults( GtkWidget widget , int left_attach, intright_attach, int top_attach, int bottom_attach);

The extra four parameters in attach() are all optional in PHP-GTK,rendering this method unnecessary.

GtkTable::set_row_spacing

void set_row_spacing(int row, int spacing);

Use this method to set the spacing below a given row, in pixels. Notethat it only works when the row below the given row is populated andcontains a child's upper edge.

The row count begins at 0.

GtkTable::set_col_spacing

void set_col_spacing(int column, int spacing);

Use this method to set the spacing to the right of a given column, in

Page 307: Apostila PHP GTK

pixels. Note that it only works when the column to the right of thegiven column is populated and contains a child's leftmost edge.

The column count begins at 0.

GtkTable::set_row_spacings

void set_row_spacings(int spacing);

Use this method to set the spacing between all rows, in pixels.

The default setting is 0.

GtkTable::set_col_spacings

void set_col_spacings(int spacing);

Use this method to set the spacing between all columns, in pixels.

The default setting is 0.

GtkTable::set_homogeneous

void set_homogeneous(bool homogeneous);

set_homogeneous() when set to true makes all child widgets' allocatedareas the same size as that of the child requesting the most space.

In most cases, this would be better set at the point of construction.

GtkTable::children

Access: Read OnlyType: array

The children property consists of an array of GtkTableChild elements.If you need to access a widget, e.g. to change the text in a label,use the GtkContainer method children() , which separates the widgetelement out of this property.

GtkTable::nrows

Access: Read OnlyType: int

The nrows property consists of the number of rows currently containedin a GtkTable.

GtkTable::ncols

Access: Read OnlyType: int

The ncols property consists of the number of columns currently

Page 308: Apostila PHP GTK

contained in a GtkTable.

GtkTable::column_spacing

Access: Read OnlyType: int

column_spacing returns the column spacing that has been set for theentire table using set_col_spacings() , or 0 if none has been set.

GtkTable::row_spacing

Access: Read OnlyType: int

row_spacing returns the row spacing that has been set for the entiretable using set_row_spacings() , or 0 if none has been set.

GtkTable::homogeneous

Access: Read OnlyType: bool

homogeneous when queried returns 1 (true) if the table is homogeneous,or 0 (false) if it is not.

GtkTableChild

Helper class for GtkTable.

Hierarquia do Objeto

GtkTableChild

Direct subclasses

None.

Descrição

A GtkTableChild is an array of information about a GtkTable'schild, which is itself stacked in the array that makes up thetable's children property.

Accessing these properties is therefore a two-tiered process:

<?php

$children = $table->children;/*returns an array of GtkTableChild elements*/

for($i = 0; $i < count($children); $i++) {$child = $children[$i];/*returns the individual GtkTableChild element from the $children array's

Page 309: Apostila PHP GTK

current pointer position*/

$widget = $child->widget;/*returns the widget property of the GtkTableChild*/

echo $widget->get_name()."\n";}

?>

Propriedades

widget:

The child widget.

left_attach:Leftmost anchor.

right_attach:Rightmost anchor.

top_attach:Upper anchor.

bottom_attach:Base anchor.

xpadding:Padding to left and right.

ypadding:Padding to top and bottom.

xexpand:Child expansion left to right.

yexpand:Child expansion top to bottom.

xshrink:Child shrink left to right.

yshrink:Child shrink top to bottom.

xfill:Child fill left to right.

yfill:Child fill top to bottom.

GtkTableChild::widget

Page 310: Apostila PHP GTK

Access: Read OnlyType: GtkObject

The widget property returns the child widget.

GtkTableChild::left_attach

Access: Read OnlyType: int

The left_attach property returns the number of the column that thechild widget is attached to on the leftmost side. The column countbegins at 0.

GtkTableChild::right_attach

Access: Read OnlyType: int

The right_attach property returns the number of the column that thechild widget is attached to on the rightmost side. The column countbegins at 0.

GtkTableChild::top_attach

Access: Read OnlyType: int

The top_attach property returns the number of the row that the childwidget is attached to on the upper side. The row count begins at 0.

GtkTableChild::bottom_attach

Access: Read OnlyType: int

The bottom_attach property returns the number of the row that thechild widget is attached to at the base. The row count begins at 0.

GtkTableChild::xpadding

Access: Read OnlyType: int

The xpadding property returns the integer value in pixels of thepadding between the widget and the left and right edges of itsallocated area.

GtkTableChild::ypadding

Access: Read OnlyType: int

The ypadding property returns the integer value in pixels of the

Page 311: Apostila PHP GTK

padding between the widget and the top and bottom edges of itsallocated area.

GtkTableChild::xexpand

Access: Read OnlyType: bool

Returns true if the GTK_EXPAND flag is set on the x axis.

GtkTableChild::yexpand

Access: Read OnlyType: int

Returns true if the GTK_EXPAND flag is set on the y axis.

GtkTableChild::xshrink

Access: Read OnlyType: int

Returns true if the GTK_SHRINK flag is set on the x axis.

GtkTableChild::yshrink

Access: Read OnlyType: int

Returns true if the GTK_SHRINK flag is set on the y axis.

GtkTableChild::xfill

Access: Read OnlyType: int

Returns true if the GTK_FILL flag is set on the x axis.

GtkTableChild::yfill

Access: Read OnlyType: int

Returns true if the GTK_FILL flag is set on the y axis.

GtkTearoffMenuItem

Menu item used to tear off and reattach its menu.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer

Page 312: Apostila PHP GTK

`-- GtkBin`-- GtkItem`-- GtkMenuItem`-- GtkTearoffMenuItem

Direct subclasses

None.

Descrição

A GtkTearoffMenuItem is a dedicated type of GtkMenuItem that can beprepended to a menu in order to give the user the option of tearingoff the popped-up menu from its parent object (usually a menu itemin a GtkMenuBar), and keeping it within an independant,non-resizeable GtkWindow of its own.

The widget appears as a dotted line across the top of the menu whenthe menu is attached to a parent object, or as a dotted line with aleft-pointing arrow where the menu is detached. Clicking on thedotted line detaches an attached menu, and clicking on the arrow ofa detached menu re-attaches it to the parent.

Construtor

GtkTearoffMenuItem (void);

-- Creates the means to tear off a menu.

GtkTearoffMenuItem Construtor

GtkTearoffMenuItem (void);

A GtkTearoffMenuItem will only work for a full menu, not for part ofone. It therefore needs to be prepended so that it takes the 0position in the GtkMenu where it is used:

<?php

$menu = &new GtkMenu();$tearoff = &new GtkTearoffMenuItem();$menu->prepend($tearoff);

?>

GtkText

Editable text-display widget.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkEditable

Page 313: Apostila PHP GTK

`-- GtkText

Direct subclasses

None.

Descrição

GtkText provides a scrolling widget with a white background whichcan have text strings passed to it programmatically or directlyfrom the keyboard (if it is set to be editable). There are a numberof keybindings for the editing features; these are listed underGtkEditable, as they are generally shared by the GtkEntry widget.

GtkText is one of two widgets marked as BROKEN throughout the 1.3series of GTK+ releases, and is being replaced entirely by a newset of text and editing widgets in GTK 2.0. If you can avoid usingit, do so. If you can't, be aware that it has issues which arenever going to be fixed.

One of these issues is that the horizontal GtkAdjustment does notwork in the GtkText widget, and that trying to declare it asanything other than NULL causes the application to stall. There isno problem with the vertical adjustment, and a vertical scrollbarassociated with the text widget will work just fine.

Another feature is that it cannot cope with very frequent textupdates for long, that being when you're most likely to generate astring that is too big for its XWindow to handle. You may find itbetter to use a GtkCList if you are using it to display the outputfor any form of network monitoring, for example.

There is also a problem with the linewrap when the GtkText widgetis utilised under Windows, causing it to display 'little blackboxes' at every soft wrap. You can get around this by using PHP'swordwrap() function to create a line-end within the GTK line-end,but bear in mind that PHP uses a given number of characters todetermine the length of the line, whereas GTK uses pixels toconfigure the relationship between the font size, the line-end, andthe container's border.

See also: GtkEditable, GdkFont, GtkFontSelectionDialog.

A final note: the signal set_scroll_adjustments has not beencovered here as it is purely used internally to allow the textwidget to communicate with scrolling-aware container widgets.

GtkText has been deprecated since GTK+ 2.0 and should not be used innewly written code.

Construtor

GtkText ([ GtkAdjustment hadj = NULL , [ GtkAdjustment vadj = NULL]]);

Page 314: Apostila PHP GTK

-- Creates a scrollable text widget.

Métodos

set_editable()Toggles whether text widget is editable.

set_word_wrap()Toggles whether words at the end of a line can be broken.

set_line_wrap()Toggles whether text should be wrapped at the widget boundary.

set_adjustments()Specifies the GtkAdjustments to be used.

set_point()Sets insertion point.

get_point()Returns the current insertion point.

get_length()Returns length of string.

freeze()Freezes display.

thaw()Thaws display.

insert()Inserts a string of text.

backward_delete()Deletes characters prior to insertion point.

forward_delete()Deletes characters ahead of insertion point.

Propriedades

hadj:Horizontal adjustment. *broken*

vadj:Vertical adjustment.

GtkText Construtor

GtkText ([ GtkAdjustment hadj = NULL , [ GtkAdjustment vadj = NULL]]);

Page 315: Apostila PHP GTK

Creates a text widget that is by default scrollable up and down usingthe bound keys given below, when there is enough text present. Thehorizontal adjustment, and therefore the horizontal scrolling, do notwork; the horizontal adjustment parameter in the constructor shouldalways be declared as null (the default setting) for that reason.

Tabela 7. Key bindings for scrolling GtkTextKey combination Scroll functionControl + Home Move to the top of the textControl + End Move to the end of the textPage Up Move up one page incrementPage Down Move down one page incrementUp arrow Move up one lineDown arrow Move down one line

Exemplo 44. Adding a scrollbar to a GtkText widget <?php

dl('php_gtk.'.(strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

$window = &new GtkWindow();$window->set_position(GTK_WIN_POS_CENTER);$window->connect_object('destroy', array('gtk', 'main_quit'));

$box = &new GtkHBox();$window->add($box);

$text = &new GtkText();$text->set_word_wrap(true);$string = "This is a string of text which will be displayed in theGtkText widget.\n\nIt isn't long enough to allow scrolling, so you willprobably need to extend it.\n\nOn the other hand, the box isn't sized, soit may just creep over that limit and be a useful demonstration afterall.";if(strstr(PHP_OS, 'WIN')) $string = wordwrap($string, 26);$text->insert_text($string, 0);$box->pack_start($text);

$adj = $text->vadj;$scrollbar = &new GtkVScrollbar($adj);$box->pack_end($scrollbar, false);

$window->show_all();

gtk::main();

?>

GtkText::set_editable

void set_editable(bool editable);

set_editable() , when set to true, allows the user to write to ormanipulate existing text displayed in the widget.

Page 316: Apostila PHP GTK

The default setting is false.

GtkText::set_word_wrap

void set_word_wrap(bool word_wrap);

This method, when set to true, ensures that words that would otherwisebe broken when reaching a line end are kept in one piece and moved tothe beginning of the next line.

If you are using the PHP wordwrap() function, you will need to use itin tandem with the GTK set_word_wrap() method.

The default setting is false.

GtkText::set_line_wrap

void set_line_wrap(bool line_wrap);

set_line_wrap() , when set to true ensures that the text is sensitiveto the boundaries of the GtkText widget and will wrap within them.

The default setting is true.

See also: set_word_wrap() .

GtkText::set_adjustments

void set_adjustments( GtkAdjustment hadj , GtkAdjustment vadj );

In most cases, set_adjustments() is a redundant method, as it isalready used internally by scrolling-aware containers to createappropriate adjustment settings for the size of the text widget. Thispre-setting by a container cannot be overridden.

Where you need to use this method, the first parameter must always benull due to the malfunctioning hadj property in a GtkText widget.

GtkText::set_point

void set_point(int index);

set_point() sets the point in the string index where any extraneoustext should be inserted. This means that the initial string has toexist in the first place.

If the text widget has focus at the time when this method is called,the insertion point will be reflected in the position of the cursor.

Note that an insertion point beyond the length of the existing string(that is, the entire existing GtkText content) cannot be set in thisway.

Page 317: Apostila PHP GTK

GtkText::get_point

int get_point(void);

This method returns the current insertion point, which is the positiontaken by the cursor. By default, that will be the position followingthe final character in the string that makes up the entire existingGtkText content.

GtkText::get_length

int get_length(void);

This method returns the length of the string making up the currenttext widget contents, measured in characters.

If you need to measure separate elements of the text contents, use thePHP function strlen() instead.

GtkText::freeze

void freeze(void);

Call the freeze() method prior to any text update. This prevents thedisplay from flickering during the time it takes for the update to bemade, as the full update is only drawn once rather than for every newcharacter.

See also: thaw() .

GtkText::thaw

void thaw(void);

The thaw() method is the corollary to the freeze() method, and shouldbe used in conjunction with it. Call this method following an updateto redraw the display.

GtkText::insert

void insert( GdkFont font , GdkColor fore , GdkColor back , stringchars, [int length = -1 ]);

This is a complex method offering more control over the appearance ofthe text in a GtkText widget than the alternative insert_text()inherited from GtkEditable. It also has the bonus that it allows somesupport for internationalization on all platforms, although multibyteconversion under win32 is not currently included in this.

Any of the first three parameters can be passed as null, making itpossible to define only one aspect of the text's appearance, or many.

The first parameter font is a GdkFont. If you are intending to changefonts, you will need to call the static function gdk::font_load()

Page 318: Apostila PHP GTK

beforehand in order to define your chosen font.

The next two parameters use GdkColor objects to describe theforeground and background colors of the text; again, you will need todefine these in order to use them. The first of these is the color ofthe text itself, the second is the color of the 'page' behind it. Notethat setting the back will only change the color for the area that istaken up by the string itself, and not for the entire widget or to thewidget's border when the end of the text is reached.

The final two parameters are chars, the string of text to insert; andthe optional length, which can be used to limit the extent of thestring where it is being input by a user. The default length -1 willallow the entire string.

You can use the current default style with: $text->insert(null, null,null, "A string of text.");

GtkText::backward_delete

int backward_delete(int nchars);

Deletes the number of characters stipulated, back from the currentinsertion point.

Note that these are literal numbers, and that shortcuts such as 0 and-1 cannot be used here.

GtkText::forward_delete

int forward_delete(int nchars);

Deletes the number of characters stipulated, forward from the currentinsertion point.

Note that these are literal numbers, and that shortcuts such as 0 and-1 cannot be used here.

GtkText::hadj

Access: Read OnlyType: GtkAdjustment

The hadj property is a GtkAdjustment that simply does not work in theGtkText widget. It should always be declared as null at the creationstage, and will always have adjustment settings of 0 throughout forthat reason.

GtkText::vadj

Access: Read OnlyType: GtkAdjustment

The vadj property is a GtkAdjustment widget. Use this property to

Page 319: Apostila PHP GTK

interrogate the adjustment settings that have been pre-set by theGtkText widget's parent container.

It can also be used to set the adjustment value for an associatedGtkScrollbar.

GtkTipsQuery

Displays help about widgets in the user interface.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkMisc`-- GtkLabel`-- GtkTipsQuery

Direct subclasses

None.

Descrição

The TipsQuery is a label which displays the tooltips of the widgetsthe mouse hovers. First it has to be activated with start_query() :The mouse cursor changes and the label comes to life, displayingthe tooltips of the hovering widget. The query is automaticallydeactivated when the user clicks somewhere.

With the help of the "widget_entered" signal, one could display asmall tool tip showing the extendet data of a tooltip or call ahelp browser. For this purpose, the private (extendet) tooltip datacould contain location of the page the help browser should display.

GtkTipsQuery has been deprecated since GTK+ 2.0 and should not be usedin newly written code.

Construtor

GtkTipsQuery (void);

-- Creates a new TipsQuery object.

Métodos

start_query()Activates the widget

stop_query()Stops a started query

set_caller()Sets the widget which initiates the query, usually a button.

Page 320: Apostila PHP GTK

set_labels()Sets the tooltip label for non-active states.

Sinais

"widget_entered"Emitted when an active tips query enters a widget by hovering it.

"widget_selected"Emitted when a widget is clicked while a tips query is active.

GtkTipsQuery Construtor

GtkTipsQuery (void);

Creates a new TipsQuery object.

GtkTipsQuery::start_query

void start_query(void);

Activates the tip query widget, so that it takes control over themouse and displays a question cursor. The query label will show thetooltip of the widget the mouse hovers.

Before starting a query, you should call the set_caller() function.

GtkTipsQuery::stop_query

void stop_query(void);

Stops a query started with the start_query() function.

GtkTipsQuery::set_caller

void set_caller(GtkWidget caller);

Sets the widget which initiates the query, usually a button. If thecaller is selected while the query is running, the query isautomatically stopped and the "widget_selected" is not called for thiswidget.This function has to be called before a query is started.

GtkTipsQuery::set_labels

void set_labels(string label_inactive, string label_no_tip);

The label_inactive is shown when the tip query widget is not in use,means not activated. It is shown the first time when the query hasbeen used once.

The label_no_tip is shown when the tip query is active, but the widgetbeneath the pointer has no tooltip.

Page 321: Apostila PHP GTK

widget_entered

Emitted when an active tips query enters a widget by hovering it.

Função Callback

void callback(GtkTipsQuery tips_query, GtkWidget widget, stringtip_text, string tip_private, GdkEvent event);

widget_selected

Emitted when a widget is clicked while a tips query is active. Afterthe click, the query is stopped.

The widget set by set_caller() does not emit this signal; it stops thequery immediately.

Note that the callback is called twice: When the user clicks thebutton, and when he releases it.

Função Callback

void callback(GtkTipsQuery tips_query, GtkWidget widget, stringtip_text, string tip_private, GdkEvent event);

GtkToggleButton

Button that retains its state.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkButton`-- GtkToggleButton

Direct subclasses

GtkCheckButton

Descrição

A GtkToggleButton is a button that will retain its state followingactivation. This can be either the active state, GtkStateTypeGTK_STATE_ACTIVE, or the normal state, GTK_STATE_NORMAL. The activestate has the appearance of a button that has been pressed down andnot released.

The "toggled" signal is emitted as part of the process when thebutton is activated. Activation also triggers a change from thecurrent state to its opposite value.

Page 322: Apostila PHP GTK

GtkToggleButton also provides some base elements for GtkCheckButtonand GtkRadioButton widgets.

Construtor

GtkToggleButton ([string label ]);

-- Creates a button that can be toggled between two states.

Métodos

set_mode()Toggles indicator mode.

set_active()Sets state.

get_active()Returns true if active.

toggled()Causes the "toggled" signal to be emitted.

Sinais

"toggled"Emitted when the toggled() method is called.

Propriedades

draw_indicator:Toggle indicator display.

GtkToggleButton Construtor

GtkToggleButton ([string label ]);

$togglebutton = &new GtkToggleButton("GtkToggleButton's label");

creates a GtkToggleButton that can be toggled between active andnormal states.

GtkToggleButton::set_mode

void set_mode(bool draw_indicator);

set_mode() is used internally to set the indicator mode for thedifferent varieties of toggle button. There is no reason to use itunless you are creating your own widget.

This method toggles whether the toggle indicator is drawn or not. InGtkToggleButton itself, the indicator happens to take up the entiresurface of the button, so that if the draw_indicator parameter is set

Page 323: Apostila PHP GTK

to true the button itself vanishes. In the classes that inherit theGtkToggleButton methods the indicator takes up a very small area ofthe button, and setting the mode as false in those classes removes theindicator from the button, leaving only a GtkToggleButton with anoffset label.

GtkToggleButton::set_active

void set_active(bool is_active);

set_active() determines whether the GtkToggleButton's initial state isGTK_STATE_ACTIVE or otherwise.

The default setting is false.

GtkToggleButton::get_active

bool get_active(void);

get_active() returns true if the calling GtkToggleButton's currentstate is GTK_STATE_ACTIVE.

GtkToggleButton::toggled

void toggled(void);

toggled() makes the calling GtkToggleButton emit the "toggled" signal.This method is called internally when the "clicked" signal is fired,that is, when the user either clicks the mouse over the button orpresses the Enter or Space key while the button is selected.

toggled

The "toggled" signal is emitted when the toggled() method is called.This happens whenever the button is activated. As part of the responseto the button classes' activating signal "clicked", the state of thetoggle indicator is switched from GTK_STATE_ACTIVE to GTK_STATE_NORMALor vice versa. Note that this state-switching has no relationship withthe "toggled" signal itself.

Função Callback

void callback(GtkToggleButton togglebutton);

GtkToggleButton::draw_indicator

Access: Read OnlyType: bool

The draw_indicator property is the setting that denotes whether thetoggle indicator is drawn or not. It is exposed here so that the valueof the indicator's mode setting can be tested programmatically.

The property can be accessed using the syntax

Page 324: Apostila PHP GTK

$togglebutton->draw_indicator;

The draw_indicator property should not be accessed directly. Useset_mode() where the value needs to be changed.

GtkToolbar

Container that creates bars of buttons and other widgets.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkToolbar

Direct subclasses

None.

Descrição

Horizontal or vertical container for bars of buttons and otherwidgets.

Toolbars are used to give the user access to often used functionslike "New document", "Open", "Save" and such. The toolbar can showbuttons of text and icons as well as only one of both, which can beset during runtime.

The methods insert_element() , append_element() , prepend_element() ,insert_item() , append_item() and prepend_item() as well as all theproperties are available since PHP-Gtk 1.0.1 only.

Construtor

GtkToolbar (GtkOrientation orientation, GtkToolbarStyle style);

-- Creates a new toolbar instance.

Métodos

add()Appends an existing widget to the toolbar.

append_space()Adds a spacer element to the end.

prepend_space()Adds a spacer element before the first item.

insert_space()Inserts a spacer element at the given position.

Page 325: Apostila PHP GTK

append_element()Adds a new toolbar element button to the end.

prepend_element()Adds a new toolbar element before the first item.

insert_element()Inserts a new toolbar element at the given position.

append_item()Adds a new button to the end.

prepend_item()Adds a new button before the first item.

insert_item()Inserts a new button at the given position.

append_widget()Adds a widget to the end.

prepend_widget()Adds a widget before the first item.

insert_widget()Inserts a widget at the given position.

set_orientation()Sets the toolbar orientation to horizontal or vertical.

set_style()Sets the text/icon style.

set_space_size()Sets the width/height which a space takes.

set_space_style()Sets the space style: line or invisible.

set_tooltips()Enables or disables the display of tooltips

set_button_relief()Sets the relief style for buttons on the toolbar

get_button_relief()Returns the button relief style.

Sinais

"style-changed"Emitted when the style has changed.

"orientation-changed"

Page 326: Apostila PHP GTK

Emitted when the orientation has changed.

Propriedades

orientation:Returns the orientation (horizontal or vertical) of the toolbar

space_size:Returns the width/height which a space takes.

space_style:Returns the current space style of the toolbar.

style:Returns the current toolbar style.

GtkToolbar Construtor

GtkToolbar (GtkOrientation orientation, GtkToolbarStyle style);

Creates a new toolbar instance.

Exemplo 45. A detachable toolbar<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

function toolbarClicked( $objButton, $strType){echo 'clicked ' . $strType . "\r\n";}

$window = &new GtkWindow();$window->set_title( 'toolbar test');$window->set_default_size( 400, 70);$window->connect_object('destroy', array('gtk', 'main_quit'));$vbox = &new GtkVBox();

$systemimage = array('13 13 5 2',' c None s None','. c topShadowColor m white c lightblue','X s iconColor1 m black c black','o s bottomShadowColor m black c #646464646464','O s selectColor m white c red'," "," . . . "," . . X X X o o "," . X X X X X X X o "," . X X X X X X X o "," . X X X X O X X X X o "," . X X X O O O X X X o "," . X X X X O X X X X o ",

Page 327: Apostila PHP GTK

" . X X X X X X X o "," . X X X X X X X o "," o o X X X o o "," o o o "," ");$window->realize();list($pixmap, $mask) = Gdk::pixmap_create_from_xpm_d($window->window, null, $systemimage);$pixmapwid = &new GtkPixmap($pixmap, $mask);

$toolbar = &new GtkToolbar( GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH);$toolbar->set_button_relief( GTK_RELIEF_NONE);$toolbar->set_space_style( GTK_TOOLBAR_SPACE_LINE);

$toolbar->append_item( 'new', 'Creates a new document', "Closes the active document\r\nand creates an empty new one",null, 'toolbarClicked', 'new' );$toolbar->append_item( 'open', 'Opens an existing document', null, null, 'toolbarClicked', 'open' );$toolbar->append_space();$toolbar->append_item( 'save', 'Saves the document', 'Saves the document on theharddisk', $pixmapwid, 'toolbarClicked', 'save' );$toolbar->append_item( 'saveas', 'Saves the document with another filename', null, null, 'toolbarClicked', 'saveas' );

$handlebox = &new GtkHandleBox();$handlebox->add( $toolbar);$vbox->pack_start_defaults( $handlebox);

$label = &new GtkLabel( 'I should be below the toolbar');$vbox->pack_start_defaults( $label);

$window->add( $vbox);$window->show_all();

gtk::main();?>

GtkToolbar::add

void add(GtkWidget widget);

Appends an existing widget to the toolbar. This function overwritesthe add() method of GtkContainer in the way that a call toappend_widget() is made with NULL as tooltip parameters.

GtkToolbar::append_space

void append_space(void);

Adds a spacer element to the end. Just calls insert_space() with theposition parameter set to the number of widgets.

Page 328: Apostila PHP GTK

GtkToolbar::prepend_space

void prepend_space(void);

Adds a spacer element before the first item. Just calls insert_space()with the position parameter set to 0.

GtkToolbar::insert_space

void insert_space(int position);

Inserts a spacer element at the given position to make a visible gapbetween 2 groups of toolbar items. The minimum value is 0, and themaximum is the number of items which are attached to the toolbar.

In the end, insert_space calls insert_item() with the type parameterset to space.

GtkToolbar::append_element

GtkWidget append_element(GtkToolbarChildType widget_type, GtkWidgetwidget, string button_text, string tooltip_text, stringtooltip_private_text, GtkPixmap icon, string callback, [mixeduserparam]);

Adds a new toolbar element to the end. Just calls insert_element()with the position parameter set to the number of widgets.

GtkToolbar::prepend_element

GtkWidget prepend_element(GtkToolbarChildType widget_type, GtkWidgetwidget, string button_text, string tooltip_text, stringtooltip_private_text, GtkPixmap icon, string callback, [mixeduserparam]);

Adds a new toolbar element before the first item. Just callsinsert_element() with the position parameter set to 0.

GtkToolbar::insert_element

GtkWidget insert_element(GtkToolbarChildType widget_type, GtkWidgetwidget, string button_text, string tooltip_text, stringtooltip_private_text, GtkWidget icon, int position, string callback,[mixed userparam]);

Inserts a new toolbar element at the given position. This is the basefunction for all other insert/append/prepend functions.

The widget_type determines which type of widget shall beinserted/created. widget has to be set if widget_type is set toGTK_TOOLBAR_CHILD_WIDGET. All other types require a null as widgetbecause they are created by the function.

button_text specifies the text ("label") to be visible on the button,

Page 329: Apostila PHP GTK

tooltip_text is the tooltip text which will be visible when the userhovers the button for a specific time. tooltip_private_text is thetext being visible using a GtkTipsQuery. See GtkTooltips for moredetails on this topic.

icon is a widget, preferably a GtkPixmap which shall be used as anicon. The icon is used when the GtkToolbarStyle is set to icon or both(only with widgets created by insert_element). You can use every typeof widget, but take care that the toolbar button can be identified byit when the style is icon only. If the icon is set to null, the textwill still be visible.

The position parameter can be in the range from 0 (insert as firstelement) to the number of widgets (append after the last) being on thetoolbar. This can be determined by doing a count($toolbar->children()), but just an append_element() should be moreeasy.

Last parameter is callback, the function to be called when the widgetis clicked. You can pass a number of self-defined extra parameters tothe callback function by appending them after the callback parameter.

Exemplo 46. Using the insert_element toolbar functionlist($pixmap, $mask) = Gdk::pixmap_create_from_xpm($window->window, null, 'icon-new.xpm');$newicon = &new GtkPixmap($pixmap, $mask);

$toolbar->insert_element(GTK_TOOLBAR_CHILD_BUTTON,'New','Create a new document',"Closes the current document and\r\ncreates a new, empty one.",$newicon,0,'toolbarClicked','new');

GtkToolbar::append_item

GtkButton append_item(string button_text, string tooltip_text, stringtooltip_private_text, GtkPixmap icon, string callback, [mixeduserparam]);

Adds a new button to the end. Just calls insert_element() with theposition parameter set to the number of widgets and the widget typeset to button.

GtkToolbar::prepend_item

GtkButton prepend_item(string button_text, string tooltip_text, stringtooltip_private_text, GtkPixmap icon, string callback, [mixeduserparam]);

Page 330: Apostila PHP GTK

Adds a widget before the first item. Just calls insert_element() withthe position parameter set to 0 and the widget type set to button.

GtkToolbar::insert_item

GtkButton insert_item(string button_text, string tooltip_text, stringtooltip_private_text, GtkPixmap icon, int position, string callback,[mixed userparam]);

Inserts a new button at the given position. Just callsinsert_element() with the the widget type set to button.

GtkToolbar::append_widget

void append_widget(GtkWidget widget, string tooltip_text, stringtooltip_private_text);

Adds a widget to the end. Just calls insert_widget() with the positionparameter set to the number of widgets.

GtkToolbar::prepend_widget

void prepend_widget(GtkWidget widget, string tooltip_text, stringtooltip_private_text);

Adds a widget before the first item. Just calls insert_widget() withthe position parameter set to 0.

GtkToolbar::insert_widget

void insert_widget(GtkWidget widget, string tooltip_text, stringtooltip_private_text, int position);

Inserts a widget at the given position. The position minimum value is0, and the maximum is the number of items on this toolbar.

The tooltip_text is the one being visible when the mouse hovers overthe element. The tooltip_private_text is for context-sensitive helpabout this widget.

GtkToolbar::set_orientation

void set_orientation(GtkOrientation orientation);

Sets the toolbar orientation to horizontal or vertical.

The "orientation-changed" signal is emitted when this function iscalled.

You can read the current orientation with the orientation property.

GtkToolbar::set_style

void set_style(GtkToolbarStyle style);

Page 331: Apostila PHP GTK

Sets the text/icon style of the toolbar. This setting is applied toall buttons on the toolbar, except for the widgets added via theinsert_widget() function.

You could write your own method which changes the styles of all thewidgets by connecting the toolbar to the "style-changed" signal.

Every application should let the user decide if he wants to haveicons, text or both displayed in the toolbar.

Note that the toolbar can grow quite large if you use text+icons thesame time. Pay attention to this when creating your application.

The "style-changed" signal is emitted when this function is called.

You can read the current style with the style property.

GtkToolbar::set_space_size

void set_space_size(int space_size);

Sets the width (horitontal orientation) or height (verticalorientation) which a spacer takes for display. The width of the lineis not affected by this setting.

You can read the current space size with the space_size property.

GtkToolbar::set_space_style

void set_space_style(GtkToolbarSpaceStyle space_style);

Sets the style of the spacers: Invisible, with only empty space beingdisplayed for the spacer or line, which draws a thin vertical(horizontal orientation) or horizontal (vertical orientation) in thecenter of the spacer.

You can read the current space style with the space_style property.

GtkToolbar::set_tooltips

void set_tooltips(int enable);

Enables or disables the display of tooltips on all the widgets on thetoolbar.

GtkToolbar::set_button_relief

void set_button_relief(GtkReliefStyle relief);

Sets the relief style for buttons on the toolbar. This does not affectwidgets added via the insert_widget() , equal if they are buttons ornot.

Page 332: Apostila PHP GTK

GtkToolbar::get_button_relief

GtkReliefStyle get_button_relief(void);

Returns the current GtkReliefStyle which can be set withset_button_relief() method.

style-changed

Emitted when the style has changed. Connect the toolbar with thissignal to your own function if you want to implement the stylechanging for widgets added via the insert_widget() function.

Função Callback

void callback(GtkToolbar widget, GtkToolbarStyle style);

orientation-changed

Emitted when the orientation has changed.

Função Callback

void callback(GtkToolbar widget, GtkOrientation orientation);

GtkToolbar::orientation

Access: Read OnlyType: GtkOrientation

Returns the orientation (horizontal or vertical) of the toolbar

It can be set with set_orientation() .

GtkToolbar::space_size

Access: Read OnlyType: int

Returns the width/height which a space takes.

It can be set with set_space_size() .

GtkToolbar::space_style

Access: Read OnlyType: GtkToolbarSpaceStyle

Returns the current space style of the toolbar (line or invisible).

It can be set with set_space_style() .

GtkToolbar::style

Page 333: Apostila PHP GTK

Access: Read OnlyType: GtkToolbarStyle

Returns the current toolbar style (icons only, text only, both).

It can be set with set_style() .

GtkTooltips

Adds tooltips to other widgets.

Hierarquia do Objeto

GtkObject`-- GtkData`-- GtkTooltips

Direct subclasses

None.

Descrição

Tooltips are the messages that appear next to a widget when themouse pointer is held over it for a short amount of time. They areset via the set_tip() method.

They are especially helpful for adding more verbose descriptions ofthings such as buttons in a toolbar.

This widget holds tooltips for other widgets. You should only needone Tooltip widget for all widgets you wish to add tips to.

Tooltips can only be used on widgets which have their own x window.Other widgets, e.g. GtkLabels can be added to an GtkEventBox tobenefit from tooltips.

A widget which wants to use a tooltip needs to exposeGDK_ENTER_NOTIFY_MASK and GDK_LEAVE_NOTIFY_MASK which can be setvia the add_events() function. Most widgets do this automatically,but e.g. a GtkDrawingArea does not.

Construtor

GtkTooltips (void);

-- Creates a new tooltips instance.

Métodos

enable()Actives the showing of tooltips.

disable()

Page 334: Apostila PHP GTK

Disable the showing of tooltips.

set_delay()Determines the time after which the tooltips are shown

set_tip()Sets the tooltip for a specific widget

set_colors()Sets the fore- and background color of the tooltips. Deprecated.

force_window()Used internally only.

GtkTooltips Construtor

GtkTooltips (void);

Creates a new tooltips instance. You need only one tooltip widget, asit can hold tooltips for several widgets.

Exemplo 47. How to use tooltips<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

$window = &new GtkWindow();$window->set_title( 'tooltip window');$window->set_default_size( 200, 200);$window->connect_object('destroy', array('gtk', 'main_quit'));$vbox = &new GtkVBox();

$btnSparkum = &new GtkButton( 'OEffnen');$btnNaclus = &new GtkButton( 'Speichern');

$label = &new GtkLabel( 'Normal label');$labelEvent = &new GtkLabel( 'Label on EventBox');$eventbox = &new GtkEventBox();$eventbox->add( $labelEvent);

$vbox->pack_start_defaults( $btnSparkum);$vbox->pack_start_defaults( $btnNaclus);$vbox->pack_start_defaults( $label);$vbox->pack_start_defaults( $eventbox);

$tooltips = &new GtkTooltips();$tooltips->set_tip( $btnSparkum, 'OEffnen is german for "Open"',"OEffnen is german for \"Open\"\r\nSee it as a way to extend\r\nyour knowledge");$tooltips->set_tip( $btnNaclus, 'Speichern is german for "Save"',"Speichern is german for \"Save\"\r\nSee it as a way to extend\r\nyourknowledge");$tooltips->set_tip( $label, 'You shouldn\'t see this.', null);

Page 335: Apostila PHP GTK

$tooltips->set_tip( $eventbox, 'A tooltip on a label... magic.',"No magic!\r\nYou just need to pack the label\r\non an EventBox.");

$window->add( $vbox);$window->show_all();

gtk::main();?>

GtkTooltips::enable

void enable(void);

Activates the tooltips so that they are shown after the specified withthe set_delay() function if they were disable() d before.

GtkTooltips::disable

void disable(void);

Deactivates the tooltips so that they aren't shown any more.

You can re-activate them with enable() .

GtkTooltips::set_delay

void set_delay(int delay);

Determines the time in milliseconds which the user has to wait on thewidget until the tooltip is shown.

With a delay of 0, the tooltips are shown immediately.

GtkTooltips::set_tip

void set_tip( GtkWidget widget , string tip_text, string tip_private);

Sets the tooltip for a specific widget. The tip_text is will bevisible when the user hovers the button for a specific delay.

The tip_private should be a longer description of the function thewidget has and can be made visible via a GtkTipsQuery object ("What'sthis" function).

GtkTooltips::set_colors

void set_colors( GdkColor background , GdkColor foreground );

This method is deprecated. Colors can be set via styles.

This method sets the foreground and background colors for thetooltips.

On linux this method doesn't work. Use the styles instead.

Page 336: Apostila PHP GTK

Exemplo 48. How to set the color of tooltips$style = 'style "tooltips" { bg[NORMAL] = "#ff6060" } widget "gtk-tooltips" style "tooltips"';gtk::rc_parse_string( $style);

GtkTooltips::force_window

void force_window(void);

This function is for internal use only. It forces the creation of thetooltip window if it doesn't exist yet. (Not meaning showing)

GtkTree

Widget for displaying hierarchical information.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkTree

Direct subclasses

None.

Descrição

A GtkTree is a structure for displaying hierchical information. Atree may contain one or more nodes which themselves may containother trees, thus creating levels or groups of nodes. A tree can beused to display information such as a map of a website or the filesand folders of a directory.

GtkTree has been deprecated since GTK+ 2.0 and should not be used innewly written code.

Construtor

GtkTree (void);

-- Creates a new GtkTree.

Métodos

append()Adds a node to the end of the tree.

prepend()Adds a node to the begining of the tree.

insert()

Page 337: Apostila PHP GTK

Adds a node to the tree in the given position.

remove_item()Removes a node from a tree.

clear_items()Removes a range of nodes from the tree.

select_item()Selects a node of the tree by position.

unselect_item()Unselects a node of the tree by position.

select_child()Selects a node of a tree by object.

unselect_child()Unselects a node of a tree by object.

child_position()Returns the position of a node.

set_selection_mode()Sets the tree's selection mode.

set_view_mode()Sets the tree's view mode.

set_view_lines()Sets how lines between nodes and children are to be drawn.

GtkTree Construtor

GtkTree (void);

Creates a new instance of a GtkTree.

Because GtkTree extends GtkContainer, it may contain one or morechildren. These children should be GtkTreeItem widgets.

Exemplo 49. Building a tree of a file structure.<?phpdl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

// Creates a tree representing a directory.function &createTreeFromDirectory($dir){// Create a new tree$tree =& new GtkTree;

// Make sure dir is a directoryif (is_dir($dir)) {// Open directory and read in file names

Page 338: Apostila PHP GTK

$dir_handle = opendir($dir);while (($file = readdir($dir_handle)) !== false) {// Create a new tree item for each file$treeItem = &new GtkTreeItem($file);$treeItem->show();// Add the tree item to the tree$tree->append($treeItem);// If the file is a directory and not . or .. call// this function recursivelyif (is_dir($dir . '/' . $file) && strpos($file, '.') !== 0) {$treeItem->set_subtree(createTreeFromDirectory($dir . '/' . $file));}}// Close the directoryclosedir($dir_handle);}// Return the treereturn $tree;}// The directory to display$directory = '/path/to/some/directory';

// Create a window to display the file structure$window =& new GtkWindow;

// Add a frame$frame =& new GtkFrame($directory);$window->add($frame);

// Add the tree$tree = createTreeFromDirectory($directory);$frame->add($tree);

$window->show_all();gtk::main();?>

GtkTree::append

void append ( GtkWidget tree_item );

Adds tree_item to the end of the tree.

Exemplo 50. Appending nodes to a tree<?php$tree =& new GtkTree;$nodes = array('These nodes', 'were added', 'in this order');

// Add the nodes. When displayed they will be in readable order.foreach ($nodes as $node) {$item =& new GtkTreeItem($node);$tree->append($item);}

Page 339: Apostila PHP GTK

?>

See also: prepend() , insert()

GtkTree::prepend

void prepend ( GtkWidget tree_item );

Adds tree_item to the begining of the tree. The first node of the treeis in position zero.

See also: append() , insert()

GtkTree::insert

void insert ( GtkWidget tree_item , int position );

Adds tree_item to the tree at position. The first node of the tree isin position zero.

If position is greater than the first empty position, tree_item is putin the first empty position.

Exemplo 51. Inserting a tree item<?phpdl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

// Create a tree$tree =& new GtkTree;

// Create a tree item$treeItem =& new GtkTreeItem('A tree item');

// Insert the tree item into the 100th position.$tree->insert($treeItem, 100);

// Check the position of the tree item.echo $tree->child_position($treeItem); // Outputs 0?>

See also: append() , prepend()

GtkTree::remove_item

void remove_item ( GtkWidget child );

Removes child from the tree.

If child is not a node of the tree, a Gtk-CRITICAL warning will beissued.

GtkTree::clear_items

void clear_items (int start , int end );

Page 340: Apostila PHP GTK

Removes nodes from start to end inclusive.

If end is greater than the number of nodes, all nodes from start tothe end of the tree will be removed.

Unlike gtk, nodes that are removed from the tree are not destroyed.

See also: remove_item()

GtkTree::select_item

void select_item (int position );

Highlights the node in position as selected. This will cause the nodeto emit the "select" signal. Selecting a node which is alreadyselected will unselect that node.

Exemplo 52. Selecting a node twice<?php// Call back function to notify when an item is deselectedfunction itemDeselected(){echo 'A tree item was deselected!';}

// Create a tree$tree =& new GtkTree;

// Create an item and add it to the tree$treeItem =& new GtkTreeItem('Select me twice');$tree->append($treeItem);

// Select the item twice and see what happens$tree->select_item(0);$tree->select_item(0); // itemDeselected() will be called.?>

Node positions are indexed begining with zero. The fourth node in atree is in position three.

See also: unselect_item() , select_child() , unselect_child() .

GtkTree::unselect_item

void unselect_item (int position );

Unselects the node in position. Unselecting a node causes the node toemit the "deselect" signal. Unselecting a node that is not selectedwill select the node.

Node positions are indexed begining with zero. The fourth node is inposition three.

Page 341: Apostila PHP GTK

GtkTree::select_child

void select_child ( GtkWidget tree_item );

Selects the node tree_item. Selecting a node causes the "select"signal to be emitted.

GtkTree::unselect_child

void unselect_child ( GtkWidget tree_item );

Unselects tree_item. Unselecting a node causes the "deselect" signalto be emitted.

GtkTree::child_position

int child_position ( GtkWidget child );

Returns the position of child. The first node of a tree is in positionzero.

If child is not a node of the tree, -1 is returned.

GtkTree::set_selection_mode

void set_selection_mode ( GtkSelectionMode mode );

Sets the selection mode to mode. GTK_SELECTION_SINGLE is the default.

The selection mode determines how many nodes may/must be selected atone time.

See also: GtkSelectionMode

GtkTree::set_view_mode

void set_view_mode ( GtkTreeViewMode mode );

Sets the tree's view mode to mode. The view mode defines how the treelooks when items are selected. The default mode is GTK_TREE_VIEW_ITEM.

See also: GtkTreeViewMode

GtkTree::set_view_lines

void set_view_lines (int flag );

Sets whether or not lines between nodes and children should be drawn.If flag evaluates to true (flag > 0) connecting lines between nodesand children will be drawn. If flag evaluates to false (flag <= 0)connecting lines between nodes and children will not be drawn. Bydefault tree's begin with view lines set to one.

GtkTreeItem

Page 342: Apostila PHP GTK

One node of a GtkTree widget.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkItem`-- GtkTreeItem

Direct subclasses

None.

Descrição

A GtkTreeItem is one node of a GtkTree. Because GtkTreeItem extendsGtkItem, it may contain one child. That child should be a GtkTree.

See also: GtkTree

GtkTreeItem has been deprecated since GTK+ 2.0 and should not be usedin newly written code.

Construtor

GtkTreeItem (string node_text );

-- Creates a new GtkTreeItem with the given text.

Métodos

set_subtree()Adds a tree of children nodes.

remove_subtree()Removes a node's subtree.

select()Selects the node.

deselect()Deselects the node.

expand()Shows the node's subtree.

collapse()Hides the node's subtree.

Sinais

Page 343: Apostila PHP GTK

"expand"Emitted when expand() is called.

"collapse"Emitted when collapse() is called.

"select"Emitted when the tree item is selected.

"deselect"Emitted when the tree item is deselected.

GtkTreeItem Construtor

GtkTreeItem (string node_text );

Creates a new instance of GtkTreeItem with node_text as the nodelabel. The new item should be added to a GtkTree using append() ,prepend() , or insert() .

Strictly speaking node_text is optional. That is, you will not get arun time error if you do not supply the text, but if no text is giventhe node will not display.

GtkTreeItem::set_subtree

void set_subtree ( GtkTree subtree );

Sets a GtkTree as the subtree (or tree of children) for a node. AGtkTreeItem may only have one subtree. Attempting to set a second treewill generate a Gtk-Warning. The orginal subtree will not beoverwritten or removed.

A node that has a subtree will be shown with a box to the leftcontaining either a plus for a collapsed tree or a minus for anexpanded tree.

Exemplo 53. Adding a subtree<?php// Create the top level tree item.$tree =& new GtkTree();$treeItem =& new GtkTreeItem('Top Level Item');$tree->append( $treeItem);

// Create the sub tree with one sub tree item.$subTree =& new GtkTree;$subTreeItem =& new GtkTreeItem('Sub Level Item');

$subTree->append($subTreeItem);

// Add the sub tree to the top level item.$treeItem->set_subtree($subTree);?>

Page 344: Apostila PHP GTK

Controlling whether or not the subtree is visible is done usingexpand() and collapse() functions.

GtkTreeItem::remove_subtree

void remove_subtree (void);Removes the subtree set using set_subtree() . If no subtree has beenset a Gtk-CRITICAL message will be issued.

GtkTreeItem::select

void select (void);

Selects the node and emits the select signal.

Exemplo 54. Selecting a node<?phpfunction treeItemSelected() {echo "A tree item was selected.\n";}

// Create a new button.$button =& new GtkButton('Press Me');// Create a new tree item$treeItem =& new GtkTreeItem('I\'ll get selected.');

// Have the treeItemSelected function called when// the tree item is selected.$treeItem->connect('select', 'treeItemSelected');

// When the button is clicked the treeItemSelected// function will be called and a message will be// printed to the terminal.$button->connect('clicked', array(&$treeItem, 'select'));?>

This method is connected to the "clicked" signal on construction.

See also: deselect()

GtkTreeItem::deselect

void deselect (void);

Deselects the node and emits the deselect signal. This method iscalled implicitly when another node in either the parent or childtrees is selected.

See also: select()

GtkTreeItem::expand

void expand (void);

Page 345: Apostila PHP GTK

Shows the node's subtree and emits the "expand" signal. When expanded,the icon to the left of the node changes from a + (plus) to a -(minus). Show must also be called on each subtree item before it willbe visible.

GtkTreeItem::collapse

void collapse(void);

Hides the node's subtree and emits the "collapse" signal. Whencollapsed the icon to the left of the node changes from a - (minus) toa + (plus).

expand

The "expand" signal is emitted when the expand() method is called.This normally occurs when the user clicks on the label of a collapsednode.

Função Callback

void callback(GtkTreeItem tree_item);

collapse

The "collapse" signal is emitted when the collapse() method is called.This normally occurs when the user clicks on the label of an expandednode.

Função Callback

void callback(GtkTreeItem tree_item);

select

The "select" signal is emitted when a tree item is about to beselected. This occurs when the user clicks on an unseleted item or theitem is selected by its parent tree using the select_item() method.

Função Callback

void callback(GtkTreeItem tree_item);

deselect

The "deselect" signal is emitted when a tree item is about to bedeselected. This occurs when the user clicks on a selected item or theitem is unselected by its parent tree using the unselect_item()method.

Função Callback

void callback(GtkTreeItem tree_item);

Page 346: Apostila PHP GTK

GtkVBox

Vertical box container.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBox`-- GtkVBox

Direct subclasses

GtkColorSelection, GtkGammaCurve

Descrição

GtkVBox is a box container that packs child widgets in a singlecolumn, using the packing methods inherited from GtkBox, such aspack_start() , as well as the less flexible add() method availableto most container widgets.

Note that all children in a GtkVBox are allocated the same width,regardless of settings and child requisition size. Widgets takingup less than the allocated width are by default centered within theavailable area in that dimension.

See also: GtkContainer, GtkBox, GtkHBox, GtkButtonBox, GtkTable.

Construtor

GtkVBox ([bool homogeneous = false , [int spacing = 0 ]]);

-- Creates a container for a single column of child widgets.

GtkVBox Construtor

GtkVBox ([bool homogeneous = false , [int spacing = 0 ]]);

Creates a new vertical box container designed for packing a singlecolumn of child widgets.

The first parameter, homogeneous, is a boolean value which, if set totrue, will set each child widget in the GtkVBox to the same height asthat of the largest child widget. The second parameter, spacing, setsthe minimum spacing between the child widgets, in pixels. Leaving bothparameters empty, e.g.$vbox = &new GtkVBox();

will set the default behaviour of individual sizing and zero spacing.

Exemplo 55. Packing child widgets using GtkVBox and GtkHBox<?php

Page 347: Apostila PHP GTK

$window = &new GtkWindow();$window->set_title("GtkHBox and GtkVBox packing demonstration");$window->set_position(GTK_WIN_POS_CENTER);$window->connect_object("destroy", array("gtk","main_quit"));$window->show();

$vbox = &new GtkVBox(false, 5);$window->add($vbox);

$label = &new GtkLabel();$label->set_text("This GtkLabel is packed at the start of a GtkVBox.The GtkCalendar below is\npacked at the start of a GtkHBox, which is in turnpacked at the end of the\nGtkVBox. The empty GtkText widget is packed at theend of the GtkHBox.");$label->set_justify(GTK_JUSTIFY_LEFT);$vbox->pack_start($label, true, true, 5);$label->show();

$hbox = &new GtkHBox(true, 0);$vbox->pack_end($hbox);

$calendar = &new GtkCalendar();$hbox->pack_start($calendar, true, true, 2);$calendar->show();

$text = &new GtkText();$text->set_editable(true);$hbox->pack_end($text, true, true, 2);$text->show();

$window->show_all();

gtk::main();

?>

GtkVButtonBox

Container for arranging a group of buttons vertically.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBox`-- GtkButtonBox`-- GtkVButtonBox

Direct subclasses

None.

Page 348: Apostila PHP GTK

Descrição

GtkVButtonBox is a container widget designed for arranging a columnof buttons in accordance with a specified GtkButtonBoxStylesetting.

See also: GtkButtonBox, GtkHButtonBox.

Construtor

GtkVButtonBox (void);

-- Creates the basis for a vertical button container.

GtkVButtonBox Construtor

GtkVButtonBox (void);

The syntax for creating a vertical buttonbox is:$vbuttonbox = &new GtkVButtonBox();

There are no parameters.

As with all container widgets, no physical space is taken by aGtkVButtonBox until its child widgets are in place.

GtkViewport

Provides scrolling capability for non-scrolling aware widgets.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkViewport

Direct subclasses

None.

Descrição

The GtkViewport object is only used alongside a GtkScrolledWindow,and provides scrolling capability where the child widget beingadded to a scrolled window is not otherwise scrollable.

It is not possible in most cases to use it outside this context, asits adjustment values are set internally by the child's sizingpolicies and can neither be overridden manually nor used directly.Note that directional keybindings in a non-scrolling aware widgetare not usually bound to any adjustment value by default; the

Page 349: Apostila PHP GTK

GtkViewport simply allows the use of scrollbars with such a widget.The exception that proves this rule is GtkList, which is set up sothat it can be made to be scrollable via the keyboard if it isadded to a GtkViewport.

In most circumstances, it is easier to construct the viewportobject by using the convenience method add_with_viewport() ratherthan by using its own constructor.

Construtor

GtkViewport ([ GtkAdjustment hadjustment = NULL , [ GtkAdjustmentvadjustment = NULL ]]);

-- Creates a scrollable container.

Métodos

get_hadjustment()Returns the horizontal adjustment object.

get_vadjustment()Returns the vertical adjustment object.

set_shadow_type()Sets the shadow style on the viewport's border.

GtkViewport Construtor

GtkViewport ([ GtkAdjustment hadjustment = NULL , [ GtkAdjustmentvadjustment = NULL ]]);

You should rarely need to construct a GtkViewport directly, as itsmain use is where a GtkScrolledWindow needs a scrollable widget as itschild - which situation is catered for with the methodadd_with_viewport() , saving three or four coding lines.

Exemplo 56. Creating a GtkViewport the hard way<?php

dl('php_gtk.'.(strstr(PHP_OS, 'WIN') ? 'dll' : 'so'));

/* set up a window */$window = &new GtkWindow();$window->set_position(GTK_WIN_POS_CENTER);$window->connect_object('destroy', array('gtk', 'main_quit'));

/* set up the scrolled window and add it to the main window,sizing it if necessary. */$scrolledwindow = &new GtkScrolledWindow();$scrolledwindow->set_usize(150, 150);$window->add($scrolledwindow);

/* create the viewport */

Page 350: Apostila PHP GTK

$viewport = &new GtkViewport();$viewport->set_shadow_type(GTK_SHADOW_ETCHED_OUT);

/* create a box container and add child widget or widgets to it - becauseas with most widgets, a GtkCalendar has no adjustment-friendly focusinternals, whereas a box container does */$box = &new GtkVBox();$calendar = &new GtkCalendar();$box->pack_start($calendar, false);

/* add the box to the viewport, and the viewport to the scrolled window */$viewport->add($box);$scrolledwindow->add($viewport);

$box->show_all();$window->show_all();

gtk::main();

?>

GtkViewport::get_hadjustment

GtkAdjustment get_hadjustment (void);

get_hadjustment() returns the GtkAdjustment object that is used inhorizontal scrolling.

GtkViewport::get_vadjustment

GtkAdjustment get_vadjustment (void);

get_vadjustment() returns the GtkAdjustment object that is used invertical scrolling.

GtkViewport::set_shadow_type

void set_shadow_type( GtkShadowType type );

Sets the shadow style of the border area around a GtkViewport to oneof five possible GtkShadowType values.

The default setting is GTK_SHADOW_IN.

GtkVPaned

Container with two panes arranged vertically.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkPaned

Page 351: Apostila PHP GTK

`-- GtkVPaned

Direct subclasses

None.

Descrição

GtkVPaned is a widget derived from GtkPaned, consisting of twopanes arranged vertically and separated by a dividing handle. Thehandle can be adjusted by the end user to alter the relative sizesof the panes.

See also: GtkPaned, GtkHPaned.

Construtor

GtkVPaned (void);

-- Creates the basis for a vertical dual-paned container.

GtkVPaned Construtor

GtkVPaned (void);

The GtkVPaned widget should be thought of in terms of an arrangementof two child widgets, rather than as an object in its own right. Theconstruct$vbox = &new GtkVBox();

needs to be within a containing GtkWindow and to contain two childwidgets of its own in order to work.

There is a code sample demonstrating the construction of a panedwidget under the entry for the GtkHPaned constructor.

GtkVRuler

Vertical ruler.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkRuler`-- GtkVRuler

Direct subclasses

None.

Descrição

Construtor

Page 352: Apostila PHP GTK

GtkVRuler (void);

--

GtkVRuler Construtor

GtkVRuler (void);

GtkVScale

Vertical slider widget for selecting a value from a range.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkRange`-- GtkScale`-- GtkVScale

Direct subclasses

None.

Descrição

A GtkVScale is a vertical scrollbar-like widget that is able todisplay its adjustment value as text.

There are some configuration issues with this widget when it isused in such a way; please refer to GtkScale for furtherinformation.

Construtor

GtkVScale ([ GtkAdjustment adjustment = NULL ]);

-- Creates a vertical slider.

GtkVScale Construtor

GtkVScale ([ GtkAdjustment adjustment = NULL ]);

A GtkVScale that can be given its own GtkAdjustment settings has noconfiguration issues whatever.

Reasonable settings on an adjustment object for a GtkVScale on asingle full page might look something like this:<?php

$adjustment = &new GtkAdjustment(0, 0, 100, 1, 25, 0);$vscale = &new GtkVScale($adjustment);

Page 353: Apostila PHP GTK

?>

This would give a scale of 0 to 100 along the height of the page, andno overlap.

GtkVScrollbar

Vertical scrollbar.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkRange`-- GtkScrollbar`-- GtkVScrollbar

Direct subclasses

None.

Descrição

A GtkVScrollbar is a vertical scrollbar.

Tabela 8. Key bindings for GtkVScrollbarKey combination Scroll functionUp arrow Move up one step incrementDown arrow Move down one step incrementPage Up Move up one page incrementPage Down Move down one page incrementControl + Page Up Move to top of scrollControl + Page Down Move to bottom of scroll

Construtor

GtkVScrollbar ([ GtkAdjustment adjustment = NULL ]);

-- Creates a vertical scrollbar.

GtkVScrollbar Construtor

GtkVScrollbar ([ GtkAdjustment adjustment = NULL ]);

A scrollbar needs a GtkAdjustment in order to operate. The values thatyou give to the adjustment object will depend on the situation wherethe scrollbar is intended to be used.

All scrollable widgets have their own adjustment object(s), and in allinstances where you are most likely to need a vertical scrollbar it ispossible to create a handle for the widget's vertical GtkAdjustmentand assign that as the new scrollbar's adjustment object.

For example:

Page 354: Apostila PHP GTK

<?php

$text = &new GtkText();$adjustment = $text->vadj;$scrollbar = &new GtkVScrollbar($adjustment);

?>

GtkVSeparator

Vertical separator.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkSeparator`-- GtkVSeparator

Direct subclasses

None.

Descrição

A GtkVSeparator is a widget that consists of a vertical line. It isused to separate widgets that are laid out horizontally.

Separators cannot be used in menu widgets, and there is currentlyno way to put a vertical separator into a GtkMenuBar.

See also: GtkHSeparator, gtk::paint_vline() .

Construtor

GtkVSeparator (void);

-- Draws a vertical line.

GtkVSeparator Construtor

GtkVSeparator (void);

Constructing a GtkVSeparator and adding it to a widget amounts to thesame thing as drawing a vertical line across that widget. Use thecontainer's packing methods to determine the spacing around theseparator.

GtkWidget

Base class for user interface elements.

Hierarquia do Objeto

Page 355: Apostila PHP GTK

GtkObject`-- GtkWidget

Direct subclasses

GtkCalendar, GtkContainer, GtkDrawingArea, GtkEditable, GtkMisc,GtkPreview, GtkProgress, GtkRange, GtkRuler, GtkSeparator

Descrição

GtkWidget is an abstract base class providing its descendants withproperties, methods and signals pertinent to displayable userinterface elements. The only objects that do not inherit GtkWidgetcharacteristics are GtkTooltips, GtkAdjustment and GtkItemFactory -all of which are relatively abstract concepts. Everything else thatis a member of the object hierarchy is a descendant of theGtkWidget class, takes up screen space, and may be referred to as awidget.

Note that GtkWidget cannot be constructed directly.

Métodos

drag_highlight()Highlight the widget.

drag_unhighlight()Unhighlight the widget.

drag_dest_set()Set a widget as a drag-and-drop destination.

drag_dest_unset()Unregister a widget as a drag-and-drop destination.

drag_source_set()Allows to drag data from the widget.

drag_source_unset()Undo the effects of drag_source_set().

drag_source_set_icon()

selection_owner_set()

selection_add_target()

selection_convert()

selection_remove_all()

Page 356: Apostila PHP GTK

unparent()Dissociates widget from current parent.

show()Displays the calling widget.

show_now()Shows a widget and enters the main loop.

hide()Hides the calling widget.

show_all()Displays calling widget and its children.

hide_all()Hides calling widget and its children.

map()Maps calling widget to the screen.

unmap()Unmaps calling widget from the screen.

realize()Instantiates calling widget's GdkWindow.

unrealize()Removes calling widget's GdkWindow.

queue_draw()Queues widget's redraw requests, for the whole widget.

queue_draw_area()Queues widget's redraw requests, for any area within the widget.

queue_clear()

queue_clear_area()

queue_resize()Queues widget's resize requests.

draw()

draw_focus()

draw_default()

Page 357: Apostila PHP GTK

add_accelerator()Adds accelerator key to a widget.

remove_accelerator()Removes a single accelerator.

remove_accelerators()Removes all accelerators meeting certain criteria.

lock_accelerators()Locks accelerator key definitions.

unlock_accelerators()Unlocks accelerators to allow alterations.

accelerators_locked()Tests accelerator lock status.

event()Triggers an event.

activate()

reparent()Moves a widget to a new container.

popup()

intersect()Checks for an intersection with a given area.

grab_focus()Gives grab and focus to the calling widget.

grab_default()Gives grab and default to the calling widget.

set_name()Sets widget name.

get_name()Returns name of widget.

set_state()Sets widget's state.

set_sensitive()Toggles sensitivity.

set_app_paintable()

Page 358: Apostila PHP GTK

set_parent()Sets the parent of the widget.

set_parent_window()

get_parent_window()

set_uposition()Sets widget's position relative to its container.

set_usize()Sets widget's size in pixels.

set_events()Extends capturable events prior to realization.

add_events()Extends capturable events after realization.

get_toplevel()

get_ancestor()

get_colormap()Returns the GdkColormap object used by the widget.

get_visual()Returns the GdkVisual object used by the widget.

set_colormap()Sets the widget's colormap.

set_visual()

get_events()

is_ancestor()Tests relationship with other widgets.

hide_on_delete()

set_style()Sets a widget's style property.

set_rc_style()

Page 359: Apostila PHP GTK

ensure_style()

get_style()Returns the GtkStyle object used by the widget.

restore_default_style()

set_composite_name()

get_composite_name()

reset_rc_styles()

shape_combine_mask()Give the widget an unusual shape.

Sinais

"show"

"hide"

"map"

"unmap"

"realize"

"unrealize"

"draw"

"draw-focus"

"draw-default"

"size-request"

Page 360: Apostila PHP GTK

"size-allocate"

"state-changed"

"parent-set"

"style-set"

"add-accelerator"

"remove-accelerator"

"grab-focus"

"event"Emitted when any event is captured.

"button-press-event"Emitted when a GDK_BUTTON_PRESS event is captured.

"button-release-event"Emitted when a GDK_BUTTON_RELEASE event is captured.

"motion-notify-event"Emitted when a GDK_MOTION_NOTIFY event is captured.

"delete-event"Emitted when a GDK_DELETE event is captured.

"destroy-event"Emitted when a GDK_DESTROY event is captured.

"expose-event"Emitted when a GDK_EXPOSE event is captured.

"key-press-event"Emitted when a GDK_KEY_PRESS event is captured.

"key-release-event"Emitted when a GDK_KEY_RELEASE event is captured.

"enter-notify-event"Emitted when a GDK_ENTER_NOTIFY event is captured.

"leave-notify-event"Emitted when a GDK_LEAVE_NOTIFY event is captured.

Page 361: Apostila PHP GTK

"configure-event"Emitted when a GDK_CONFIGURE event is captured.

"focus-in-event"Emitted when a GDK_FOCUS_CHANGE event is captured.

"focus-out-event"Emitted when a GDK_FOCUS_CHANGE event is captured.

"map-event"Emitted when a GDK_MAP event is captured.

"unmap-event"Emitted when a GDK_UNMAP event is captured.

"property-notify-event"Emitted when a GDK_PROPERTY_NOTIFY event is captured.

"selection-clear-event"Emitted when a GDK_SELECTION_CLEAR event is captured.

"selection-request-event"Emitted when a GDK_SELECTION_REQUEST event is captured.

"selection-notify-event"Emitted when a GDK_SELECTION_NOTIFY event is captured.

"selection-received"

"selection-get"

"proximity-in-event"Emitted when a GDK_PROXIMITY_IN event is captured.

"proximity-out-event"Emitted when a GDK_PROXIMITY_OUT event is captured.

"drag-begin"

"drag-end"

"drag-data-delete"

"drag-motion"The mouse cursor is moved over the drop target

"drag-leave"The mouse leaves the drop target

Page 362: Apostila PHP GTK

"drag-drop"

"drag-data-get"Requests drag'n'drop data.

"drag-data-received"Receives data dropped over the widget.

"visibility-notify-event"Emitted when a GDK_VISIBILITY_NOTIFY event is captured.

"client-event"Emitted when a GDK_CLIENT_EVENT event is captured.

"no-expose-event"

"debug-msg"

Propriedades

style:Style associated with a widget.

window:Underlying GdkWindow that captures events on a widget.

allocation:Size and position allocated to a widget.

state:Degree of response to events.

parent:A widget's parent.

GtkWidget::drag_highlight

void drag_highlight(void);

Highlights the calling widget. This method is usually calledinternally when a widget is selected. When called, drag_hihglightattaches handlers to "expose-event" and "draw" so that the widget willremain highlighed until it is unhighlighted using drag_unhighlight() .

See also: drag_unhighlight()

GtkWidget::drag_unhighlight

void drag_unhighlight(void);

Page 363: Apostila PHP GTK

Unhighlights the calling widget. This method is usually usedinternally when another widget is selected.

See also: drag_highlight()

GtkWidget::drag_dest_set

void drag_dest_set( GtkDestDefaults flags , array targets ,GdkDragAction actions );

Sets the calling widget as a drag-and-drop destination. flags is oneof four GtkDestDefaults values which define how the widget reacts whenthe drag is over the widget.

The targets parameter defines a list with all data types which can bedropped over the widget. The parameter is an array of arrays of sizethree:$targets = array(//array( target, flags, info),array( 'text/plain', GTK_TARGET_SAME_APP, 0),array( 'text/uri-list', 0, 1));

In our example, the widget would accept textual data and files. Thefiles could be dragged from everywhere (flag parameter 0), but thetextual data are only accepted if they come from within ourapplication.

It is not possible to use a "*" mime type in the target.

The flags of the targets determine from which widget the drag has tocome from:

Tabela 9. Values for flags0 Accept drags from everywhere.GTK_TARGET_SAME_APP Accept drags only from widgets of the sameapplication only.GTK_TARGET_SAME_WIDGET Accept drags only from the same widget. This isuseful for e.g. moving items up/down in a list by dragging them.

info allows you to pass a number to the function connected to the"drag-data-received" signal. This is useful when e.g. allowingmultiple image types to be dropped, as well as some other non-imagetypes: All image types could be assigned "1" as info parameter, allother types "2" or so. In the drag received function could pass thenecessary data to a image open function by checking if the infoparameter is "1", without having to compare the mime type.

Exemplo 57. Using the info parameterdefine('TYPE_IMAGE', 1);define('TYPE_PDF' , 2);define('TYPE_OTHER', 3);$targets = array(array( 'image/jpg' , 0, TYPE_IMAGE),

Page 364: Apostila PHP GTK

array( 'image/jpeg', 0, TYPE_IMAGE),array( 'image/gif' , 0, TYPE_IMAGE),array( 'image/png' , 0, TYPE_IMAGE),array( 'application/pdf', 0, TYPE_PDF),array( 'text/plain' , 0, TYPE_OTHER));

$list->drag_dest_set(GTK_DEST_DEFAULT_ALL, $targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);$list->connect('drag-data-received', 'dnd_drag_data_received');

function dnd_drag_data_received( $widget, $context, $x, $y, $data, $info, $time){if( $info == TYPE_IMAGE) { handle_image( $data); return; }//do different things with pdf and other type here}

See also: drag_dest_unset()

GtkWidget::drag_dest_unset

void drag_dest_unset(void);

Unregisters the calling widget as a drag-and-drop destination. Aftercalling this method, no special action will take place when the dragis over the widget. This method has no effect if the widget was notregistered as a drag-and-drop destination using drag_dest_set() .

See also: drag_dest_set()

GtkWidget::drag_source_set

void drag_source_set( GdkModifierType start_button_mask , arraytargets , GdkDragAction actions );

Sets the calling widgets as a drag-and-drop source, so that data canbe dragged from the widget to a drop target.

Exemplo 58. Using drag_source_set() $targets = array( array( 'text/uri-list', 0, 0));$list->drag_source_set(GDK_BUTTON1_MASK|GDK_BUTTON3_MASK, $targets, GDK_ACTION_COPY);

The first parameter, start_button_mask, is a bitmask with all mousebuttons allowed to start the drag.

The targets is an array of data types provided as drag/drop data. Seedrag_dest_set() for a detailed explanation of this topic.

actions determine which actions will take place if the drop eventoccurs; a copy/move/delete. See GdkDragAction for all possibleoptions.

Page 365: Apostila PHP GTK

GtkWidget::drag_source_unset

void drag_source_unset(void);

Unregisters the settings which have been done with drag_source_set() .After calling this function, the widget won't act as a drag source anymore.

GtkWidget::drag_source_set_icon

void drag_source_set_icon( GdkColormap colormap , GdkPixmap pixmap ,GdkBitmap mask );

GtkWidget::selection_owner_set

int selection_owner_set(GdkAtom selection, int time);

GtkWidget::selection_add_target

void selection_add_target(GdkAtom selection, GdkAtom target, intinfo);

GtkWidget::selection_convert

int selection_convert(GdkAtom selection, GdkAtom target, int time);

GtkWidget::selection_remove_all

void selection_remove_all(void);

GtkWidget::unparent

void unparent(void);

This method takes away the association between the calling widget andits current GdkWindow parent, allowing a new parent to be set for thewidget.

GtkWidget::show

void show(void);

show() is a commonly-used method that combines a series of othermethods in order to display a widget on the screen.

A widget cannot be shown until its containing parent is shown. Ifshow() is called on a widget whose parent has not been shown, thatwidget will not be realized or mapped until the show is called by theparent widget.

See also: map() , realize() , hide.

GtkWidget::show_now

Page 366: Apostila PHP GTK

void show_now (void);

Shows a widget. If the widget is an unmapped toplevel widget (i.e. aGtkWindow that has not yet been shown), enter the main loop and waitfor the window to actually be mapped. This is equivilent to callingshow immediately followed by gtk::main() .

Note: Once the main loop has begun your application will be able torecveive user events. Make sure that show_now() is the method you wantto call before using it.

See also: show() .

GtkWidget::hide

void hide(void);

hide() is the corollary to the show() method. It combines othermethods in order to hide the calling widget from display.

See also: show() .

GtkWidget::show_all

void show_all(void);

This method is used to display the calling widget and its children.The extent to which it 'sees' children is system-dependant; somesystems will not display children belonging to a child widget whenshow_all() is called from a top-level container. You may find that youstill need to show() the children individually in order to displaythem, and it is good practice to do so consistently.

GtkWidget::hide_all

void hide_all(void);

hide_all() is the corollary to show_all() , and the same reservationsregards the levels of children that will respond to this call, apply.If in doubt, hide() the child widgets individually.

See also: hide()

GtkWidget::map

void map(void);

This method maps a widget to the screen area it will take. It ismostly used internally, being one of the methods that is called aspart of the show() routine. It causes the "map" signal to be emittedby the widget, which in turn switches a flag causing the widget to bemapped.

Page 367: Apostila PHP GTK

At the point of a widget's becoming mapped, the GdkEvent GDK_MAP istriggered, causing the "map-event" signal to also be emitted by thatwidget. Use this signal to trigger functions that rely on the mapevent having occurred.

See also: show() , realize() .

GtkWidget::unmap

void unmap(void);

This method destroys information regards the dimensions of the screenarea where the widget is displayed . It is mostly used internally,being one of the methods that is called as part of the hide() routine.It causes the "unmap" signal to be emitted by the widget, which inturn switches a flag causing the widget to be unmapped.

At the point of a widget's becoming unmapped, the GdkEvent GDK_UNMAPis triggered, causing the "unmap-event" signal to also be emitted bythat widget. Use this signal to trigger functions that rely on theunmap event having occurred.

See also: map()

GtkWidget::realize

void realize (void);

realize() allocates the GDK resources associated with the callingwidget. A widget must be realized before it can be mapped to thescreen. This means that when show() is called, the widget is firstrealized and then mapped to the screen.

Before a widget can be realized, its parent and all of its ancestorsmust be realized. If an ancestor of a widget has not been realized atthe time realize() is called, it will be implicitly realized beforethe calling widget is realized.

If you want a widget to be displayed on the screen do not userealize() . Instead use show() . See the pixmap tutorial for anexample of when it is appropriate to use realize() .

See also: map() unrealize() .

GtkWidget::unrealize

void unrealize (void);

unrealize() is the corollary to realize() . When a widget isunrealized, all of its GDK resources ($widget->window) are released.

See also: realize()

GtkWidget::queue_draw

Page 368: Apostila PHP GTK

void queue_draw(void);

This method is the one to use if you need to force a widget to redrawitself. Put it into a callback function and determine an appropriatesignal to trigger the redraws. queue_draw() creates an expose event,in most situations.

In the event that this method does not have the desired effect, trycalling queue_resize() instead. If that also fails, you will need toresort to calling hide() followed immediately by show() in thecallback.

GtkWidget::queue_draw_area

void queue_draw_area (int x , int y , int width , int height );

This has exactly the same functionality as queue_draw() , with theexception that the area to be redrawn can be defined in theparameters. The upper left corner of the rectangle to be redrawn isgiven by x and y. width is the width of the rectangle to be redrawnand height is the height of the rectangle to be redrawn.

See also: queue_draw()

GtkWidget::queue_clear

void queue_clear(void);

GtkWidget::queue_clear_area

void queue_clear_area(int x, int y, int width, int height);

GtkWidget::queue_resize

void queue_resize(void);

Use this method to force a widget to resize. See GtkScale for aworking example.

queue_resize() is useful in conjunction with a GtkDrawingArea, wherethe widget creates synthetic configure events in response to theresizing. It can also trigger expose events in some situations wherethe queue_draw() has proved ineffective in doing same.

This method is used extensively within GTK+ internals.

GtkWidget::draw

void draw(GdkRectangle area);

GtkWidget::draw_focus

void draw_focus(void);

Page 369: Apostila PHP GTK

GtkWidget::draw_default

void draw_default(void);

GtkWidget::add_accelerator

void add_accelerator(string accel_signal, GtkAccelGroup accel_group ,int accel_key, GdkModifierType accel_mods, GtkAccelFlags accel_flags);

add_accelerator() defines and adds a keyboard accelerator to thecalling widget, usually a GtkMenuItem.

The first parameter is the name of the signal that you want the widgetto emit when the key is pressed. Generally this will probably be"activate".

The second parameter is the GtkAccelGroup that this GtkAccelEntry willbelong to when it has been created. This will generally be anaccelerator group that has been newly created and added to thetoplevel window.

Thirdly there is the accel_key parameter. This can be pulled from theGtkAccelLabel using the parse_uline() method if you have an underscoreunder the appropriate letter, or alternatively you could use the keysymbols which have been hard-coded into PHP-GTK. Usually these wouldbe in the format GDK_KEY__a - always in lower case, because theaccelerator functions return lower case key values.

The full list of PHP-GTK key symbol hard codings is available in thesource code in the file ext/gtk+/php_gdk.c.

The fourth and fifth parameters are GdkModifierType and GtkAccelFlagsrespectively. In both cases, passing 0 is accepted as a null field.

There is no limit on the number of accelerator keys that can beassociated with a widget.

GtkWidget::remove_accelerator

void remove_accelerator( GtkAccelGroup accel_group , int accel_key,GdkModifierType accel_mods);

remove_accelerator() is a way to remove a single accelerator, definedby its key value and GtkModifierType.

Note that the accelerator needs to be unlocked before this method willwork.

GtkWidget::remove_accelerators

void remove_accelerators(string accel_signal, bool visible_only);

Page 370: Apostila PHP GTK

remove_accelerators() is a way to remove any number of acceleratorsbelonging to the calling widget and causing the given signal to befired. The second parameter toggles whether this should include allsuch accelerators, or only those displayed on the GtkAccelLabel.

Note that the accelerators on the widget need to be unlocked beforethis method will work.

GtkWidget::lock_accelerators

void lock_accelerators(void);

lock_accelerators() locks any accelerators defined on the callingwidget - usually a GtkMenuItem - so that no further keys can beentered or existing keys removed or altered.

Note that if you do not lock your accelerators the end user will beable to define their own, whether any exist on that widget or not.

See also: unlock_accelerators() , accelerators_locked()

GtkWidget::unlock_accelerators

void unlock_accelerators(void);

unlock_accelerators() unlocks the accelerator entries defined in thecalling widget, allowing changes or additions to be made to them.

See also: lock_accelerators() , accelerators_locked()

GtkWidget::accelerators_locked

bool accelerators_locked(void);

accelerators_locked() returns true if the accelerators on the callingwidget are locked, and false if they are not.

See also: lock_accelerators() , unlock_accelerators()

GtkWidget::event

int event( GdkEvent event );

This method causes event to be triggered. This in turn causes thewidget to emit an appropriate signal.

Note: This is not the recommended method for triggering events. It isbetter to use main_do_event() because this ensures that the event isentered into the events queue.

GtkWidget::activate

bool activate(void);

Page 371: Apostila PHP GTK

GtkWidget::reparent

void reparent ( GtkWidget new_parent );

reparent() moves the calling widget from its current GtkContainer tothe new GtkContainer new_parent.

When called, reparent() will cause the "parent-set" signal to beemitted.

See also: reparent()

GtkWidget::popup

void popup(int x, int y);

GtkWidget::intersect

GdkRectangle intersect ( GdkRectangle area );

intersect() returns the rectangle consisting of the overlap of thearea taken up by the calling widget and area. This method could beuseful to determine if a use is trying to drag and drop a widget somewhere that they shouldn't.

If the two areas do not intersect false is return.

GtkWidget::grab_focus

void grab_focus(void);

This method sets the initial grab and focus on the calling widget sothat, for example, if a GtkText were to call it, any keyboard eventswould be picked up immediately by the text widget.

grab_focus() can only be called when the widget in question has theGTK_CAN_FOCUS flag set. Some will have this set at source, others willnot, and will generate an error message to that effect when the methodis called. Use set_flags() to override the source settings.

GtkWidget::grab_default

void grab_default(void);

This method sets the keyboard grab and default status on the callingwidget.

The single most likely scenario where you might use this would be toset up a GtkButton so that the user could activate it by immediatelypressing the return key.

In order to make this possible, you will need to set theGTK_CAN_DEFAULT widget flag on the button. See also: set_flags() .

Page 372: Apostila PHP GTK

GtkWidget::set_name

void set_name(string name);

You may give a widget a unique name. This is mainly intended for usewhen creating a derived object, but it can also be useful foridentifying individual widgets, for example, when an array of buttonsis going to be queried at a later point in the script.

See also: get_name() .

GtkWidget::get_name

string get_name(void);

This method returns the name of the calling widget. If no name hasbeen set for the widget, this will be in the format GtkWidget.

get_name() is very useful where the widget could be one of many, e.g.in a callback that is used by several different widgets.

See also: get_type, set_name() .

GtkWidget::set_state

void set_state( GtkStateType state );

Sets the initial GtkStateType for the calling widget. Note that thiswill be overridden when the user interacts with the widget, and isprimarily useful for offering visual cues.

A widget's current state can be queried using the state property.

See also: GtkStyle.

GtkWidget::set_sensitive

void set_sensitive(bool sensitive);

Use this function to toggle whether or not the user can interact witha widget. Setting it to false sets the widget's state toGTK_STATE_INSENSITIVE, which 'greys out' the widget.

You might use this if, for instance, you wanted to prevent a buttonfrom being pressed in certain situations.

Setting a container as 'insensitive' will make all that container'schildren insensitive too.

GtkWidget::set_app_paintable

void set_app_paintable(bool app_paintable);

GtkWidget::set_parent

Page 373: Apostila PHP GTK

void set_parent( GtkWidget container );

set_parent() sets container as the parent of the calling widget.container should be a subclass of GtkContainer.

When called, set_parent() will cause the "parent-set" signal to beemitted.

See also: reparent()

GtkWidget::set_parent_window

void set_parent_window( GdkWindow parent_window );

GtkWidget::get_parent_window

GdkWindow get_parent_window (void);

GtkWidget::set_uposition

void set_uposition(int x, int y);

set_uposition() sets the position of a child widget in pixels relativeto the top left corner of its container or, if the widget is atoplevel window, relative to the top left corner of the screen.

GtkWidget::set_usize

void set_usize(int width, int height);

set_usize() sets a widget's size in pixels. Sizing methods should onlybe called at one level of the packing hierarchy; you may need to sizeeither the container or its children, but doing both will createconflicts in the size requests made by child widgets internally, whichin turn can lead to unexpected results.

If you need either parameter to be ignored, use -1.

See also: GtkAlignment, and the packing methods supplied by GtkBox andGtkTable.

GtkWidget::set_events

void set_events( GdkEventMask events );

This method is used to set the GdkEventMask flags on a widget,extending the type of event that the widget can capture from itsdefault capabilities. You may need to do this, for instance, tocapture a key press event on a widget that does not normally capturesuch events.

set_events() can be used at any point in the widget's life-cycle.

Page 374: Apostila PHP GTK

Staying with the key-press example, the syntax would be:$widget->set_events(GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK); Thiswould enable a previously keyboard-insensitive widget to emit"key-press-event" and "key-release-event" signals.

GtkWidget::add_events

void add_events( GdkEventMask events );

This method is used to set the GdkEventMask flags on a widget,extending the type of event that the widget can capture from itsdefault capabilities. You may need to do this, for instance, tocapture a button press event on a widget that does not normallycapture such events.

add_events() can only be used after a widget has had realize() calledon it. Note that realization is a part of the show() routine as wellas being a method/signal pair in its own right.

Staying with the button-press example, the syntax would be:$widget->add_events(GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK);This would enable a previously mouse-insensitive widget to emit"button-press-event" and "button-release-event" signals.

GtkWidget::get_toplevel

GtkWidget get_toplevel (void);

GtkWidget::get_ancestor

GtkWidget get_ancestor (int widget_type);

GtkWidget::get_colormap

GdkColormap get_colormap (void);

GtkWidget::get_visual

GdkVisual get_visual (void);

GtkWidget::set_colormap

void set_colormap( GdkColormap colormap );

Sets the widget's colormap to colormap. The widget must not have beenrealized or shown before calling set_colormap() .

GtkWidget::set_visual

void set_visual( GdkVisual visual );

GtkWidget::get_events

int get_events(void);

Page 375: Apostila PHP GTK

GtkWidget::is_ancestor

bool is_ancestor( GtkWidget ancestor );

is_ancestor() tests whether the widget named in the ancestor parameteris an ancestor of the calling widget, in the packing hierarchy ratherthan in the GTK object hierarchy.

This method is used extensively in GTK+ internals, but can also beuseful in PHP-GTK, particularly for debugging purposes.

GtkWidget::hide_on_delete

int hide_on_delete(void);

GtkWidget::set_style

void set_style( GtkStyle style );

set_style() is used when some or all of the elements that make up anindividual widget's default style property are being overwritten by adifferent instance of a GtkStyle object.

See also: GtkStyle, copy() .

GtkWidget::set_rc_style

void set_rc_style(void);

GtkWidget::ensure_style

void ensure_style(void);

GtkWidget::get_style

GtkStyle get_style (void);

GtkWidget::restore_default_style

void restore_default_style(void);

GtkWidget::set_composite_name

void set_composite_name(string name);

GtkWidget::get_composite_name

string get_composite_name(void);

GtkWidget::reset_rc_styles

void reset_rc_styles(void);

Page 376: Apostila PHP GTK

GtkWidget::shape_combine_mask

void shape_combine_mask( GdkBitmap shape_mask , int offset_x, intoffset_y);

This method can be used to give widgets an unnormal shape, e.g. acircle or something angulary. You can use it with all types ofwidgets, e.g. buttons and even windows. But see yourself:

Exemplo 59. Making an unusual shaped button<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

$clickme = array("174 70 3 1"," c None",". c #000000","+ c #FFBA01"," +++++++++++++++++++++++++++++++++++++++++++++". ""," ++++++++++++++++++++++++++++++++++++++++++++++++++++". ""," +++++++++++++++++++++++++++++++++++++++++++++++++++++++++". ""," ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++". ""," ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++". ""," ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++". "+++++++++++++++++++++++++++++++++++++++++++++++"," +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++". "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++"," ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++". "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++","

Page 377: Apostila PHP GTK

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++". "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"," +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++". "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"," ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++". "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"," ++++++++++++++++++++++ +++++++++++++++++++++++++++++++". "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"," +++++++++++++++++++++ ++++++++++++++++++++++++++++++". "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"," ++++++++++++++++++++ ++++++++++++++++++++++++++++". "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "," ++++++++++++++++ ++++++++++++++++++++++++++". "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "," ++++++++++++++ +++++++++++++++". "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "," +++++++++++++ +++++++ ". " ++++++++++++++++++++++++++++++++++++++++ "," ++++++++++++". " ++++++++++++++++++++++++

Page 378: Apostila PHP GTK

++++++ "," +++++++++++". " ++++++++++++++++++++++++ "," +++++++++++". " +++++++++++++++++++++ "," +++++++++++". " +++++++++++++++++++ "," +++++++++++". " ++++++++++++++++++ "," +++++++++++". " ++++++++++++++++ ","++++++++++++". " +++++++++++++++ ","++++++++++++". " +++++++++++++++","++++++++++++". " ++++++++++++++","++++++++++++ .. .. ". " +++++++++++++","++++++++++++ ........ .... ... .... ". " +++++++++++++","+++++++++++ ........... .... ..... .... ". " ++++++++++++","+++++++++++ ............ .... ..... .... ". " ++++++++++++","+++++++++++ ............. .... ... .... ". " +++++++++++","+++++++++++ ....... ..... .... ..

Page 379: Apostila PHP GTK

... "

. " +++++++++++","+++++++++++ ...... .... .... ..... ". " +++++++++++","+++++++++++ ...... ... .... ..... ". " +++++++++++","+++++++++++ ..... .... ..... .". ".. .. +++++++++++","+++++++++++ ..... .... .. ....... ..... ..". "... .... ...... ...... ...... +++++++++++","+++++++++++ ..... .... .... .......... ..... ...". "... .... ................ .......... +++++++++++","+++++++++++ ..... .... .... ............ ..... ....". "... ..................... ............ +++++++++++","+++++++++++ .... .... .... ............. ..... .....". ".. ...................... ............. +++++++++++","+++++++++++ .... .... .... ..... ... ..... ......". ". ........ ....... ..... ...... ..... +++++++++++","+++++++++++ ..... .... .... ..... ............". " ....... ..... .... ..... ..... ++++++++++++","+++++++++++ .... .... .... ..... ........... ". " ...... .... .... .... ....... ++++++++++++","+++++++++++ .... .... .... ..... .......... ". " ..... .... .... .... ........ +++++++++++++","+++++++++++ .... .... .... ..... ........... ". " .... .... .... ............ ++++++++++++++","+++++++++++ .... .. .... .... .... ............". " .... .... ..... .......... ++++

Page 380: Apostila PHP GTK

++++++++++","++++++++++++ ..... ..... .... .... .... ...... .....". " .... ..... ..... ........ +++++++++++++ ","++++++++++++ ..... ...... .... .... .... .... ....". ". .... ..... ..... ...... +++++++++++++ ","+++++++++++++ ...... ........ .... .... ..... .. .... ....". ".. .... ..... ..... ..... ... +++++++++++++ ","++++++++++++++ ............... .... .... ...... ..... .... ...". "... .... .... .... ...... ..... +++++++++++++ ","+++++++++++++++ ............ .... .... .............. .... ..". "... .... .... .... ............... ++++++++++++ "," ++++++++++++++++ .......... .... .... ............. .... .". ".... .... .... .... ............. ++++++++++++ "," +++++++++++++++++ ..... .... .... .......... .... .". "... .... .... .... ........... +++++++++++++ "," +++++++++++++++++++ .. .. ...... .. ". "... .. ... ... ....... +++++++++++++ "," +++++++++++++++++++". " ++++++++++++++ "," ++++++++++++++++++++++". " +++++++++++++++++ "," +++++++++++++++++++++++++++++". " +++++++++++++++++++ "," +++++++++++++++++++++++++++++++++". " ++++++++++++++++++++++ "," ++++++++++++++++++++++++++++++++++++++++++++". " ++++++++++++++++++++++++++++++++ "," ++++++++++++++++++++++++++++++++++++++++++++++++++++++

Page 381: Apostila PHP GTK

". " +++++++++++++++++++++++++++++++++++++ "," ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++". "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "," ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++". "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "," +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++". "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "," +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++". "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"," ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++". "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"," ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++". "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"," ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++". "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"," +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++". "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"," +++++++++++++++++++++++++++++++++++++++++++++++++++++++". "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"," ++++++++++++++++++++++++++++++++++++++++++". "++++++++++++++++++++++++++++++++++++++++++++++++++++++

Page 382: Apostila PHP GTK

"," ++++++++++++++++++++++++++++++++". "++++++++++++++++++++++++++++++++++++++++++++++++");

$window = &new GtkWindow();$window->set_default_size( 200, 100);

$window->connect_object('destroy', array('gtk', 'main_quit'));$window->realize();

list($pixmap, $mask) = gdk::pixmap_create_from_xpm_d( $window->window, null, $clickme);

$btn = &new GtkButton( '');$btn->shape_combine_mask($mask, 5, 5);

$style = $btn->style;$style->bg[GTK_STATE_NORMAL] = new GdkColor( 'orange');$style->bg[GTK_STATE_PRELIGHT] = new GdkColor('#FF0000');$style->bg[GTK_STATE_ACTIVE] = new GdkColor('#00FF00');$btn->set_style( $style);

$window->add( $btn);

$window->show_all();gtk::main();?>

show

Função Callback

void callback(GtkWidget widget);

hide

Função Callback

void callback(GtkWidget widget);

map

Função Callback

void callback(GtkWidget widget);

unmap

Função Callback

void callback(GtkWidget widget);

Page 383: Apostila PHP GTK

realize

Função Callback

void callback(GtkWidget widget);

unrealize

Função Callback

void callback(GtkWidget widget);

draw

Função Callback

void callback(GtkWidget widget, );

draw-focus

Função Callback

void callback(GtkWidget widget);

draw-default

Função Callback

void callback(GtkWidget widget);

size-request

Função Callback

void callback(GtkWidget widget, );

size-allocate

Função Callback

void callback(GtkWidget widget, );

state-changed

Função Callback

void callback(GtkWidget widget, );

parent-set

Função Callback

void callback(GtkWidget widget, GtkWidget parent);

Page 384: Apostila PHP GTK

style-set

Função Callback

void callback(GtkWidget widget, );

add-accelerator

Função Callback

void callback(GtkWidget widget);

remove-accelerator

Função Callback

void callback(GtkWidget widget);

grab-focus

Função Callback

void callback(GtkWidget widget);

event

The "event" signal is emitted when any GdkEvent is captured by theconnected widget's underlying GdkWindow.

All event signals return false until the event has been propagated tothe widget that will handle it, at which point they return true, theevent is no longer propagated and the signal is no longer fired.

Each event causes two signal emissions; the generic event signaldescribed here, and the specific event signal that is being called,such as the "key-press-event" signal. The "event" signal itself isunlikely to be used directly on its own account very often.

All event signals carry the event that caused the signal to be firedas the first parameter after the connecting widget. You may add asmany parameters as you like that contain data specific to yourapplication.

You can limit or extend the events that are captured by a windowedwidget by setting one or more GdkEventMask flags for the widget. Seeadd_events() , and set_events() .

Função Callback

bool callback(GtkWidget widget, GdkEvent event);

button-press-event

Page 385: Apostila PHP GTK

This is an event signal, fired when the connected widget picks up aGDK_BUTTON_PRESS event. Button press events are generated by any ofthe mouse buttons being pressed. You can distinguish between the mousebuttons in the callback by using an if or switch statement:

<?phpfunction on_click($widget, $event, $data){switch($event->button) {case 1:/* do something appropriate to a left click */break;case 2:/* do something appropriate to a middle click */break;case 3:/* do something appropriate to a right click */break;}}

$widget->connect('button-press-event', 'on_click', $data);?>

See also: "button-release-event", "event", "key-press-event".

Função Callback

bool callback(GtkWidget widget, GdkEvent button_press);

button-release-event

This is an event signal, fired when the connected widget picks up aGDK_BUTTON_RELEASE event. Button release events are generated by anyof the mouse buttons being released. You can distinguish between themouse buttons in the callback by using $event->button.

See also: "button-press-event", "event", "key-press-event".

Função Callback

bool callback(GtkWidget widget, GdkEvent button_release);

motion-notify-event

This is an event signal, fired when the connected widget picks up aGDK_MOTION_NOTIFY event. Motion notify events are triggered when themouse pointer moves across the screen. There are a great many of them,which has given rise to several different kinds of GdkEventMask aimingto minimise the amount that are captured.

See also: "event".

Função Callback

Page 386: Apostila PHP GTK

bool callback(GtkWidget widget, GdkEvent motion_notify);

delete-event

This is an event signal, fired when the window manager requests that awidget be deleted. This is generally when a user clicks the X closebutton on a toplevel window.

The delete event is not propagated. If you want to prevent the enduser from using the window decorations to close your application,returning true from the "delete-event" signal will do just that.Allowing it to return false - which it does by default - will causeits default handler to be called. This happens to be the destroy()method, which in turns fires the "destroy" signal. In most cases, it'ssimpler to connect directly to the latter.

See also: "event".

Função Callback

bool callback(GtkWidget widget, GdkEvent delete);

destroy-event

You really shouldn't ever find a widget that emits this signal. Thedestroy event is triggered by the destruction of a widget's underlyingGdkWindow, so if that widget is still capable of emitting the"destroy-event" signal something has gone badly awry.

See also: "delete-event", "event".

Função Callback

bool callback(GtkWidget widget, GdkEvent destroy);

expose-event

This is an event signal, initially emitted when the connected widgetbecomes fully visible on screen. Every widget can capture exposeevents; they are even synthesized for widgets that don't have aGdkWindow.

Expose events are also generated when a widget has been partially orfully covered by another widget, and is re-exposed. These eventstrigger a redraw internally; a GdkWindow that is not currently exposedis not currently drawn, and the same applies to any unexposed area ofa window.

Following suit, the most likely reason to connect to an "expose-event"signal is that you have a drawing function in the callback.

See also: "event", GtkDrawingArea, GdkWindow, and the numerous GTK andGDK drawing functions filed under 'Misc'.

Page 387: Apostila PHP GTK

Função Callback

bool callback(GtkWidget widget, GdkEvent expose);

key-press-event

This is an event signal, fired when the connected widget picks up aGDK_KEY_PRESS event. Key press events are generated by any of the keyson a keyboard being pressed. You can distinguish between the keyvalues in the callback using an if or switch statement:

<?phpfunction on_click($widget, $event, $data){if($event->keyval==GDK_KEY_Return) {/*do something appropriate for the return key being pressed*/} elseif($event->keyval > GDK_KEY__a) {/*we can reach the character strings, too*/echo $event->string."\n";}}?>

Yes, we have hard-coded keysyms. The full list of PHP-GTK keysymbolconstants is in the source code in the filephp-gtk/ext/gtk+/php_gdk.c.

Função Callback

bool callback(GtkWidget widget, GdkEvent key_press);

key-release-event

Função Callback

bool callback(GtkWidget widget, GdkEvent key_release);

enter-notify-event

Função Callback

bool callback(GtkWidget widget, GdkEvent enter_notify);

leave-notify-event

Função Callback

bool callback(GtkWidget widget, GdkEvent leave_notify);

configure-event

Função Callback

Page 388: Apostila PHP GTK

bool callback(GtkWidget widget, GdkEvent configure);

focus-in-event

Função Callback

bool callback(GtkWidget widget, GdkEvent focus_change);

focus-out-event

Função Callback

bool callback(GtkWidget widget, GdkEvent focus_change);

map-event

Função Callback

bool callback(GtkWidget widget, GdkEvent map);

unmap-event

Função Callback

bool callback(GtkWidget widget, GdkEvent unmap);

property-notify-event

Função Callback

bool callback(GtkWidget widget, GdkEvent property_notify);

selection-clear-event

Função Callback

bool callback(GtkWidget widget, GdkEvent selection_clear);

selection-request-event

Função Callback

bool callback(GtkWidget widget, GdkEvent selection_request);

selection-notify-event

Função Callback

bool callback(GtkWidget widget, GdkEvent selection_notify);

selection-received

Função Callback

Page 389: Apostila PHP GTK

void callback(GtkWidget widget, , );

selection-get

Função Callback

void callback(GtkWidget widget, , , );

proximity-in-event

Função Callback

bool callback(GtkWidget widget, GdkEvent proximity_in);

proximity-out-event

Função Callback

bool callback(GtkWidget widget, GdkEvent proximity_out);

drag-begin

Função Callback

void callback(GtkWidget widget, );

drag-end

Função Callback

void callback(GtkWidget widget, );

drag-data-delete

Função Callback

void callback(GtkWidget widget, );

drag-motion

This signal is emitted when the "loaded" mouse cursor (draggingsomething) is moved over the widget, which accepts the data the cursorcarries.

Função Callback

bool callback( GtkWidget widget , GdkDragContext context , int x, inty, int time);

drag-leave

When a "loaded" (dragging) mouse moves away (leaves) the currentwidget it entered before (signaled by "drag-motion"), this signal isemitted. It can be used to self-un-highlight the widget, restoring it

Page 390: Apostila PHP GTK

to the normal state.

Função Callback

void callback( GtkWidget widget , GdkDragContext context , int time);

drag-drop

Função Callback

bool callback(GtkWidget widget, , , , );

drag-data-get

This signal is emitted when the user has dragged something from onewidget and dropped it onto another widget. The data to be transferredfrom one to another widget is requested via this signal.

To set the data, use the set() function of the selection.

Exemplo 60. Passing drag data to the drop targetfunction dnd_drag_data_get($widget, $context, $selection_data, $info, $time){$dnd_string = "Perl is the only language that looks\nthe same before and after RSA encryption";$selection_data->set($selection_data->target, 8, $dnd_string);}

Função Callback

void callback( GtkWidget widget , GdkDragContext context ,GtkSelectionData selection_data , int info, int time);

drag-data-received

This signal is emitted when the user has dropped drag data over thewidget.

Função Callback

void callback( GtkWidget widget , GdkDragContext context , int x, inty, GtkSelectionData data , int info, int time);

visibility-notify-event

Função Callback

bool callback( GtkWidget widget , GdkEvent visibility_notify );

client-event

Função Callback

bool callback(GtkWidget widget, GdkEvent client_event);

Page 391: Apostila PHP GTK

no-expose-event

Emitted when a GDK_NO_EXPOSE event is captured.

Função Callback

bool callback(GtkWidget widget, GdkEvent no_expose);

debug-msg

Função Callback

void callback(GtkWidget widget, );

GtkWidget::style

Access: Read OnlyType: GtkStyle

GtkWidget::window

Access: Read OnlyType: GdkWindow

GtkWidget::allocation

Access: Read OnlyType: GtkAllocation

GtkWidget::state

Access: Read OnlyType: GtkStateType

GtkWidget::parent

Access: Read OnlyType: GtkWidget

The widget's parent must be derived from GtkContainer.

GtkWindow

Widget that provides windows for an application.

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkWindow

Page 392: Apostila PHP GTK

Direct subclasses

GtkColorSelectionDialog, GtkDialog, GtkFileSelection,GtkFontSelectionDialog, GtkPlug

Descrição

GtkWindow is the widget providing the windows for an application.There are three different types, defined by the programmer duringconstruction - toplevel, dialog or popup.

Toplevel windows contain the standard window decorations minimize,maximize and close. Of these, the first two exhibit the expecteddefault behaviour; this is pre-set within the GDK source, andcannot currently be altered from within PHP-GTK. The close buttonis not pre-set in same way, in that its emission of the "destroy"signal can be overridden by connecting a function to the window's"delete-event" signal and having that function return true. Notethat the main window's "destroy" signal should be connected,directly or otherwise, to a function that will quit the GTK mainloop.

A dialog window is not the same thing as a GtkDialog, but is simplya normal toplevel window with the maximize function disabled. Bothdialog and popup windows are designed to be used when a message tothe user requires a response, and should be used in conjunctionwith the set_transient_for() and set_modal() methods.

A popup window lacks any window decoration, so needs an alternativemeans of closure. This could triggered by a timer, an event, or awidget capable of user interaction.

Note that both the window decorations and the associated functionsdescribed above are provided by the underlying system's windowmanager, and could possibly vary or be absent.

A GtkWindow object is derived from GtkBin, and can therefore only haveone child widget added to it directly. To add more children it isnecessary to make that child a container that can hold mulitplechildren. See GtkBox.

There is no clean way to maximize a window in php-gtk 1. You onlycan use the following workaround:

$window->set_usize(gdk::screen_width(),gdk::screen_height());

This leads to the problem that the size of task bars are notrespected; so you shouldn't do that. For Windows you can use an APIcall:

dl("php_w32api.dll");$api =& new win32;define('SW_MAXIMIZE',3);define('SW_MINIMIZE',6);

Page 393: Apostila PHP GTK

//register windows functions$api->registerfunction("long GetLastError Alias GetError () From kernel32.dll");$api->registerfunction("long FindWindow (string &ClassName, string &WindowName)From user32.dll");$api->registerfunction("long ShowWindow (long hWnd, long nCmdShow) From user32.dll");

$window =& new GtkWindow();$window->set_title('PHP Test');$window->show();$class_string = 'gdkWindowToplevel';$title_string = 'PHP Test';if(!$sw = $api->FindWindow($class_string,$title_string)){$error = $api->getError();echo ' Oops FindWindow error: '.$error."\n";}else{$api->ShowWindow($sw,SW_MAXIMIZE);}

You still have to take care only to call these functions when thephp-gtk application is running on Windows.

If you need to set the window cursor, you should have look atGdkWindow.

Construtor

GtkWindow ([ GtkWindowType type = GTK_WINDOW_TOPLEVEL ]);

-- Creates a new GtkWindow.

Métodos

set_title()Sets window title.

set_wmclass()Sets window manager class and name.

set_policy()Sets window resizing policy. *deprecated in GTK2*

add_accel_group()Associates accelerator group with window.

remove_accel_group()Removes associated accelerator group from window.

set_position()Sets screen position of window.

activate_focus()

Page 394: Apostila PHP GTK

Activates child that currently has focus.

activate_default()Activates child currently set as default.

set_transient_for()Sets window as transient for the given parent.

set_default_size()Sets default window size.

set_modal()Toggles window modality.

set_focus()Gives child widget focus.

set_default()Sets child widget as default.

Sinais

"set-focus"Emitted when set_focus() is called.

GtkWindow Construtor

GtkWindow ([ GtkWindowType type = GTK_WINDOW_TOPLEVEL ]);

Creates a new GtkWindow which is toplevel by default. Most of theother widgets in PHP-GTK need to have a window constructed and to beadded to that window (or a container within that window) before theycan be instantiated. There are exceptions, such as GtkDialog andGtkColorSelectionDialog; these are compound widgets which are alreadybased upon their own internal instance of a GtkWindow.

As the GtkWindow is such a fundamental object in the design ofwindowed applications, there follows a brief code sample to reiteratethe essential basic steps in creating any PHP-GTK script:<?php

/*load the php_gtk module*/dl('php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')) ||die("Can't load php_gtk module!\n");

/*create the main window*/$window = &new GtkWindow();

/*ensure that the destruction of the main window also kills the main loop*/$window->connect_object('destroy', array('gtk', 'main_quit'));

/*realize the underlying GdkWindow, flag the GtkWindow's visibility and mapit onto the screen, all in one simple line*/$window->show();

Page 395: Apostila PHP GTK

/*without the main loop, there is no PHP-GTK script*/gtk::main();

?>

GtkWindow::set_title

void set_title(string title);

Sets the title shown in the window's title bar, and also in the taskbar icon for the window when it is minimized. The text is truncated tothe width of the window.

Either single or double quotation marks may be used to contain thestring. Note that any apostrophes will need to be escaped with abackslash if single quotation marks are used.

GtkWindow::set_wmclass

void set_wmclass(string wmclass_name, string wmclass_class);

Sets the window manager name and class across an application. However,given that the window manager class is already set in precisely thisway by GTK, and that there are no functions in PHP-GTK where we mightneed this information, this method is best left untouched.

GtkWindow::set_policy

void set_policy(int allow_shrink, int allow_grow, int auto_shrink);

The default policy on a GtkWindow is false, true, false, which retainsthe default size of the window on opening and allows the user toresize it thereafter.

allow_shrink when set to true allows the window to be smaller than itschild's size requisition, which has the effect of truncating thechild. For this reason, it should always be set to false.

allow_grow when set to true allows the window to be expanded beyondits initial size. The default behaviour of the child is to expand withthe window, in most cases. Setting the allow_grow parameter to falseprevents such resizing, taking the requisition size of the window'schild as the window's base size.

auto_shrink when set to true overrides the window's default sizesetting, and shrinks or expands the window to fit the child'srequisition size if the second parameter hasn't already done so.

Basically the only reason to use this method is likely to be when youdon't want the window to be user-resizable. In this case, the settingyou should use is false, false, true, or alternatively false, false,false which will have the same effect due to the redundancy of thethird parameter here.

Page 396: Apostila PHP GTK

This method has been deprecated in GTK 2.0 in favour of a new and moreefficient method. It would be wise to bear this in mind and useset_policy() sparingly.

GtkWindow::add_accel_group

void add_accel_group( GtkAccelGroup accel_group );

Adds an existing GtkAccelGroup to the window, allowing keyboardshortcuts to be created - usually for menus.

GtkWindow::remove_accel_group

void remove_accel_group( GtkAccelGroup accel_group );

Removes the named accelerator group from the window.

GtkWindow::set_position

void set_position( GtkWindowPosition position );

set_position() sets the position of the window on opening to one offour possible GtkWindowPosition values.

GtkWindow::activate_focus

int activate_focus(void);

activate_focus() is a method that will emit the activate signal fromthe child widget having focus at the point that the method is called.In GTK+, each widget has one signal which has activate signal status;the signal with this status has the ability to respond to eventsgenerated from the keyboard. If you do not have that widget-specificactivate signal connected to the widget with focus, nothing will befired.

The widget that is most likely to be used in this situation isprobably GtkButton, which has "clicked" as its activate signal.

If this method is part of a callback called from another widget, thatwidget will have focus at the time that the callback is run and PHPwill - understandably - crash. It needs to be called from an eventsignal in order to work.

See also: Signals and Events in the PHP-GTK userguide,activate_default() , set_focus() , "activate".

GtkWindow::activate_default

int activate_default(void);

As with activate_focus() , the activate_default() method causes thewidget-specific activate signal to be emitted by the targeted child.

Page 397: Apostila PHP GTK

See also: activate_focus() , set_default() , "activate".

GtkWindow::set_transient_for

void set_transient_for( GtkWindow parent );

set_transient_for() is used to set a dialog or popup window as atemporary child of the toplevel window it is associated with. Thisprevents there being an additional icon for the transient message inthe taskbar, and also allows the transient window to take on thebehaviour of the parent window, e.g. if the parent is minimized thechild will minimize along with it.

This method does not work in the win32 version of GTK+ currently usedby PHP-GTK, but as the bug causing the problem has now been fixed inGnome CVS it would be sensible to use it.

Attempting to delete the parent window before destroying the transientwindow produces a gdk warning on win32. To avoid this, always useset_modal() where you have used set_transient_for() .

GtkWindow::set_default_size

void set_default_size(int width, int height);

set_default_size() sets the default opening size of a window, inpixels. This can be overridden by size requests from the window'schild widget exceeding the default size of the window, or by activelysetting the resizing policy of the window so that the window alwaysshrink-wraps its child.

Note that a smaller child widget whose size has not been set orotherwise restricted by the programmer will generally expand to fitthe default size of the parent window.

GtkWindow::set_modal

void set_modal(bool modal);

set_modal() is used to prevent the other windows in an applicationfrom reacting to user activity until the modal window has had anappropriate user response. It is usually used where dialog or popupwindows are acting as message boxes.

A similar effect can be achieved with most widgets by using the staticfunction gtk::grab_add() ; however note that set_modal() is a slightlymore complex method and is equipped to deal more fully with thescenarios likely to arise when using modal windows.

GtkWindow::set_focus

void set_focus( GtkWidget focus );

Page 398: Apostila PHP GTK

set_focus() sets the focus to the child widget passed as theparameter. The child must have the flag GTK_CAN_FOCUS set in order tobe allowed focus. Some widgets are created with this flag already set(including the GtkButton widget), others are not.

See also: GtkWidgetFlags, GtkWidget, set_flags() .

GtkWindow::set_default

void set_default( GtkWidget defaultw );

set_default() sets the child widget passed to it as the default child.(This will usually be a GtkButton.) The child must have the flagGTK_CAN_DEFAULT set in order to be allowed focus. Some widgets arecreated with this flag already set; GtkButton is not one of thosewidgets, and needs to be flagged.

Child widgets that are set as default are marked as such in a way thatwill be familiar to users. For instance, a button set as default has adecorative frame and shadow around it.

See also: GtkWidgetFlags, GtkWidget, set_flags() .

set-focus

The "set-focus" signal is emitted by the GtkWindow in response to aset_focus() method call, which is triggered each time the child havingfocus within that window changes, that is, every time the user choosesa different child widget.

The signal is primarily for internal GTK use.

Função Callback

void callback( GtkWindow window , GtkWidget child_widget );

GTK Functions

GTK functions not belonging to any class.

gtk::accel_group_get_default()

Gets the toplevel window's default GtkAccelGroup.

gtk::button_box_set_child_ipadding_default()Sets GtkButtonBox default child internal padding.

gtk::button_box_set_child_size_default()Sets GtkButtonBox default minimum child size.

gtk::check_version()Checks which version of GTK+ is being used.

gtk::drag_finish()

Page 399: Apostila PHP GTK

gtk::drag_get_source_widget()

gtk::drag_set_default_icon()

gtk::drag_set_icon_default()

gtk::drag_set_icon_pixmap()

gtk::drag_set_icon_widget()

gtk::drag_dest_handle_event()

gtk::drag_source_handle_event()

gtk::draw_arrow()Draws an arrow.

gtk::draw_box()Draws a box.

gtk::draw_diamond()

gtk::draw_hline()

gtk::draw_oval()Not implemented.

gtk::draw_shadow()

gtk::draw_string()Draws text in a given GdkWindow

gtk::draw_vline()Draws a vertical line in a given GdkWindow

gtk::entry_new_with_max_length()Creates a limited-character GtkEntry.

gtk::events_pending()Tests whether there are GdkEvents queueing.

gtk::false()

Page 400: Apostila PHP GTK

Returns false.

gtk::hbutton_box_get_layout_default()Returns GtkHButtonBox layout default.

gtk::hbutton_box_get_spacing_default()Returns GtkHButtonBox spacing default.

gtk::grab_add()Endows a widget with keyboard grab.

gtk::grab_get_current()Returns widget that currently has keyboard grab.

gtk::grab_remove()Removes keyboard grab from a widget.

gtk::hbutton_box_set_layout_default()Sets layout default for GtkHButtonBoxes.

gtk::hbutton_box_set_spacing_default()Sets spacing default for GtkHButtonBoxes.

gtk::idle_add()Causes the mainloop to call a function whenever no events are to beprocessed.

gtk::idle_remove()Removes the idle function with the given id.

gtk::input_add()

gtk::input_remove()

gtk::item_factories_path_delete()

gtk::item_factory_from_path()

gtk::item_factory_from_widget()Get the GtkItemFactory that created a widget

gtk::item_factory_parse_rc()

gtk::item_factory_parse_rc_string()

gtk::item_factory_path_from_widget()

Page 401: Apostila PHP GTK

gtk::main()Runs the main loop.

gtk::main_do_event()Processes a single GdkEvent.

gtk::main_iteration()Runs the main loop once and then blocks GTK until an event ispending.

gtk::main_iteration_do()Runs the main loop once, with optional blocking.

gtk::main_level()Returns the main loop nesting level.

gtk::main_quit()Quits the main loop.

gtk::paint_arrow()

gtk::paint_box()

gtk::paint_box_gap()

gtk::paint_check()

gtk::paint_cross()

gtk::paint_diamond()

gtk::paint_extension()

gtk::paint_flat_box()Paints a flat box.

gtk::paint_focus()A quick way to draw focus-like shadow around a given rectangle.

gtk::paint_handle()

gtk::paint_hline()

gtk::paint_option()

Page 402: Apostila PHP GTK

gtk::paint_oval()Not implemented.

gtk::paint_ramp()

gtk::paint_shadow()

gtk::paint_shadow_gap()

gtk::paint_slider()

gtk::paint_string()

gtk::paint_tab()

gtk::paint_vline()

gtk::preview_get_cmap()

gtk::preview_get_visual()

gtk::preview_reset()

gtk::preview_set_color_cube()

gtk::preview_set_gamma()

gtk::preview_set_install_cmap()

gtk::preview_set_reserved()

gtk::quit_add()Register a function to be called when a main loop level is exited.

gtk::quit_remove()Unregister a function from being called when a main loop level isexited.

gtk::rc_add_default_file()

Page 403: Apostila PHP GTK

Add a file to the list of files to be parsed at the end ofgtk_init().

gtk::rc_get_module_dir()Return the directory that PHP-GTK looks for theme engines in.

gtk::rc_get_style()Return the GtkStyle that will be applied to the widget.

gtk::rc_parse()Parses an application's rc file(s).

gtk::rc_parse_string()Parse resource information directly from a string.

gtk::rc_reparse_all()Reparse all of an application's rc files.

gtk::timeout_add()Sets up a function to be called at regular intervals.

gtk::timeout_remove()Removes timeout.

gtk::true()Returns true.

gtk::type_from_name()Returns object type from object name.

gtk::type_name()Returns name of object.

gtk::vbutton_box_get_layout_default()Returns GtkVButtonBox layout default.

gtk::vbutton_box_get_spacing_default()Returns GtkVButtonBox spacing default.

gtk::vbutton_box_set_layout_default()Sets layout default for GtkVButtonBoxes.

gtk::vbutton_box_set_spacing_default()Sets spacing default for GtkVButtonBoxes.

gtk::widget_get_default_colormap()Returns the application's default GdkColormap.

gtk::widget_get_default_style()Returns the application's default GtkStyle.

gtk::widget_get_default_visual()Returns the application's default GdkVisual.

Page 404: Apostila PHP GTK

gtk::widget_pop_colormap()

gtk::widget_pop_composite_child()

gtk::widget_pop_style()

gtk::widget_pop_visual()

gtk::widget_push_colormap()

gtk::widget_push_composite_child()

gtk::widget_push_style()

gtk::widget_push_visual()

gtk::widget_set_default_colormap()Sets a GdkColormap as default for the application.

gtk::widget_set_default_style()Sets a GtkStyle as default for the application.

gtk::widget_set_default_visual()Sets a GdkVisual as default for the application.

gtk::accel_group_get_default

GtkAccelGroup gtk::accel_group_get_default (void);

gtk::button_box_set_child_ipadding_default

void gtk::button_box_set_child_ipadding_default (int ipad_x, intipad_y);

gtk::button_box_set_child_size_default

void gtk::button_box_set_child_size_default (int min_width, intmin_height);

gtk::check_version

string gtk::check_version(int required_major, int required_minor, intrequired_micro);

gtk::drag_finish

Page 405: Apostila PHP GTK

void gtk::drag_finish( GdkDragContext context , bool success, booldel, int time);

gtk::drag_get_source_widget

GtkWidget gtk::drag_get_source_widget ( GdkDragContext context );

gtk::drag_set_default_icon

void gtk::drag_set_default_icon( GdkColormap colormap , GdkPixmappixmap , GdkBitmap mask , int hot_x, int hot_y);

gtk::drag_set_icon_default

void gtk::drag_set_icon_default( GdkDragContext context );

gtk::drag_set_icon_pixmap

void gtk::drag_set_icon_pixmap( GdkDragContext context , GdkColormapcolormap , GdkPixmap pixmap , GdkBitmap mask , int hot_x, int hot_y);

gtk::drag_set_icon_widget

void gtk::drag_set_icon_widget( GdkDragContext context , GtkWidgetwidget , int hot_x, int hot_y);

gtk::drag_dest_handle_event

void gtk::drag_dest_handle_event( GtkWidget toplevel , GdkEvent event);

gtk::drag_source_handle_event

void gtk::drag_source_handle_event ( GtkWidget widget , GdkEvent event);

gtk::draw_arrow

void gtk::draw_arrow( GtkStyle style , GdkWindow window , GtkStateTypestate_type , GtkShadowType shadow_type , GtkArrowType arrow_type ,bool fill, int x, int y, int width, int height);

The chief advantage of drawing your own GTK arrow rather than usingthe GtkArrow widget is that you can shape it, using the width andheight parameters. The fill parameter refers to the color of thearrow, with false giving it the same color as the area it is drawnonto. All positions and sizes are absolute in terms of the underlyingdrawable.

gtk::draw_arrow($style, $gdkwindow, GTK_STATE_NORMAL, GTK_SHADOW_OUT,GTK_ARROW_RIGHT, false, $x, $y, $width, $height);

gtk::draw_box

Page 406: Apostila PHP GTK

void gtk::draw_box( GtkStyle style , GdkWindow window , GtkStateTypestate_type , GtkShadowType shadow_type , int x, int y, int width, intheight);

This is the simplest way to draw a box, with or without a shadow. Anycoloring is completely dependant on the GtkStyle that is passed as thefirst parameter.

gtk::draw_box($style, $gdkwindow, GTK_STATE_ACTIVE, GTK_SHADOW_IN, $x,$y, $width, $height);

gtk::draw_diamond

void gtk::draw_diamond( GtkStyle style , GdkWindow window ,GtkStateType state_type , GtkShadowType shadow_type , int x, int y,int width, int height);

gtk::draw_hline

void gtk::draw_hline( GtkStyle style , GdkWindow window , GtkStateTypestate_type , int x1, int x2, int y);

See also: draw_vline

gtk::draw_oval

void gtk::draw_oval( GtkStyle style , GdkWindow window , GtkStateTypestate_type , GtkShadowType shadow_type , int x, int y, int width, intheight);

gtk::draw_shadow

void gtk::draw_shadow( GtkStyle style , GdkWindow window ,GtkStateType state_type , GtkShadowType shadow_type , int x, int y,int width, int height);

gtk::draw_string

void gtk::draw_string( GtkStyle style , GdkWindow window ,GtkStateType state_type , int x, int y, string string);

Draws string in window. style is used to set the style of the text tobe written. The upper left hand corner of string will begin x pixeslfrom the left edge of window and y pixels from the top of window.

gtk::draw_vline

void gtk::draw_vline( GtkStyle style , GdkWindow window , GtkStateTypestate_type , int y1, int y2, int x);

Draws a vertical line in window. The line will be x pixels from theleft edge of window, start y1 pixels from the top edge of window, andend y2 pixels from the top edge of window. style will be used todefine the style of the line.

Page 407: Apostila PHP GTK

gtk::entry_new_with_max_length

GtkWidget gtk::entry_new_with_max_length (int max);

gtk::events_pending

int gtk::events_pending(void);

gtk::events_pending() is useful when there is a function that needs tobe carried out during a long-running process, for example, updating astatus bar during an SQL query.

The way it would be used in such a situation is to have<?php

while(gtk::events_pending()) gtk::main_iteration();

?>

after every update that is made to the GUI. This causes the main loopto run once each time events are anticipated.

See also: gtk::main_iteration() , gtk::main_iteration_do() ,gtk::timeout_add() .

gtk::false

int gtk::false(void);

A static function that simply returns false. By default this is null;you can force a 0 return by declaring it as a PHP (int) type.

gtk::hbutton_box_get_layout_default

GtkButtonBoxStyle gtk::hbutton_box_get_layout_default (void);

gtk::hbutton_box_get_spacing_default

int gtk::hbutton_box_get_spacing_default (void);

gtk::grab_add

void gtk::grab_add( GtkWidget widget );

gtk::grab_get_current

GtkWidget gtk::grab_get_current (void);

Returns the widget which currently has the keyboard grab. NULL isreturned if there is no active grab.

Widgets can grab the pointer and keyboard away from other widgets.This essentially means that the widget becomes "modal"; input goes

Page 408: Apostila PHP GTK

only to that widget, and the focus can't be changed to another widget.A typical reason to grab input is to create a modal dialog; if awindow has the grab, interaction with other windows is blocked.

gtk::grab_remove

void gtk::grab_remove( GtkWidget widget );

Removes the keyboard grab from the given widget.

If you don't know what a grab is, have a look at grab_get_currentfunction.

gtk::hbutton_box_set_layout_default

void gtk::hbutton_box_set_layout_default ( GtkButtonBoxStyle layout );

gtk::hbutton_box_set_spacing_default

void gtk::hbutton_box_set_spacing_default (int spacing);

gtk::idle_add

int gtk::idle_add( GtkFunction function , [mixed data ]);

Causes the mainloop to call the given function whenever no events withhigher priority are to be processed.

The returned number is an unique handle which you should keep savedsomewhere for the case you want to remove the idle function.

gtk::idle_remove

void gtk::idle_remove(int idle_handler_id);

Removes the idle function with the given idle_handler_id. You get thisid when adding an idle function

gtk::input_add

XXX gtk::input_add(XXX);

gtk::input_remove

void gtk::input_remove(int input_handler_id);

gtk::item_factories_path_delete

void gtk::item_factories_path_delete (string ifactory_path, stringpath);

gtk::item_factory_from_path

GtkItemFactory gtk::item_factory_from_path (string path);

Page 409: Apostila PHP GTK

gtk::item_factory_from_widget

GtkItemFactory gtk::item_factory_from_widget ( GtkWidget widget );Returns the GtkWidgetFactory that created widget.

gtk::item_factory_parse_rc

void gtk::item_factory_parse_rc(string file_name);

gtk::item_factory_parse_rc_string

void gtk::item_factory_parse_rc_string (string rc_string);

gtk::item_factory_path_from_widget

string gtk::item_factory_path_from_widget ( GtkWidget widget );

gtk::main

void gtk::main(void);

gtk::main_do_event

void gtk::main_do_event( GdkEvent event );

gtk::main_iteration

int gtk::main_iteration(void);

Runs the main loop once (e.g. updates the GUI) and blocks until anevent is pending.

This is useful during long-running functions which block the wholeapplication. Have a look at the example at events_pending.

gtk::main_iteration_do

int gtk::main_iteration_do([bool blocking = TRUE ]);

Runs the main loop once, with optional blocking.

gtk::main_level

int gtk::main_level(void);

gtk::main_quit

void gtk::main_quit(void);

gtk::paint_arrow

void gtk::paint_arrow( GtkStyle style , GdkWindow window ,GtkStateType state_type , GtkShadowType shadow_type , GdkRectangle

Page 410: Apostila PHP GTK

area, GtkWidget widget , string detail, GtkArrowType arrow_type , boolfill, int x, int y, int width, int height);

gtk::paint_box

void gtk::paint_box( GtkStyle style , GdkWindow window , GtkStateTypestate_type , GtkShadowType shadow_type , GdkRectangle area, GtkWidgetwidget , string detail, int x, int y, int width, int height);

gtk::paint_box_gap

void gtk::paint_box_gap( GtkStyle style , GdkWindow window ,GtkStateType state_type , GtkShadowType shadow_type , GdkRectanglearea, GtkWidget widget , string detail, int x, int y, int width, intheight, GtkPositionType gap_side , int gap_x, int gap_width);

gtk::paint_check

void gtk::paint_check( GtkStyle style , GdkWindow window ,GtkStateType state_type , GtkShadowType shadow_type , GdkRectanglearea, GtkWidget widget , string detail, int x, int y, int width, intheight);

gtk::paint_cross

void gtk::paint_cross( GtkStyle style , GdkWindow window ,GtkStateType state_type , GtkShadowType shadow_type , GdkRectanglearea, GtkWidget widget , string detail, int x, int y, int width, intheight);

gtk::paint_diamond

void gtk::paint_diamond( GtkStyle style , GdkWindow window ,GtkStateType state_type , GtkShadowType shadow_type , GdkRectanglearea, GtkWidget widget , string detail, int x, int y, int width, intheight);

gtk::paint_extension

void gtk::paint_extension( GtkStyle style , GdkWindow window ,GtkStateType state_type , GtkShadowType shadow_type , GdkRectanglearea, GtkWidget widget , string detail, int x, int y, int width, intheight, GtkPositionType gap_side );

gtk::paint_flat_box

void gtk::paint_flat_box( GtkStyle style , GdkWindow window ,GtkStateType state_type , GtkShadowType shadow_type , GdkRectanglearea, GtkWidget widget , string detail, int x, int y, int width, intheight);

Regardless of the GtkShadowType detailed here, the effect is similarto the box drawn using gtk::draw_box() and GTK_SHADOW_NONE.

Page 411: Apostila PHP GTK

The GdkRectangle used should be in the same position and have the samedimensions as those passed in the function, as otherwise only theoverlap between the two rectangles will be displayed, or nothing atall if there is no overlapping area. The detail parameter actuallydoes nothing here, but is needed for back compatibility. Passing it asnull, or as any string you feel, is okay.

$rectangle = &new GdkRectangle($x, $y, $width, $height);gtk::paint_flat_box($style, $gdkwindow, GTK_STATE_ACTIVE, GTK_SHADOW_NONE,$rectangle, $drawingarea, null, $x, $y, $width, $height);

gtk::paint_focus

void gtk::paint_focus( GtkStyle style , GdkWindow window ,GdkRectangle area, GtkWidget widget , string detail, int x, int y, intwidth, int height);

gtk::paint_focus() is a convenience function that draws a dark shadowalong the left and top sides of the given rectangle, making it appearas GTK widgets generally do when they have focus.

This is the only function that uses the detail parameter at all now;if you pass 'set-mode' as that parameter, the shadow will appear aslong dashes rather than as a continuous line. Any other string isregarded the same as if it were null.

The other parameters are on the whole self-explanatory. The widgetparameter refers to the widget that is being drawn upon (usually aGtkDrawingArea).

gtk::paint_handle

void gtk::paint_handle( GtkStyle style , GdkWindow window ,GtkStateType state_type , GtkShadowType shadow_type , GdkRectanglearea, GtkWidget widget , string detail, int x, int y, int width, intheight, GtkOrientation orientation );

gtk::paint_hline

void gtk::paint_hline( GtkStyle style , GdkWindow window ,GtkStateType state_type , GdkRectangle area, GtkWidget widget , stringdetail, int x1, int x2, int y);

gtk::paint_option

void gtk::paint_option( GtkStyle style , GdkWindow window ,GtkStateType state_type , GtkShadowType shadow_type , GdkRectanglearea, GtkWidget widget , string detail, int x, int y, int width, intheight);

gtk::paint_oval

void gtk::paint_oval( GtkStyle style , GdkWindow window , GtkStateTypestate_type , GtkShadowType shadow_type , GdkRectangle area, GtkWidget

Page 412: Apostila PHP GTK

widget , string detail, int x, int y, int width, int height);

gtk::paint_ramp

void gtk::paint_ramp( GtkStyle style , GdkWindow window , GtkStateTypestate_type , GtkShadowType shadow_type , GdkRectangle area, GtkWidgetwidget , string detail, GtkArrowType arrow_type , int x, int y, intwidth, int height);

gtk::paint_shadow

void gtk::paint_shadow( GtkStyle style , GdkWindow window ,GtkStateType state_type , GtkShadowType shadow_type , GdkRectanglearea, GtkWidget widget , string detail, int x, int y, int width, intheight);

gtk::paint_shadow_gap

void gtk::paint_shadow_gap( GtkStyle style , GdkWindow window ,GtkStateType state_type , GtkShadowType shadow_type , GdkRectanglearea, GtkWidget widget , string detail, int x, int y, int width, intheight, GtkPositionType gap_side , int gap_x, int gap_width);

gtk::paint_slider

void gtk::paint_slider( GtkStyle style , GdkWindow window ,GtkStateType state_type , GtkShadowType shadow_type , GdkRectanglearea, GtkWidget widget , string detail, int x, int y, int width, intheight, GtkOrientation orientation );

gtk::paint_string

void gtk::paint_string( GtkStyle style , GdkWindow window ,GtkStateType state_type , GdkRectangle area, GtkWidget widget , stringdetail, int x, int y, string string);

gtk::paint_tab

void gtk::paint_tab( GtkStyle style , GdkWindow window , GtkStateTypestate_type , GtkShadowType shadow_type , GdkRectangle area, GtkWidgetwidget , string detail, int x, int y, int width, int height);

gtk::paint_vline

void gtk::paint_vline( GtkStyle style , GdkWindow window ,GtkStateType state_type , GdkRectangle area, GtkWidget widget , stringdetail, int y1, int y2, int x);

gtk::preview_get_cmap

GdkColormap gtk::preview_get_cmap (void);

gtk::preview_get_visual

Page 413: Apostila PHP GTK

GdkVisual gtk::preview_get_visual (void);

gtk::preview_reset

void gtk::preview_reset(void);

gtk::preview_set_color_cube

void gtk::preview_set_color_cube(int nred_shades, int ngreen_shades,int nblue_shades, int ngray_shades);

gtk::preview_set_gamma

void gtk::preview_set_gamma(double gamma);

gtk::preview_set_install_cmap

void gtk::preview_set_install_cmap(int install_cmap);

gtk::preview_set_reserved

void gtk::preview_set_reserved(int nreserved);

gtk::quit_add

int gtk::quit_add(int level , string callback , [mixed data ]);

Registers the function callback to be called when main loop levellevel exits. If data is given, it will be passed to callback whencalled. Adding a function using gtk::quit_add() is similar toconnecting a method to the destroy signal for a gtk loop.

gtk::quit_add() returns an integer identifier which can be passed togtk::quit_remove() in order to prevent the function from being called.

See also: gtk::quit_remove()

gtk::quit_remove

void gtk::quit_remove(int quit_handler_id);

Unregisters a function which was preivously registered by callinggtk::quit_add() . quit_handler_id is the value returned fromgtk::quit_add() .

See also: quit_add

gtk::rc_add_default_file

void gtk::rc_add_default_file(string filename);

Adds a file to the list of files to be parsed at the end ofgtk_init(). The default file to be parsed is ~/.gtkrc. This file doesnot need to be added using gtk::rc_add_default_file() in order to be

Page 414: Apostila PHP GTK

parsed.

See also: gtk::rc_parse()

gtk::rc_get_module_dir

string gtk::rc_get_module_dir(void);

Returns the directory that PHP-GTK looks for theme engines in. Thedefault theme directory is /usr/lib/gtk/themes/engines/.

gtk::rc_get_style

GtkStyle gtk::rc_get_style ( GtkWidget widget );

Returns the GtkStyle that will be applied to widget.

gtk::rc_get_style() finds all rc styles that will be applied to widgetand combines them into one GtkStyle widget representing the finalappearance of the widget.

Exemplo 61. Getting the rc style for a widget<?php

// Create a backgound style to apply to buttons only.$style = 'style "button" { bg[NORMAL] = "#ff6060" }';gtk::rc_parse_string($style);

// Create a foreground style that applies to the entire application.$style = 'style "window" { fg[NORMAL] = "#ffffff" }';gtk::rc_parse_string($style);

// Create a window and add a button.$window =& new GtkWindow();$button =& new GtkButton('Example');$window->add($button);

// Get the rc style$rcStyle = gtk::rc_get_style($button);

// Output the style properties.echo $rcStyle->fg . "\n"; // Will print #ffffffecho $rcStyle->bg . "\n"; // Will print #ff6060

?>

gtk::rc_parse

void gtk::rc_parse(string filename);

Parses an application's rc file(s). filename is the name of the rcfile to parse.

RC files are PHP-GTK's method for setting the default look and feel

Page 415: Apostila PHP GTK

for and application, class of widgets, or an individaul widget. Whenan application loads you can tell it to parse an rc file that actssimilar to a style sheet for GTK objects. It defines how widgetsshould appear in their default state (before any user code alterstheir appearance). For more details about rc files, including theirformat, see http://www.gtk.org/tutorial/ch-gtkrcfiles.html

See also: gtk::rc_parse_string() , gtk::rc_add_default_file() ,gtk::rc_reparse_all()

gtk::rc_parse_string

void gtk::rc_parse_string(string rc_string);

Parse resource information directly from a string. This can be used todynamically change colors and background images for whole widgets andwidget classes at once.

There is an example at GtkTooltips::set_colors.

gtk::rc_reparse_all

bool gtk::rc_reparse_all(void);

Reparses all of an application's rc files if the modification time ofany of the previously parse files has changed. This will reset thelook and feel of the application to its original state. Any changesthat were made to an individual widget's style will be lost.

If the files were reread, true is returned.

See also: gtk::rc_parse()

gtk::timeout_add

int gtk::timeout_add(int interval, GtkFunction function , [mixed data]);

Registers function to be called periodically. The function will becalled repeatedly after interval milliseconds while it returns TRUE.When function no longer returns TRUE the timeout is destroyed and willnot be called again.

You should save the returned number if you want togtk::timeout_remove() it.

gtk::timeout_remove

void gtk::timeout_remove(int timeout_handler_id);

Removes the given timeout destroying all information about it.

You get the timeout_handler_id when you gtk::timeout_add() a function.

Page 416: Apostila PHP GTK

gtk::true

int gtk::true(void);

This is a static function that simply returns 1. It has no otherfunctionality.

gtk::type_from_name

int gtk::type_from_name(string name);

gtk::type_name

string gtk::type_name(int type);

gtk::vbutton_box_get_layout_default

GtkButtonBoxStyle gtk::vbutton_box_get_layout_default (void);

gtk::vbutton_box_get_spacing_default

int gtk::vbutton_box_get_spacing_default (void);

gtk::vbutton_box_set_layout_default

void gtk::vbutton_box_set_layout_default ( GtkButtonBoxStyle layout );

gtk::vbutton_box_set_spacing_default

void gtk::vbutton_box_set_spacing_default (int spacing);

gtk::widget_get_default_colormap

GdkColormap gtk::widget_get_default_colormap (void);

Returns the application's default GdkColormap.

gtk::widget_get_default_style

GtkStyle gtk::widget_get_default_style (void);

Returns the default GtkStyle that is currently being used throughoutan application.

Use gtk::widget_set_default_style() to change aspects of the defaultstyle.

gtk::widget_get_default_visual

GdkVisual gtk::widget_get_default_visual (void);

Returns the application's default GdkVisual.

gtk::widget_pop_colormap

Page 417: Apostila PHP GTK

void gtk::widget_pop_colormap(void);

gtk::widget_pop_composite_child

void gtk::widget_pop_composite_child(void);

gtk::widget_pop_style

void gtk::widget_pop_style(void);

gtk::widget_pop_visual

void gtk::widget_pop_visual(void);

gtk::widget_push_colormap

void gtk::widget_push_colormap( GdkColormap cmap );

gtk::widget_push_composite_child

void gtk::widget_push_composite_child(void);

gtk::widget_push_style

void gtk::widget_push_style( GtkStyle style );

gtk::widget_push_visual

void gtk::widget_push_visual( GdkVisual visual );

gtk::widget_set_default_colormap

void gtk::widget_set_default_colormap ( GdkColormap colormap );

gtk::widget_set_default_style

void gtk::widget_set_default_style ( GtkStyle style );

gtk::widget_set_default_visual

void gtk::widget_set_default_visual ( GdkVisual visual );

Classes do GDK

Classes derivadas da Biblioteca GDK

Índice

GdkAtom

GdkBitmap

Page 418: Apostila PHP GTK

GdkColorA structure that holds a defined color.

GdkColormapMapping between the color values stored in memory and the RGBvalues that are used to display color values.

GdkCursorA GdkCursor is represents a predefined or self-created mousepointer.

GdkDragContext

GdkEventOne of the stream of mainloop events.

GdkFontStructure holding font information.

GdkGCA structure that contains graphics information.

GdkPixmap

GdkVisual

GdkWindowUnderlying window class for every GtkWidget.

GDK FunctionsGDK functions not belonging to any class.

GdkAtom

Hierarquia do Objeto

GdkAtom

Direct subclasses

None.

Descrição

GdkBitmap

Hierarquia do Objeto

GdkBitmap

Page 419: Apostila PHP GTK

Direct subclasses

None.

Descrição

Métodos

extents()

lock()

height()

width()

GdkBitmap::extents

array extents(void);

GdkBitmap::lock

int lock(void);

GdkBitmap::height

int height(void);

GdkBitmap::width

int width(void);

GdkColor

A structure that holds a defined color.

Hierarquia do Objeto

GdkColor

Direct subclasses

None.

Descrição

A GdkColor provides an object structure for retaining informationabout a defined color.

This is an XcmsColor structure, and will take values in anyXcmsColor format accordingly. Probably the most generally useful of

Page 420: Apostila PHP GTK

these formats is the gamma-corrected XcmsRGB structure, which takesthe range 0 to 65535 per RGB value, with 0, 0, 0 being the colorblack. RGB values that are given in this way are scaled to matchthe color range of the hardware device currently being used.

Colors can be assigned through an application's RC files, where theGdkColor objects are constructed via the application colormapdefined through the file. Colors that are assigned in this way canbe constructed using any of the formats accepted by the XcmsColorstructure, including intensity doubles.

Note that this is not the case when assigning a color to a GdkColordirectly.

Construtor

GdkColor (int red, int green, int blue);

-- Creates a new color object using one of three possibleconstructs.

Propriedades

red:

The red part of the color

green:The green part of the color

blue:The blue part of the color

GdkColor Construtor

GdkColor (int red, int green, int blue);

When constructing a GdkColor directly, you will need to use thesystem's color names, hex RGB triples or XcmsRGB values. Attempting touse other formats here will not result in an error message, becausethe structure itself recognises them, but equally they will notdisplay, because the function doesn't recognise them at all.

The options when directly constructing colors in PHP-GTK are:<?php/* XcmsRGB values, expressed as three integers */$cyan = &new GdkColor(0, 65535, 65535);

/* hex triples expressed as a single string */$cyan = &new GdkColor('#00FFFF');

/* a color name expressed as a single string */$cyan = &new GdkColor('cyan');?>

Page 421: Apostila PHP GTK

Color names that are used on a given system are defined in a filenamed rgb.txt. The equivalent file is not available in human-readableform under win32, although utilised. Here is one of the betterreference pages currently online detailing the standard color namesused by window management systems.

See also: GtkStyle.

GdkColor::red

Access: Read WriteType: int

Returns the red part of the color in the range from 0 to 65536. If youconvert it to hexadecimal via dechex, you will see that only the first2 values are used, the last 2 are zero. So if you want to convert itto a nice html-like hexadecimal value like AF, you've got to shift itbitwise.$orange = &new GdkColor('#FF8000');echo dechex( $orange->red >> 8);

You can use the property to set the red part of the color as well.

GdkColor::green

Access: Read WriteType: int

Returns the green part of the color in the range from 0 to 65536. Ifyou convert it to hexadecimal via dechex, you will see that only thefirst 2 values are used, the last 2 are zero. So if you want toconvert it to a nice html-like hexadecimal value like AF, you've gotto shift it bitwise.$orange = &new GdkColor('#FF8000');echo dechex( $orange->green >> 8);

You can use the property to set the green part of the color as well.

GdkColor::blue

Access: Read WriteType: int

Returns the blue part of the color in the range from 0 to 65536. Ifyou convert it to hexadecimal via dechex, you will see that only thefirst 2 values are used, the last 2 are zero. So if you want toconvert it to a nice html-like hexadecimal value like AF, you've gotto shift it bitwise.$orange = &new GdkColor('#FF8000');echo dechex( $orange->blue >> 8);

You can use the property to set the blue part of the color as well.

Page 422: Apostila PHP GTK

GdkColormap

Mapping between the color values stored in memory and the RGBvalues that are used to display color values.

Hierarquia do Objeto

GdkColormap

Direct subclasses

None.

Descrição

A GdkColormap maps the color values stored in memory to the RGBvalues that are used to display color values. The RGB componentvalues correspond to the GdkColor red, green and blue values.

Métodos

size()

alloc()

GdkColormap::size

void size(void);

GdkColormap::alloc

void alloc(void);

GdkCursor

A GdkCursor is represents a predefined or self-created mousepointer.

Hierarquia do Objeto

GdkCursor

Direct subclasses

None.

Descrição

A GdkCursor is represents an X11 mouse pointer. There are severalpredefined cursors (see GdkCursorType), but you can create your ownmonochrome (2-color, not just black/white) pointers as well.

See: cursor_new, cursor_new_from_pixmap, set_cursor()

Page 423: Apostila PHP GTK

Propriedades

type:

The number of the current GdkCursorType.

name:The name of the current cursor type.

GdkCursor::type

Access: Read OnlyType: int

The number of the current GdkCursorType.

GdkCursor::name

Access: Read OnlyType: string

The name of the current cursor type. The names are the same as theGdkCursorType constants, except that they are lowercase, omit thebeginning GDK_ and have hyphens instead of underscores. For example,GDK_IRON_CROSS has the name iron-cross.

GdkDragContext

Hierarquia do Objeto

GdkDragContext

Direct subclasses

None.

Descrição

Propriedades

protocol:

is_source:

source_window:

dest_window:

Page 424: Apostila PHP GTK

targets:

actions:

suggested_action:

action:

start_time:

GdkDragContext::protocol

Access: Read OnlyType: int

GdkDragContext::is_source

Access: Read OnlyType: bool

GdkDragContext::source_window

Access: Read OnlyType: GdkWindow

GdkDragContext::dest_window

Access: Read OnlyType: GdkWindow

GdkDragContext::targets

Access: Read OnlyType: array

GdkDragContext::actions

Access: Read OnlyType: int

GdkDragContext::suggested_action

Access: Read OnlyType: int

GdkDragContext::action

Access: Read OnlyType: int

Page 425: Apostila PHP GTK

GdkDragContext::start_time

Access: Read OnlyType: int

GdkEvent

One of the stream of mainloop events.

Hierarquia do Objeto

GdkEvent

Direct subclasses

None.

Descrição

A GdkEvent is one of the continual stream of events that help makeup the GTK main loop. Events crossing a widget indicate some formof activity - generally, but not exclusively, user activity.

There are 32 different kinds of GdkEvent, each of which has onlythe properties appropriate to it exposed. Those differences arekeyed using an enumerated value known as GdkEventType, which is atype property of both GdkEventAny and GdkEvent itself. Confusedyet? That'll be because GdkEvent has a union structure, which isunique in GTK+ programming, and because the type property isintentionally accessible both through $event->type and through$any->type.

Each event carries GdkEventType and GdkEventAny information. Beyondthat, the properties that can be accessed within an event dependcompletely on its type. See the table below for details.

The types of event that can be captured by an object depend on theGdkEventMask or masks that are in effect on that object. Each GTKwidget is created with a set of these flags; this base set can beadded to or limited within PHP-GTK using set_events() oradd_events() as appropriate. The masks required by each event typeare also listed in the table below, where applicable.

See also: GtkEventBox, add_events() , set_events() , and thesection on events in the Userguide.

Further reading: The relevant chapter of Havoc Pennington's GTK+ /Gnome Application Development provides an in-depth overview of GDKevents. It's aimed at C programmers, but is easy to read despitethat caveat.

Tabela 10. GdkEvent propertiesGdkEventType property GdkEventMaskGDK_NOTHING

Page 426: Apostila PHP GTK

GDK_DELETEGDK_DESTROYGDK_EXPOSEexposeGDK_EXPOSURE_MASKGDK_MOTION_NOTIFYmotionGDK_POINTER_MOTION_MASKGDK_BUTTON1_MOTION_MASKGDK_BUTTON2_MOTION_MASKGDK_BUTTON3_MOTION_MASKGDK_BUTTON_PRESSGDK_2BUTTON_PRESSGDK_3BUTTON_PRESSGDK_BUTTON_RELEASEbuttonGDK_BUTTON_PRESS_MASKGDK_BUTTON_RELEASE_MASKGDK_KEY_PRESSGDK_KEY_RELEASEkeyGDK_KEY_PRESS_MASKGDK_KEY_RELEASE_MASKGDK_ENTER_NOTIFYGDK_LEAVE_NOTIFYcrossingGDK_ENTER_NOTIFY_MASKGDK_LEAVE_NOTIFY_MASKGDK_FOCUS_CHANGEfocus_changeGDK_FOCUS_CHANGE_MASKGDK_CONFIGUREconfigureGDK_MAPGDK_UNMAPGDK_PROPERTY_NOTIFYpropertyGDK_PROPERTY_CHANGE_MASKGDK_SELECTION_CLEARGDK_SELECTION_REQUESTGDK_SELECTION_NOTIFYselectionGDK_PROXIMITY_INGDK_PROXIMITY_OUTproximityGDK_PROXIMITY_IN_MASKGDK_PROXIMITY_OUT_MASKGDK_DRAG_ENTERGDK_DRAG_LEAVEGDK_DRAG_MOTIONGDK_DRAG_STATUSGDK_DROP_STARTGDK_DROP_FINISHdnd

Page 427: Apostila PHP GTK

GDK_CLIENT_EVENTclientGDK_VISIBILITY_NOTIFYvisibilityGDK_VISIBILITY_NOTIFY_MASKGDK_NO_EXPOSEno_expose

GdkEventAny

Hierarquia do Objeto

GdkEventAny

Direct subclasses

None.

Descrição

Propriedades

type:

window:

send_event:

GdkEventAny::type

Access: Read OnlyType: GdkEventType

GdkEventAny::window

Access: Read OnlyType: GdkWindow

GdkEventAny::send_event

Access: Read OnlyType: bool

GdkEventButton

Hierarquia do Objeto

GdkEventButton

Direct subclasses

Page 428: Apostila PHP GTK

None.

Descrição

Propriedades

time:

x:

y:

pressure:

xtilt:

ytilt:

state:

button:

source:

deviceid:

x_root:

y_root:

GdkEventButton::time

Access: Read OnlyType: int

GdkEventButton::x

Access: Read OnlyType: double

GdkEventButton::y

Page 429: Apostila PHP GTK

Access: Read OnlyType: double

GdkEventButton::pressure

Access: Read OnlyType: double

GdkEventButton::xtilt

Access: Read OnlyType: double

GdkEventButton::ytilt

Access: Read OnlyType: double

GdkEventButton::state

Access: Read OnlyType: int

GdkEventButton::button

Access: Read OnlyType: int

GdkEventButton::source

Access: Read OnlyType: GdkInputSource

GdkEventButton::deviceid

Access: Read OnlyType: int

GdkEventButton::x_root

Access: Read OnlyType: double

GdkEventButton::y_root

Access: Read OnlyType: double

GdkEventClient

Hierarquia do Objeto

GdkEventClient

Page 430: Apostila PHP GTK

Direct subclasses

None.

Descrição

Propriedades

message_type:

data_format:

data:

GdkEventClient::message_type

Access: Read OnlyType: GdkAtom

GdkEventClient::data_format

Access: Read OnlyType: int

GdkEventClient::data

Access: Read OnlyType: array

GdkEventConfigure

Hierarquia do Objeto

GdkEventConfigure

Direct subclasses

None.

Descrição

Propriedades

x:

y:

width:

Page 431: Apostila PHP GTK

height:

GdkEventConfigure::x

Access: Read OnlyType: int

GdkEventConfigure::y

Access: Read OnlyType: int

GdkEventConfigure::width

Access: Read OnlyType: int

GdkEventConfigure::height

Access: Read OnlyType: int

GdkEventCrossing

Hierarquia do Objeto

GdkEventCrossing

Direct subclasses

None.

Descrição

Propriedades

subwindow:

time:

x:

y:

x_root:

Page 432: Apostila PHP GTK

y_root:

mode:

detail:

focus:

state:

GdkEventCrossing::subwindow

Access: Read OnlyType: GdkWindow

GdkEventCrossing::time

Access: Read OnlyType: int

GdkEventCrossing::x

Access: Read OnlyType: double

GdkEventCrossing::y

Access: Read OnlyType: double

GdkEventCrossing::x_root

Access: Read OnlyType: double

GdkEventCrossing::y_root

Access: Read OnlyType: double

GdkEventCrossing::mode

Access: Read OnlyType: GdkCrossingMode

GdkEventCrossing::detail

Access: Read OnlyType: GdkNotifyType

Page 433: Apostila PHP GTK

GdkEventCrossing::focus

Access: Read OnlyType: bool

GdkEventCrossing::state

Access: Read OnlyType: int

GdkEventDND

Hierarquia do Objeto

GdkEventDND

Direct subclasses

None.

Descrição

Propriedades

context:

time:

x_root:

y_root:

GdkEventDND::context

Access: Read OnlyType: GdkDragContext

GdkEventDND::time

Access: Read OnlyType: int

GdkEventDND::x_root

Access: Read OnlyType: int

GdkEventDND::y_root

Access: Read Only

Page 434: Apostila PHP GTK

Type: int

GdkEventExpose

Hierarquia do Objeto

GdkEventExpose

Direct subclasses

None.

Descrição

Propriedades

area:

count:

GdkEventExpose::area

Access: Read OnlyType: GdkRectangle

GdkEventExpose::count

Access: Read OnlyType: int

GdkEventFocus

Hierarquia do Objeto

GdkEventFocus

Direct subclasses

None.

Descrição

Propriedades

in:

GdkEventFocus::in

Access: Read OnlyType: int

Page 435: Apostila PHP GTK

GdkEventKey

Hierarquia do Objeto

GdkEventKey

Direct subclasses

None.

Descrição

Propriedades

time:

state:

keyval:

length:

string:

GdkEventKey::time

Access: Read OnlyType: int

GdkEventKey::state

Access: Read OnlyType: int

GdkEventKey::keyval

Access: Read OnlyType: int

GdkEventKey::length

Access: Read OnlyType: int

GdkEventKey::string

Access: Read OnlyType: string

Page 436: Apostila PHP GTK

GdkEventMotion

Hierarquia do Objeto

GdkEventMotion

Direct subclasses

None.

Descrição

Propriedades

time:

x:

y:

pressure:

xtilt:

ytilt:

state:

is_hint:

source:

deviceid:

x_root:

y_root:

GdkEventMotion::time

Access: Read OnlyType: int

Page 437: Apostila PHP GTK

GdkEventMotion::x

Access: Read OnlyType: double

GdkEventMotion::y

Access: Read OnlyType: double

GdkEventMotion::pressure

Access: Read OnlyType: double

GdkEventMotion::xtilt

Access: Read OnlyType: double

GdkEventMotion::ytilt

Access: Read OnlyType: double

GdkEventMotion::state

Access: Read OnlyType: int

GdkEventMotion::is_hint

Access: Read OnlyType: int

GdkEventMotion::source

Access: Read OnlyType: GdkInputSource

GdkEventMotion::deviceid

Access: Read OnlyType: int

GdkEventMotion::x_root

Access: Read OnlyType: double

GdkEventMotion::y_root

Access: Read Only

Page 438: Apostila PHP GTK

Type: double

GdkEventNoExpose

Hierarquia do Objeto

GdkEventNoExpose

Direct subclasses

None.

Descrição

Propriedades

type:

window:

send_event:

GdkEventNoExpose::type

Access: Read OnlyType: GdkEventType

GdkEventNoExpose::window

Access: Read OnlyType: GdkWindow

GdkEventNoExpose::send_event

Access: Read OnlyType: bool

GdkEventProperty

Hierarquia do Objeto

GdkEventProperty

Direct subclasses

None.

Descrição

Propriedades

Page 439: Apostila PHP GTK

atom:

time:

state:

GdkEventProperty::atom

Access: Read OnlyType: GdkAtom

GdkEventProperty::time

Access: Read OnlyType: int

GdkEventProperty::state

Access: Read OnlyType: int

GdkEventProximity

Hierarquia do Objeto

GdkEventProximity

Direct subclasses

None.

Descrição

Propriedades

time:

source:

deviceid:

GdkEventProximity::time

Access: Read OnlyType: int

GdkEventProximity::source

Page 440: Apostila PHP GTK

Access: Read OnlyType: GdkInputSource

GdkEventProximity::deviceid

Access: Read OnlyType: int

GdkEventSelection

Hierarquia do Objeto

GdkEventSelection

Direct subclasses

None.

Descrição

Propriedades

selection:

target:

property:

requestor:

time:

GdkEventSelection::selection

Access: Read OnlyType: GdkAtom

GdkEventSelection::target

Access: Read OnlyType: GdkAtom

GdkEventSelection::property

Access: Read OnlyType: GdkAtom

GdkEventSelection::requestor

Page 441: Apostila PHP GTK

Access: Read OnlyType: int

GdkEventSelection::time

Access: Read OnlyType: int

GdkEventVisibility

Hierarquia do Objeto

GdkEventVisibility

Direct subclasses

None.

Descrição

Propriedades

state:

GdkEventVisibility::state

Access: Read OnlyType: GdkVisibilityState

GdkFont

Structure holding font information.

Hierarquia do Objeto

GdkFont

Direct subclasses

None.

Descrição

A GdkFont is a data structure containing basic information about afont, in terms of its type, ascent and descent. There is noconstructor, as the fonts available are provided by the system. TheGdkFont structure simply allows a new font to be loaded andqueried.

To load a font, use gdk::font_load() . To load a fontset - a rangeof different fonts - use gdk::fontset_load() . Either function willreturn a single GdkFont.

Page 442: Apostila PHP GTK

Under win32 currently, all fonts are of the type GDK_FONT_FONTSET,regardless of the loading method.

Métodos

extents()Returns an array of sizing information.

measure()The drawn width of a text-string, measured in pixels.

height()Returns the line height, measured in pixels.

width()The logical width of a text string, measured in pixels.

Propriedades

type:Font or fontset type.

ascent:Baseline to top of logical area.

descent:Baseline to bottom of logical area.

GdkFont::extents

array extents(string text_string);

extents() returns an array of five integers representing the leftbearing, right bearing, width, ascent and descent of the string usingthe font, or the font itself, as appropriate.

The left and right bearing are the distance from the drawing origin tothe leftmost and rightmost extent of the drawn string respectively,measured in pixels.

The width is the length of the current string, measured in pixels.This measurement supplies information regarding where to begin drawingthe next string, if there is more than one. The returned integer maybe greater or smaller than the value of the right bearing.

The ascent and descent are the pixel measurements of the extents ofthe current string above and below the baseline.

If you're working with unix, all the above should be correct. Ifyou're using win32, the left bearing will always be 0, the rightbearing will match the width, the ascent is actually the line-height +1 pixel, and the descent is the descent + 1 pixel. Use GdkFontproperties if you need the ascent and descent values under win32.

Page 443: Apostila PHP GTK

GdkFont::measure

int measure(string text_string);

The return from this method is the equivalent of the right bearingreturned by extents() . It is the size in pixels of the width of thestring, to the point where the final part of the final character inthe string is drawn.

If you need the logical width of the string - that is, to the pointwhere the next character should be inserted - use width() instead.

GdkFont::height

int height(string text_string);

The return value of height() is arrived at by summing the values ofascent and descent returned by extents() and relating to the currentstring.

Under win32, this is a bogus value. Add the values returned by theGdkFont properties ascent and descent to get the value of the font'sheight.

The value of the height is the line-height, given in pixels, andrepresents the logical space required by a line. If you are using thismeasurement to calculate the size of a text box, you will need to add6 pixels to the total to allow for the borders of the text widget.

GdkFont::width

int width(string text_string);

width() returns the logical width of the text string, measured inpixels. The logical width includes the area up to where the nextcharacter should be drawn.

This method is completely broken in Windows, and will always returnthe right bearing measurement instead.

GdkFont::type

Access: Read OnlyType: int

The returned integer may have a value of 0, indicating that the fontwas loaded as a unique font, or of 1, indicating that the font wasloaded as part of a fontset. See GdkFontType.

Note that under win32 this property will always have a value of 1, asall fonts are loaded as fontsets in order to provide support for thewide characters used by the operating system.

GdkFont::ascent

Page 444: Apostila PHP GTK

Access: Read OnlyType: int

The ascent is the distance between a font's baseline and the top ofthe logical space taken up by that font.

Add this to the descent to obtain the full font height value inpixels.

GdkFont::descent

Access: Read OnlyType: int

The descent is the distance between a font's baseline and the bottomof the logical space taken up by that font.

GdkGC

A structure that contains graphics information.

Hierarquia do Objeto

GdkGC

Direct subclasses

None.

Descrição

A GdkGC is made up of a series of properties, each of which may ormay not be set, that describe everything from color to font toline-width. It forms several of the underlying elements of thestyle property in widgets, and is used in GDK where GtkStyle wouldbe used at GTK level. The GC part of GdkGC stands for graphicscontext, and every GDK drawing function requires one in much thesame way that every GTK drawing function requires a style.

The functions that allow the getting and setting of GdkGCproperties are internalised in PHP-GTK. For the most part, we havewriteable properties instead of these methods. Please note thatthere is no guarantee that all these properties will be supportedby your operating system; win32's 'little black boxes' text issueis there because win32 does not support stippling, for example.

There is no direct constructor for a GdkGC. To create one, you willneed to use the GdkWindow method new_gc() and set the propertiesthat you are interested in directly.

Métodos

set_dashes()

Page 445: Apostila PHP GTK

Configures the appearance of dashed lines.

Propriedades

foreground:The foreground color.

background:The background color.

font:The loaded font.

function:Bitwise description of the drawing function.

fill:The style of the fill.

tile:The pixmap used for tiling.

stipple:The pixmap used for stippling.

clip_mask:The clip mask bitmap.

subwindow_mode:The way subwindows are treated.

ts_x_origin:Tile or stipple's x origin.

ts_y_origin:Tile or stipple's y origin.

clip_x_origin:Clip mask's x origin.

clip_y_origin:Clip mask's y origin.

graphics_exposures:Whether expose events are generated during pixmap copies.

line_width:The pixel width of a drawn line.

line_style:The way a dashed line is drawn.

cap_style:The way the end of a line is drawn.

Page 446: Apostila PHP GTK

join_style:The way line joins are drawn.

GdkGC::set_dashes

void set_dashes(int offset, array dash_list);

GdkGC::foreground

Access: Read WriteType: GdkColor

This looks so straightforward, and isn't. GdkGC objects are so fardown in the evolutionary scale that they don't have an associatedcolormap. If you try to apply color directly, any color will bereturned as a muddy brown.

The way around this is to borrow an existing GdkColormap and allocatea color from there. You can use gdk::colormap_get_system() to do this,or you can access the colormap in a GdkWindow.

The syntax is: $gc->foreground = $colormap->alloc('red');

As with the GdkColor constructor, you could use '#FF0000' or 65535, 0,0 in place of 'red', but not 1.0, 0.0. 0.0.

GdkGC::background

Access: Read WriteType: GdkColor

It is not possible to apply a new or existing GdkColor to a GdkGC,because there is no colormap there for the color to reference.

You will need to take an existing GdkColormap, either by usinggdk::colormap_get_system() or by accessing the colormap property inthe existing GdkWindow that most widgets have, and give it a handle.Then you do something like: $gc->background = $colormap->alloc('limegreen'); and the color is allocated intelligently.

The background color fills the areas not taken up by the foregroundcolor, e.g. the gaps in a dashed line will take the background color.If you don't want this, just don't set this property.

GdkGC::font

Access: Read WriteType: GdkFont

GdkGC::function

Access: Read WriteType: GdkFunction

Page 447: Apostila PHP GTK

GdkGC::fill

Access: Read WriteType: GdkFill

GdkGC::tile

Access: Read WriteType: GdkPixmap

GdkGC::stipple

Access: Read WriteType: GdkPixmap

GdkGC::clip_mask

Access: Read WriteType: GdkBitmap

GdkGC::subwindow_mode

Access: Read WriteType: GdkSubwindowMode

GdkGC::ts_x_origin

Access: Read WriteType: int

GdkGC::ts_y_origin

Access: Read WriteType: int

GdkGC::clip_x_origin

Access: Read WriteType: int

GdkGC::clip_y_origin

Access: Read WriteType: int

GdkGC::graphics_exposures

Access: Read WriteType: bool

GdkGC::line_width

Access: Read Write

Page 448: Apostila PHP GTK

Type: int

GdkGC::line_style

Access: Read WriteType: GdkLineStyle

GdkGC::cap_style

Access: Read WriteType: GdkCapStyle

GdkGC::join_style

Access: Read WriteType: GdkJoinStyle

GdkPixmap

Hierarquia do Objeto

GdkPixmap

Direct subclasses

None.

Descrição

Construtor

GdkPixmap ();

--

Métodos

new_gc()

property_get()

property_change()

property_delete()

GdkPixmap Construtor

GdkPixmap ();

GdkPixmap::new_gc

Page 449: Apostila PHP GTK

void new_gc(void);

GdkPixmap::property_get

void property_get(void);

GdkPixmap::property_change

void property_change(void);

GdkPixmap::property_delete

void property_delete(void);

GdkVisual

Hierarquia do Objeto

GdkVisual

Direct subclasses

None.

Descrição

Propriedades

type:

depth:

byte_order:

colormap_size:

bits_per_rgb:

red_mask:

red_shift:

red_prec:

green_mask:

Page 450: Apostila PHP GTK

green_shift:

green_prec:

blue_mask:

blue_shift:

blue_prec:

GdkVisual::type

Access: Read OnlyType: int

GdkVisual::depth

Access: Read OnlyType: int

GdkVisual::byte_order

Access: Read OnlyType: int

GdkVisual::colormap_size

Access: Read OnlyType: int

GdkVisual::bits_per_rgb

Access: Read OnlyType: int

GdkVisual::red_mask

Access: Read OnlyType: int

GdkVisual::red_shift

Access: Read OnlyType: int

GdkVisual::red_prec

Access: Read Only

Page 451: Apostila PHP GTK

Type: int

GdkVisual::green_mask

Access: Read OnlyType: int

GdkVisual::green_shift

Access: Read OnlyType: int

GdkVisual::green_prec

Access: Read OnlyType: int

GdkVisual::blue_mask

Access: Read OnlyType: int

GdkVisual::blue_shift

Access: Read OnlyType: int

GdkVisual::blue_prec

Access: Read OnlyType: int

GdkWindow

Underlying window class for every GtkWidget.

Hierarquia do Objeto

GdkWindow

Direct subclasses

None.

Descrição

A GdkWindow represents the underlying window class of anyGtkWidget, resp. the onscreen display areas in the target windowsystem which the widget covers.

It can be accessed using the window property of the GtkWidgetclass.

Métodos

Page 452: Apostila PHP GTK

raise()Raises the window to the top of the z-order.

lower()Lowers the window to the bottom of the Z-order.

get_pointer()Returns an array of information about the mouse pointer.

set_cursor()Sets the mouse cursor used in that window.

new_gc()

property_get()

property_change()

property_delete()

set_icon()Sets the window icon.

Propriedades

width:The width of the window in pixels.

height:The height of the window in pixels.

x:The x coordinate of the window position relative to the parent.

y:The y coordinate of the window position relative to the parent.

colormap:

pointer:Array with the current mouse cursor position.

pointer_state:The current status of the mouse buttons.

parent:Returns the parent GdkWindow.

Page 453: Apostila PHP GTK

toplevel:Returns the GdkWindow of the toplevel GtkWindow.

children:Array of all direct children.

type:Returns the type of the widget.

depth:Returns the color depth in bits per pixel.

xid:Returns the XWindow window id, but not on Windows.

GdkWindow::raise

void raise(void);

Raises the window to the top of the Z-order (stacking order), so thatother windows with the same parent window appear below the window. Ifthe window is a toplevel, the window manager may choose to deny therequest to move the window in the Z-order. Therefore, the raise()method only requests the restack, it does not guarantee it.

GdkWindow::lower

void lower(void);

Lowers the window to the bottom of the Z-order (stacking order), sothat other windows with the same parent window appear above thewindow. If the window is a toplevel, the window manager may choose todeny the request to move the window in the Z-order. Therefore, thelower() method only requests the restack, it does not guarantee it.

Note that the show() method raises the window again, so don't callthis method before calling the show() method to avoid duplication.

GdkWindow::get_pointer

array get_pointer(void);

Returns an array of information about the mouse pointer.

The first 2 values are the X and Y coordinates of the mouse pointer,and the third is the button pointer_state.

GdkWindow::set_cursor

void set_cursor([ GdkCursor cursor ]);

Sets the mouse cursor used in that window. The parameter is omitted,the cursor is reset to the default pointer.

Page 454: Apostila PHP GTK

Exemplo 62. Setting the cursor$cursor = gdk::cursor_new(150); //GDK_WATCH$window = $mainWindow->window; //GdkWindow$window->set_cursor($cursor);

GdkWindow::new_gc

void new_gc(void);

GdkWindow::property_get

void property_get(void);

GdkWindow::property_change

void property_change(void);

GdkWindow::property_delete

void property_delete(void);

void

GdkWindow::set_icon

void set_icon(GdkWindow window, GdkPixmap pixmap, GdkBitmap mask);

Sets the window icon which can be shown by the window manager in thetitle or the task bar.This function does not work on Windows.list( $pixmap, $mask) = gdk::pixmap_create_from_xpm($window->window, null, 'window.xpm');$gdkwindow = $window->window;$gdkwindow->set_icon( $gdkwindow, $pixmap, $mask);

GdkWindow::width

Access: Read OnlyType: int

The width of the window in pixels.

GdkWindow::height

Access: Read OnlyType: int

The height of the window in pixels.

GdkWindow::x

Access: Read OnlyType: int

Page 455: Apostila PHP GTK

The x coordinate of the window position relative to parent.

GdkWindow::y

Access: Read OnlyType: int

The y coordinate of the window position relative to parent.

GdkWindow::colormap

Access: Read OnlyType: GdkColormap

GdkWindow::pointer

Access: Read OnlyType: array

Array with the current mouse cursor position. pointer[0] contains theX and pointer[1] the Y position.

GdkWindow::pointer_state

Access: Read OnlyType: int

Returns the current status of the mouse buttons, so that you candetermine if the left/middle/right button is being held.

GdkWindow::parent

Access: Read OnlyType: GdkWindow

Returns the parent GdkWindow.

The highest window in the packing hierarchy will return itself as theparent. Note that even the GdkWindow of a GtkWindow has a parent.$gtk_window =& new GtkWindow();$gdk_window = $gtk_window->window;var_dump( $gdk_window == $gdk_window->parent);

The example output is false.

GdkWindow::toplevel

Access: Read OnlyType: GdkWindow

Returns the GdkWindow of the toplevel Widget, usually the GtkWindow.

GdkWindow::children

Page 456: Apostila PHP GTK

Access: Read OnlyType: array

The array contains all direct widgets of this container which havebeen added with add() or another pack function.

GdkWindow::type

Access: Read OnlyType: GdkWindowType

Returns the GdkWindowType of the widget's GdkWindow.

GdkWindow::depth

Access: Read OnlyType: int

Returns the color depth in bits per pixel, e.g. 24.

GdkWindow::xid

Access: Read OnlyType: int

This property is not available on the Windows operating system. On*nix, it returns the XWindow window id.

GDK Functions

GDK functions not belonging to any class.

gdk::atom_intern()

gdk::beep()Emits a sound.

gdk::colormap_new()Creates a new GdkColormap.

gdk::colormap_get_system()Returns the system colormap.

gdk::colormap_get_system_size()Returns the size of the system colormap.

gdk::color_parse()Creates a GdkColor from a color specification.

gdk::cursor_new()Creates a new GdkCursor.

Page 457: Apostila PHP GTK

gdk::cursor_new_from_pixmap()Creates a new GdkCursor using a pixmap.

gdk::drag_status()

gdk::draw_arc()Draws an arc.

gdk::draw_gray_image()

gdk::draw_line()Draws a line.

gdk::draw_pixmap()

gdk::draw_point()

gdk::draw_rectangle()Draws a rectangle.

gdk::draw_rgb_32_image()

gdk::draw_rgb_image()

gdk::draw_rgb_image_dithalign()

gdk::draw_string()Draws a string of text.

gdk::draw_text()

gdk::flush()

gdk::font_load()Loads the given font.

gdk::fontset_load()Loads a selection of fonts described as a fontset.

gdk::get_display()Returns the name of the system.

gdk::input_remove()

Page 458: Apostila PHP GTK

gdk::pixmap_colormap_create_from_xpm()

gdk::pixmap_colormap_create_from_xpm_d()

gdk::pixmap_create_from_xpm()Creates a GdkPixmap from an xpm file.

gdk::pixmap_create_from_xpm_d()Creates a GdkPixmap from inline data.

gdk::pointer_is_grabbed()

gdk::rgb_gc_set_background()

gdk::rgb_gc_set_foreground()

gdk::rgb_get_cmap()

gdk::rgb_get_visual()

gdk::rgb_xpixel_from_rgb()

gdk::screen_height()Returns screen height in pixels.

gdk::screen_height_mm()Returns screen height in mm.

gdk::screen_width()Returns screen width in pixels.

gdk::screen_width_mm()Returns screen width in mm.

gdk::threads_enter()

gdk::threads_leave()

gdk::visual_get_best()

gdk::visual_get_best_with_both()

Page 459: Apostila PHP GTK

gdk::visual_get_best_with_depth()

gdk::visual_get_best_with_type()

gdk::visual_get_system()Returns the system visual.

gdk::atom_intern

GdkAtom gdk::atom_intern(string atom_name, [int only_if_exists = FALSE]);

gdk::beep

void gdk::beep(void);

This function causes a warning sound to be emitted. The precise natureof the sound is system and setup dependant.

gdk::colormap_new

GdkColormap gdk::colormap_new ( GdkVisual visual , bool allocate);

gdk::colormap_get_system

GdkColormap gdk::colormap_get_system (void);

gdk::colormap_get_system_size

int gdk::colormap_get_system_size(void);

gdk::color_parse

GdkColor gdk::color_parse(string color_spec);

This function creates a new GdkColor structure and fills it accordingto the color named in the color_spec parameter. The string that ispassed as the parameter can be the hex triplet version of the color,e.g. '#FF0000', or the equivalent color name linked in rgb.txt, e.g.'red'.

Win32 users will not be able to find that file, as it is compiled.There is a good rgb.txt reference page here.

gdk::cursor_new

GdkCursor gdk::cursor_new ( GdkCursorType cursor_type );

Creates a new cursor from one of the predefined cursor types.

You can find an example at set_cursor() .

Page 460: Apostila PHP GTK

gdk::cursor_new_from_pixmap

GdkCursor gdk::cursor_new_from_pixmap ( GdkPixmap source , GdkPixmapmask , GdkColor fg , GdkColor bg , int x, int y);

This function creates a new cursor from a pixmap. After you havecreated the cursor, the set_cursor() has to be used on a widget's gdkwindow to make the cursor active. The cursor will be visible when themouse hovers the widget on which it has been set.

In Gtk 1.x, you can make monochrome cursors only. This means, thatevery color (except black and None) is converted to the fg or bgcolor.

The x and y parameters are the hotspot coordinates with (0,0)describing the top left position.This function is working since PHP-Gtk 1.0.1

Exemplo 63. Using a new cursor<?phpif( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

$window = &new GtkWindow();$window->set_default_size(300, 300);$window->connect_object('destroy', array('gtk', 'main_quit'));

$cursorpmp = array("16 16 3 1"," c None",". c white","1 c black"," ",".... . . ... ",".111..1.1.111. ",".1..1.1.1.1..1. ",".111..111.111. ",".1.. .1.1.1.. ",".1. .1.1.1. "," . . . "," ... . "," .111. .1. . . ",".1... .1..1..1.",".1. .. .1..1.1. ",".1..11.111.11. ",".1. .1..1..1.1. "," .111. .11.1..1."," ... .. . . ",);

$window->realize();$gdkwin = $window->window;

Page 461: Apostila PHP GTK

list($pixmap, $mask) = gdk::pixmap_create_from_xpm_d($gdkwin, null, $cursorpmp);

$colBlue = &new GdkColor( 'blue');$style = new GtkStyle();$cursor =gdk::cursor_new_from_pixmap($pixmap, $mask, $style->white, $colBlue, 1, 1);

$gdkwin->set_cursor($cursor);$window->show();

gtk::main();?>

gdk::drag_status

void gdk::drag_status( GdkDragContext context , GdkDragAction action ,int time);

gdk::draw_arc

void gdk::draw_arc(GdkWindow drawable, GdkGC gc , int filled, int x,int y, int width, int height, int angle1, int angle2);

gdk::draw_gray_image

void gdk::draw_gray_image(GdkWindow drawable, GdkGC gc , int x, int y,int width, int height, GdkRgbDither dith , string buf, int rowstride);

gdk::draw_line

void gdk::draw_line(GdkWindow drawable, GdkGC gc , int x1, int y1, intx2, int y2);

gdk::draw_pixmap

void gdk::draw_pixmap(GdkWindow drawable, GdkGC gc , GdkWindow src,int xsrc, int ysrc, int xdest, int ydest, int width, int height);

gdk::draw_point

void gdk::draw_point(GdkWindow drawable, GdkGC gc , int x, int y);

gdk::draw_rectangle

void gdk::draw_rectangle(GdkWindow drawable, GdkGC gc , int filled,int x, int y, int width, int height);

gdk::draw_rgb_32_image

void gdk::draw_rgb_32_image(GdkWindow drawable, GdkGC gc , int x, inty, int width, int height, GdkRgbDither dith , string buf, introwstride);

Page 462: Apostila PHP GTK

gdk::draw_rgb_image

void gdk::draw_rgb_image(GdkWindow drawable, GdkGC gc , int x, int y,int width, int height, GdkRgbDither dith , string rgb_buf, introwstride);

gdk::draw_rgb_image_dithalign

void gdk::draw_rgb_image_dithalign (GdkWindow drawable, GdkGC gc , intx, int y, int width, int height, GdkRgbDither dith , string rgb_buf,int rowstride, int xdith, int ydith);

gdk::draw_string

void gdk::draw_string(GdkWindow drawable, GdkFont font , GdkGC gc ,int x, int y, string string);

gdk::draw_text

void gdk::draw_text(GdkWindow drawable, GdkFont font , GdkGC gc , intx, int y, string text, int text_length);

gdk::flush

void gdk::flush(void);

gdk::font_load

GdkFont gdk::font_load (string font_name);

This method loads a font_name, which must be given in the form of an XLogical Font Description (XLFD).

The XLFD is a way of describing a font that is completelysystem-independant. It contains 14 fields, most of which can berepresented by a wildcard * in order to allow flexibility when a matchis being sought - the exceptions are addedstyle, which doesn't needone, and registry, which is the only mandatory field. The descriptionopens with a hyphen, -, and each field is also separated by a hyphen.

If you need more information on fonts than is given here, the fullXWindows definition is available online through the relevant XWindowsdocumentation.

foundry xxx (where the font was created. 'unknown' is okay)family xxx (e.g. Arial)weight xxx (e.g. bold, medium)slant x (r - roman, i = italic, o = oblique)setwidth xxx (e.g. normal, condensed)addedstyle xxx (e.g. serif, sans. Leave blank for none)pixelsize N (set either this or pointsize, not both)pointsize N (point size, e.g. 120)resx N (x res the font was created for, in dots per inch)resy N (y res the font was created for, in dots per inch)

Page 463: Apostila PHP GTK

space x (m = monospaced, p = proportional, c = cell)averagewidth N (average character width in pixels. 0 if unknown)registry xxx (e.g. utf, iso8859 or adobe)encoding xxx (e.g. 1 or 2 (for iso8859) or fontspecific)

A typical font-load would look something like this: $font =gdk::font_load('-unknown-Arial-normal-r-normal--*-120-96-96-p-0-iso8859-1');

Font information in the XLFD format can be retrieved from any systemby utilising the GtkFontSelection or GtkFontSelectionDialog widgets.

Note that there are sizing issues in GdkFont in the version of GTK+currently used in PHP-GTK under win32. As a result, the point sizeshould always be set in win32 - using the pixel size may giveunexpected results.

gdk::fontset_load

GdkFont gdk::fontset_load (string fontset_name);

This method is used when any of a range of fonts would be acceptable.Usually, that would be when internationalization is an issue. It couldalso be useful anywhere that some flexibility over the choice of fontis needed.

Load in exactly the same way as with gdk::font_load() , separatingeach of the potential fonts to be used with a comma. The systemrunning the application will use the first font in the set thatachieves a match.

In win32, the fontset_load method is used internally regardless ofwhether this or gdk::font_load() is called.

gdk::get_display

string gdk::get_display(void);

gdk::input_remove

void gdk::input_remove(int tag);

gdk::pixmap_colormap_create_from_xpm

XXX gdk::pixmap_colormap_create_from_xpm (XXX);

gdk::pixmap_colormap_create_from_xpm_d

XXX gdk::pixmap_colormap_create_from_xpm_d (XXX);

gdk::pixmap_create_from_xpm

array gdk::pixmap_create_from_xpm (GdkWindow window , GdkColortransparent_color , string filename);

Page 464: Apostila PHP GTK

gdk::pixmap_create_from_xpm() returns a array consisting of aGdkPixmap and a GdkBitmap mask that has been created from thespecified .xpm file.

The GdkPixmap is the underlying structure that holds the image readyto be displayed in a GtkPixmap. In order to make that image appear onthe screen, you will need to use one of the following constructs:<?php

$gdkpixmap = gdk::pixmap_create_from_xpm($main_window->window, null,'test.xpm');$image = &new GtkPixmap($gdkpixmap[0], $gdkpixmap[1]);

?>

or

<?phplist ($gdkpixmap, $mask) =gdk::pixmap_create_from_xpm($gdkwindow, $transparent_color, 'test.xpm');$image = &new GtkPixmap($gdkpixmap, $mask);

?>

The transparent_color determines what color the None pixels will getif you don't use the pixmask.

See the tutorial for more details and some examples.

gdk::pixmap_create_from_xpm_d

array gdk::pixmap_create_from_xpm_d (GdkWindow window , GdkColortransparent_color , array data);

gdk::pixmap_create_from_xpm() returns a array consisting of aGdkPixmap and a GdkBitmap mask that has been created from thespecified pixmap data given by the array.

The array has to have the same structure like the "normal" C-array inan xpm file.

$gdkpixmap = gdk::pixmap_create_from_xpm_d($main_window->window,$transparent_color, $data);

The transparent_color determines what color the None pixels will getif you don't use the pixmask.

See the tutorial for more details and some examples.

gdk::pointer_is_grabbed

bool gdk::pointer_is_grabbed(void);

Page 465: Apostila PHP GTK

gdk::rgb_gc_set_background

void gdk::rgb_gc_set_background( GdkGC gc , int rgb);

gdk::rgb_gc_set_foreground

void gdk::rgb_gc_set_foreground( GdkGC gc , int rgb);

gdk::rgb_get_cmap

GdkColormap gdk::rgb_get_cmap (void);

gdk::rgb_get_visual

GdkVisual gdk::rgb_get_visual (void);

gdk::rgb_xpixel_from_rgb

int gdk::rgb_xpixel_from_rgb(int rgb);

gdk::screen_height

int gdk::screen_height(void);

This function returns the screen height in pixels. This can be used insize-setting methods to ensure that containers are sized relative tothe screen resolution.

gdk::screen_height_mm

int gdk::screen_height_mm(void);

This function returns the screen height in millimeters. This can beused in size-setting methods to ensure that containers are sizedrelative to the screen size being used.

gdk::screen_width

int gdk::screen_width(void);

This function returns the screen width in pixels. This can be used insize-setting methods to ensure that containers are sized relative tothe screen resolution.

gdk::screen_width_mm

int gdk::screen_width_mm(void);

This function returns the screen width in millimeters. This can beused in size-setting methods to ensure that containers are sizedrelative to the screen size being used.

gdk::threads_enter

Page 466: Apostila PHP GTK

void gdk::threads_enter(void);

gdk::threads_leave

void gdk::threads_leave(void);

gdk::visual_get_best

GdkVisual gdk::visual_get_best (void);

gdk::visual_get_best_with_both

GdkVisual gdk::visual_get_best_with_both (int depth, GdkVisualTypevisual_type );

gdk::visual_get_best_with_depth

GdkVisual gdk::visual_get_best_with_depth (int depth);

gdk::visual_get_best_with_type

GdkVisual gdk::visual_get_best_with_type ( GdkVisualType visual_type);

gdk::visual_get_system

GdkVisual gdk::visual_get_system (void);

This function returns the GdkVisual that is currently used by thesystem.

GTK Extra Classes

GtkExtra is set of widget classes which fill gaps the original gtkclasses left. It can be found at gtkextra.sourceforge.net

Índice

GtkSheetA spreadsheet widget for displaying and editing data intables

GtkSheet

A spreadsheet widget for displaying and editing data in tables

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkSheet

Direct subclasses

Page 467: Apostila PHP GTK

None.

Descrição

A spreadsheet widget for displaying and editing data in tables. Itgives all the tools and the graphic interface to build applicationsthat need an editable grid of cells.

Construtor

GetSheet (int rows, int cols, String title);

--

Métodos

add_column()Add a column at a specific position

add_row()

Add a row at a specific position

attach()Attach a widget to a cell.

button_attach()Attach a button???

cell_clear()Clear a cell (remove contents)

cell_delete()Removes all the content from a cell

cell_get_state()Get the cell state???

cell_get_text()Get the content of a cell

change_entry()???

columns_labels_set_visibility()Shows or hides the column labels

columns_set_sensitivity()Sets the sensitivity of all columns - like col_set_sensitivity, butfor all rows

column_button_add_label()Add a label to the column title

Page 468: Apostila PHP GTK

column_button_justify()Sets the alignment of a column title

column_label_set_visibility()Shows or hides a column title

column_set_justification()Set the justification/alignment of a whole column

column_set_sensitivity()Set the column sensivity.

column_set_visibility()Shows or hides an entire column

construct()...

construct_browser()???

construct_with_custom_entry()???

delete_columns()Delete columns from the sheet

delete_rows()Delete rows from the sheet

freeze()Freeze the widget.

get_active_cell()Returns the position of the active cell

get_columns_count()Get the number of columns defined in the GtkSheet

get_entry()[perhaps] Returns the entry used for cell content insertion

get_entry_widget()Returns the widget with which you enter the text in the cells

get_rows_count()Get the number of rows defined in the GtkSheet

get_state()Checks the state????

grid_visible()Checks if the grid is visible

Page 469: Apostila PHP GTK

hide_column_titles()Hide the column titles on the top

hide_row_titles()Hide the row titles on the left side

insert_columns()Insert a number of columns into the sheet

insert_rows()Insert a number of columns into the sheet

moveto()???

move_child()???

remove_link()...

rows_labels_set_visibility()Hides or shows all row titles

rows_set_sensitivity()Sets the sensitivity of all rows.

row_button_add_label()Add a label to the row title

row_button_justify()Sets the alignment of a row title

row_label_set_visibility()Shows or hides a row title

row_set_sensitivity()Set the row sensivity.

row_set_visibility()Shows or hides an entire row

select_column()Select an entire column

select_row()Select an entire row

set_active_cell()Activate/select one cell

set_background()Set the background color of the whole sheet

Page 470: Apostila PHP GTK

set_cell()Set the contents of a cell

set_cell_text()Set the text of a cell

set_column_title()Set the title of a column

set_column_titles_height()Set the height of the column titles

set_column_width()Set the width of a column

set_grid()Set the color of the grid lines

set_hadjustment()...

set_row_height()Set the height of a row

set_row_title()Set the title of a row

set_row_titles_width()Set the width of the row titles on the left

set_selection_mode()Set the selection mode

set_title()Set the title of the whole sheet

set_vadjustment()...

show_column_titles()Make the column titles visible

show_grid()Show or hide the grid

show_row_titles()Show the row titles

thaw()Continue updating the widget

unclip_range()...

Page 471: Apostila PHP GTK

unselect_range()Removes a selection on more than 1 cell leaving only 1 cell selected

Sinais

"select_row"

"select_column"

"select_range"

"clip_range"

"resize_range"

"move_range"

"deactivate"

"activate"

"set_cell"

"clear_cell"

"changed"

"new_col_width"

"new_row_height"

"last_signal"

GtkSheet Construtor

GetSheet (int rows, int cols, String title);Default constructor; creates an GtkSheet object

GtkSheet::add_column

Page 472: Apostila PHP GTK

add_column (int position);Add a column at a specific position

GtkSheet::add_row

add_row (int position);Add a row at a specific position

GtkSheet::attach

null attach(GtkWidget widget, int row, int column, double ??? perhapsoffset, double ???);Attach a widget to a cell.

GtkSheet::button_attach

null button_attach(GtkWidget widget, int row, int column, double ???perhaps offset, double ???);Attach a button???

GtkSheet::cell_clear

null cell_clear(int row, int column);Clear a cell (remove contents)

GtkSheet::cell_delete

cell_delete (int row, int column);Removes all the content from a cell

GtkSheet::cell_get_state

int cell_get_state(int row, int column);Get the cell state???

GtkSheet::cell_get_text

String cell_get_text(int row, int column);Get the content of a cell

GtkSheet::change_entry

change_entry (int ???);???

GtkSheet::columns_labels_set_visibility

columns_labels_set_visibility (boolean true - the column labels areshown);Shows or hides the column labels

GtkSheet::columns_set_sensitivity

columns_set_sensitivity (boolean If the columns shall be sensitive);

Page 473: Apostila PHP GTK

Sets the sensitivity of all columns - like col_set_sensitivity, butfor all rows

GtkSheet::column_button_add_label

column_button_add_label (int column, String title);Add a label to the column title

GtkSheet::column_button_justify

column_button_justify (int row, int/String The style???);Sets the alignment of a column title

GtkSheet::column_label_set_visibility

column_label_set_visibility (int column, boolean visibility);

Shows or hides a column title

true - the title is shown

GtkSheet::column_set_justification

column_set_justification (int column, int/String style???);Set the justification/alignment of a whole column

GtkSheet::column_set_sensitivity

column_set_sensitivity (int column, boolean sensitivity);

Set the column sensivity. If a column is insensitive, it can't beselected and the title of the column is greyed out. The cells in thiscolumn can still be edited.

true - the column is sensitive, false - not sensitive

GtkSheet::column_set_visibility

column_set_visibility (int column, boolean visibility);Shows or hides an entire column

GtkSheet::construct

construct (int ???);...

GtkSheet::construct_browser

construct_browser (int ???, int ???, String ???);???

GtkSheet::construct_with_custom_entry

construct_with_custom_entry (int ???, int ???, String ???, int ???);

Page 474: Apostila PHP GTK

???

GtkSheet::delete_columns

delete_columns (int column_begin, int column_amount);Delete columns from the sheet

GtkSheet::delete_rows

delete_rows (int row_begin, int row_amount);Delete rows from the sheet

GtkSheet::freeze

freeze (void);

Freeze the widget - it will stop updating the gui until you thaw it

This is good for big content operations

GtkSheet::get_active_cell

Array get_active_cell(void);Returns the position of the active cell

GtkSheet::get_columns_count

int get_columns_count(void);Get the number of columns defined in the GtkSheet

GtkSheet::get_entry

GtkEntry get_entry(void);[perhaps] Returns the entry used for cell content insertion

GtkSheet::get_entry_widget

GtkEntry get_entry_widget(void);Returns the widget with which you enter the text in the cells

GtkSheet::get_rows_count

int get_rows_count(void);Get the number of rows defined in the GtkSheet

GtkSheet::get_state

int get_state(void);Checks the state????

GtkSheet::grid_visible

boolean grid_visible(void);Checks if the grid is visible

Page 475: Apostila PHP GTK

GtkSheet::hide_column_titles

null hide_column_titles(void);Hide the column titles on the top

GtkSheet::hide_row_titles

null hide_row_titles(void);Hide the row titles on the left side

GtkSheet::insert_columns

insert_columns (int column_begin, int column_amount);Insert a number of columns into the sheet

GtkSheet::insert_rows

insert_rows (int row_begin, int row_amount);Insert a number of columns into the sheet

GtkSheet::moveto

moveto (int row, int column, double ???, double ???);???

GtkSheet::move_child

move_child (GtkWidget widget, int row, int column);???

GtkSheet::remove_link

remove_link (int ???);...

GtkSheet::rows_labels_set_visibility

rows_labels_set_visibility (boolean visibility);Hides or shows all row titles (true - show, false - hide)

GtkSheet::rows_set_sensitivity

rows_set_sensitivity (boolean sensitivity);Sets the sensitivity of all rows - like row_set_sensitivity, but forall rows

GtkSheet::row_button_add_label

row_button_add_label (int row, String title);Add a label to the row title

GtkSheet::row_button_justify

Page 476: Apostila PHP GTK

row_button_justify (int row, int/String style???);Sets the alignment of a row title

GtkSheet::row_label_set_visibility

row_label_set_visibility (int row, boolean visibility);Shows or hides a row title (true - the title is shown, false - thetitle is hidden)

GtkSheet::row_set_sensitivity

row_set_sensitivity (int row, boolean sensitivity);

Set the row sensivity. If a row is insensitive, it can't be selectedand the title of the row is greyed out. The cells in this row canstill be edited.

true - the row is sensitive, false - the row is insensitive

GtkSheet::row_set_visibility

row_set_visibility (int row, boolean visibility);

Shows or hides an entire row

true - the row is visible, false - the row is hidden

GtkSheet::select_column

select_column (int column);Select an entire column

GtkSheet::select_row

select_row (int row);Select an entire row

GtkSheet::set_active_cell

boolean set_active_cell(int row, int column);Activate/select one cell

GtkSheet::set_background

set_background (GdkColor bg_color);Set the background color of the whole sheet (but not the headers)

GtkSheet::set_cell

set_cell (int row, int column, int/String style???, String text);Set the contents of a cell

GtkSheet::set_cell_text

Page 477: Apostila PHP GTK

set_cell_text (int row, int column, String text);Set the text of a cell

GtkSheet::set_column_title

set_column_title (int column, String text);Set the title of a column

GtkSheet::set_column_titles_height

set_column_titles_height (int height);Set the height of the column titles

GtkSheet::set_column_width

set_column_width (int column, int width);Set the width of a column (in pixels)

GtkSheet::set_grid

set_grid (GdkColor color);Set the color of the grid lines

GtkSheet::set_hadjustment

set_hadjustment (GtkAdjustment ???);...

GtkSheet::set_row_height

set_row_height (int row, int height);Set the height of a row (in pixels)

GtkSheet::set_row_title

set_row_title (int row, String text);Set the title of a row

GtkSheet::set_row_titles_width

set_row_titles_width (int width);Set the width of the row titles on the left

GtkSheet::set_selection_mode

set_selection_mode (int mode);Set the selection mode

GtkSheet::set_title

set_title (String text);Set the title of the whole sheet

GtkSheet::set_vadjustment

Page 478: Apostila PHP GTK

set_vadjustment (GtkAdjustment ???);...

GtkSheet::show_column_titles

show_column_titles (void);Make the column titles visible if they were hidden withhide_column_titles

GtkSheet::show_grid

show_grid (boolean visibility);Show or hide the grid (true - show, false - hide)

GtkSheet::show_row_titles

show_row_titles (void);Show the row titles if they were hidden with hide_row_titles

GtkSheet::thaw

thaw (void);Let the GtkSheet continue updating the widget GUI if it was frozenwith freeze

GtkSheet::unclip_range

unclip_range (int ???);...

GtkSheet::unselect_range

unselect_range (void);Removes a selection on more than 1 cell leaving only 1 cell selected

select_row

Função Callback

void callback(GtkWidget widget);

select_column

Função Callback

void callback(GtkWidget widget);

select_range

Função Callback

void callback(GtkWidget widget);

Page 479: Apostila PHP GTK

clip_range

Função Callback

void callback(GtkWidget widget);

resize_range

Função Callback

void callback(GtkWidget widget);

move_range

Função Callback

void callback(GtkWidget widget);

deactivate

Função Callback

void callback(GtkWidget widget);

activate

Função Callback

void callback(GtkWidget widget);

set_cell

Função Callback

void callback(GtkWidget widget);

clear_cell

Função Callback

void callback(GtkWidget widget);

changed

Função Callback

void callback(GtkWidget widget);

new_col_width

Função Callback

void callback(GtkWidget widget);

Page 480: Apostila PHP GTK

new_row_height

Função Callback

void callback(GtkWidget widget);

last_signal

Função Callback

void callback(GtkWidget widget);

GTK Enums

Os valores enumerados podem ser qualquer um dos valores listados.Flags podem ser uma combinação de qualquer um dos valores listados.Ambos enums e as flags tem um valor número e uma chave que pode serentendida pelo ser humano.

Índice

GtkAccelFlagsGtkAnchorTypeGtkArrowTypeGtkAttachOptionsGtkButtonActionGtkButtonBoxStyleGtkCalendarDisplayOptionsGtkCellTypeGtkCornerTypeGtkCTreeExpanderStyleGtkCTreeExpansionTypeGtkCTreeLineStyleGtkCurveTypeGtkDestDefaultsGtkDirectionTypeGtkFontFilterTypeGtkFontTypeGtkJustificationGtkObjectFlagsGtkOrientationGtkPackerOptionsGtkPackTypeGtkPolicyTypeGtkPositionTypeGtkPreviewTypeGtkProgressBarOrientationGtkProgressBarStyleGtkReliefStyleGtkResizeModeGtkScrollTypeGtkSelectionModeGtkShadowTypeGtkSideType

Page 481: Apostila PHP GTK

GtkSortTypeGtkSpinButtonUpdatePolicyGtkSpinTypeGtkStateTypeGtkSubmenuPlacementGtkToolbarChildTypeGtkToolbarSpaceStyleGtkToolbarStyleGtkTreeViewModeGtkUpdateTypeGtkVisibilityGtkWidgetFlagsGtkWindowPositionGtkWindowType

GtkAccelFlags

Flags

Valor

Nome simbólico

Descrição

0 GTK_ACCEL_VISIBLE Denotes that the accelerator key along with anyassociated modifiers should be displayed to the right of any text in aGtkAccelLabel. Note that this will always be displayed as upper case,whereas a lower case key value is actually being returned. Use a shiftmodifier if this is likely to cause a problem for your users. (Seealso: GdkModifierTypes.)1 GTK_ACCEL_SIGNAL_VISIBLE This flag does not work, and has beeneliminated completely in later versions of GTK+. Use GTK_ACCEL_MASK toachieve the desired effect.2 GTK_ACCEL_LOCKED Denotes that the accelerator entry is locked.However, this does not seem to work everywhere in the current versionof GTK+. Call the GtkWidget method lock_accelerators() on the targetwidget - usually a GtkMenuItem - in order to ensure accelerator entrylocking.3 GTK_ACCEL_MASK Returns full information for a GtkAccelGroupEntry(the individual element in a GtkAccelGroup array), displaying anymodifiers, the accelerator key and the name of the associated signalto the right of any existing GtkAccelLabel text.

GtkAnchorType

Enums

Valor

Nome simbólico

Descrição

Page 482: Apostila PHP GTK

0 GTK_ANCHOR_CENTER1 GTK_ANCHOR_NORTH2 GTK_ANCHOR_NORTH_WEST3 GTK_ANCHOR_NORTH_EAST4 GTK_ANCHOR_SOUTH5 GTK_ANCHOR_SOUTH_WEST6 GTK_ANCHOR_SOUTH_EAST7 GTK_ANCHOR_WEST8 GTK_ANCHOR_EAST9 GTK_ANCHOR_N10 GTK_ANCHOR_NW11 GTK_ANCHOR_NE12 GTK_ANCHOR_S13 GTK_ANCHOR_SW14 GTK_ANCHOR_SE15 GTK_ANCHOR_W16 GTK_ANCHOR_E

GtkArrowType

Enums

Valor

Nome simbólico

Descrição

0 GTK_ARROW_UP The arrow points up.1 GTK_ARROW_DOWN The arrow points down.2 GTK_ARROW_LEFT The arrow points to the left.3 GTK_ARROW_RIGHT The arrow points to the right.

GtkAttachOptions

Flags

Valor

Nome simbólico

Descrição

0 GTK_EXPAND The child's allocated area will expand proportionatelywhen the parent container is resized.1 GTK_SHRINK The child will shrink to the dimensions of its sizerequest regardless of the size of the parent or its allocated area.2 GTK_FILL The child will expand to fill its allocated area.

GtkButtonAction

Enums

Valor

Page 483: Apostila PHP GTK

Nome simbólico

Descrição

0 GTK_BUTTON_IGNORED Denotes that an instance of GtkCList willignore mouse button events.1 GTK_BUTTON_SELECTS Denotes that an instance of GtkCList will reactto select mouse events.2 GTK_BUTTON_DRAGS Denotes that an instance of GtkCList will reactto drag mouse button events.3 GTK_BUTTON_EXPANDS Denotes that an instance of GtkCList will reactto expand mouse button events.

GtkButtonBoxStyle

Enums

Valor

Nome simbólico

Descrição

0 GTK_BUTTONBOX_DEFAULT_STYLE The current default style for buttonarrangement, which can be reset. The default setting isGTK_BUTTONBOX_EDGE.1 GTK_BUTTONBOX_SPREAD Specifies that the buttons should be spacedevenly across the area of the buttonbox, with a full-sized space ateither edge of the column or row.2 GTK_BUTTONBOX_EDGE Specifies that the buttons should be spacedevenly across the area of the buttonbox, with no space at either edgeof the column or row.3 GTK_BUTTONBOX_START Specifies that the buttons should be packedfrom the top or left edge of the buttonbox, and spaced according totheir spacing and internal padding settings.4 GTK_BUTTONBOX_END Specifies that the buttons should be packed fromthe bottom or right edge of the buttonbox, and spaced according totheir spacing and internal padding settings.

GtkCalendarDisplayOptions

Flags

GtkCalendarDisplayOptions flags can only ever be set from within aGtkCalendar object.

Valor

Nome simbólico

Descrição

0 GTK_CALENDAR_SHOW_HEADING Specifies that the month and year should

Page 484: Apostila PHP GTK

be displayed.1 GTK_CALENDAR_SHOW_DAY_NAMES Specifies that three letter daydescriptions should be present.2 GTK_CALENDAR_NO_MONTH_CHANGE Prevents the user from switchingmonths with the calendar.3 GTK_CALENDAR_SHOW_WEEK_NUMBERS Displays each week numbers of thecurrent year, down the left side of the calendar4 GTK_CALENDAR_WEEK_START_MONDAY Starts the calendar week on Monday,instead of the default Sunday

GtkCellType

Enums

Valor

Nome simbólico

Descrição

0 GTK_CELL_EMPTY Denotes that a cell of an instance of GtkCListshould not contain anything.1 GTK_CELL_TEXT Denotes a cell of an instance of GtkCList shouldcontain text.2 GTK_CELL_PIXMAP Denotes a cell of an instance of GtkCList shouldcontain a pixel map.3 GTK_CELL_PIXTEXT Denotes a cell of an instance of GtkCList shouldcontain text and a pixelmap.4 GTK_CELL_WIDGET Support for a GtkClist containing a widget has notbeen completed in GTK+, therefore it is not currently available inPHP-GTK itself.

GtkCornerType

Enums

Valor

Nome simbólico

Descrição

0 GTK_CORNER_TOP_LEFT The child is above and to the left of thescrollbars, so that the scrollbars are placed to the right and bottomof it. This is the default behaviour.1 GTK_CORNER_BOTTOM_LEFT The child is below and to the left of thescrollbars, so that the scrollbars are placed at the right and top ofthe window.2 GTK_CORNER_TOP_RIGHT The child is above and to the right of thescrollbars, i.e. the scrollbars are positioned at the left and bottomof the window.3 GTK_CORNER_BOTTOM_RIGHT The child is below and to the right of thescrollbars, so that the scrollbars are displayed at the left and topof the window.

Page 485: Apostila PHP GTK

GtkCTreeExpanderStyle

Enums

Valor

Nome simbólico

Descrição

0 GTK_CTREE_EXPANDER_NONE Denotes that this instance of the GtkCTreeshould have no visible expanders.1 GTK_CTREE_EXPANDER_SQUARE Denotes that this instance of theGtkCTree should have square expanders.2 GTK_CTREE_EXPANDER_TRIANGLE Denotes that this instance of theGtkCTree should have triangular expanders.3 GTK_CTREE_EXPANDER_CIRCULAR Denotes that this instance of theGtkCTree should have circular expanders.

GtkCTreeExpansionType

Enums

Valor

Nome simbólico

Descrição

0 GTK_CTREE_EXPANSION_EXPAND Tells PHP-GTK to expand the currentnode of this instance of GtkCTree.1 GTK_CTREE_EXPANSION_EXPAND_RECURSIVE Tells PHP-GTK to expand thecurrent node, and all nodes below it in this instance of the GtkCTreeclass.2 GTK_CTREE_EXPANSION_COLLAPSE Tells PHP-GTK to collapse the currentnode of this instance of GtkCTree.3 GTK_CTREE_EXPANSION_COLLAPSE_RECURSIVE Tells PHP-GTK to collapsethe current node, and all nodes below it in this instance of theGtkCTree class.4 GTK_CTREE_EXPANSION_TOGGLE Tells PHP-GTK to toggle the currentnode of this instance of GtkCTree, this will cause an expanded node tocollapse and a collapsed node to expand.5 GTK_CTREE_EXPANSION_TOGGLE_RECURSIVE Tells PHP-GTK to toggle thecurrent node, and all nodes below it in this instance of the GtkCTreeclass, this will cause an expanded node to collapse and a collapsednode to expand.

GtkCTreeLineStyle

Enums

Valor

Page 486: Apostila PHP GTK

Nome simbólico

Descrição

0 GTK_CTREE_LINES_NONE Denotes there should be no lines between thenodes on this instance of GtkCTree.1 GTK_CTREE_LINES_SOLID Denotes that the lines between the nodes inthis instance of GtkCTree should be solid.2 GTK_CTREE_LINES_DOTTED Denotes that the lines between the nodes inthis instance of GtkCTree should be dotted lines.3 GTK_CTREE_LINES_TABBED Denotes that the lines between the nodes inthis instance of GtkCTree should be tabs rather than lines.

GtkCurveType

Enums

Valor

Nome simbólico

Descrição

0 GTK_CURVE_TYPE_LINEAR1 GTK_CURVE_TYPE_SPLINE2 GTK_CURVE_TYPE_FREE

GtkDestDefaults

Enums

Valor

Nome simbólico

Descrição

0 GTK_DEST_DEFAULT_MOTION1 GTK_DEST_DEFAULT_HIGHLIGHT2 GTK_DEST_DEFAULT_DROP3 GTK_DEST_DEFAULT_ALL

GtkDirectionType

Enums

Valor

Nome simbólico

Descrição

0 GTK_DIR_TAB_FORWARD Intended to tab forward through the childrencapable of having focus, starting at the left or top. This option

Page 487: Apostila PHP GTK

appears not to work in the versions of GTK+ used in PHP-GTK, and hasbeen completely rewritten for GTK 2.1 GTK_DIR_TAB_BACKWARD Intended to tab backward through the childrenwith focus capability, starting at the right or bottom. This optionappears not to work in the versions of GTK+ used in PHP-GTK, and hasbeen completely rewritten for GTK 2.2 GTK_DIR_UP Sets initial focus on the child nearest the bottom ofthe container.3 GTK_DIR_DOWN Sets initial focus on the child nearest the top ofthe container.4 GTK_DIR_LEFT Sets initial focus on the child nearest the rightedge of the container.5 GTK_DIR_RIGHT Sets initial focus on the child nearest the leftedge of the container.

GtkFontFilterType

Enums

Valor

Nome simbólico

Descrição

0 GTK_FONT_FILTER_BASE Tells PHP-GTK not to allow the user to changethe filter via the Filters page of the GtkFontSelection class.1 GTK_FONT_FILTER_USER Tells PHP-GTK to allow the user to change thefilter via the Filters page of the GtkFontSelection class.

GtkFontType

Enums

Valor

Nome simbólico

Descrição

0 GTK_FONT_BITMAP Instructs PHP-GTK to show bitmap fonts whencalling GtkFontSelection:: set_filter or GtkFontSelectionDialog::set_filter.1 GTK_FONT_SCALABLE Instructs PHP-GTK to show scaleable fonts whencalling GtkFontSelection:: set_filter or GtkFontSelectionDialog::set_filter.2 GTK_FONT_SCALABLE_BITMAP Instructs PHP-GTK to show scaleablebitmap fonts when calling GtkFontSelection:: set_filter orGtkFontSelectionDialog:: set_filter.3 GTK_FONT_ALL Instructs PHP-GTK to show any font that matches anyof the above flags when calling GtkFontSelection:: set_filter orGtkFontSelectionDialog:: set_filter.

GtkJustification

Page 488: Apostila PHP GTK

Enums

Valor

Nome simbólico

Descrição

0 GTK_JUSTIFY_LEFT Left-justifies text within the containing area.1 GTK_JUSTIFY_RIGHT Right-justifies text within the containing area.2 GTK_JUSTIFY_CENTER Centers text within the containing area.3 GTK_JUSTIFY_FILL Justifies text from edge to edge of thecontaining area.

GtkObjectFlags

Flags

Valor

Nome simbólico

Descrição

0 GTK_DESTROYED The object has been destroyed and is processing anyshutdown callbacks required.1 GTK_FLOATING The object is not contained within another object.2 GTK_CONNECTED There are signals which are connected to thisobject.3 GTK_CONSTRUCTED The object has undergone its construction processand is ready to be used.

GtkOrientation

Enums

Valor

Nome simbólico

Descrição

0 GTK_ORIENTATION_HORIZONTAL1 GTK_ORIENTATION_VERTICAL

GtkPackerOptions

Flags

Valor

Nome simbólico

Page 489: Apostila PHP GTK

Descrição

0 GTK_PACK_EXPAND1 GTK_FILL_X2 GTK_FILL_Y

GtkPackType

Flags

Valor

Nome simbólico

Descrição

0 GTK_PACK_START Specifies that the packing should be done from topor left of the container widget.1 GTK_PACK_END Specifies that the packing should be done from thebottom or right of the container widget.

GtkPolicyType

Enums

Valor

Nome simbólico

Descrição

0 GTK_POLICY_ALWAYS The scrollbar is always on display.1 GTK_POLICY_AUTOMATIC The scrollbar is shown only when it isneeded. For instance, a GtkText may alter in size according to theamount of text displayed in it. The scrollbar will not be present whenthe text widget is empty, but will become apparent when the size ofthe text exceeds the size of the displayable page.2 GTK_POLICY_NEVER The scrollbar is never shown.

GtkPositionType

Enums

Valor

Nome simbólico

Descrição

0 GTK_POS_LEFT The feature is at the left edge.1 GTK_POS_RIGHT The feature is at the right edge.2 GTK_POS_TOP The feature is at the top edge.3 GTK_POS_BOTTOM The feature is at the bottom edge.

Page 490: Apostila PHP GTK

GtkPreviewType

Enums

Valor

Nome simbólico

Descrição

0 GTK_PREVIEW_COLOR1 GTK_PREVIEW_GRAYSCALE

GtkProgressBarOrientation

Enums

Valor

Nome simbólico

Descrição

0 GTK_PROGRESS_LEFT_TO_RIGHT A horizontal progress bar growing fromleft to right.1 GTK_PROGRESS_RIGHT_TO_LEFT A horizontal progress bar growing fromright to left.2 GTK_PROGRESS_BOTTOM_TO_TOP A vertical progress bar growing frombottom to top.3 GTK_PROGRESS_TOP_TO_BOTTOM A vertical progress bar growing fromtop to bottom.

GtkProgressBarStyle

Enums

Valor

Nome simbólico

Descrição

0 GTK_PROGRESS_CONTINUOUS The progress bar grows in a smooth,continuous manner.1 GTK_PROGRESS_DISCRETE The progress bar grows in discrete, visibleblocks.

GtkReliefStyle

Enums

Valor

Nome simbólico

Page 491: Apostila PHP GTK

Descrição

0 GTK_RELIEF_NORMAL The default relief style for a button.1 GTK_RELIEF_HALF Sets the shadow around the button toGTK_SHADOW_OUT until the button is pressed, and GTK_SHADOW_IN when itis. This is currently the normal relief style for a button.2 GTK_RELIEF_NONE Sets the shadow around the button toGTK_SHADOW_NONE except when the cursor enters the area of the button,meaning that only the contents (e.g. the label) of the button showuntil that point.

GtkResizeMode

Enums

Valor

Nome simbólico

Descrição

0 GTK_RESIZE_PARENT Default setting. Effectively shares thebehaviour described in GTK_RESIZE_QUEUE. Only used when writing anoriginal container widget.1 GTK_RESIZE_QUEUE Adds any resize requests from a container widgetto a queue of resize requests marked GTK_RESIZE_PENDING.2 GTK_RESIZE_IMMEDIATE Immediately resets the private flags on acontainer to GTK_RESIZE_NEEDED, giving the request priority over any(standard) queued resize requests.

GtkScrollType

Enums

Valor

Nome simbólico

Descrição

0 GTK_SCROLL_NONE The default setting. Indicates that thescrollbar's slider is not moved.1 GTK_SCROLL_STEP_BACKWARD Sets the scrollbar's slider back one stepincrement from its current position. The value of the step incrementis taken from the underlying GtkAdjustment in the scrollbar.2 GTK_SCROLL_STEP_FORWARD Sets the scrollbar's slider forward onestep increment from its current position. The value of the stepincrement is taken from the underlying GtkAdjustment in the scrollbar.3 GTK_SCROLL_PAGE_BACKWARD Sets the scrollbar's slider back one pageincrement from its current position. The value of the page incrementis taken from the underlying GtkAdjustment in the scrollbar.4 GTK_SCROLL_PAGE_FORWARD Sets the scrollbar's slider forward onepage increment from its current position. The value of the page

Page 492: Apostila PHP GTK

increment is taken from the underlying GtkAdjustment in the scrollbar.5 GTK_SCROLL_JUMP Sets the scrollbar's slider to the positiondescribed in the accompanying float parameter. The range of values are0 to 1, with the halfway point being 0.5.

GtkSelectionMode

Enums

Used in:* GtkCList::set_selection_mode()

Valor

Nome simbólico

Descrição

0 GTK_SELECTION_SINGLE Only one item can be selected at any givenmoment. Other items can have focus, but will not be marked asselected.1 GTK_SELECTION_BROWSE Only one item can be selected at any givenmoment. Any item currently having focus will be marked as selected.2 GTK_SELECTION_MULTIPLE Several items may be selected or unselectedwith a click or using the spacebar. They cannot be selected orunselected in any other way. Note that multiple selection should onlybe used where all items share the exact same callback routine.3 GTK_SELECTION_EXTENDED Several items may be selected or unselectedusing drag, or the shift (selects all items from the leader to thecurrent focus) or control (selects the item having current focus)keys. Note that extended selection should only be used where all itemsshare the exact same callback routine.

GtkShadowType

Enums

Valor

Nome simbólico

Descrição

0 GTK_SHADOW_NONE No shadow is displayed, resulting in atwo-dimensional appearance.1 GTK_SHADOW_IN Displays dark shadow on left and upper sides of thewidget, resulting in the appearance of the widget being lower than itssurrounding area.2 GTK_SHADOW_OUT Displays dark shadow on right and lower sides ofthe widget, resulting in the illusion that the widget is raised aboveits surrounding area.3 GTK_SHADOW_ETCHED_IN Displays the appearance of sunken detail.4 GTK_SHADOW_ETCHED_OUT Displays the appearance of raised detail.

Page 493: Apostila PHP GTK

GtkSideType

Enums

Valor

Nome simbólico

Descrição

0 GTK_SIDE_TOP1 GTK_SIDE_BOTTOM2 GTK_SIDE_LEFT3 GTK_SIDE_RIGHT

GtkSortType

Enums

Used in:* GtkCList::set_sort_type()

Valor

Nome simbólico

Descrição

0 GTK_SORT_ASCENDING Lowest value first: 1, 2, 31 GTK_SORT_DESCENDING Highest value first: 3, 2, 1

GtkSpinButtonUpdatePolicy

Enums

Valor

Nome simbólico

Descrição

0 GTK_UPDATE_ALWAYS Always updates the spinbutton value. If an entryis invalid, the value is updated to the lower or upper bound asappropriate.1 GTK_UPDATE_IF_VALID Prevents the spinbutton's current value frombeing altered where an entry is invalid.

GtkSpinType

Enums

Valor

Nome simbólico

Page 494: Apostila PHP GTK

Descrição

0 GTK_SPIN_STEP_FORWARD Spins forward by the value set in theunderlying step_increment. This value can be overridden by setting theincrement parameter to a value above 0.0.1 GTK_SPIN_STEP_BACKWARD Spins backward by the value set in theunderlying step_increment. This value can be overridden by setting theincrement parameter to a value above 0.0.2 GTK_SPIN_PAGE_FORWARD Spins forward by the value set aspage_increment in the underlying GtkAdjustment. The value set in theincrement parameter is ignored.3 GTK_SPIN_PAGE_BACKWARD Spins backward by the value set aspage_increment in the underlying GtkAdjustment. The value set in theincrement parameter is ignored.4 GTK_SPIN_HOME Spins to value set as lower bound. The value set inthe increment parameter is ignored.5 GTK_SPIN_END Spins to value set as upper bound. The value set inthe increment parameter is ignored.6 GTK_SPIN_USER_DEFINED Used where the amount of spin is not definedanywhere in the underlying GtkAdjustment. Negative or positive valuesset in the increment parameter are used to indicate the direction ofthe spin.

GtkStateType

Enums

Valor

Nome simbólico

Descrição

0 GTK_STATE_NORMAL Default state.1 GTK_STATE_ACTIVE Denotes that the widget is currently active, e.g.that a button is in the process of being clicked.2 GTK_STATE_PRELIGHT Denotes that the area of the widget has beenentered by the cursor.3 GTK_STATE_SELECTED Denotes that the widget is currently selected.4 GTK_STATE_INSENSITIVE Denotes that the widget cannot react to userinput.

GtkSubmenuPlacement

Enums

Valor

Nome simbólico

Descrição

0 GTK_TOP_BOTTOM

Page 495: Apostila PHP GTK

1 GTK_LEFT_RIGHT

GtkToolbarChildType

Enums

Valor

Nome simbólico

Descrição

0 GTK_TOOLBAR_CHILD_SPACE Just a space in the style of the toolbar'sGtkToolbarSpaceStyle.1 GTK_TOOLBAR_CHILD_BUTTON A GtkButton.2 GTK_TOOLBAR_CHILD_TOGGLEBUTTON A GtkToggleButton.3 GTK_TOOLBAR_CHILD_RADIOBUTTON A GtkRadioButton,4 GTK_TOOLBAR_CHILD_WIDGET Tells that you want to insert an existingwidget.

GtkToolbarSpaceStyle

Enums

Valor

Nome simbólico

Descrição

0 GTK_TOOLBAR_SPACE_EMPTY1 GTK_TOOLBAR_SPACE_LINE

GtkToolbarStyle

Enums

Valor

Nome simbólico

Descrição

0 GTK_TOOLBAR_ICONS1 GTK_TOOLBAR_TEXT2 GTK_TOOLBAR_BOTH

GtkTreeViewMode

Enums

Valor

Nome simbólico

Page 496: Apostila PHP GTK

Descrição

0 GTK_TREE_VIEW_LINE Entire item, including children, is highlightedwhen selected.1 GTK_TREE_VIEW_ITEM Only item, not children, is highlighted whenselected.

GtkUpdateType

Enums

Valor

Nome simbólico

Descrição

0 GTK_UPDATE_CONTINUOUS The value of the adjustment is updated whileslider is in motion.1 GTK_UPDATE_DISCONTINUOUS The value of the adjustment is updatedonly when the user releases the mouse and the slider drag operation isfinished.2 GTK_UPDATE_DELAYED The value of the adjustment is updated shortlyafter the slider has stopped moving, but not necessarily after theslider drag operation has finished.

GtkVisibility

Enums

Valor

Nome simbólico

Descrição

0 GTK_VISIBILITY_NONE1 GTK_VISIBILITY_PARTIAL2 GTK_VISIBILITY_FULL

GtkWidgetFlags

Flags

Valor

Nome simbólico

Descrição

0 GTK_TOPLEVEL Marks a widget as toplevel. This would generally beused internally by GTK.1 GTK_NO_WINDOW Marks a widget as having no GDK window. This would

Page 497: Apostila PHP GTK

generally be used internally by GTK, and indicates that the widget isunable to capture GDK events. See also: GtkEventBox.2 GTK_REALIZED Marks a widget as having been realized, that is,having its GdkWindow instantiated.3 GTK_MAPPED Marks a widget as having been mapped to the screen. Inorder to be mapped, a widget must have the GTK_VISIBLE flag set. Seealso: realize() , map() , show() .4 GTK_VISIBLE Marks a widget as visible. This is necessary beforethe widget can be mapped onto the screen.5 GTK_SENSITIVE Marks a widget as able to react to user input.6 GTK_PARENT_SENSITIVE Marks the parent of a widget as able to reactto user input.7 GTK_CAN_FOCUS Marks a widget as able to have focus.8 GTK_HAS_FOCUS Gives a widget focus.9 GTK_CAN_DEFAULT Marks a widget as able to have default status.This also has the effect of drawing the widget with enough spacearound it to display its default style.10 GTK_HAS_DEFAULT Gives a widget default status. The widget willrespond directly to keyboard events, and will be drawn in such a wayas to make this apparent to the user.11 GTK_HAS_GRAB Mostly used internally, to ensure that the widgetcurrently having focus is able to grab events relevant to it. Notethat flagging a widget in this way requires that the widget is alsoflagged as sensitive and has its reference count increased. Flaggingthe widget does not in itself have any bearing on the widget'srelationship with other widgets; if you want modality, use GtkWindow'sset_modal() method or the static function gtk::grab_add() asappropriate.12 GTK_RC_STYLE13 GTK_COMPOSITE_CHILD14 GTK_NO_REPARENT15 GTK_APP_PAINTABLE16 GTK_RECEIVES_DEFAULT A widget flagged in this way will receivethe default action and have GTK_HAS_DEFAULT set when it is focused,even if there is a different widget set as default.

GtkWindowPosition

Enums

Valor

Nome simbólico

Descrição

0 GTK_WIN_POS_NONE Default state. This setting uses the defaultwindow gravity on the underlying windowing system to determine theposition of the window. This generally results in the window beingmapped from the top left corner of the screen.1 GTK_WIN_POS_CENTER Places the window over the center of thescreen.2 GTK_WIN_POS_MOUSE Draws the window at the point of the mousecursor. This is useful for popup menus or similar widgets initiated by

Page 498: Apostila PHP GTK

a mouse-click.3 GTK_WIN_POS_CENTER_ALWAYS Places the window over the center of thescreen and keeps those co-ordinates stored in memory, so that a redrawfollowing a move elsewhere will reposition the window at the center.

GtkWindowType

Enums

Valor

Nome simbólico

Descrição

0 GTK_WINDOW_TOPLEVEL The default window type, describing a toplevelwindow with a title bar, minimize, maximize and close buttons. Notethat these window decorations are provided by the window manager andmay vary in appearance or even not exist on some operating systems.1 GTK_WINDOW_DIALOG A window type that is intended for messagesrequiring a user response. If a maximize button is displayed, it isgreyed out and the maximize function disabled on a dialog window.2 GTK_WINDOW_POPUP A window type with no window decorations orassociated functions. Do not use this to create popup menus; referinstead to the popup() method in GtkMenu, which provides its owninternal popup window.

GDK Enums

Os valores enumerados podem ser qualquer um dos valores listados.Flags podem ser uma combinação de qualquer um dos valores listados.Ambos enums e as flags tem um valor número e uma chave que pode serentendida pelo ser humano.

Índice

GdkCapStyleGdkCursorTypeGdkDragActionGdkEventMaskGdkEventTypeGdkFillGdkFontTypeGdkFunctionGdkInputConditionGdkInputSourceGdkJoinStyleGdkLineStyleGdkModifierTypeGdkRgbDitherGdkSubwindowModeGdkVisibilityStateGdkVisualTypeGdkWindowType

Page 499: Apostila PHP GTK

GdkCapStyle

Enums

Valor

Nome simbólico

Descrição

0 GDK_CAP_NOT_LAST1 GDK_CAP_BUTT2 GDK_CAP_ROUND3 GDK_CAP_PROJECTING

GdkCursorType

Enums

The cursor type determines which symbol is used for the mouse pointer.Default is an arrow pointing to the upper left.

Valor

Nome simbólico

Descrição

-1 GDK_CURSOR_IS_PIXMAP The cursor is self-created from pixmap.0 GDK_X_CURSOR A fat black line from the upper left to the lowerright, and a fat black line lower left to upper right2 GDK_ARROW Arrow pointing to the upper right.4 GDK_BASED_ARROW_DOWN6 GDK_BASED_ARROW_UP8 GDK_BOAT10 GDK_BOGOSITY12 GDK_BOTTOM_LEFT_CORNER Cursor indicating the lower left corner.14 GDK_BOTTOM_RIGHT_CORNER Cursor indicating the lower right corner.16 GDK_BOTTOM_SIDE Cursor indicating the lower edge.18 GDK_BOTTOM_TEE20 GDK_BOX_SPIRAL22 GDK_CENTER_PTR24 GDK_CIRCLE26 GDK_CLOCK28 GDK_COFFEE_MUG30 GDK_CROSS32 GDK_CROSS_REVERSE34 GDK_CROSSHAIR36 GDK_DIAMOND_CROSS38 GDK_DOT40 GDK_DOTBOX42 GDK_DOUBLE_ARROW For resizing a horizontal edge (up-down).44 GDK_DRAFT_LARGE

Page 500: Apostila PHP GTK

46 GDK_DRAFT_SMALL48 GDK_DRAPED_BOX50 GDK_EXCHANGE Reload symbol52 GDK_FLEUR Move symbol54 GDK_GOBBLER A bird56 GDK_GUMBY58 GDK_HAND1 Hand pointing to the upper right.60 GDK_HAND2 Hand pointing to the upper left.62 GDK_HEART A heart.64 GDK_ICON66 GDK_IRON_CROSS68 GDK_LEFT_PTR Normal pointer to the upper left.70 GDK_LEFT_SIDE Cursor indicating the left edge.72 GDK_LEFT_TEE74 GDK_LEFTBUTTON Three-button mouse with left button activated.76 GDK_LL_ANGLE78 GDK_LR_ANGLE80 GDK_MAN82 GDK_MIDDLEBUTTON Three-button mouse with middle button activated.84 GDK_MOUSE The upper half of a mouse.86 GDK_PENCIL A pencil.88 GDK_PIRATE The pirate sign (skull with crossed bones).90 GDK_PLUS Just a plus.92 GDK_QUESTION_ARROW Question cursor; mostly used for "What'sthis?" functions.94 GDK_RIGHT_PTR Normal cursor pointing to the upper right.96 GDK_RIGHT_SIDE Cursor indicating the right edge.98 GDK_RIGHT_TEE100 GDK_RIGHTBUTTON Three-button mouse with right button activated.102 GDK_RTL_LOGO104 GDK_SAILBOAT Sailing boat.106 GDK_SB_DOWN_ARROW108 GDK_SB_H_DOUBLE_ARROW110 GDK_SB_LEFT_ARROW112 GDK_SB_RIGHT_ARROW114 GDK_SB_UP_ARROW116 GDK_SB_V_DOUBLE_ARROW118 GDK_SHUTTLE Space shuttle.120 GDK_SIZING122 GDK_SPIDER Spider...124 GDK_SPRAYCAN Spraying can, useful for drawing programs.126 GDK_STAR Star with 5 corners.128 GDK_TARGET130 GDK_TCROSS Thin cross.132 GDK_TOP_LEFT_ARROW Arrow pointing to the upper left.134 GDK_TOP_LEFT_CORNER Cursor indicating the upper left corner.136 GDK_TOP_RIGHT_CORNER Cursor indicating the upper right corner.138 GDK_TOP_SIDE Cursor indicating the upper edge.140 GDK_TOP_TEE142 GDK_TREK Star Trek ship NCC 1701-A144 GDK_UL_ANGLE146 GDK_UMBRELLA An umbrella symbol.148 GDK_UR_ANGLE150 GDK_WATCH A watch for the wrist.

Page 501: Apostila PHP GTK

152 GDK_XTERM Caret symbol (text input)

GdkDragAction

Enums

Valor

Nome simbólico

Descrição

0 GDK_ACTION_DEFAULT1 GDK_ACTION_COPY2 GDK_ACTION_MOVE3 GDK_ACTION_LINK4 GDK_ACTION_PRIVATE5 GDK_ACTION_ASK

GdkEventMask

Flags

Valor

Nome simbólico

Descrição

0 GDK_EXPOSURE_MASK Setting this flag allows the GDK_EXPOSE event tobe captured by a widget's GdkWindow. This causes the widget to emitthe "expose-event" signal.1 GDK_POINTER_MOTION_MASK Setting this flag allows theGDK_MOTION_NOTIFY event to be captured by a widget's GdkWindow. Thismakes the widget emit the "motion-notify-event" signal.2 GDK_POINTER_MOTION_HINT_MASK This is a special flag allowing aless intensive version of the GDK_POINTER_MOTION_MASK functionality.This can be necessary to avoid a time-lag in processing caused by thesheer volume of GDK_MOTION_NOTIFY events produced by mouse movement,each once of which causes a "motion-notify-event" signal to be firedby the widget.3 GDK_BUTTON_MOTION_MASK Allows the GDK_MOTION_NOTIFY events to bepicked up by the widget's GdkWindow only while a mouse-button (any) ispressed down. This is a way of limiting the widget's"motion-notify-event" signal emissions.4 GDK_BUTTON1_MOTION_MASK Allows the GDK_MOTION_NOTIFY events to bepicked up by the widget's GdkWindow only while mouse-button 1 ispressed down - usually that's the left button. This is a way oflimiting the widget's "motion-notify-event" signal emissions.5 GDK_BUTTON2_MOTION_MASK Allows the GDK_MOTION_NOTIFY events to bepicked up by the widget's GdkWindow only while mouse-button 2 ispressed down - usually that's the center button, where it exists. Thisis a way of limiting the widget's "motion-notify-event" signalemissions.

Page 502: Apostila PHP GTK

6 GDK_BUTTON3_MOTION_MASK Allows the GDK_MOTION_NOTIFY events to bepicked up by the widget's GdkWindow only while mouse-button 3 ispressed down - usually that's the right button. This is a way oflimiting the widget's "motion-notify-event" signal emissions.7 GDK_BUTTON_PRESS_MASK Setting this flag allows theGDK_BUTTON_PRESS events to be captured by a widget's GdkWindow. Thismakes the widget emit the "button-press-event" signal.8 GDK_BUTTON_RELEASE_MASK Setting this flag allows theGDK_BUTTON_RELEASE event to be captured by a widget's GdkWindow. Thismakes the widget emit the "button-release-event" signal.9 GDK_KEY_PRESS_MASK Setting this flag allows the GDK_KEY_PRESSevent to be captured by a widget's GdkWindow. This makes the widgetemit the "key-press-event" signal.10 GDK_KEY_RELEASE_MASK Setting this flag allows the GDK_KEY_RELEASEevent to be captured by a widget's GdkWindow. This makes the widgetemit the "key-release-event" signal.11 GDK_ENTER_NOTIFY_MASK Setting this flag allows theGDK_ENTER_NOTIFY event to be captured by a widget's GdkWindow. Thiscauses the widget to emit the "enter-notify-event" signal.12 GDK_LEAVE_NOTIFY_MASK Setting this flag allows theGDK_LEAVE_NOTIFY event to be captured by a widget's GdkWindow. Thismakes the widget emit the "leave-notify-event" signal.13 GDK_FOCUS_CHANGE_MASK Setting this flag allows theGDK_FOCUS_CHANGE event to be captured by a widget's GdkWindow. Thismakes the widget emit the "focus-in-event" or "focus-out-event" signalas appropriate.14 GDK_STRUCTURE_MASK This flag is set on all new instances ofGdkWindow. It allows map, unmap, destroy and configure events to becaptured, causing "map-event", "unmap-event", "destroy-event" and"configure-event" signals to be emitted from all windowed widgets.15 GDK_PROPERTY_CHANGE_MASK Setting this flag allows theGDK_PROPERTY_NOTIFY event to be captured by a widget's GdkWindow. Thismakes the widget emit the "property-notify-event" signal.16 GDK_VISIBILITY_NOTIFY_MASK Setting this flag allows theGDK_VISIBILITY_NOTIFY event to be captured by a widget's GdkWindow.This causes the widget to emit the "visibility-notify-event" signal.17 GDK_PROXIMITY_IN_MASK Setting this flag allows theGDK_PROXIMITY_IN event to be captured by a widget's GdkWindow. Thiscauses the widget to emit the "proximity-in-event" signal.18 GDK_PROXIMITY_OUT_MASK Setting this flag allows theGDK_PROXIMITY_OUT event to be captured by a widget's GdkWindow. Thismakes the widget emit the "proximity-out-event" signal.19 GDK_SUBSTRUCTURE_MASK Enables the widget's GdkWindow to captureGDK_STRUCTURE_MASK events on any child windows.20 GDK_ALL_EVENTS_MASK Setting this flag allows any GdkEvent to becaptured by a widget's GdkWindow.

GdkEventType

Enums

Valor

Nome simbólico

Page 503: Apostila PHP GTK

Descrição

-1 GDK_NOTHING A null event.0 GDK_DELETE This event is triggered when the user clicks on the Xbutton on a decorated window.1 GDK_DESTROY This event is triggered when a widget is beingdestroyed.2 GDK_EXPOSE This event is triggered whenever a widget is exposed todisplay. That includes all redraws, full or partial.3 GDK_MOTION_NOTIFY This event is triggered when the mouse is moved.4 GDK_BUTTON_PRESS This event is triggered when any mouse button ispressed.5 GDK_2BUTTON_PRESS This event is triggered when there are two mousebutton presses in quick succession - a double-click. It is preceded bya second GDK_BUTTON_PRESS and that event's corollary, aGDK_BUTTON_RELEASE.6 GDK_3BUTTON_PRESS This event is triggered when there are threemouse button presses in quick succession - a treble-click. It ispreceded by two GDK_BUTTON_PRESS and one GDK_2BUTTON_PRESS event, aswell as the associated GDK_BUTTON_RELEASE events.7 GDK_BUTTON_RELEASE This event is triggered when any mouse buttonis released.8 GDK_KEY_PRESS This event is triggered when any key is pressed.9 GDK_KEY_RELEASE This event is triggered when any key is released.10 GDK_ENTER_NOTIFY This event is triggered when the cursor entersthe screen area of a widget.11 GDK_LEAVE_NOTIFY This event is triggered when the cursor leavesthe screen area of a widget.12 GDK_FOCUS_CHANGE This event is triggered whenever there is akeyboard focus change, in or out.13 GDK_CONFIGURE This event is triggered whenever a widget is drawn,that is, at its first display and on any subsequent redraws caused bymoving or resizing.14 GDK_MAP This event is triggered during the show() process, whilethe widget is being mapped to the screen.15 GDK_UNMAP This event is triggered during the hide() process,while the widget is being removed from display.16 GDK_PROPERTY_NOTIFY17 GDK_SELECTION_CLEAR18 GDK_SELECTION_REQUEST19 GDK_SELECTION_NOTIFY20 GDK_PROXIMITY_IN21 GDK_PROXIMITY_OUT22 GDK_DRAG_ENTER23 GDK_DRAG_LEAVE24 GDK_DRAG_MOTION25 GDK_DRAG_STATUS26 GDK_DROP_START27 GDK_DROP_FINISHED28 GDK_CLIENT_EVENT29 GDK_VISIBILITY_NOTIFY30 GDK_NO_EXPOSE

Page 504: Apostila PHP GTK

GdkFill

Enums

Valor

Nome simbólico

Descrição

0 GDK_SOLID1 GDK_TILED2 GDK_STIPPLED3 GDK_OPAQUE_STIPPLED

GdkFontType

Enums

Valor

Nome simbólico

Descrição

0 GDK_FONT_FONT An internal constuct denoting that a single font hasbeen loaded into a GdkFont structure.1 GDK_FONT_FONTSET An internal construct denoting that severalalternate fonts have been loaded into a GdkFont structure. In win32,all GdkFont type queries will return this type.

GdkFunction

Enums

Valor

Nome simbólico

Descrição

0 GDK_COPY1 GDK_INVERT2 GDK_XOR3 GDK_CLEAR4 GDK_AND5 GDK_AND_REVERSE6 GDK_AND_INVERT7 GDK_NOOP8 GDK_OR9 GDK_INVERT10 GDK_XOR11 GDK_EQUIV12 GDK_OR_REVERSE

Page 505: Apostila PHP GTK

13 GDK_COPY_INVERT14 GDK_OR_INVERT15 GDK_NAND16 GDK_SET

GdkInputCondition

Enums

Valor

Nome simbólico

Descrição

0 GDK_INPUT_READ1 GDK_INPUT_WRITE2 GDK_INPUT_EXCEPTION

GdkInputSource

Enums

Valor

Nome simbólico

Descrição

0 GDK_SOURCE_MOUSE1 GDK_SOURCE_PEN2 GDK_SOURCE_ERASER3 GDK_SOURCE_CURSOR

GdkJoinStyle

Enums

Valor

Nome simbólico

Descrição

0 GDK_JOIN_MITER1 GDK_JOIN_ROUND2 GDK_JOIN_BEVEL

GdkLineStyle

Enums

Valor

Page 506: Apostila PHP GTK

Nome simbólico

Descrição

0 GDK_LINE_SOLID1 GDK_LINE_ON_OFF_DASH2 GDK_LINE_DOUBLE_DASH

GdkModifierType

Flags

Valor

Nome simbólico

Descrição

0 GDK_SHIFT_MASK Denotes that a shift modifier is in place. Adedicated key or mouse-button will not become active until the Shiftkey is pressed down.1 GDK_LOCK_MASK Denotes that a Caps Lock modifier is in place. Notethat this modifier is illegal for use with accelerator keys, and willnot work there.2 GDK_CONTROL_MASK Denotes that a control modifier is in place. Adedicated key or mouse-button will not become active until the Controlkey is pressed down.3 GDK_MOD1_MASK Denotes that an alt modifier is in place. Adedicated key or mouse-button will not become active until the Alt keyis pressed down.4 GDK_MOD2_MASK5 GDK_MOD3_MASK6 GDK_MOD4_MASK7 GDK_MOD5_MASK8 GDK_BUTTON1_MASK The first (mostly left) mouse button.9 GDK_BUTTON2_MASK The second (middle) mouse button.10 GDK_BUTTON3_MASK The third (mostly right) mouse button.11 GDK_BUTTON4_MASK Mouse wheel up.12 GDK_BUTTON5_MASK Mouse wheel down.13 GDK_RELEASE_MASK Denotes that the act of releasing the button isa modifier.14 GDK_MODIFIER_MASK Returns all the modifiers that are possible inthe current context.

GdkRgbDither

Enums

Valor

Nome simbólico

Descrição

Page 507: Apostila PHP GTK

0 GDK_RGB_DITHER_NONE1 GDK_RGB_DITHER_NORMAL2 GDK_RGB_DITHER_MAX

GdkSubwindowMode

Enums

Valor

Nome simbólico

Descrição

0 GDK_CLIP_BY_CHILDREN1 GDK_INCLUDE_INFERIORS

GdkVisibilityState

Enums

Valor

Nome simbólico

Descrição

0 GDK_VISIBILITY_UNOBSCURED1 GDK_VISIBILITY_PARTIAL2 GDK_VISIBILITY_FULLY_OBSCURED

GdkVisualType

Enums

Valor

Nome simbólico

Descrição

0 GDK_VISUAL_STATIC_GRAY1 GDK_VISUAL_GRAYSCALE2 GDK_VISUAL_STATIC_COLOR3 GDK_VISUAL_PSEUDO_COLOR4 GDK_VISUAL_TRUE_COLOR5 GDK_VISUAL_DIRECT_COLOR

GdkWindowType

Enums

Identifies the type of a GdkWindow

Page 508: Apostila PHP GTK

Used by the type property of GdkWindow.

Valor

Nome simbólico

Descrição

0 GDK_WINDOW_ROOT The root gdk window of a GtkWindow's GdkWindow.1 GDK_WINDOW_TOPLEVEL A toplevel GdkWindow, e.g. of a GtkWindow.2 GDK_WINDOW_CHILD3 GDK_WINDOW_DIALOG4 GDK_WINDOW_TEMP5 GDK_WINDOW_PIXMAP6 GDK_WINDOW_FOREIGN

GtkExtra Enums

Enumerated values for the GtkExtra classes

Índice

GtkPlotEnumsGtkPlotScaleGtkPlotSymbolTypeGtkPlotSymbolStyleGtkPlotBorderStyleGtkPlotLineStyleGtkPlotConnectorGtkPlotLabelPosGtkPlotErrorGtkPlotOrientationGtkPlotAxisPosGtkPlotLabelStyleGtkPlotTicksPosGtkPlotCanvasGtkPlotCanvasActionGtkPlotCanvasFlagGtkPlotCanvasArrowGtkPlotCanvasSelectionGtkPlotCanvasSelectionModeGtkPlotCanvasTypeGtkPlotCanvasPosGtkSheetAttrTypeGtkSheetEnums

GtkPlotEnums

Enums

Valor

Nome simbólico

Page 509: Apostila PHP GTK

Descrição

0 GTK_PLOT_GRADIENT_H1 GTK_PLOT_GRADIENT_V2 GTK_PLOT_GRADIENT_S

GtkPlotScale

Enums

Valor

Nome simbólico

Descrição

0 GTK_PLOT_SCALE_LINEAR1 GTK_PLOT_SCALE_LOG10

GtkPlotSymbolType

Enums

Valor

Nome simbólico

Descrição

0 GTK_PLOT_SYMBOL_NONE1 GTK_PLOT_SYMBOL_SQUARE2 GTK_PLOT_SYMBOL_CIRCLE3 GTK_PLOT_SYMBOL_UP_TRIANGLE4 GTK_PLOT_SYMBOL_DOWN_TRIANGLE5 GTK_PLOT_SYMBOL_RIGHT_TRIANGLE6 GTK_PLOT_SYMBOL_LEFT_TRIANGLE7 GTK_PLOT_SYMBOL_DIAMOND8 GTK_PLOT_SYMBOL_PLUS9 GTK_PLOT_SYMBOL_CROSS10 GTK_PLOT_SYMBOL_STAR11 GTK_PLOT_SYMBOL_DOT12 GTK_PLOT_SYMBOL_IMPULSE

GtkPlotSymbolStyle

Enums

Valor

Nome simbólico

Descrição

0 GTK_PLOT_SYMBOL_EMPTY

Page 510: Apostila PHP GTK

1 GTK_PLOT_SYMBOL_FILLED2 GTK_PLOT_SYMBOL_OPAQUE

GtkPlotBorderStyle

Enums

Valor

Nome simbólico

Descrição

0 GTK_PLOT_BORDER_NONE1 GTK_PLOT_BORDER_LINE2 GTK_PLOT_BORDER_SHADOW

GtkPlotLineStyle

Enums

Valor

Nome simbólico

Descrição

0 GTK_PLOT_LINE_NONE1 GTK_PLOT_LINE_SOLID2 GTK_PLOT_LINE_DOTTED3 GTK_PLOT_LINE_DASHED4 GTK_PLOT_LINE_DOT_DASH5 GTK_PLOT_LINE_DOT_DOT_DASH6 GTK_PLOT_LINE_DOT_DASH_DASH

GtkPlotConnector

Enums

Valor

Nome simbólico

Descrição

0 GTK_PLOT_CONNECT_NONE1 GTK_PLOT_CONNECT_STRAIGHT2 GTK_PLOT_CONNECT_SPLINE3 GTK_PLOT_CONNECT_HV_STEP4 GTK_PLOT_CONNECT_VH_STEP5 GTK_PLOT_CONNECT_MIDDLE_STEP

GtkPlotLabelPos

Page 511: Apostila PHP GTK

Enums

Valor

Nome simbólico

Descrição

0 GTK_PLOT_LABEL_NONE1 GTK_PLOT_LABEL_IN2 GTK_PLOT_LABEL_OUT

GtkPlotError

Enums

Valor

Nome simbólico

Descrição

0 GTK_PLOT_ERROR_DIV_ZERO

GtkPlotOrientation

Enums

Valor

Nome simbólico

Descrição

0 GTK_PLOT_AXIS_X1 GTK_PLOT_AXIS_Y2 GTK_PLOT_AXIS_Z

GtkPlotAxisPos

Enums

Valor

Nome simbólico

Descrição

0 GTK_PLOT_AXIS_LEFT1 GTK_PLOT_AXIS_RIGHT2 GTK_PLOT_AXIS_TOP3 GTK_PLOT_AXIS_BOTTOM

GtkPlotLabelStyle

Page 512: Apostila PHP GTK

Enums

Valor

Nome simbólico

Descrição

0 GTK_PLOT_LABEL_FLOAT1 GTK_PLOT_LABEL_EXP2 GTK_PLOT_LABEL_POW

GtkPlotTicksPos

Enums

Valor

Nome simbólico

Descrição

0 GTK_PLOT_TICKS_NONE1 GTK_PLOT_TICKS_IN2 GTK_PLOT_TICKS_OUT

GtkPlotCanvas

Enums

Valor

Nome simbólico

Descrição

0 GTK_PLOT_CANVAS_CAN_SELECT1 GTK_PLOT_CANVAS_CAN_SELECT_ITEM2 GTK_PLOT_CANVAS_CAN_SELECT_POINT3 GTK_PLOT_CANVAS_CAN_DND4 GTK_PLOT_CANVAS_CAN_DND_POINT

GtkPlotCanvasAction

Enums

Valor

Nome simbólico

Descrição

0 GTK_PLOT_CANVAS_ACTION_INACTIVE

Page 513: Apostila PHP GTK

1 GTK_PLOT_CANVAS_ACTION_SELECTION2 GTK_PLOT_CANVAS_ACTION_DRAG3 GTK_PLOT_CANVAS_ACTION_RESIZE

GtkPlotCanvasFlag

Enums

Valor

Nome simbólico

Descrição

0 GTK_PLOT_CANVAS_FROZEN1 GTK_PLOT_CANVAS_CAN_MOVE2 GTK_PLOT_CANVAS_CAN_X_RESIZE3 GTK_PLOT_CANVAS_CAN_Y_RESIZE

GtkPlotCanvasArrow

Enums

Valor

Nome simbólico

Descrição

0 GTK_PLOT_ARROW_NONE1 GTK_PLOT_ARROW_ORIGIN2 GTK_PLOT_ARROW_END

GtkPlotCanvasSelection

Enums

Valor

Nome simbólico

Descrição

0 GTK_PLOT_CANVAS_SELECT_NONE1 GTK_PLOT_CANVAS_SELECT_MARKERS2 GTK_PLOT_CANVAS_SELECT_TARGET

GtkPlotCanvasSelectionMode

Enums

Valor

Nome simbólico

Page 514: Apostila PHP GTK

Descrição

0 GTK_PLOT_CANVAS_SELECT_CLICK_11 GTK_PLOT_CANVAS_SELECT_CLICK_2

GtkPlotCanvasType

Enums

Valor

Nome simbólico

Descrição

0 GTK_PLOT_CANVAS_NONE1 GTK_PLOT_CANVAS_PLOT2 GTK_PLOT_CANVAS_AXIS3 GTK_PLOT_CANVAS_LEGENDS4 GTK_PLOT_CANVAS_TITLE5 GTK_PLOT_CANVAS_TEXT6 GTK_PLOT_CANVAS_DATA7 GTK_PLOT_CANVAS_LINE8 GTK_PLOT_CANVAS_RECTANGLE9 GTK_PLOT_CANVAS_ELLIPSE10 GTK_PLOT_CANVAS_PIXMAP11 GTK_PLOT_CANVAS_MARKER12 GTK_PLOT_CANVAS_CUSTOM

GtkPlotCanvasPos

Enums

Valor

Nome simbólico

Descrição

0 GTK_PLOT_CANVAS_OUT1 GTK_PLOT_CANVAS_IN2 GTK_PLOT_CANVAS_LEFT3 GTK_PLOT_CANVAS_RIGHT4 GTK_PLOT_CANVAS_TOP5 GTK_PLOT_CANVAS_BOTTOM6 GTK_PLOT_CANVAS_TOP_LEFT7 GTK_PLOT_CANVAS_TOP_RIGHT8 GTK_PLOT_CANVAS_BOTTOM_LEFT9 GTK_PLOT_CANVAS_BOTTOM_RIGHT

GtkSheetAttrType

Enums

Page 515: Apostila PHP GTK

Valor

Nome simbólico

Descrição

0 GTK_SHEET_FOREGROUND1 GTK_SHEET_BACKGROUND2 GTK_SHEET_FONT3 GTK_SHEET_JUSTIFICATION4 GTK_SHEET_BORDER5 GTK_SHEET_BORDER_COLOR6 GTK_SHEET_IS_EDITABLE7 GTK_SHEET_IS_VISIBLE

GtkSheetEnums

Enums

Valor

Nome simbólico

Descrição

0 GTK_SHEET_IS_LOCKED1 GTK_SHEET_IS_FROZEN2 GTK_SHEET_IN_XDRAG3 GTK_SHEET_IN_YDRAG4 GTK_SHEET_IN_DRAG5 GTK_SHEET_IN_SELECTION6 GTK_SHEET_IN_RESIZE7 GTK_SHEET_IN_CLIP8 GTK_SHEET_ROW_FROZEN9 GTK_SHEET_COLUMN_FROZEN10 GTK_SHEET_AUTORESIZE11 GTK_SHEET_CLIP_TEXT12 GTK_SHEET_ROW_TITLES_VISIBLE13 GTK_SHEET_COL_TITLES_VISIBLE14 GTK_SHEET_AUTO_SCROLL15 GTK_SHEET_JUSTIFY_ENTRY

Classes do Glade

A Classe Glade

Índice

GladeXMLLoading XML GUI definition files on the fly

Misc Glade FunctionsPrefix the functions with "libglade::".

Page 516: Apostila PHP GTK

GladeXML

Loading XML GUI definition files on the fly

Hierarquia do Objeto

GtkObject`-- GtkData`-- GladeXML

Direct subclasses

None.

Descrição

Glade is a user interface builder for Gtk. With it you can createyour the surface of your applications in a WYSIWYG manner withouthhaving to worry about commands like add() , pack_start() andpack_end() .

Glade has the ability to generate source code which creates thewhole interface - but only for C, C++ and Ada95. Another way ofusing the interfaces created with glade is to load the .glade filesdynamically from the application with the GladeXML class, andPHP-Gtk supports this.

When using glade in your PHP-Gtk applications, you have at least 2files:

* Your .phpw application with the php code* A .glade file which contains the user interface definition

When starting the program, the glade class is used to load the fullcontents (if you designed the full UI in glade) or only a part ofthe user interface (if you e.g. created just the menus with glade)from the .glade file. After loading, the widgets behave the same asif they were created the "normal" way.

Single widgets can be accessed with the get_widget() functions.Signals which can be assigned directly in Glade can be connectedautomatically with signal_autoconnect() .

The original glade application can be found at glade.gnome.org anda windows port at wingtk.sourceforge.net. There is also a toolcalled AppWizard which creates the php framework from .glade filesso that you can concentrate on implementing the real applicationfunctions.

PHP-Gtk 1.x supports glade 1 files only. This means you can not useGlade2 for user interface creation but Glade1.

Construtor

Page 517: Apostila PHP GTK

GladeXML (string fname, [string root = NULL, [string domain = NULL]]);

-- Creates a new GladeXML instance.

Métodos

get_widget()Returns the widget with the given name.

get_widget_by_long_name()

Returns the widget specified by the given path.

signal_connect()Connects all signals with the given handler to a callback function.

signal_connect_object()Connects all signals with the given handler to a callback function.

signal_autoconnect()Connects all signal handlers to functions.

signal_autoconnect_object()Connects all signal handlers to functions.

relative_file()Creates an absolute filename from a relative one.

GladeXML Construtor

GladeXML (string fname, [string root = NULL, [string domain = NULL]]);

Creates a new instance of the glade class, based on a glade filefname.

If you want to load the whole glade file, you can omit the rootparameter. For loading only a part of the file, e.g. the menudefinition, you can pass the name of the wished root element. In theexample we could use "btnClose" to load the close button only. If thebutton had subwidgets, they would be loaded as well.

When using the GNU Gettext module for internationalization, you canspecifiy the gettext domain as third parameter. Glade will translateall the properties marked with "translatable" via the gettextfunctions on this domain.

The following two files result in a sample application which loads theglade file and connect the button's "clicked" signal to exit theapplication. You don't need to call the show() and realize() functionsas glade takes care of this.

Exemplo 64. Basic application which loads a glade file<?php

Page 518: Apostila PHP GTK

if( !extension_loaded('gtk')) {dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);}

$glade =& new GladeXML( dirname( __FILE__) . "/hellowg.glade");

$dlgHello = $glade->get_widget( 'dlgHellow');$dlgHello->connect_object( 'destroy', array( 'gtk', 'main_quit'));

$btnClose = $glade->get_widget( 'btnClose');$btnClose->connect_object( 'clicked', array( 'gtk', 'main_quit'));

gtk::main();?>

Exemplo 65. Basic glade file "hellowg.glade"<?xml version="1.0"?><GTK-Interface>

<project><name>example-gladexml.constructor</name><program_name>example-gladexml.constructor</program_name><directory></directory><source_directory>src</source_directory><pixmaps_directory>pixmaps</pixmaps_directory><language>C</language><gnome_support>False</gnome_support><gettext_support>False</gettext_support></project>

<widget><class>GtkWindow</class><name>dlgHellow</name><title>Hello World!</title><type>GTK_WINDOW_TOPLEVEL</type><position>GTK_WIN_POS_NONE</position><modal>False</modal><allow_shrink>False</allow_shrink><allow_grow>True</allow_grow><auto_shrink>False</auto_shrink>

<widget><class>GtkVBox</class><name>vbox1</name><homogeneous>False</homogeneous><spacing>0</spacing>

<widget><class>GtkLabel</class><name>lblHello</name><label>Hello world!This is the example programfor the GladeXML class</label><justify>GTK_JUSTIFY_CENTER</justify>

Page 519: Apostila PHP GTK

<wrap>False</wrap><xalign>0.5</xalign><yalign>0.5</yalign><xpad>0</xpad><ypad>0</ypad><child><padding>0</padding><expand>True</expand><fill>True</fill></child></widget>

<widget><class>GtkButton</class><name>btnClose</name><can_focus>True</can_focus><signal><name>clicked</name><handler>test</handler><last_modification_time>Sun, 29 Aug 2004 10:33:10 GMT</last_modification_time></signal><label>Close this window</label><relief>GTK_RELIEF_NORMAL</relief><child><padding>0</padding><expand>False</expand><fill>False</fill></child></widget></widget></widget>

</GTK-Interface>

When defining more than one window in the glade file, all windows areshown when loading it. You can set the "Visible" property in glade toavoid this.

A small explanation of the code above: The glade code wasautomatically created with glade. The instantiation of the gladerequires the filename as first parameter, and we use dirname(__FILE__) . '/hellow.glade' to make sure the glade file is loaded fromthe same location where the php script is located. If you would passthe filename without the parameter to the glade constructor, the gladefile wouldn't be found if the program is run in a working directorywhich is not the directory of the php script. To let the applicationexit tidily, we connect the "destroy" signal of the window as normal;but before we get the widget via the get_widget() function.

GladeXML::get_widget

GtkWidget get_widget(string name);

Page 520: Apostila PHP GTK

Returns the widget with the given name, so that it can be accessed asif it were constructed directly. In the example, you would just haveto pass "btnClose" to get the close button.

The function returns NULL if the widget does not exist.

The counterpart to this function is get_widget_name().

GladeXML::get_widget_by_long_name

GtkWidget get_widget_by_long_name(string path);

Returns the widget specified by the given path, so that it can beaccessed normally. Other than with get_widget() you don't pass thename but the full path with all parent widget names, separated byperiods. In the example you get the close button with"dlgHellow.vbox1.btnClose".

The function returns NULL if the widget does not exist.

The counterpart to this function is get_widget_long_name().

GladeXML::signal_connect

void signal_connect(string handler, mixed callback, [mixeduser_param]);

Connects all signals with the given handler to a callback function.

In glade, you can "connect" signals to "handlers". These handlers canbe named like functions but not necessarily have to be: When usingthis signal_connect() function you can connect the handler "clicker"to a function called "test". When using signal_autoconnect() this isnot possible as glade connects only handlers to functions of the samename as the handler.

Try to extend the example with the following (after gladeinstantiation and before gtk_main):function tester(){echo 'test' . "\r\n";}$glade->signal_connect( 'test', 'tester');

If you click the close button now, you will see an "test" output linein the shell prompt.

If you want to connect to a function of an object, you should use thefollowing construct:$glade->signal_connect( 'test', array( $obj, 'function'));

which would cause the 'function' function of the $obj object to beused as the callback for the test handler. Instead of an object youcan use a normal string; this means the static function of this class

Page 521: Apostila PHP GTK

is called:$glade->signal_connect( 'test', array( 'gtk', 'main_quit'));

This would be the same as a call of gtk::main_quit().

You can pass any type and number of additional parameters to thecallback function. Note that the first parameter will be the callingwidget.

GladeXML::signal_connect_object

void signal_connect_object(string handler, mixed callback, [mixeduser_param]);

Connects all signals with the given handler to a callback function.Other than signal_connect() the calling widget will not be passed asthe first parameter (just omitted).

GladeXML::signal_autoconnect

void signal_autoconnect([array handlers]);

Connects all signal handlers defined in the glade file to functionswith the same name as the signal handler.

In the example, the "clicked" signal of the close button would beconnected to a function called "test" if it exists in the source.

Try to extend the example with the following (after gladeinstantiation and before gtk_main):function test(){echo 'test' . "\r\n";}$glade->signal_autoconnect();

If you click the close button now, you will see an "test" output linein the shell prompt.

The first parameter passed to the callback will be the calling widget.

The handlers parameter can be used to define a whole signal-callbackstructure and connect them with one call. The array itself containskey-value pairs with the keys being the handlers defined in the gladefile (see signal_connect() for an explanation of handlers). The valuesitself have also to be arrays. This subarrays contain (mostly one) anumber of callbacks.

Exemplo 66. Using the autoconnect parameter$glade->signal_autoconnect(array('test' => array( 'test'),'moved' => array( 'moved'))

Page 522: Apostila PHP GTK

);

Although the subarray needs to be an array, it is not possible toconnect a handler to several callbacks.

GladeXML::signal_autoconnect_object

void signal_autoconnect_object([array handlers]);

Connects all signal handlers defined in the glade file to functionswith the same name as the signal handler. Other thansignal_autoconnect() the calling widget will not be passed as thefirst parameter (just omitted).

For an explanation of the handlers parameter see signal_autoconnect().

GladeXML::relative_file

string relative_file(string filename);

Creates an absolute filename from a relative one. The new filenamewill be absolute to the directory of the .glade file. If the filenamewas absolute, it stays untouched.

Example: The .glade file is located at /data/php/gtk/test.glade andyou pass "window.xpm" to this function, the result will be/data/php/gtk/window.xpm.

Misc Glade Functions

Prefix the functions with "libglade::".

get_widget_name()

Returns the name of a widget from a glade file.

get_widget_long_name()Returns the long name of a widget from a glade file.

get_widget_tree()Returns the glade object to a widget.

xml_new_from_memory()Creates a glade object from a string instead of a file.

get_widget_name

string get_widget_name(GtkWidget widget);

Returns the name of a widget which has been loaded from a glade file.

If the widget has been created the "normal" way and not with glade,NULL is returned.

Page 523: Apostila PHP GTK

In the example you could use avar_dump( libglade::get_widget_name( $btnClose));

which would return string(8) "btnClose".

get_widget_long_name

string get_widget_long_name(GtkWidget widget);

Returns the long name of a widget which has been loaded from a gladefile.

If the widget has been created the "normal" way and not with glade,NULL is returned.

In the example you could use avar_dump( libglade::get_widget_long_name( $btnClose));

which would return string(24) "dlgHellow.vbox1.btnClose".

get_widget_tree

GladeXML get_widget_tree(GtkWidget widget);

Returns the glade object which created the given widget.

xml_new_from_memory

GladeXML xml_new_from_memory(string buffer, int size, string root,string domain);

Creates a glade object from a string instead of a file. This can beused to e.g. dynamically load glade user interface definitions from aremote server without having to store them in a file.

The function behaves exactly like the GladeXML constructor, except thefact that you pass a string (and the string length) to the function.Note that - other than the constructor - all parameters are required.

Classes do Scintilla

A Classe Scintilla

Índice

GtkScintillaGtkScintilla is an advanced text edition component with codecompletion, sintax highlight and others.

GtkScintilla

GtkScintilla is an advanced text edition component with codecompletion, sintax highlight and others.

Page 524: Apostila PHP GTK

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkBin`-- GtkFrame`-- GtkScintilla

Direct subclasses

None.

Descrição

GtkScintilla is an advanced widget for code edition. It's acomponent with lots of resources that make it a great choice towrite code editors. GtkScintilla provides advanced features likecode completion, sintax highlight, caret lines, line numbers,besides lots of text controls, giving strong powers to theprogrammer. GtkScintilla inherits from GtkFrame, so you can embbedGtkScintilla object inside another containers like GtkWindow,GtkVBox, GtkHBox, GtkFrame and others.

Construtor

GtkScintilla (void);

-- Creates the GtkScintilla text area.

Métodos

find_text()Finds a portion of text in GtkScintilla.

add_text()

Add the string at the end of text area.

insert_text()Inserts text in the text area of GtkScintilla.

clear_all()Clear all text area.

clear_document_style()

get_length()Gets the length of the text inside the text area.

get_current_pos()Gets the current position of cursor. It means the character position

Page 525: Apostila PHP GTK

inside the text.

get_char_at()Return the character that is located at the specific position.

get_anchor()

get_style_at()

redo()Redo is like "redo" action of every text editor. Redo does againsome task undone by "Undo" operation.

set_undo_collection()

select_all()Select all text inside the text area.

set_save_point()

marker_line_from_handle()

marker_delete_handle()

get_undo_collection()

get_view_ws()

set_view_ws()

position_from_point()

goto_line()This method set the cursor position to the specific line.

goto_pos()This method set the cursor position to the specific characterposition.

set_anchor()

get_cur_line()Returns an array containing the current line string and the current

Page 526: Apostila PHP GTK

column.

get_end_styled()

convert_eols()

get_eol_mode()Return the current End of Line Mode. See set_eol_mode() .

set_eol_mode()Define the End of Line Mode.

start_styling()

set_styling()

get_buffered_draw()

set_buffered_draw()

set_tab_width()Set the Tab Width.

get_tab_width()Gets the Tab Width.

set_code_page()

set_use_palette()

marker_define()Define a specific symbol for a marker number.

marker_set_fore()Set the Fore color of a marker, for markers table, seemarker_define()

marker_set_back()Set the Background color of a marker, for markers table, seemarker_define()

marker_add()Add a Marker symbol in front of the line, for markers table, seemarker_define()

marker_delete()

Page 527: Apostila PHP GTK

Deletes a Marker symbol from the line, for markers table, seemarker_define()

marker_delete_all()Removes all line markers of a specific type, for markers table, seemarker_define()

marker_get()

marker_next()

marker_previous()

set_margin_type_n()

get_margin_type_n()

set_margin_width_n()

get_margin_width_n()

set_margin_mask_n()

get_margin_mask_n()

set_margin_sensitive_n()

get_margin_sensitive_n()

style_clear_all()

style_set_fore()Set the fore color of some style.

style_set_back()Set the background color of some style.

style_set_bold()Define some style to be formated as bold.

style_set_italic()Define some style to be formated as italic.

Page 528: Apostila PHP GTK

style_set_size()Define the size of some style

style_set_font()Set the font of some style.

style_set_eol_filled()

style_reset_default()

style_set_underline()Define some style to be formated as underlined.

style_set_case()Turn OFF/ON the Case Sensitive of some Style.

style_set_character_set()

set_sel_fore()Set the fore color of the selection.

set_sel_back()Set the back color of the selection.

set_caret_fore()

get_caret_fore()

clear_all_cmd_keys()

set_styling_ex()

style_set_visible()Define if some style will be visible or not.

get_caret_period()

set_caret_period()

set_word_chars()

begin_undo_action()Define when start to store the actions of the user for "Undo

Page 529: Apostila PHP GTK

Action".

end_undo_action()Define when finish to store the actions of the user for "UndoAction".

indic_set_style()

indic_get_style()

indic_set_fore()

indic_get_fore()

set_style_bits()

get_style_bits()

set_line_state()

get_line_state()

get_max_line_state()

set_caret_line_visible()Define if the selected line must have the background in anothercolor.

get_caret_line_visible()Return if caret lines are visible or not.

get_caret_line_back()Get the background color of Caret Lines.

set_caret_line_back()Changes the background color of the Caret Lines.

autoc_show()Show the auto-complation list.

autoc_cancel()

autoc_active()

Page 530: Apostila PHP GTK

autoc_pos_start()

autoc_complete()

autoc_stops()

autoc_set_separator()

autoc_get_separator()

autoc_select()

autoc_set_cancel_at_start()

autoc_get_cancel_at_start()

autoc_set_fill_ups()

autoc_set_choose_single()

autoc_get_choose_single()

autoc_set_ignore_case()

autoc_get_ignore_case()

user_list_show()

autoc_set_auto_hide()

autoc_get_auto_hide()

set_indent()Set indentation size.

get_indent()Get Indentation Size.

Page 531: Apostila PHP GTK

set_use_tabs()Set if the [TAB] key must use tabs or spaces.

get_use_tabs()Get if the [TAB] key is using tabs or spaces.

set_line_indentation()Set the line indentation of some line.

get_line_indentation()Get the Line indentation of some line.

get_line_indent_position()

get_column()Returns the column number of the character position.

set_h_scroll_bar()

get_h_scroll_bar()

set_indentation_guides()Set wheather the indentation guides are visible or not.

get_indentation_guides()Get wheather the indentation guides are visible or not.

set_highlight_guide()

get_highlight_guide()

get_line_end_position()

get_code_page()

get_use_palette()

get_read_only()

set_current_pos()

set_selection_start()Set the start of the selection (character position).

Page 532: Apostila PHP GTK

get_selection_start()Get the begin of the selection (character position).

set_selection_end()Set the end of the selection (character position).

get_selection_end()Get the end of the selection (character position).

set_print_magnification()

get_print_magnification()

set_print_colour_mode()

get_print_colour_mode()

get_first_visible_line()

get_line()Get the content of some line.

get_line_count()Get the quantity of lines of the text area.

set_margin_left()

get_margin_left()

set_margin_right()

get_margin_right()

get_modify()

set_sel()

get_sel_text()Get the selected text.

hide_selection()

Page 533: Apostila PHP GTK

point_x_from_position()

point_y_from_position()

line_from_position()Get the line number from character position.

position_from_line()Get the character position from the line number.

line_scroll()

scroll_caret()

replace_sel()

set_read_only()Define if the text area may be edited or not.

null()

can_redo()Can Redo returns wheather "Redo" Operation may be done or not.

can_paste()Can Paste returns wheather "Paste" Operation may be done or not.

can_undo()Can Undo returns wheather "Undo" Operation may be done or not.

empty_undo_buffer()Empty the action list for "Undo" Action.

undo()Undo makes the last action undone.

cut()Cut the selected text and transfer it to the memory.

copy()Copy the selected text and transfer it to the memory.

paste()Paste the selected text from the memory to the text area.

clear()

Page 534: Apostila PHP GTK

set_text()Set all the content of Scintilla text area edition with thespecified string.

get_text()Return all the content of Scintilla text area edition as a string.

get_text_length()Return the length of the text inside scintilla object.

get_direct_function()

get_direct_pointer()

set_overtype()

get_overtype()

set_caret_width()

get_caret_width()

set_target_start()

get_target_start()

set_target_end()

get_target_end()

replace_target()

replace_target_re()

search_in_target()

set_search_flags()

get_search_flags()

Page 535: Apostila PHP GTK

call_tip_show()Show the sintax hint about one function

call_tip_cancel()

call_tip_active()

call_tip_pos_start()

call_tip_set_hlt()

call_tip_set_back()

visible_from_doc_line()

doc_line_from_visible()

set_fold_level()Define the fold level for some line. Fold level means the level ofbraces {} in the code.

get_fold_level()Returns the fold level for some line. See set_fold_level()

get_last_child()

get_fold_parent()

show_lines()Show the specified lines.

hide_lines()Hide the specified lines.

get_line_visible()

set_fold_expanded()

get_fold_expanded()

Page 536: Apostila PHP GTK

toggle_fold()

ensure_visible()

set_fold_flags()

set_tab_indents()

get_tab_indents()

set_backspace_unindents()

get_backspace_unindents()

line_down()Places the cursor one line down.

line_down_extend()Selects one line down.

line_up()Places the cursor one line up.

line_up_extend()Selects one line up.

char_left()Places the cursor one character to the left.

char_left_extend()Selects the character at the left side.

char_right()Places the cursor one character to the right.

char_right_extend()Selects the character at the right side.

word_left()Places the cursor one word to the left.

word_left_extend()Selects the word at the left side.

word_right()Places the cursor one word to the right.

Page 537: Apostila PHP GTK

word_right_extend()Selects the word at the right side.

home()Places the cursor at the begin of the line.

home_extend()Selects the text untill the home of the line.

line_end()Places the cursor at the end of the line.

line_end_extend()Selects the text untill the end of the line.

document_start()

document_start_extend()

document_end()

document_end_extend()

page_up()Goes one page up.

page_up_extend()Selects the text of one page up.

page_down()Goes one page down.

page_down_extend()Selects the text of one page down.

edit_toggle_overtype()

cancel()

delete_back()

tab()

back_tab()

Page 538: Apostila PHP GTK

new_line()

form_feed()

v_c_home()

v_c_home_extend()

zoom_in()

zoom_out()

del_word_left()Delete word of the left side of the cursor.

del_word_right()Delete word of the right side of the cursor.

line_cut()Cuts the current line's content to the memory.

line_delete()Deletes the current line.

line_transpose()

lower_case()

upper_case()

line_scroll_down()

line_scroll_up()

move_caret_inside_view()

line_length()Return the length of some line.

brace_match()Get the character position of the complement of "{", "[", "("

Page 539: Apostila PHP GTK

brace_highlight()Set positions inside the text to be showed in brace mode.

brace_bad_light()

get_view_eol()Get wheather the end of line marks are visible or not.

set_view_eol()Define wheather the end of line marks are visible or not.

get_doc_pointer()

set_doc_pointer()

set_mod_event_mask()

get_edge_column()Returns the column number that is used as the edge of text area.

set_edge_column()Changes the column number that is used as the edge of the text area.

get_edge_mode()Returns the edge mode. See set_edge_mode()

set_edge_mode()Changes the edge mode.

get_edge_colour()Gets the background color of text out of the edge.

set_edge_colour()Changes the background color of text out of the edge.

search_anchor()

search_next()

search_prev()

set_caret_policy()

lines_on_screen()

Page 540: Apostila PHP GTK

use_pop_up()

selection_is_rectangle()

set_zoom()

get_zoom()

create_document()

add_ref_document()

release_document()

get_mod_event_mask()

set_focus()

get_focus()

set_status()

get_status()

set_mouse_down_captures()

get_mouse_down_captures()

set_cursor()

get_cursor()

word_part_left()

word_part_left_extend()

Page 541: Apostila PHP GTK

word_part_right()

word_part_right_extend()

set_visible_policy()

del_line_left()

del_line_right()

grab_focus()

start_record()

stop_record()

set_lexer()Define what kind of lexer language will be used to highlight thecode.

get_lexer()Return what kind of lexer language is used to highlight the code.See set_lexer() .

colourise()

set_property()

set_keywords()Define the keywords list for some keywords set.

set_lexer_language()

Sinais

"style_needed"

"char_added"This signal is emitted when a character is added.

"save_point_reached"

Page 542: Apostila PHP GTK

"save_point_left"

"modify_attempt_ro"

"key"

"double_click"

"update_ui"update_ui signal is emitted when the screen needs to be refreshed.

"modified"modified signal is emitted when the user changes the text insideGtkScintilla text area, by adding or deleting some character.

"macro_record"

"margin_click"margin_click signal is emitted when the users clicks on the marginof GtkScintilla object.

"need_shown"

"painted"

"user_list_selection"

"uri_dropped"

GtkScintilla Construtor

GtkScintilla (void);

Creates the GtkScintilla text area.$scintilla = new GtkScintilla;

GtkScintilla::find_text

int find_text(int FLAGS, string search, int start, int end);

find_text() Finds a portion of text in GtkScintilla.$flags = SCINTILLA_FIND_DOWN +SCINTILLA_FIND_WHOLE_WORDS +SCINTILLA_FIND_MATCH_CASE +SCINTILLA_FIND_WHOLE_WORDS +

Page 543: Apostila PHP GTK

SCINTILLA_FIND_WORD_START +SCINTILLA_FIND_REGEXP;

$what = 'text to find';

// start and end positions...$start = 0;$end = $scintilla->get_length();$result = $scintilla->find_text($flags, $what, $start, $end);

GtkScintilla::add_text

voidadd_text(stringtext);

add_text() add the string at the end of text area.$scintilla->add_text("line with break \n");

GtkScintilla::insert_text

void insert_text(int pos, string text);

Inserts text in the text area of GtkScintilla.// inserting text at the begin of GtkScintilla$scintilla->insert_text(-1, 'inserting text...');

GtkScintilla::clear_all

void clear_all(void);

Clear all text area.// clear all text area...$scintilla->clear_all();

GtkScintilla::clear_document_style

void clear_document_style(void);

GtkScintilla::get_length

int get_length(void);

Gets the length of the text inside the text area.// get the text's lenghtecho $scintilla->get_lenght();

GtkScintilla::get_current_pos

int get_current_pos(void);

Gets the current position of cursor. It means the character positioninside the text.// echo the current cursor position.echo $scintilla->get_current_pos();

Page 544: Apostila PHP GTK

GtkScintilla::get_char_at

int get_char_at(int pos);

Return the character that is located at the specific position.// echo the current character at the cursor position.$position = $scintilla->get_current_pos();$character = $scintilla->get_char_at($position);

GtkScintilla::get_anchor

int get_anchor(void);

GtkScintilla::get_style_at

int get_style_at(int pos);

GtkScintilla::redo

void redo(void);

Redo is like "redo" action of every text editor. Redo does again sometask undone by "Undo" operation. You can design a "Edit" menu withmany options like that linked with one callback like this one:// redo$scintilla->redo();

GtkScintilla::set_undo_collection

void set_undo_collection(int collect_undo);

GtkScintilla::select_all

void select_all(void);

Select all text inside the text area.// select all the text$scintilla->select_all();

GtkScintilla::set_save_point

void set_save_point(void);

GtkScintilla::marker_line_from_handle

int marker_line_from_handle(int handle);

GtkScintilla::marker_delete_handle

void marker_delete_handle(int handle);

GtkScintilla::get_undo_collection

int get_undo_collection(void);

Page 545: Apostila PHP GTK

GtkScintilla::get_view_ws

int get_view_ws(void);

GtkScintilla::set_view_ws

void set_view_ws(int view_ws);

GtkScintilla::position_from_point

int position_from_point(int x, int y);

GtkScintilla::goto_line

void goto_line(int line);

This method set the cursor position to the specific line.// go to line 20...$scintilla->goto_line(20);

GtkScintilla::goto_pos

void goto_pos(int pos);

This method set the cursor position to the specific characterposition.// go to 3 positions ahead...$scintilla->goto_pos($this->get_current_pos() + 3);

GtkScintilla::set_anchor

void set_anchor(int pos_anchor);

GtkScintilla::get_cur_line

arrayget_cur_line(void);

Returns an array containing the current line string and the currentcolumn. The position "0" of array contain the entire line. Theposition "1" of array contain the current column.$line = $scintilla->get_cur_line();var_dump($line);/*array(2) {[0]=>string(6) "sdfsdf"[1]=>int(3)}*/

GtkScintilla::get_end_styled

Page 546: Apostila PHP GTK

int get_end_styled(void);

GtkScintilla::convert_eols

void convert_eols(int eol_mode);

GtkScintilla::get_eol_mode

int get_eol_mode(void);

Return the current End of Line Mode. See set_eol_mode() .echo $scintilla->get_eol_mode();

GtkScintilla::set_eol_mode

void set_eol_mode(int eol_mode);

Define the End of Line Mode. This protocol dates back to the days ofteletypewriters. CR stands for "carriage return" - the CR controlcharacter returned the print head ("carriage") to column 0 withoutadvancing the paper. LF stands for "linefeed" - the LF controlcharacter advanced the paper one line without moving the print head.So if you wanted to return the print head to column zero (ready toprint the next line) and advance the paper (so it prints on freshpaper), you need both CR and LF.// GtkScintillaEolModedefine( "SCINTILLA_EOL_CRLF" , 0 );define( "SCINTILLA_EOL_CR" , 1 );define( "SCINTILLA_EOL_LF" , 2 );

# CRLF = Carriage return + line feed# CR = Carriage return# LF = Line feed

# Win32 uses CR+LF, Linux uses LF.

$scintilla->set_eol_mode(SCINTILLA_EOL_CRLF);

GtkScintilla::start_styling

void start_styling(int pos, int mask);

GtkScintilla::set_styling

void set_styling(int length, int style);

GtkScintilla::get_buffered_draw

int get_buffered_draw(void);

GtkScintilla::set_buffered_draw

void set_buffered_draw(int buffered);

Page 547: Apostila PHP GTK

GtkScintilla::set_tab_width

void set_tab_width(int tab_width);

Set the Tab Width.$scintilla->set_tab_width(4);

GtkScintilla::get_tab_width

int get_tab_width(void);

Gets the Tab Width.echo $scintilla->get_tab_width();

GtkScintilla::set_code_page

void set_code_page(int code_page);

GtkScintilla::set_use_palette

void set_use_palette(int use_palette);

GtkScintilla::marker_define

void marker_define(int marker_number, int marker_symbol);

Define a specific symbol for a marker number.# markers table of symbols# 0 = little blob# 1 = big blob# 2 = triangle# 3 = recangle (shaped)# 4 - arrow# 5 = empty!# 6 = triangle down# 7 = minus sign# 8 = small dot# 9 = arrow right#10 = arrow right

// defining marker 1...$scintilla->marker_define(1,0);

// defining marker 2...$scintilla->marker_define(2,2);

GtkScintilla::marker_set_fore

void marker_set_fore(int marker_number, int fore);

Set the Fore color of a marker, for markers table, see marker_define()// defining fore color of marker 1...$scintilla->marker_set_fore(1, hexdec('FF0000'));

Page 548: Apostila PHP GTK

// defining fore color of marker 2...$scintilla->marker_set_fore(1, hexdec('00FF00'));

GtkScintilla::marker_set_back

void marker_set_back(int marker_number, int back);

Set the Background color of a marker, for markers table, seemarker_define()// defining background color of marker 1...$scintilla->marker_set_back(1, hexdec('0000FF'));

// defining background color of marker 2...$scintilla->marker_set_back(2, hexdec('0000FF'));

GtkScintilla::marker_add

void marker_add(int line, int marker_number);

Add a Marker symbol in front of the line, for markers table, seemarker_define()// add the marker 1 at line 4...$scintilla->marker_add(4, 1);

GtkScintilla::marker_delete

void marker_delete(int line, int marker_number);

Deletes a Marker symbol from the line, for markers table, seemarker_define()

// removes the marker 1 from line 4...$scintilla->marker_delete(4, 1);

GtkScintilla::marker_delete_all

void marker_delete_all(int marker_number);

Removes all line markers of a specific type, for markers table, seemarker_define()// adding marker 1 at line 4...$scintilla->marker_add(4, 1);

// adding marker 1 at line 6...$scintilla->marker_add(6, 1);

// adding marker 1 at line 8...$scintilla->marker_add(8, 1);

// adding marker 2 at line 5...$scintilla->marker_add(5, 2);

// removes all markers "1"...$scintilla->marker_delete_all(1);

Page 549: Apostila PHP GTK

GtkScintilla::marker_get

int marker_get(int line);

GtkScintilla::marker_next

int marker_next(int line_start, int marker_mask);

GtkScintilla::marker_previous

int marker_previous(int line_start, int marker_mask);

GtkScintilla::set_margin_type_n

void set_margin_type_n(int margin, int margin_type);

GtkScintilla::get_margin_type_n

int get_margin_type_n(int margin);

GtkScintilla::set_margin_width_n

void set_margin_width_n(int margin, int pixel_width);

GtkScintilla::get_margin_width_n

int get_margin_width_n(int margin);

GtkScintilla::set_margin_mask_n

void set_margin_mask_n(int margin, int mask);

GtkScintilla::get_margin_mask_n

int get_margin_mask_n(int margin);

GtkScintilla::set_margin_sensitive_n

void set_margin_sensitive_n(int margin, int sensitive);

GtkScintilla::get_margin_sensitive_n

int get_margin_sensitive_n(int margin);

GtkScintilla::style_clear_all

void style_clear_all(void);

GtkScintilla::style_set_fore

void style_set_fore(int style, int fore);

Set the fore color of some style.

Page 550: Apostila PHP GTK

// GtkScintillaStyledefine( "SCINTILLA_STYLE_DEFAULT", 32 );$scintilla->style_set_fore(SCINTILLA_STYLE_DEFAULT, 0);

GtkScintilla::style_set_back

void style_set_back(int style, int back);

Set the background color of some style.// GtkScintillaStyledefine( "SCINTILLA_STYLE_DEFAULT", 32 );$scintilla->style_set_back(SCINTILLA_STYLE_DEFAULT, hexdec('0000FF'));

GtkScintilla::style_set_bold

void style_set_bold(int style, int bold);

Define some style to be formated as bold.$scintilla->style_set_bold(SCINTILLA_STYLE_DEFAULT, 1);

GtkScintilla::style_set_italic

void style_set_italic(int style, int italic);

Define some style to be formated as italic.$scintilla->style_set_italic(SCINTILLA_STYLE_DEFAULT, 1);

GtkScintilla::style_set_size

void style_set_size(int style, int size_points);

Define the size of some style$scintilla->style_set_size(SCINTILLA_STYLE_DEFAULT, 20);

GtkScintilla::style_set_font

void style_set_font(int style, string font_name);

Set the font of some style.// GtkScintillaStyledefine( "SCINTILLA_STYLE_DEFAULT", 32 );$scintilla->style_set_font(SCINTILLA_STYLE_DEFAULT, '-*-luxisans-medium-r-normal-*-18-*-*-*-*-*-*');

GtkScintilla::style_set_eol_filled

void style_set_eol_filled(int style, int filled);

GtkScintilla::style_reset_default

void style_reset_default(void);

GtkScintilla::style_set_underline

Page 551: Apostila PHP GTK

void style_set_underline(int style, int underline);

Define some style to be formated as underlined.$scintilla->style_set_underline(SCINTILLA_STYLE_DEFAULT, 1);

GtkScintilla::style_set_case

void style_set_case(int style, int case_force);

Turn OFF/ON the Case Sensitive of some Style.// TURN ON$scintilla->style_set_case(SCINTILLA_STYLE_DEFAULT, 0);// TURN OFF$scintilla->style_set_case(SCINTILLA_STYLE_DEFAULT, 1);

GtkScintilla::style_set_character_set

void style_set_character_set(int style, int character_set);

GtkScintilla::set_sel_fore

void set_sel_fore(int use_setting, int fore);

Set the fore color of the selection.$scintilla->set_sel_fore(true, hexdec('FF0000'));

GtkScintilla::set_sel_back

void set_sel_back(int use_setting, int back);

Set the back color of the selection.$scintilla->set_sel_back(true, 11250603);

GtkScintilla::set_caret_fore

void set_caret_fore(int fore);

GtkScintilla::get_caret_fore

int get_caret_fore(void);

GtkScintilla::clear_all_cmd_keys

void clear_all_cmd_keys(void);

GtkScintilla::set_styling_ex

void set_styling_ex(int length, string styles);

GtkScintilla::style_set_visible

void style_set_visible(int style, int visible);

Define if some style will be visible or not.

Page 552: Apostila PHP GTK

// defining the style as invisible...$scintilla->set_sel_visible(SCINTILLA_STYLE_DEFAULT, 0);

GtkScintilla::get_caret_period

int get_caret_period(void);

GtkScintilla::set_caret_period

void set_caret_period(int period_milliseconds);

GtkScintilla::set_word_chars

void set_word_chars(string characters);

GtkScintilla::begin_undo_action

void begin_undo_action(void);

Define when start to store the actions of the user for "Undo Action".$scintilla->begin_undo_action();

GtkScintilla::end_undo_action

void end_undo_action(void);

Define when finish to store the actions of the user for "Undo Action".$scintilla->end_undo_action();

GtkScintilla::indic_set_style

void indic_set_style(int indic, int style);

GtkScintilla::indic_get_style

int indic_get_style(int indic);

GtkScintilla::indic_set_fore

void indic_set_fore(int indic, int fore);

GtkScintilla::indic_get_fore

int indic_get_fore(int indic);

GtkScintilla::set_style_bits

void set_style_bits(int bits);

GtkScintilla::get_style_bits

int get_style_bits(void);

GtkScintilla::set_line_state

Page 553: Apostila PHP GTK

void set_line_state(int line, int state);

GtkScintilla::get_line_state

int get_line_state(int line);

GtkScintilla::get_max_line_state

int get_max_line_state(void);

GtkScintilla::set_caret_line_visible

void set_caret_line_visible(int show);

Define if the selected line must have the background in another color.$scintilla->set_caret_line_visible(1);

GtkScintilla::get_caret_line_visible

int get_caret_line_visible(void);

Return if caret lines are visible or not.echo $scintilla->get_caret_line_visible();

GtkScintilla::get_caret_line_back

int get_caret_line_back(void);

Get the background color of Caret Lines.echo $scintilla->get_caret_line_back();

GtkScintilla::set_caret_line_back

void set_caret_line_back(int back);

Changes the background color of the Caret Lines.$scintilla->set_caret_line_back(9999204548);

GtkScintilla::autoc_show

void autoc_show(int len_entered, string item_list);

Show the auto-complation list.$l = trim(implode("",array_unique(array("aaa ", "bbb "))));$word='a';GtkScintilla::autoc_show(strlen($word), $l);

GtkScintilla::autoc_cancel

void autoc_cancel(void);

GtkScintilla::autoc_active

Page 554: Apostila PHP GTK

int autoc_active(void);

GtkScintilla::autoc_pos_start

int autoc_pos_start(void);

GtkScintilla::autoc_complete

void autoc_complete(void);

GtkScintilla::autoc_stops

void autoc_stops(string character_set);

GtkScintilla::autoc_set_separator

void autoc_set_separator(int separator_character);

GtkScintilla::autoc_get_separator

int autoc_get_separator(void);

GtkScintilla::autoc_select

void autoc_select(string text);

GtkScintilla::autoc_set_cancel_at_start

void autoc_set_cancel_at_start(int cancel);

GtkScintilla::autoc_get_cancel_at_start

int autoc_get_cancel_at_start(void);

GtkScintilla::autoc_set_fill_ups

void autoc_set_fill_ups(string character_set);

GtkScintilla::autoc_set_choose_single

void autoc_set_choose_single(int choose_single);

GtkScintilla::autoc_get_choose_single

int autoc_get_choose_single(void);

GtkScintilla::autoc_set_ignore_case

void autoc_set_ignore_case(int ignore_case);

GtkScintilla::autoc_get_ignore_case

int autoc_get_ignore_case(void);

Page 555: Apostila PHP GTK

GtkScintilla::user_list_show

void user_list_show(int list_type, string item_list);

GtkScintilla::autoc_set_auto_hide

void autoc_set_auto_hide(int auto_hide);

GtkScintilla::autoc_get_auto_hide

int autoc_get_auto_hide(void);

GtkScintilla::set_indent

void set_indent(int indent_size);

Set indentation size.$scintilla->set_indent(4);

GtkScintilla::get_indent

int get_indent(void);

Get Indentation Size.

GtkScintilla::set_use_tabs

void set_use_tabs(int use_tabs);

Set if the [TAB] key must use tabs or spaces.

GtkScintilla::get_use_tabs

int get_use_tabs(void);

Get if the [TAB] key is using tabs or spaces.

GtkScintilla::set_line_indentation

void set_line_indentation(int line, int indent_size);

Set the line indentation of some line.$cur_line = $scintilla->get_cur_line();$scintilla->set_line_indentation($cur_line, 8);

GtkScintilla::get_line_indentation

int get_line_indentation(int line);

Get the Line indentation of some line.echo $scintilla->get_line_indentation($cur_line);

GtkScintilla::get_line_indent_position

Page 556: Apostila PHP GTK

int get_line_indent_position(int line);

GtkScintilla::get_column

int get_column(int pos);

Returns the column number of the character position.// get the column number of position 40...echo $scintilla->get_column(40);

GtkScintilla::set_h_scroll_bar

void set_h_scroll_bar(int show);

GtkScintilla::get_h_scroll_bar

int get_h_scroll_bar(void);

GtkScintilla::set_indentation_guides

void set_indentation_guides(int show);

Set wheather the indentation guides are visible or not.

GtkScintilla::get_indentation_guides

int get_indentation_guides(void);

Get wheather the indentation guides are visible or not.

GtkScintilla::set_highlight_guide

void set_highlight_guide(int column);

GtkScintilla::get_highlight_guide

int get_highlight_guide(void);

GtkScintilla::get_line_end_position

int get_line_end_position(int line);

GtkScintilla::get_code_page

int get_code_page(void);

GtkScintilla::get_use_palette

int get_use_palette(void);

GtkScintilla::get_read_only

int get_read_only(void);

Page 557: Apostila PHP GTK

GtkScintilla::set_current_pos

void set_current_pos(int pos);

GtkScintilla::set_selection_start

void set_selection_start(int pos);

Set the start of the selection (character position).$scintilla->set_selection_start(100);

GtkScintilla::get_selection_start

int get_selection_start(void);

Get the begin of the selection (character position).

GtkScintilla::set_selection_end

void set_selection_end(int pos);

Set the end of the selection (character position).$scintilla->set_selection_end(200);

GtkScintilla::get_selection_end

int get_selection_end(void);

Get the end of the selection (character position).

GtkScintilla::set_print_magnification

void set_print_magnification(int magnification);

GtkScintilla::get_print_magnification

int get_print_magnification(void);

GtkScintilla::set_print_colour_mode

void set_print_colour_mode(int mode);

GtkScintilla::get_print_colour_mode

int get_print_colour_mode(void);

GtkScintilla::get_first_visible_line

int get_first_visible_line(void);

GtkScintilla::get_line

string get_line(int line);

Page 558: Apostila PHP GTK

Get the content of some line.

GtkScintilla::get_line_count

int get_line_count(void);

Get the quantity of lines of the text area.echo $scintilla->get_line_count();

GtkScintilla::set_margin_left

void set_margin_left(int pixel_width);

GtkScintilla::get_margin_left

int get_margin_left(void);

GtkScintilla::set_margin_right

void set_margin_right(int pixel_width);

GtkScintilla::get_margin_right

int get_margin_right(void);

GtkScintilla::get_modify

int get_modify(void);

GtkScintilla::set_sel

void set_sel(int start, int end);

GtkScintilla::get_sel_text

string get_sel_text(void);echo $scintilla->get_sel_text();

GtkScintilla::hide_selection

void hide_selection(int normal);

GtkScintilla::point_x_from_position

int point_x_from_position(int pos);

GtkScintilla::point_y_from_position

int point_y_from_position(int pos);

GtkScintilla::line_from_position

int line_from_position(int pos);

Page 559: Apostila PHP GTK

Get the line number from character position.$cur_line = $scintilla->line_from_position($scintilla->get_current_pos());

GtkScintilla::position_from_line

int position_from_line(int line);

Get the character position from the line number.$pos = $scintilla->position_from_line(10);

GtkScintilla::line_scroll

void line_scroll(int columns, int lines);

GtkScintilla::scroll_caret

void scroll_caret(void);

GtkScintilla::replace_sel

void replace_sel(string text);

GtkScintilla::set_read_only

void set_read_only(int read_only);

Define if the text area may be edited or not.// avoiding the user to edit...$scintilla->set_read_only(1);

GtkScintilla::null

void null(void);

GtkScintilla::can_redo

int can_redo(void);

Can Redo returns wheather "Redo" Operation may be done or not.if ($scintilla->can_redo()){// there are something to be "redone"...}

GtkScintilla::can_paste

int can_paste(void);

Can Paste returns wheather "Paste" Operation may be done or not.if ($scintilla->can_paste()){// there are something to be "paste"...}

Page 560: Apostila PHP GTK

GtkScintilla::can_undo

int can_undo(void);

Can Undo returns wheather "Undo" Operation may be done or not.if ($scintilla->can_undo()){// there are something to be "undone"...}

GtkScintilla::empty_undo_buffer

void empty_undo_buffer(void);

Empty the action list for "Undo" Action.$scintilla->empty_undo_buffer();

GtkScintilla::undo

void undo(void);

Undo makes the last action undone.$scintilla->undo();

GtkScintilla::cut

void cut(void);

Cut the selected text and transfer it to the memory.$scintilla->cut();

GtkScintilla::copy

void copy(void);

Copy the selected text and transfer it to the memory.$scintilla->copy();

GtkScintilla::paste

void paste(void);

Paste the selected text from the memory to the text area.$scintilla->paste();

GtkScintilla::clear

void clear(void);

GtkScintilla::set_text

void set_text(string text);

Set all the content of Scintilla text area edition with the specified

Page 561: Apostila PHP GTK

string.$scintilla->set_text('my text');

GtkScintilla::get_text

stringget_text(void);

Return all the content of Scintilla text area edition as a string.echo $scintilla->get_text();

GtkScintilla::get_text_length

int get_text_length(void);

Return the length of the text inside scintilla object.echo $scintilla->get_text_length();

GtkScintilla::get_direct_function

int get_direct_function(void);

GtkScintilla::get_direct_pointer

int get_direct_pointer(void);

GtkScintilla::set_overtype

void set_overtype(int overtype);

GtkScintilla::get_overtype

int get_overtype(void);

GtkScintilla::set_caret_width

void set_caret_width(int pixel_width);

GtkScintilla::get_caret_width

int get_caret_width(void);

GtkScintilla::set_target_start

void set_target_start(int pos);

GtkScintilla::get_target_start

int get_target_start(void);

GtkScintilla::set_target_end

void set_target_end(int pos);

GtkScintilla::get_target_end

Page 562: Apostila PHP GTK

int get_target_end(void);

GtkScintilla::replace_target

XXX replace_target(XXX);

GtkScintilla::replace_target_re

XXX replace_target_re(XXX);

GtkScintilla::search_in_target

XXX search_in_target(XXX);

GtkScintilla::set_search_flags

void set_search_flags(int flags);

GtkScintilla::get_search_flags

int get_search_flags(void);

GtkScintilla::call_tip_show

void call_tip_show(int pos, string definition);

Show the sintax hint about one function$scintilla->call_tip_show(10, 'function myfunction ( string name, int position)');

GtkScintilla::call_tip_cancel

void call_tip_cancel(void);

GtkScintilla::call_tip_active

int call_tip_active(void);

GtkScintilla::call_tip_pos_start

int call_tip_pos_start(void);

GtkScintilla::call_tip_set_hlt

void call_tip_set_hlt(int start, int end);

GtkScintilla::call_tip_set_back

void call_tip_set_back(int back);

GtkScintilla::visible_from_doc_line

int visible_from_doc_line(int line);

Page 563: Apostila PHP GTK

GtkScintilla::doc_line_from_visible

int doc_line_from_visible(int line_display);

GtkScintilla::set_fold_level

void set_fold_level(int line, int level);

Define the fold level for some line. Fold level means the level ofbraces {} in the code.// defining the fold level for line 10...$scintilla->set_fold_level(10, SCINTILLA_FOLDLEVELBASE + 1);

GtkScintilla::get_fold_level

int get_fold_level(int line);

Returns the fold level for some line. See set_fold_level()// getting the fold level of line 10...echo $scintilla->get_fold_level(10);

GtkScintilla::get_last_child

int get_last_child(int line, int level);

GtkScintilla::get_fold_parent

int get_fold_parent(int line);

GtkScintilla::show_lines

void show_lines(int line_start, int line_end);

Show the specified lines.// show all the lines...$scintilla->show_lines(0,$scintilla->get_line_count());

GtkScintilla::hide_lines

void hide_lines(int line_start, int line_end);

Hide the specified lines.// hide all the lines...$scintilla->hide_lines(0,$scintilla->get_line_count());

GtkScintilla::get_line_visible

int get_line_visible(int line);

GtkScintilla::set_fold_expanded

void set_fold_expanded(int line, int expanded);

Page 564: Apostila PHP GTK

GtkScintilla::get_fold_expanded

int get_fold_expanded(int line);

GtkScintilla::toggle_fold

void toggle_fold(int line);

GtkScintilla::ensure_visible

void ensure_visible(int line);

GtkScintilla::set_fold_flags

void set_fold_flags(int flags);

GtkScintilla::set_tab_indents

void set_tab_indents(int tab_indents);

GtkScintilla::get_tab_indents

int get_tab_indents(void);

GtkScintilla::set_backspace_unindents

void set_backspace_unindents(int bs_unindents);

GtkScintilla::get_backspace_unindents

int get_backspace_unindents(void);

GtkScintilla::line_down

void line_down(void);

Places the cursor one line down.$scintilla->line_down();

GtkScintilla::line_down_extend

void line_down_extend(void);

Selects one line down.$scintilla->line_down_extend();

GtkScintilla::line_up

void line_up(void);

Places the cursor one line up.$scintilla->line_up();

GtkScintilla::line_up_extend

Page 565: Apostila PHP GTK

void line_up_extend(void);

Selects one line up.$scintilla->line_up_extend();

GtkScintilla::char_left

void char_left(void);

Places the cursor one character to the left.$scintilla->char_left()

GtkScintilla::char_left_extend

void char_left_extend(void);

Selects the character at the left side.$scintilla->char_left_extend();

GtkScintilla::char_right

void char_right(void);

Places the cursor one character to the right.$scintilla->char_right();

GtkScintilla::char_right_extend

void char_right_extend(void);

Selects the character at the right side.$scintilla->char_right_extend();

GtkScintilla::word_left

void word_left(void);

Places the cursor one word to the left.$scintilla->word_left();

GtkScintilla::word_left_extend

void word_left_extend(void);

Selects the word at the left side.$scintilla->word_left_extend();

GtkScintilla::word_right

void word_right(void);

Places the cursor one word to the right.$scintilla->word_right();

Page 566: Apostila PHP GTK

GtkScintilla::word_right_extend

void word_right_extend(void);

Selects the word at the right side.$scintilla->word_right_extend();

GtkScintilla::home

void home(void);

Places the cursor at the begin of the line.$scintilla->home();

GtkScintilla::home_extend

void home_extend(void);

Selects the text untill the home of the line.$scintilla->home_extend();

GtkScintilla::line_end

void line_end(void);

Places the cursor at the end of the line.$scintilla->line_end();

GtkScintilla::line_end_extend

void line_end_extend(void);

Selects the text untill the end of the line.$scintilla->line_end_extend();

GtkScintilla::document_start

void document_start(void);

GtkScintilla::document_start_extend

void document_start_extend(void);

GtkScintilla::document_end

void document_end(void);

GtkScintilla::document_end_extend

void document_end_extend(void);

GtkScintilla::page_up

Page 567: Apostila PHP GTK

void page_up(void);

Goes one page up.$scintilla->page_up();

GtkScintilla::page_up_extend

void page_up_extend(void);

Selects the text of one page up.$scintilla->page_up_extend();

GtkScintilla::page_down

void page_down(void);

Goes one page down.$scintilla->page_down();

GtkScintilla::page_down_extend

void page_down_extend(void);

Selects the text of one page down.$scintilla->page_down_extend();

GtkScintilla::edit_toggle_overtype

void edit_toggle_overtype(void);

GtkScintilla::cancel

void cancel(void);

GtkScintilla::delete_back

void delete_back(void);

GtkScintilla::tab

void tab(void);

GtkScintilla::back_tab

void back_tab(void);

GtkScintilla::new_line

void new_line(void);

GtkScintilla::form_feed

void form_feed(void);

Page 568: Apostila PHP GTK

GtkScintilla::v_c_home

void v_c_home(void);

GtkScintilla::v_c_home_extend

void v_c_home_extend(void);

GtkScintilla::zoom_in

void zoom_in(void);

GtkScintilla::zoom_out

void zoom_out(void);

GtkScintilla::del_word_left

void del_word_left(void);

Delete word of the left side of the cursor.$scintilla->del_word_left();

GtkScintilla::del_word_right

void del_word_right(void);

Delete word of the right side of the cursor.$scintilla->del_word_right();

GtkScintilla::line_cut

void line_cut(void);

Cuts the current line's content to the memory.$scintilla->line_cut();

GtkScintilla::line_delete

void line_delete(void);

Deletes the current line.$scintilla->line_delete();

GtkScintilla::line_transpose

void line_transpose(void);

GtkScintilla::lower_case

void lower_case(void);

GtkScintilla::upper_case

Page 569: Apostila PHP GTK

void upper_case(void);

GtkScintilla::line_scroll_down

void line_scroll_down(void);

GtkScintilla::line_scroll_up

void line_scroll_up(void);

GtkScintilla::move_caret_inside_view

void move_caret_inside_view(void);

GtkScintilla::line_length

int line_length(int line);

Return the length of some line.// the length of line 5...echo $scintilla->line_length(5);

GtkScintilla::brace_match

int brace_match(int position);

Get the character position of the complement of "{", "[", "("$brace_pos = $scintilla->get_current_pos();$char = $scintilla->get_char_at($brace_pos);if (($char == '{') or ($char == '}')) // or...$other_pos = $scintilla->brace_match($brace_pos);

GtkScintilla::brace_highlight

void brace_highlight(int pos1, int pos2);

Set positions inside the text to be showed in brace mode. Brace colorsand fonts indentify characters like "{", "(" and "["$brace_pos = $scintilla->get_current_pos();$char = $scintilla->get_char_at($brace_pos);if (($char == '{') or ($char == '}')) // or...$other_pos = $scintilla->brace_match($brace_pos);

$scintilla->brace_highlight($brace_pos, $other_pos);

GtkScintilla::brace_bad_light

void brace_bad_light(int pos);

GtkScintilla::get_view_eol

int get_view_eol(void);

Get wheather the end of line marks are visible or not.

Page 570: Apostila PHP GTK

echo $scintilla->get_view_eol();

GtkScintilla::set_view_eol

void set_view_eol(int visible);

Define wheather the end of line marks are visible or not.// view end of lines...$scintilla->set_view_eol(1);

GtkScintilla::get_doc_pointer

int get_doc_pointer(void);

GtkScintilla::set_doc_pointer

void set_doc_pointer(int pointer);

GtkScintilla::set_mod_event_mask

void set_mod_event_mask(int mask);

GtkScintilla::get_edge_column

int get_edge_column(void);

Returns the column number that is used as the edge of text area.

GtkScintilla::set_edge_column

void set_edge_column(int column);

Changes the column number that is used as the edge of the text area.

GtkScintilla::get_edge_mode

int get_edge_mode(void);

Returns the edge mode. See set_edge_mode()

GtkScintilla::set_edge_mode

void set_edge_mode(int mode);

Changes the edge mode.// GtkScintillaEdgeMode@define( "SCINTILLA_EDGE_NONE" , 0 );@define( "SCINTILLA_EDGE_LINE" , 1 );@define( "SCINTILLA_EDGE_BACKGROUND" , 2 );

// changing the edge mode...$scintilla->set_edge_mode(SCINTILLA_EDGE_NONE);

GtkScintilla::get_edge_colour

Page 571: Apostila PHP GTK

int get_edge_colour(void);

Gets the background color of text out of the edge.echo $scintilla->get_edge_colour();

GtkScintilla::set_edge_colour

void set_edge_colour(int edge_colour);

Changes the background color of text out of the edge.$scintilla->set_edge_colour(hexdec('FF0000'));

GtkScintilla::search_anchor

void search_anchor(void);

GtkScintilla::search_next

int search_next(int flags, string text);

GtkScintilla::search_prev

int search_prev(int flags, string text);

GtkScintilla::set_caret_policy

void set_caret_policy(int caret_policy, int caret_slop);

GtkScintilla::lines_on_screen

int lines_on_screen(void);

GtkScintilla::use_pop_up

void use_pop_up(int allow_pop_up);

GtkScintilla::selection_is_rectangle

int selection_is_rectangle(void);

GtkScintilla::set_zoom

void set_zoom(int zoom);

GtkScintilla::get_zoom

int get_zoom(void);

GtkScintilla::create_document

int create_document(void);

GtkScintilla::add_ref_document

Page 572: Apostila PHP GTK

void add_ref_document(int doc);

GtkScintilla::release_document

void release_document(int doc);

GtkScintilla::get_mod_event_mask

int get_mod_event_mask(void);

GtkScintilla::set_focus

void set_focus(int focus);

GtkScintilla::get_focus

int get_focus(void);

GtkScintilla::set_status

void set_status(int status_code);

GtkScintilla::get_status

int get_status(void);

GtkScintilla::set_mouse_down_captures

void set_mouse_down_captures(int captures);

GtkScintilla::get_mouse_down_captures

int get_mouse_down_captures(void);

GtkScintilla::set_cursor

void set_cursor(int cursor_type);

GtkScintilla::get_cursor

int get_cursor(void);

GtkScintilla::word_part_left

void word_part_left(void);

GtkScintilla::word_part_left_extend

void word_part_left_extend(void);

GtkScintilla::word_part_right

void word_part_right(void);

Page 573: Apostila PHP GTK

GtkScintilla::word_part_right_extend

void word_part_right_extend(void);

GtkScintilla::set_visible_policy

void set_visible_policy(int visible_policy, int visible_slop);

GtkScintilla::del_line_left

void del_line_left(void);

GtkScintilla::del_line_right

void del_line_right(void);

GtkScintilla::grab_focus

void grab_focus(void);

GtkScintilla::start_record

void start_record(void);

GtkScintilla::stop_record

void stop_record(void);

GtkScintilla::set_lexer

void set_lexer(int lexer);

Define what kind of lexer language will be used to highlight the code.// GtkScintillaLexer@define( "SCINTILLA_LEXER_CONTAINER" , 0 );@define( "SCINTILLA_LEXER_NULL" , 1 );@define( "SCINTILLA_LEXER_PYTHON" , 2 );@define( "SCINTILLA_LEXER_CPP" , 3 );@define( "SCINTILLA_LEXER_HTML" , 4 );@define( "SCINTILLA_LEXER_XML" , 5 );@define( "SCINTILLA_LEXER_PERL" , 6 );@define( "SCINTILLA_LEXER_SQL" , 7 );@define( "SCINTILLA_LEXER_VB" , 8 );@define( "SCINTILLA_LEXER_PROPERTIES" , 9 );@define( "SCINTILLA_LEXER_ERRORLIST" , 10 );@define( "SCINTILLA_LEXER_MAKEFILE" , 11 );@define( "SCINTILLA_LEXER_BATCH" , 12 );@define( "SCINTILLA_LEXER_XCODE" , 13 );@define( "SCINTILLA_LEXER_LATEX" , 14 );@define( "SCINTILLA_LEXER_LUA" , 15 );@define( "SCINTILLA_LEXER_DIFF" , 16 );@define( "SCINTILLA_LEXER_CONF" , 17 );@define( "SCINTILLA_LEXER_PASCAL" , 18 );

Page 574: Apostila PHP GTK

@define( "SCINTILLA_LEXER_AVE" , 19 );@define( "SCINTILLA_LEXER_ADA" , 20 );

$scintilla->set_lexer(SCINTILLA_LEXER_HTML);

GtkScintilla::get_lexer

int get_lexer(void);

Return what kind of lexer language is used to highlight the code. Seeset_lexer() .echo $scintilla->get_lexer();

GtkScintilla::colourise

void colourise(int start, int end);

GtkScintilla::set_property

void set_property(string key, string value);

GtkScintilla::set_keywords

void set_keywords(int keyword_set, string key_words);

Define the keywords list for some keywords set.$scintilla->set_keywords(0, 'doctype a abbr abbr accept accept-charset accesskey acronym action address align alink alt applet archive area axis b backgroundbase basefont bdo bgcolor big blockquote body border br button caption cellpadding cellspacing center char charoff charset checkbox checked cite cite class classid clear code codebase codetype col colgroup color cols colspan compact content coords data datafld dataformatas datapagesize datasrc datetime dd declare defer del dfn dir dir disabled div dl dt em enctype event face fieldset file font for foreach form frame frame frameborder frameset h1 h2 h3 h4 h5 h6 head headers height hidden hr href hreflang hspace html http-equiv i id iframe image imginput ins isindex ismap kbd label label lang language leftmargin legend li link link longdesc map marginheight marginwidth maxlength media menu meta method multiple name noframes nohref noresize noscript noshade nowrap object object olonblur onchange onclick ondblclick onfocus onkeydown onkeypress onkeyup onloadonmousedown onmousemove onmouseout onmouseover onmouseup onreset onselect onsubmit onunload optgroup option p param password pre profile prompt public q radioreadonly rel reset rev rows rowspan rules s samp scheme scope script select selected shape size small span span src standby start strike strong style style sub submit summary sup tabindex table target tbody td text text textarea tfoot th thead title title topmargin tr tt type u ul usemap valign value valuetype varversion vlink vspace width xml xmlns');$scintilla->set_keywords(1, 'abstract boolean break byte case catch char classconst continue debugger default delete do double else enum export extends finalfinally float for foreach function goto if implements import in instanceof intinterface long native new package private protected public return short staticsuper switch synchronized this throw throws transient try typeof var void volatile while with');$scintilla->set_keywords(2, 'None and assert break class continue def del elifelse except exec finally for from global if import in is lambda not or pass pri

Page 575: Apostila PHP GTK

nt raise return try while function include include_once require require_once');

GtkScintilla::set_lexer_language

void set_lexer_language(string language);

style_needed

Função Callback

void callback(GtkScintilla widget, int position);

char_added

This signal is emitted when a character is added.

Função Callback

void callback(GtkScintilla widget, int character);

save_point_reached

Função Callback

void callback(GtkScintilla widget);

save_point_left

Função Callback

void callback(GtkScintilla widget);

modify_attempt_ro

Função Callback

void callback(GtkScintilla widget);

key

Função Callback

void callback(GtkScintilla widget, int character, int modifiers);

double_click

Função Callback

void callback(GtkScintilla widget);

update_ui

update_ui signal is emitted when the screen needs to be refreshed.

Page 576: Apostila PHP GTK

Função Callback

void callback(GtkScintilla widget);

modified

modified signal is emitted when the user changes the text insideGtkScintilla text area, by adding or deleting some character.

Função Callback

void callback(GtkScintilla widget);

macro_record

Função Callback

void callback(GtkScintilla widget, int message, int wparam, intlparam);

margin_click

margin_click signal is emitted when the users clicks on the margin ofGtkScintilla object.

Função Callback

void callback(GtkScintilla widget, int modifiers, int position, intmargin);

need_shown

Função Callback

void callback(GtkScintilla widget, int position, int lenght);

painted

Função Callback

void callback(GtkScintilla widget);

user_list_selection

Função Callback

void callback(GtkScintilla widget, int type, char text);

uri_dropped

Função Callback

void callback(GtkScintilla widget);

Page 577: Apostila PHP GTK

Classes do Sqpane

A Classe Sqpane

Índice

GtkSQPane

GtkSQPane

Hierarquia do Objeto

GtkObject`-- GtkWidget`-- GtkContainer`-- GtkSQPane

Direct subclasses

None.

Descrição

Construtor

GtkSQPane (void);

--

Métodos

set_position()

set_handle_size()

compute_position()

GtkSQPane Construtor

GtkSQPane (void);

GtkSQPane::set_position

void set_position(int x, int y);

GtkSQPane::set_handle_size

void set_handle_size(int size);

GtkSQPane::compute_position

Page 578: Apostila PHP GTK

void compute_position(int width, int height);

Apêndice_________________________________________________________________

Índice

Agradecimentos à equipe do PHP-GTKAgradecimentos à equipe da Documentação do PHP-GTKGNU Free Documentation LicenseNomes simbólicos para as chaves no PHP-GTK

Apêndice A. Agradecimentos à equipe do PHP-GTK

Autores do PHP-GTKAndrei Zmievski : Trabalho principalContribuidores do PHP-GTKFrank Kromann : Compilação Win32 e distribuições binárias, algumtrabalho no gerador de códigoMarkus Fischer :Alan Knowles :

Apêndice B. Agradecimentos à equipe da Documentação do PHP-GTK

Autores do Manual do PHP-GTKJames Moore : Esboço do Manual e criador do framework, guia dousuário, tutoriais, documentação das classes e editor original (en)Steph Fox : Reestruturação e internacionalização, guia do usuário,documentação das classes, atual editor (en)Contribuidores do Manual do PHP-GTKAndrei Zmievski : Documentação das ClassesSimon Wheeler : Documentação das ClassesPablo Dall'Oglio : Tradução do Manual para Português BrasileiroThomas Gonzalez Miranda : Tradução do Manual para Português Brasileiro

Apêndice C. GNU Free Documentation License

Version 1.1, March 2000

Copyright

Copyright (C) 2000 Free Software Foundation, Inc. 59 Temple Place,Suite 330, Boston, MA 02111-1307 USA. Everyone is permitted to copyand distribute verbatim copies of this license document, but changingit is not allowed.

1. PREAMBLEThe purpose of this License is to make a manual, textbook, orother written document "free" in the sense of freedom: to assureeveryone the effective freedom to copy and redistribute it, withor without modifying it, either commercially or noncommercially.Secondarily, this License preserves for the author and publisher away to get credit for their work, while not being consideredresponsible for modifications made by others.

Page 579: Apostila PHP GTK

This License is a kind of "copyleft", which means that derivativeworks of the document must themselves be free in the same sense.It complements the GNU General Public License, which is a copyleftlicense designed for free software.We have designed this License in order to use it for manuals forfree software, because free software needs free documentation: afree program should come with manuals providing the same freedomsthat the software does. But this License is not limited tosoftware manuals; it can be used for any textual work, regardlessof subject matter or whether it is published as a printed book. Werecommend this License principally for works whose purpose isinstruction or reference.2. APPLICABILITY AND DEFINITIONSThis License applies to any manual or other work that contains anotice placed by the copyright holder saying it can be distributedunder the terms of this License. The "Document", below, refers toany such manual or work. Any member of the public is a licensee,and is addressed as "you".A "Modified Version" of the Document means any work containing theDocument or a portion of it, either copied verbatim, or withmodifications and/or translated into another language.A "Secondary Section" is a named appendix or a front-mattersection of the Document that deals exclusively with therelationship of the publishers or authors of the Document to theDocument's overall subject (or to related matters) and containsnothing that could fall directly within that overall subject. (Forexample, if the Document is in part a textbook of mathematics, aSecondary Section may not explain any mathematics.) Therelationship could be a matter of historical connection with thesubject or with related matters, or of legal, commercial,philosophical, ethical or political position regarding them.The "Invariant Sections" are certain Secondary Sections whosetitles are designated, as being those of Invariant Sections, inthe notice that says that the Document is released under thisLicense.The "Cover Texts" are certain short passages of text that arelisted, as Front-Cover Texts or Back-Cover Texts, in the noticethat says that the Document is released under this License.A "Transparent" copy of the Document means a machine-readablecopy, represented in a format whose specification is available tothe general public, whose contents can be viewed and editeddirectly and straightforwardly with generic text editors or (forimages composed of pixels) generic paint programs or (fordrawings) some widely available drawing editor, and that issuitable for input to text formatters or for automatic translationto a variety of formats suitable for input to text formatters. Acopy made in an otherwise Transparent file format whose markup hasbeen designed to thwart or discourage subsequent modification byreaders is not Transparent. A copy that is not "Transparent" iscalled "Opaque".Examples of suitable formats for Transparent copies include plainASCII without markup, Texinfo input format, LaTeX input format,SGML or XML using a publicly available DTD, andstandard-conforming simple HTML designed for human modification.

Page 580: Apostila PHP GTK

Opaque formats include PostScript, PDF, proprietary formats thatcan be read and edited only by proprietary word processors, SGMLor XML for which the DTD and/or processing tools are not generallyavailable, and the machine-generated HTML produced by some wordprocessors for output purposes only.The "Title Page" means, for a printed book, the title page itself,plus such following pages as are needed to hold, legibly, thematerial this License requires to appear in the title page. Forworks in formats which do not have any title page as such, "TitlePage" means the text near the most prominent appearance of thework's title, preceding the beginning of the body of the text.3. VERBATIM COPYINGYou may copy and distribute the Document in any medium, eithercommercially or noncommercially, provided that this License, thecopyright notices, and the license notice saying this Licenseapplies to the Document are reproduced in all copies, and that youadd no other conditions whatsoever to those of this License. Youmay not use technical measures to obstruct or control the readingor further copying of the copies you make or distribute. However,you may accept compensation in exchange for copies. If youdistribute a large enough number of copies you must also followthe conditions in section 3.You may also lend copies, under the same conditions stated above,and you may publicly display copies.4. COPYING IN QUANTITYIf you publish printed copies of the Document numbering more than100, and the Document's license notice requires Cover Texts, youmust enclose the copies in covers that carry, clearly and legibly,all these Cover Texts: Front-Cover Texts on the front cover, andBack-Cover Texts on the back cover. Both covers must also clearlyand legibly identify you as the publisher of these copies. Thefront cover must present the full title with all words of thetitle equally prominent and visible. You may add other material onthe covers in addition. Copying with changes limited to thecovers, as long as they preserve the title of the Document andsatisfy these conditions, can be treated as verbatim copying inother respects.If the required texts for either cover are too voluminous to fitlegibly, you should put the first ones listed (as many as fitreasonably) on the actual cover, and continue the rest ontoadjacent pages.If you publish or distribute Opaque copies of the Documentnumbering more than 100, you must either include amachine-readable Transparent copy along with each Opaque copy, orstate in or with each Opaque copy a publicly-accessiblecomputer-network location containing a complete Transparent copyof the Document, free of added material, which the generalnetwork-using public has access to download anonymously at nocharge using public-standard network protocols. If you use thelatter option, you must take reasonably prudent steps, when youbegin distribution of Opaque copies in quantity, to ensure thatthis Transparent copy will remain thus accessible at the statedlocation until at least one year after the last time youdistribute an Opaque copy (directly or through your agents or

Page 581: Apostila PHP GTK

retailers) of that edition to the public.It is requested, but not required, that you contact the authors ofthe Document well before redistributing any large number ofcopies, to give them a chance to provide you with an updatedversion of the Document.5. MODIFICATIONSYou may copy and distribute a Modified Version of the Documentunder the conditions of sections 2 and 3 above, provided that yourelease the Modified Version under precisely this License, withthe Modified Version filling the role of the Document, thuslicensing distribution and modification of the Modified Version towhoever possesses a copy of it. In addition, you must do thesethings in the Modified Version:A. Use in the Title Page (and on the covers, if any) a titledistinct from that of the Document, and from those of previousversions (which should, if there were any, be listed in theHistory section of the Document). You may use the same title as aprevious version if the original publisher of that version givespermission.B. List on the Title Page, as authors, one or more persons orentities responsible for authorship of the modifications in theModified Version, together with at least five of the principalauthors of the Document (all of its principal authors, if it hasless than five).C. State on the Title page the name of the publisher of theModified Version, as the publisher.D. Preserve all the copyright notices of the Document.E. Add an appropriate copyright notice for your modificationsadjacent to the other copyright notices.F. Include, immediately after the copyright notices, a licensenotice giving the public permission to use the Modified Versionunder the terms of this License, in the form shown in the Addendumbelow.G. Preserve in that license notice the full lists of InvariantSections and required Cover Texts given in the Document's licensenotice.H. Include an unaltered copy of this License.I. Preserve the section entitled "History", and its title, and addto it an item stating at least the title, year, new authors, andpublisher of the Modified Version as given on the Title Page. Ifthere is no section entitled "History" in the Document, create onestating the title, year, authors, and publisher of the Document asgiven on its Title Page, then add an item describing the ModifiedVersion as stated in the previous sentence.J. Preserve the network location, if any, given in the Documentfor public access to a Transparent copy of the Document, andlikewise the network locations given in the Document for previousversions it was based on. These may be placed in the "History"section. You may omit a network location for a work that waspublished at least four years before the Document itself, or ifthe original publisher of the version it refers to givespermission.K. In any section entitled "Acknowledgements" or "Dedications",preserve the section's title, and preserve in the section all the

Page 582: Apostila PHP GTK

substance and tone of each of the contributor acknowledgementsand/or dedications given therein.L. Preserve all the Invariant Sections of the Document, unalteredin their text and in their titles. Section numbers or theequivalent are not considered part of the section titles.M. Delete any section entitled "Endorsements". Such a section maynot be included in the Modified Version.N. Do not retitle any existing section as "Endorsements" or toconflict in title with any Invariant Section.If the Modified Version includes new front-matter sections orappendices that qualify as Secondary Sections and contain nomaterial copied from the Document, you may at your optiondesignate some or all of these sections as invariant. To do this,add their titles to the list of Invariant Sections in the ModifiedVersion's license notice. These titles must be distinct from anyother section titles.You may add a section entitled "Endorsements", provided itcontains nothing but endorsements of your Modified Version byvarious parties--for example, statements of peer review or thatthe text has been approved by an organization as the authoritativedefinition of a standard.You may add a passage of up to five words as a Front-Cover Text,and a passage of up to 25 words as a Back-Cover Text, to the endof the list of Cover Texts in the Modified Version. Only onepassage of Front-Cover Text and one of Back-Cover Text may beadded by (or through arrangements made by) any one entity. If theDocument already includes a cover text for the same cover,previously added by you or by arrangement made by the same entityyou are acting on behalf of, you may not add another; but you mayreplace the old one, on explicit permission from the previouspublisher that added the old one.The author(s) and publisher(s) of the Document do not by thisLicense give permission to use their names for publicity for or toassert or imply endorsement of any Modified Version.6. COMBINING DOCUMENTSYou may combine the Document with other documents released underthis License, under the terms defined in section 4 above formodified versions, provided that you include in the combinationall of the Invariant Sections of all of the original documents,unmodified, and list them all as Invariant Sections of yourcombined work in its license notice.The combined work need only contain one copy of this License, andmultiple identical Invariant Sections may be replaced with asingle copy. If there are multiple Invariant Sections with thesame name but different contents, make the title of each suchsection unique by adding at the end of it, in parentheses, thename of the original author or publisher of that section if known,or else a unique number. Make the same adjustment to the sectiontitles in the list of Invariant Sections in the license notice ofthe combined work.In the combination, you must combine any sections entitled"History" in the various original documents, forming one sectionentitled "History"; likewise combine any sections entitled"Acknowledgements", and any sections entitled "Dedications". You

Page 583: Apostila PHP GTK

must delete all sections entitled "Endorsements."7. COLLECTIONS OF DOCUMENTSYou may make a collection consisting of the Document and otherdocuments released under this License, and replace the individualcopies of this License in the various documents with a single copythat is included in the collection, provided that you follow therules of this License for verbatim copying of each of thedocuments in all other respects.You may extract a single document from such a collection, anddistribute it individually under this License, provided you inserta copy of this License into the extracted document, and followthis License in all other respects regarding verbatim copying ofthat document.8. AGGREGATION WITH INDEPENDENT WORKSA compilation of the Document or its derivatives with otherseparate and independent documents or works, in or on a volume ofa storage or distribution medium, does not as a whole count as aModified Version of the Document, provided no compilationcopyright is claimed for the compilation. Such a compilation iscalled an "aggregate", and this License does not apply to theother self-contained works thus compiled with the Document, onaccount of their being thus compiled, if they are not themselvesderivative works of the Document.If the Cover Text requirement of section 3 is applicable to thesecopies of the Document, then if the Document is less than onequarter of the entire aggregate, the Document's Cover Texts may beplaced on covers that surround only the Document within theaggregate. Otherwise they must appear on covers around the wholeaggregate.9. TRANSLATIONTranslation is considered a kind of modification, so you maydistribute translations of the Document under the terms of section4. Replacing Invariant Sections with translations requires specialpermission from their copyright holders, but you may includetranslations of some or all Invariant Sections in addition to theoriginal versions of these Invariant Sections. You may include atranslation of this License provided that you also include theoriginal English version of this License. In case of adisagreement between the translation and the original Englishversion of this License, the original English version willprevail.10. TERMINATIONYou may not copy, modify, sublicense, or distribute the Documentexcept as expressly provided for under this License. Any otherattempt to copy, modify, sublicense or distribute the Document isvoid, and will automatically terminate your rights under thisLicense. However, parties who have received copies, or rights,from you under this License will not have their licensesterminated so long as such parties remain in full compliance.11. FUTURE REVISIONS OF THIS LICENSEThe Free Software Foundation may publish new, revised versions ofthe GNU Free Documentation License from time to time. Such newversions will be similar in spirit to the present version, but maydiffer in detail to address new problems or concerns. See

Page 584: Apostila PHP GTK

http://www.gnu.org/copyleft/.Each version of the License is given a distinguishing versionnumber. If the Document specifies that a particular numberedversion of this License "or any later version" applies to it, youhave the option of following the terms and conditions either ofthat specified version or of any later version that has beenpublished (not as a draft) by the Free Software Foundation. If theDocument does not specify a version number of this License, youmay choose any version ever published (not as a draft) by the FreeSoftware Foundation.

Apêndice D. Nomes simbólicos para as chaves no PHP-GTK

GDK_KEY_VoidSymbolGDK_KEY_BackSpaceGDK_KEY_TabGDK_KEY_LinefeedGDK_KEY_ClearGDK_KEY_ReturnGDK_KEY_PauseGDK_KEY_Scroll_LockGDK_KEY_Sys_ReqGDK_KEY_EscapeGDK_KEY_DeleteGDK_KEY_Multi_keyGDK_KEY_SingleCandidateGDK_KEY_MultipleCandidateGDK_KEY_PreviousCandidateGDK_KEY_KanjiGDK_KEY_MuhenkanGDK_KEY_Henkan_ModeGDK_KEY_HenkanGDK_KEY_RomajiGDK_KEY_HiraganaGDK_KEY_KatakanaGDK_KEY_Hiragana_KatakanaGDK_KEY_ZenkakuGDK_KEY_HankakuGDK_KEY_Zenkaku_HankakuGDK_KEY_TourokuGDK_KEY_MassyoGDK_KEY_Kana_LockGDK_KEY_Kana_ShiftGDK_KEY_Eisu_ShiftGDK_KEY_Eisu_toggleGDK_KEY_Zen_KohoGDK_KEY_Mae_KohoGDK_KEY_HomeGDK_KEY_LeftGDK_KEY_UpGDK_KEY_RightGDK_KEY_DownGDK_KEY_PriorGDK_KEY_Page_Up

Page 585: Apostila PHP GTK

GDK_KEY_NextGDK_KEY_Page_DownGDK_KEY_EndGDK_KEY_BeginGDK_KEY_SelectGDK_KEY_PrintGDK_KEY_ExecuteGDK_KEY_InsertGDK_KEY_UndoGDK_KEY_RedoGDK_KEY_MenuGDK_KEY_FindGDK_KEY_CancelGDK_KEY_HelpGDK_KEY_BreakGDK_KEY_Mode_switchGDK_KEY_script_switchGDK_KEY_Num_LockGDK_KEY_KP_SpaceGDK_KEY_KP_TabGDK_KEY_KP_EnterGDK_KEY_KP_F1GDK_KEY_KP_F2GDK_KEY_KP_F3GDK_KEY_KP_F4GDK_KEY_KP_HomeGDK_KEY_KP_LeftGDK_KEY_KP_UpGDK_KEY_KP_RightGDK_KEY_KP_DownGDK_KEY_KP_PriorGDK_KEY_KP_Page_UpGDK_KEY_KP_NextGDK_KEY_KP_Page_DownGDK_KEY_KP_EndGDK_KEY_KP_BeginGDK_KEY_KP_InsertGDK_KEY_KP_DeleteGDK_KEY_KP_EqualGDK_KEY_KP_MultiplyGDK_KEY_KP_AddGDK_KEY_KP_SeparatorGDK_KEY_KP_SubtractGDK_KEY_KP_DecimalGDK_KEY_KP_DivideGDK_KEY_KP_0GDK_KEY_KP_1GDK_KEY_KP_2GDK_KEY_KP_3GDK_KEY_KP_4GDK_KEY_KP_5GDK_KEY_KP_6GDK_KEY_KP_7GDK_KEY_KP_8

Page 586: Apostila PHP GTK

GDK_KEY_KP_9GDK_KEY_F1GDK_KEY_F2GDK_KEY_F3GDK_KEY_F4GDK_KEY_F5GDK_KEY_F6GDK_KEY_F7GDK_KEY_F8GDK_KEY_F9GDK_KEY_F10GDK_KEY_F11GDK_KEY_L1GDK_KEY_F12GDK_KEY_L2GDK_KEY_F13GDK_KEY_L3GDK_KEY_F14GDK_KEY_L4GDK_KEY_F15GDK_KEY_L5GDK_KEY_F16GDK_KEY_L6GDK_KEY_F17GDK_KEY_L7GDK_KEY_F18GDK_KEY_L8GDK_KEY_F19GDK_KEY_L9GDK_KEY_F20GDK_KEY_L10GDK_KEY_F21GDK_KEY_R1GDK_KEY_F22GDK_KEY_R2GDK_KEY_F23GDK_KEY_R3GDK_KEY_F24GDK_KEY_R4GDK_KEY_F25GDK_KEY_R5GDK_KEY_F26GDK_KEY_R6GDK_KEY_F27GDK_KEY_R7GDK_KEY_F28GDK_KEY_R8GDK_KEY_F29GDK_KEY_R9GDK_KEY_F30GDK_KEY_R10GDK_KEY_F31GDK_KEY_R11GDK_KEY_F32

Page 587: Apostila PHP GTK

GDK_KEY_R12GDK_KEY_F33GDK_KEY_R13GDK_KEY_F34GDK_KEY_R14GDK_KEY_F35GDK_KEY_R15GDK_KEY_Shift_LGDK_KEY_Shift_RGDK_KEY_Control_LGDK_KEY_Control_RGDK_KEY_Caps_LockGDK_KEY_Shift_LockGDK_KEY_Meta_LGDK_KEY_Meta_RGDK_KEY_Alt_LGDK_KEY_Alt_RGDK_KEY_Super_LGDK_KEY_Super_RGDK_KEY_Hyper_LGDK_KEY_Hyper_RGDK_KEY_ISO_LockGDK_KEY_ISO_Level2_LatchGDK_KEY_ISO_Level3_ShiftGDK_KEY_ISO_Level3_LatchGDK_KEY_ISO_Level3_LockGDK_KEY_ISO_Group_ShiftGDK_KEY_ISO_Group_LatchGDK_KEY_ISO_Group_LockGDK_KEY_ISO_Next_GroupGDK_KEY_ISO_Next_Group_LockGDK_KEY_ISO_Prev_GroupGDK_KEY_ISO_Prev_Group_LockGDK_KEY_ISO_First_GroupGDK_KEY_ISO_First_Group_LockGDK_KEY_ISO_Last_GroupGDK_KEY_ISO_Last_Group_LockGDK_KEY_ISO_Left_TabGDK_KEY_ISO_Move_Line_UpGDK_KEY_ISO_Move_Line_DownGDK_KEY_ISO_Partial_Line_UpGDK_KEY_ISO_Partial_Line_DownGDK_KEY_ISO_Partial_Space_LeftGDK_KEY_ISO_Partial_Space_RightGDK_KEY_ISO_Set_Margin_LeftGDK_KEY_ISO_Set_Margin_RightGDK_KEY_ISO_Release_Margin_LeftGDK_KEY_ISO_Release_Margin_RightGDK_KEY_ISO_Release_Both_MarginsGDK_KEY_ISO_Fast_Cursor_LeftGDK_KEY_ISO_Fast_Cursor_RightGDK_KEY_ISO_Fast_Cursor_UpGDK_KEY_ISO_Fast_Cursor_DownGDK_KEY_ISO_Continuous_Underline

Page 588: Apostila PHP GTK

GDK_KEY_ISO_Discontinuous_UnderlineGDK_KEY_ISO_EmphasizeGDK_KEY_ISO_Center_ObjectGDK_KEY_ISO_EnterGDK_KEY_dead_graveGDK_KEY_dead_acuteGDK_KEY_dead_circumflexGDK_KEY_dead_tildeGDK_KEY_dead_macronGDK_KEY_dead_breveGDK_KEY_dead_abovedotGDK_KEY_dead_diaeresisGDK_KEY_dead_aboveringGDK_KEY_dead_doubleacuteGDK_KEY_dead_caronGDK_KEY_dead_cedillaGDK_KEY_dead_ogonekGDK_KEY_dead_iotaGDK_KEY_dead_voiced_soundGDK_KEY_dead_semivoiced_soundGDK_KEY_dead_belowdotGDK_KEY_First_Virtual_ScreenGDK_KEY_Prev_Virtual_ScreenGDK_KEY_Next_Virtual_ScreenGDK_KEY_Last_Virtual_ScreenGDK_KEY_Terminate_ServerGDK_KEY_AccessX_EnableGDK_KEY_AccessX_Feedback_EnableGDK_KEY_RepeatKeys_EnableGDK_KEY_SlowKeys_EnableGDK_KEY_BounceKeys_EnableGDK_KEY_StickyKeys_EnableGDK_KEY_MouseKeys_EnableGDK_KEY_MouseKeys_Accel_EnableGDK_KEY_Overlay1_EnableGDK_KEY_Overlay2_EnableGDK_KEY_AudibleBell_EnableGDK_KEY_Pointer_LeftGDK_KEY_Pointer_RightGDK_KEY_Pointer_UpGDK_KEY_Pointer_DownGDK_KEY_Pointer_UpLeftGDK_KEY_Pointer_UpRightGDK_KEY_Pointer_DownLeftGDK_KEY_Pointer_DownRightGDK_KEY_Pointer_Button_DfltGDK_KEY_Pointer_Button1GDK_KEY_Pointer_Button2GDK_KEY_Pointer_Button3GDK_KEY_Pointer_Button4GDK_KEY_Pointer_Button5GDK_KEY_Pointer_DblClick_DfltGDK_KEY_Pointer_DblClick1GDK_KEY_Pointer_DblClick2

Page 589: Apostila PHP GTK

GDK_KEY_Pointer_DblClick3GDK_KEY_Pointer_DblClick4GDK_KEY_Pointer_DblClick5GDK_KEY_Pointer_Drag_DfltGDK_KEY_Pointer_Drag1GDK_KEY_Pointer_Drag2GDK_KEY_Pointer_Drag3GDK_KEY_Pointer_Drag4GDK_KEY_Pointer_Drag5GDK_KEY_Pointer_EnableKeysGDK_KEY_Pointer_AccelerateGDK_KEY_Pointer_DfltBtnNextGDK_KEY_Pointer_DfltBtnPrevGDK_KEY_3270_DuplicateGDK_KEY_3270_FieldMarkGDK_KEY_3270_Right2GDK_KEY_3270_Left2GDK_KEY_3270_BackTabGDK_KEY_3270_EraseEOFGDK_KEY_3270_EraseInputGDK_KEY_3270_ResetGDK_KEY_3270_QuitGDK_KEY_3270_PA1GDK_KEY_3270_PA2GDK_KEY_3270_PA3GDK_KEY_3270_TestGDK_KEY_3270_AttnGDK_KEY_3270_CursorBlinkGDK_KEY_3270_AltCursorGDK_KEY_3270_KeyClickGDK_KEY_3270_JumpGDK_KEY_3270_IdentGDK_KEY_3270_RuleGDK_KEY_3270_CopyGDK_KEY_3270_PlayGDK_KEY_3270_SetupGDK_KEY_3270_RecordGDK_KEY_3270_ChangeScreenGDK_KEY_3270_DeleteWordGDK_KEY_3270_ExSelectGDK_KEY_3270_CursorSelectGDK_KEY_3270_PrintScreenGDK_KEY_3270_EnterGDK_KEY_spaceGDK_KEY_exclamGDK_KEY_quotedblGDK_KEY_numbersignGDK_KEY_dollarGDK_KEY_percentGDK_KEY_ampersandGDK_KEY_apostropheGDK_KEY_quoterightGDK_KEY_parenleftGDK_KEY_parenright

Page 590: Apostila PHP GTK

GDK_KEY_asteriskGDK_KEY_plusGDK_KEY_commaGDK_KEY_minusGDK_KEY_periodGDK_KEY_slashGDK_KEY_0GDK_KEY_1GDK_KEY_2GDK_KEY_3GDK_KEY_4GDK_KEY_5GDK_KEY_6GDK_KEY_7GDK_KEY_8GDK_KEY_9GDK_KEY_colonGDK_KEY_semicolonGDK_KEY_lessGDK_KEY_equalGDK_KEY_greaterGDK_KEY_questionGDK_KEY_atGDK_KEY_AGDK_KEY_BGDK_KEY_CGDK_KEY_DGDK_KEY_EGDK_KEY_FGDK_KEY_GGDK_KEY_HGDK_KEY_IGDK_KEY_JGDK_KEY_KGDK_KEY_LGDK_KEY_MGDK_KEY_NGDK_KEY_OGDK_KEY_PGDK_KEY_QGDK_KEY_RGDK_KEY_SGDK_KEY_TGDK_KEY_UGDK_KEY_VGDK_KEY_WGDK_KEY_XGDK_KEY_YGDK_KEY_ZGDK_KEY_bracketleftGDK_KEY_backslashGDK_KEY_bracketrightGDK_KEY_asciicircumGDK_KEY_underscore

Page 591: Apostila PHP GTK

GDK_KEY_graveGDK_KEY_quoteleftGDK_KEY__aGDK_KEY__bGDK_KEY__cGDK_KEY__dGDK_KEY__eGDK_KEY__fGDK_KEY__gGDK_KEY__hGDK_KEY__iGDK_KEY__jGDK_KEY__kGDK_KEY__lGDK_KEY__mGDK_KEY__nGDK_KEY__oGDK_KEY__pGDK_KEY__qGDK_KEY__rGDK_KEY__sGDK_KEY__tGDK_KEY__uGDK_KEY__vGDK_KEY__wGDK_KEY__xGDK_KEY__yGDK_KEY__zGDK_KEY_braceleftGDK_KEY_barGDK_KEY_bracerightGDK_KEY_asciitildeGDK_KEY_nobreakspaceGDK_KEY_exclamdownGDK_KEY_centGDK_KEY_sterlingGDK_KEY_currencyGDK_KEY_yenGDK_KEY_brokenbarGDK_KEY_sectionGDK_KEY_diaeresisGDK_KEY_copyrightGDK_KEY_ordfeminineGDK_KEY_guillemotleftGDK_KEY_notsignGDK_KEY_hyphenGDK_KEY_registeredGDK_KEY_macronGDK_KEY_degreeGDK_KEY_plusminusGDK_KEY_twosuperiorGDK_KEY_threesuperiorGDK_KEY_acuteGDK_KEY_mu

Page 592: Apostila PHP GTK

GDK_KEY_paragraphGDK_KEY_periodcenteredGDK_KEY_cedillaGDK_KEY_onesuperiorGDK_KEY_masculineGDK_KEY_guillemotrightGDK_KEY_onequarterGDK_KEY_onehalfGDK_KEY_threequartersGDK_KEY_questiondownGDK_KEY_AgraveGDK_KEY_AacuteGDK_KEY_AcircumflexGDK_KEY_AtildeGDK_KEY_AdiaeresisGDK_KEY_AringGDK_KEY_AEGDK_KEY_CcedillaGDK_KEY_EgraveGDK_KEY_EacuteGDK_KEY_EcircumflexGDK_KEY_EdiaeresisGDK_KEY_IgraveGDK_KEY_IacuteGDK_KEY_IcircumflexGDK_KEY_IdiaeresisGDK_KEY_ETHGDK_KEY__EthGDK_KEY_NtildeGDK_KEY_OgraveGDK_KEY_OacuteGDK_KEY_OcircumflexGDK_KEY_OtildeGDK_KEY_OdiaeresisGDK_KEY_multiplyGDK_KEY_OobliqueGDK_KEY_UgraveGDK_KEY_UacuteGDK_KEY_UcircumflexGDK_KEY_UdiaeresisGDK_KEY_YacuteGDK_KEY_THORNGDK_KEY__ThornGDK_KEY_ssharpGDK_KEY__agraveGDK_KEY__aacuteGDK_KEY__acircumflexGDK_KEY__atildeGDK_KEY__adiaeresisGDK_KEY__aringGDK_KEY__aeGDK_KEY__ccedillaGDK_KEY__egraveGDK_KEY__eacute

Page 593: Apostila PHP GTK

GDK_KEY__ecircumflexGDK_KEY__ediaeresisGDK_KEY__igraveGDK_KEY__iacuteGDK_KEY__icircumflexGDK_KEY__idiaeresisGDK_KEY___ethGDK_KEY__ntildeGDK_KEY__ograveGDK_KEY__oacuteGDK_KEY__ocircumflexGDK_KEY__otildeGDK_KEY__odiaeresisGDK_KEY_divisionGDK_KEY_oslashGDK_KEY__ugraveGDK_KEY__uacuteGDK_KEY__ucircumflexGDK_KEY__udiaeresisGDK_KEY__yacuteGDK_KEY___thornGDK_KEY_ydiaeresisGDK_KEY_AogonekGDK_KEY_breveGDK_KEY_LstrokeGDK_KEY_LcaronGDK_KEY_SacuteGDK_KEY_ScaronGDK_KEY_ScedillaGDK_KEY_TcaronGDK_KEY_ZacuteGDK_KEY_ZcaronGDK_KEY_ZabovedotGDK_KEY__aogonekGDK_KEY_ogonekGDK_KEY__lstrokeGDK_KEY__lcaronGDK_KEY__sacuteGDK_KEY_caronGDK_KEY__scaronGDK_KEY__scedillaGDK_KEY__tcaronGDK_KEY__zacuteGDK_KEY_doubleacuteGDK_KEY__zcaronGDK_KEY__zabovedotGDK_KEY_RacuteGDK_KEY_AbreveGDK_KEY_LacuteGDK_KEY_CacuteGDK_KEY_CcaronGDK_KEY_EogonekGDK_KEY_EcaronGDK_KEY_Dcaron

Page 594: Apostila PHP GTK

GDK_KEY_DstrokeGDK_KEY_NacuteGDK_KEY_NcaronGDK_KEY_OdoubleacuteGDK_KEY_RcaronGDK_KEY_UringGDK_KEY_UdoubleacuteGDK_KEY_TcedillaGDK_KEY__racuteGDK_KEY__abreveGDK_KEY__lacuteGDK_KEY__cacuteGDK_KEY__ccaronGDK_KEY__eogonekGDK_KEY__ecaronGDK_KEY__dcaronGDK_KEY__dstrokeGDK_KEY__nacuteGDK_KEY__ncaronGDK_KEY__odoubleacuteGDK_KEY__udoubleacuteGDK_KEY__rcaronGDK_KEY__uringGDK_KEY__tcedillaGDK_KEY_abovedotGDK_KEY_HstrokeGDK_KEY_HcircumflexGDK_KEY_IabovedotGDK_KEY_GbreveGDK_KEY_JcircumflexGDK_KEY__hstrokeGDK_KEY__hcircumflexGDK_KEY_idotlessGDK_KEY__gbreveGDK_KEY__jcircumflexGDK_KEY_CabovedotGDK_KEY_CcircumflexGDK_KEY_GabovedotGDK_KEY_GcircumflexGDK_KEY_UbreveGDK_KEY_ScircumflexGDK_KEY__cabovedotGDK_KEY__ccircumflexGDK_KEY__gabovedotGDK_KEY__gcircumflexGDK_KEY__ubreveGDK_KEY__scircumflexGDK_KEY_kraGDK_KEY_kappaGDK_KEY_RcedillaGDK_KEY_ItildeGDK_KEY_LcedillaGDK_KEY_EmacronGDK_KEY_Gcedilla

Page 595: Apostila PHP GTK

GDK_KEY_TslashGDK_KEY__rcedillaGDK_KEY__itildeGDK_KEY__lcedillaGDK_KEY__emacronGDK_KEY__gcedillaGDK_KEY__tslashGDK_KEY_ENGGDK_KEY__engGDK_KEY_AmacronGDK_KEY_IogonekGDK_KEY_EabovedotGDK_KEY_ImacronGDK_KEY_NcedillaGDK_KEY_OmacronGDK_KEY_KcedillaGDK_KEY_UogonekGDK_KEY_UtildeGDK_KEY_UmacronGDK_KEY__amacronGDK_KEY__iogonekGDK_KEY__eabovedotGDK_KEY__imacronGDK_KEY__ncedillaGDK_KEY__omacronGDK_KEY__kcedillaGDK_KEY__uogonekGDK_KEY__utildeGDK_KEY__umacronGDK_KEY_overlineGDK_KEY_kana_fullstopGDK_KEY_kana_openingbracketGDK_KEY_kana_closingbracketGDK_KEY_kana_commaGDK_KEY_kana_conjunctiveGDK_KEY_kana_middledotGDK_KEY_kana_WOGDK_KEY_kana_aGDK_KEY_kana_iGDK_KEY_kana_uGDK_KEY_kana_eGDK_KEY_kana_oGDK_KEY_kana_yaGDK_KEY_kana_yuGDK_KEY_kana_yoGDK_KEY_kana_tsuGDK_KEY_kana_tuGDK_KEY_prolongedsoundGDK_KEY__kana_AGDK_KEY__kana_IGDK_KEY__kana_UGDK_KEY__kana_EGDK_KEY__kana_OGDK_KEY_kana_KA

Page 596: Apostila PHP GTK

GDK_KEY_kana_KIGDK_KEY_kana_KUGDK_KEY_kana_KEGDK_KEY_kana_KOGDK_KEY_kana_SAGDK_KEY_kana_SHIGDK_KEY_kana_SUGDK_KEY_kana_SEGDK_KEY_kana_SOGDK_KEY_kana_TAGDK_KEY_kana_CHIGDK_KEY_kana_TIGDK_KEY__kana_TSUGDK_KEY__kana_TUGDK_KEY_kana_TEGDK_KEY_kana_TOGDK_KEY_kana_NAGDK_KEY_kana_NIGDK_KEY_kana_NUGDK_KEY_kana_NEGDK_KEY_kana_NOGDK_KEY_kana_HAGDK_KEY_kana_HIGDK_KEY_kana_FUGDK_KEY_kana_HUGDK_KEY_kana_HEGDK_KEY_kana_HOGDK_KEY_kana_MAGDK_KEY_kana_MIGDK_KEY_kana_MUGDK_KEY_kana_MEGDK_KEY_kana_MOGDK_KEY__kana_YAGDK_KEY__kana_YUGDK_KEY__kana_YOGDK_KEY_kana_RAGDK_KEY_kana_RIGDK_KEY_kana_RUGDK_KEY_kana_REGDK_KEY_kana_ROGDK_KEY_kana_WAGDK_KEY_kana_NGDK_KEY_voicedsoundGDK_KEY_semivoicedsoundGDK_KEY_kana_switchGDK_KEY_Arabic_commaGDK_KEY_Arabic_semicolonGDK_KEY_Arabic_question_markGDK_KEY_Arabic_hamzaGDK_KEY_Arabic_maddaonalefGDK_KEY_Arabic_hamzaonalefGDK_KEY_Arabic_hamzaonwawGDK_KEY_Arabic_hamzaunderalefGDK_KEY_Arabic_hamzaonyeh

Page 597: Apostila PHP GTK

GDK_KEY_Arabic_alefGDK_KEY_Arabic_behGDK_KEY_Arabic_tehmarbutaGDK_KEY_Arabic_tehGDK_KEY_Arabic_thehGDK_KEY_Arabic_jeemGDK_KEY_Arabic_hahGDK_KEY_Arabic_khahGDK_KEY_Arabic_dalGDK_KEY_Arabic_thalGDK_KEY_Arabic_raGDK_KEY_Arabic_zainGDK_KEY_Arabic_seenGDK_KEY_Arabic_sheenGDK_KEY_Arabic_sadGDK_KEY_Arabic_dadGDK_KEY_Arabic_tahGDK_KEY_Arabic_zahGDK_KEY_Arabic_ainGDK_KEY_Arabic_ghainGDK_KEY_Arabic_tatweelGDK_KEY_Arabic_fehGDK_KEY_Arabic_qafGDK_KEY_Arabic_kafGDK_KEY_Arabic_lamGDK_KEY_Arabic_meemGDK_KEY_Arabic_noonGDK_KEY_Arabic_haGDK_KEY_Arabic_hehGDK_KEY_Arabic_wawGDK_KEY_Arabic_alefmaksuraGDK_KEY_Arabic_yehGDK_KEY_Arabic_fathatanGDK_KEY_Arabic_dammatanGDK_KEY_Arabic_kasratanGDK_KEY_Arabic_fathaGDK_KEY_Arabic_dammaGDK_KEY_Arabic_kasraGDK_KEY_Arabic_shaddaGDK_KEY_Arabic_sukunGDK_KEY_Arabic_switchGDK_KEY_Serbian_djeGDK_KEY_Macedonia_gjeGDK_KEY_Cyrillic_ioGDK_KEY_Ukrainian_ieGDK_KEY_Ukranian_jeGDK_KEY_Macedonia_dseGDK_KEY_Ukrainian_iGDK_KEY_Ukranian_iGDK_KEY_Ukrainian_yiGDK_KEY_Ukranian_yiGDK_KEY_Cyrillic_jeGDK_KEY_Serbian_jeGDK_KEY_Cyrillic_lje

Page 598: Apostila PHP GTK

GDK_KEY_Serbian_ljeGDK_KEY_Cyrillic_njeGDK_KEY_Serbian_njeGDK_KEY_Serbian_tsheGDK_KEY_Macedonia_kjeGDK_KEY_Byelorussian_shortuGDK_KEY_Cyrillic_dzheGDK_KEY_Serbian_dzeGDK_KEY_numerosignGDK_KEY__Serbian_DJEGDK_KEY__Macedonia_GJEGDK_KEY__Cyrillic_IOGDK_KEY__Ukrainian_IEGDK_KEY__Ukranian_JEGDK_KEY__Macedonia_DSEGDK_KEY__Ukrainian_IGDK_KEY__Ukranian_IGDK_KEY__Ukrainian_YIGDK_KEY__Ukranian_YIGDK_KEY__Cyrillic_JEGDK_KEY__Serbian_JEGDK_KEY__Cyrillic_LJEGDK_KEY__Serbian_LJEGDK_KEY__Cyrillic_NJEGDK_KEY__Serbian_NJEGDK_KEY__Serbian_TSHEGDK_KEY__Macedonia_KJEGDK_KEY__Byelorussian_SHORTUGDK_KEY__Cyrillic_DZHEGDK_KEY__Serbian_DZEGDK_KEY_Cyrillic_yuGDK_KEY_Cyrillic_aGDK_KEY_Cyrillic_beGDK_KEY_Cyrillic_tseGDK_KEY_Cyrillic_deGDK_KEY_Cyrillic_ieGDK_KEY_Cyrillic_efGDK_KEY_Cyrillic_gheGDK_KEY_Cyrillic_haGDK_KEY_Cyrillic_iGDK_KEY_Cyrillic_shortiGDK_KEY_Cyrillic_kaGDK_KEY_Cyrillic_elGDK_KEY_Cyrillic_emGDK_KEY_Cyrillic_enGDK_KEY_Cyrillic_oGDK_KEY_Cyrillic_peGDK_KEY_Cyrillic_yaGDK_KEY_Cyrillic_erGDK_KEY_Cyrillic_esGDK_KEY_Cyrillic_teGDK_KEY_Cyrillic_uGDK_KEY_Cyrillic_zheGDK_KEY_Cyrillic_ve

Page 599: Apostila PHP GTK

GDK_KEY_Cyrillic_softsignGDK_KEY_Cyrillic_yeruGDK_KEY_Cyrillic_zeGDK_KEY_Cyrillic_shaGDK_KEY_Cyrillic_eGDK_KEY_Cyrillic_shchaGDK_KEY_Cyrillic_cheGDK_KEY_Cyrillic_hardsignGDK_KEY__Cyrillic_YUGDK_KEY__Cyrillic_AGDK_KEY__Cyrillic_BEGDK_KEY__Cyrillic_TSEGDK_KEY__Cyrillic_DEGDK_KEY__Cyrillic_IEGDK_KEY__Cyrillic_EFGDK_KEY__Cyrillic_GHEGDK_KEY__Cyrillic_HAGDK_KEY__Cyrillic_IGDK_KEY__Cyrillic_SHORTIGDK_KEY__Cyrillic_KAGDK_KEY__Cyrillic_ELGDK_KEY__Cyrillic_EMGDK_KEY__Cyrillic_ENGDK_KEY__Cyrillic_OGDK_KEY__Cyrillic_PEGDK_KEY__Cyrillic_YAGDK_KEY__Cyrillic_ERGDK_KEY__Cyrillic_ESGDK_KEY__Cyrillic_TEGDK_KEY__Cyrillic_UGDK_KEY__Cyrillic_ZHEGDK_KEY__Cyrillic_VEGDK_KEY__Cyrillic_SOFTSIGNGDK_KEY__Cyrillic_YERUGDK_KEY__Cyrillic_ZEGDK_KEY__Cyrillic_SHAGDK_KEY__Cyrillic_EGDK_KEY__Cyrillic_SHCHAGDK_KEY__Cyrillic_CHEGDK_KEY__Cyrillic_HARDSIGNGDK_KEY_Greek_ALPHAaccentGDK_KEY_Greek_EPSILONaccentGDK_KEY_Greek_ETAaccentGDK_KEY_Greek_IOTAaccentGDK_KEY_Greek_IOTAdiaeresisGDK_KEY_Greek_OMICRONaccentGDK_KEY_Greek_UPSILONaccentGDK_KEY_Greek_UPSILONdieresisGDK_KEY_Greek_OMEGAaccentGDK_KEY_Greek_accentdieresisGDK_KEY_Greek_horizbarGDK_KEY__Greek_alphaaccentGDK_KEY__Greek_epsilonaccentGDK_KEY__Greek_etaaccent

Page 600: Apostila PHP GTK

GDK_KEY__Greek_iotaaccentGDK_KEY_Greek_iotadieresisGDK_KEY_Greek_iotaaccentdieresisGDK_KEY__Greek_omicronaccentGDK_KEY__Greek_upsilonaccentGDK_KEY__Greek_upsilondieresisGDK_KEY_Greek_upsilonaccentdieresisGDK_KEY__Greek_omegaaccentGDK_KEY_Greek_ALPHAGDK_KEY_Greek_BETAGDK_KEY_Greek_GAMMAGDK_KEY_Greek_DELTAGDK_KEY_Greek_EPSILONGDK_KEY_Greek_ZETAGDK_KEY_Greek_ETAGDK_KEY_Greek_THETAGDK_KEY_Greek_IOTAGDK_KEY_Greek_KAPPAGDK_KEY_Greek_LAMDAGDK_KEY_Greek_LAMBDAGDK_KEY_Greek_MUGDK_KEY_Greek_NUGDK_KEY_Greek_XIGDK_KEY_Greek_OMICRONGDK_KEY_Greek_PIGDK_KEY_Greek_RHOGDK_KEY_Greek_SIGMAGDK_KEY_Greek_TAUGDK_KEY_Greek_UPSILONGDK_KEY_Greek_PHIGDK_KEY_Greek_CHIGDK_KEY_Greek_PSIGDK_KEY_Greek_OMEGAGDK_KEY__Greek_alphaGDK_KEY__Greek_betaGDK_KEY__Greek_gammaGDK_KEY__Greek_deltaGDK_KEY__Greek_epsilonGDK_KEY__Greek_zetaGDK_KEY__Greek_etaGDK_KEY__Greek_thetaGDK_KEY__Greek_iotaGDK_KEY__Greek_kappaGDK_KEY__Greek_lamdaGDK_KEY__Greek_lambdaGDK_KEY__Greek_muGDK_KEY__Greek_nuGDK_KEY__Greek_xiGDK_KEY__Greek_omicronGDK_KEY__Greek_piGDK_KEY__Greek_rhoGDK_KEY__Greek_sigmaGDK_KEY_Greek_finalsmallsigmaGDK_KEY__Greek_tau

Page 601: Apostila PHP GTK

GDK_KEY__Greek_upsilonGDK_KEY__Greek_phiGDK_KEY__Greek_chiGDK_KEY__Greek_psiGDK_KEY__Greek_omegaGDK_KEY_Greek_switchGDK_KEY_leftradicalGDK_KEY_topleftradicalGDK_KEY_horizconnectorGDK_KEY_topintegralGDK_KEY_botintegralGDK_KEY_vertconnectorGDK_KEY_topleftsqbracketGDK_KEY_botleftsqbracketGDK_KEY_toprightsqbracketGDK_KEY_botrightsqbracketGDK_KEY_topleftparensGDK_KEY_botleftparensGDK_KEY_toprightparensGDK_KEY_botrightparensGDK_KEY_leftmiddlecurlybraceGDK_KEY_rightmiddlecurlybraceGDK_KEY_topleftsummationGDK_KEY_botleftsummationGDK_KEY_topvertsummationconnectorGDK_KEY_botvertsummationconnectorGDK_KEY_toprightsummationGDK_KEY_botrightsummationGDK_KEY_rightmiddlesummationGDK_KEY_lessthanequalGDK_KEY_notequalGDK_KEY_greaterthanequalGDK_KEY_integralGDK_KEY_thereforeGDK_KEY_variationGDK_KEY_infinityGDK_KEY_nablaGDK_KEY_approximateGDK_KEY_similarequalGDK_KEY_ifonlyifGDK_KEY_impliesGDK_KEY_identicalGDK_KEY_radicalGDK_KEY_includedinGDK_KEY_includesGDK_KEY_intersectionGDK_KEY_unionGDK_KEY_logicalandGDK_KEY_logicalorGDK_KEY_partialderivativeGDK_KEY_functionGDK_KEY_leftarrowGDK_KEY_uparrowGDK_KEY_rightarrow

Page 602: Apostila PHP GTK

GDK_KEY_downarrowGDK_KEY_blankGDK_KEY_soliddiamondGDK_KEY_checkerboardGDK_KEY_htGDK_KEY_ffGDK_KEY_crGDK_KEY_lfGDK_KEY_nlGDK_KEY_vtGDK_KEY_lowrightcornerGDK_KEY_uprightcornerGDK_KEY_upleftcornerGDK_KEY_lowleftcornerGDK_KEY_crossinglinesGDK_KEY_horizlinescan1GDK_KEY_horizlinescan3GDK_KEY_horizlinescan5GDK_KEY_horizlinescan7GDK_KEY_horizlinescan9GDK_KEY_lefttGDK_KEY_righttGDK_KEY_bottGDK_KEY_toptGDK_KEY_vertbarGDK_KEY_emspaceGDK_KEY_enspaceGDK_KEY_em3spaceGDK_KEY_em4spaceGDK_KEY_digitspaceGDK_KEY_punctspaceGDK_KEY_thinspaceGDK_KEY_hairspaceGDK_KEY_emdashGDK_KEY_endashGDK_KEY_signifblankGDK_KEY_ellipsisGDK_KEY_doubbaselinedotGDK_KEY_onethirdGDK_KEY_twothirdsGDK_KEY_onefifthGDK_KEY_twofifthsGDK_KEY_threefifthsGDK_KEY_fourfifthsGDK_KEY_onesixthGDK_KEY_fivesixthsGDK_KEY_careofGDK_KEY_figdashGDK_KEY_leftanglebracketGDK_KEY_decimalpointGDK_KEY_rightanglebracketGDK_KEY_markerGDK_KEY_oneeighthGDK_KEY_threeeighths

Page 603: Apostila PHP GTK

GDK_KEY_fiveeighthsGDK_KEY_seveneighthsGDK_KEY_trademarkGDK_KEY_signaturemarkGDK_KEY_trademarkincircleGDK_KEY_leftopentriangleGDK_KEY_rightopentriangleGDK_KEY_emopencircleGDK_KEY_emopenrectangleGDK_KEY_leftsinglequotemarkGDK_KEY_rightsinglequotemarkGDK_KEY_leftdoublequotemarkGDK_KEY_rightdoublequotemarkGDK_KEY_prescriptionGDK_KEY_minutesGDK_KEY_secondsGDK_KEY_latincrossGDK_KEY_hexagramGDK_KEY_filledrectbulletGDK_KEY_filledlefttribulletGDK_KEY_filledrighttribulletGDK_KEY_emfilledcircleGDK_KEY_emfilledrectGDK_KEY_enopencircbulletGDK_KEY_enopensquarebulletGDK_KEY_openrectbulletGDK_KEY_opentribulletupGDK_KEY_opentribulletdownGDK_KEY_openstarGDK_KEY_enfilledcircbulletGDK_KEY_enfilledsqbulletGDK_KEY_filledtribulletupGDK_KEY_filledtribulletdownGDK_KEY_leftpointerGDK_KEY_rightpointerGDK_KEY_clubGDK_KEY_diamondGDK_KEY_heartGDK_KEY_maltesecrossGDK_KEY_daggerGDK_KEY_doubledaggerGDK_KEY_checkmarkGDK_KEY_ballotcrossGDK_KEY_musicalsharpGDK_KEY_musicalflatGDK_KEY_malesymbolGDK_KEY_femalesymbolGDK_KEY_telephoneGDK_KEY_telephonerecorderGDK_KEY_phonographcopyrightGDK_KEY_caretGDK_KEY_singlelowquotemarkGDK_KEY_doublelowquotemarkGDK_KEY_cursor

Page 604: Apostila PHP GTK

GDK_KEY_leftcaretGDK_KEY_rightcaretGDK_KEY_downcaretGDK_KEY_upcaretGDK_KEY_overbarGDK_KEY_downtackGDK_KEY_upshoeGDK_KEY_downstileGDK_KEY_underbarGDK_KEY_jotGDK_KEY_quadGDK_KEY_uptackGDK_KEY_circleGDK_KEY_upstileGDK_KEY_downshoeGDK_KEY_rightshoeGDK_KEY_leftshoeGDK_KEY_lefttackGDK_KEY_righttackGDK_KEY_hebrew_doublelowlineGDK_KEY_hebrew_alephGDK_KEY_hebrew_betGDK_KEY_hebrew_bethGDK_KEY_hebrew_gimelGDK_KEY_hebrew_gimmelGDK_KEY_hebrew_daletGDK_KEY_hebrew_dalethGDK_KEY_hebrew_heGDK_KEY_hebrew_wawGDK_KEY_hebrew_zainGDK_KEY_hebrew_zayinGDK_KEY_hebrew_chetGDK_KEY_hebrew_hetGDK_KEY_hebrew_tetGDK_KEY_hebrew_tethGDK_KEY_hebrew_yodGDK_KEY_hebrew_finalkaphGDK_KEY_hebrew_kaphGDK_KEY_hebrew_lamedGDK_KEY_hebrew_finalmemGDK_KEY_hebrew_memGDK_KEY_hebrew_finalnunGDK_KEY_hebrew_nunGDK_KEY_hebrew_samechGDK_KEY_hebrew_samekhGDK_KEY_hebrew_ayinGDK_KEY_hebrew_finalpeGDK_KEY_hebrew_peGDK_KEY_hebrew_finalzadeGDK_KEY_hebrew_finalzadiGDK_KEY_hebrew_zadeGDK_KEY_hebrew_zadiGDK_KEY_hebrew_qophGDK_KEY_hebrew_kuf

Page 605: Apostila PHP GTK

GDK_KEY_hebrew_reshGDK_KEY_hebrew_shinGDK_KEY_hebrew_tawGDK_KEY_hebrew_tafGDK_KEY_Hebrew_switchGDK_KEY_Thai_kokaiGDK_KEY_Thai_khokhaiGDK_KEY_Thai_khokhuatGDK_KEY_Thai_khokhwaiGDK_KEY_Thai_khokhonGDK_KEY_Thai_khorakhangGDK_KEY_Thai_ngonguGDK_KEY_Thai_chochanGDK_KEY_Thai_chochingGDK_KEY_Thai_chochangGDK_KEY_Thai_sosoGDK_KEY_Thai_chochoeGDK_KEY_Thai_yoyingGDK_KEY_Thai_dochadaGDK_KEY_Thai_topatakGDK_KEY_Thai_thothanGDK_KEY_Thai_thonangmonthoGDK_KEY_Thai_thophuthaoGDK_KEY_Thai_nonenGDK_KEY_Thai_dodekGDK_KEY_Thai_totaoGDK_KEY_Thai_thothungGDK_KEY_Thai_thothahanGDK_KEY_Thai_thothongGDK_KEY_Thai_nonuGDK_KEY_Thai_bobaimaiGDK_KEY_Thai_poplaGDK_KEY_Thai_phophungGDK_KEY_Thai_fofaGDK_KEY_Thai_phophanGDK_KEY_Thai_fofanGDK_KEY_Thai_phosamphaoGDK_KEY_Thai_momaGDK_KEY_Thai_yoyakGDK_KEY_Thai_roruaGDK_KEY_Thai_ruGDK_KEY_Thai_lolingGDK_KEY_Thai_luGDK_KEY_Thai_wowaenGDK_KEY_Thai_sosalaGDK_KEY_Thai_sorusiGDK_KEY_Thai_sosuaGDK_KEY_Thai_hohipGDK_KEY_Thai_lochulaGDK_KEY_Thai_oangGDK_KEY_Thai_honokhukGDK_KEY_Thai_paiyannoiGDK_KEY_Thai_saraaGDK_KEY_Thai_maihanakat

Page 606: Apostila PHP GTK

GDK_KEY_Thai_saraaaGDK_KEY_Thai_saraamGDK_KEY_Thai_saraiGDK_KEY_Thai_saraiiGDK_KEY_Thai_saraueGDK_KEY_Thai_saraueeGDK_KEY_Thai_sarauGDK_KEY_Thai_sarauuGDK_KEY_Thai_phinthuGDK_KEY_Thai_maihanakat_maithoGDK_KEY_Thai_bahtGDK_KEY_Thai_saraeGDK_KEY_Thai_saraaeGDK_KEY_Thai_saraoGDK_KEY_Thai_saraaimaimuanGDK_KEY_Thai_saraaimaimalaiGDK_KEY_Thai_lakkhangyaoGDK_KEY_Thai_maiyamokGDK_KEY_Thai_maitaikhuGDK_KEY_Thai_maiekGDK_KEY_Thai_maithoGDK_KEY_Thai_maitriGDK_KEY_Thai_maichattawaGDK_KEY_Thai_thanthakhatGDK_KEY_Thai_nikhahitGDK_KEY_Thai_leksunGDK_KEY_Thai_leknungGDK_KEY_Thai_leksongGDK_KEY_Thai_leksamGDK_KEY_Thai_leksiGDK_KEY_Thai_lekhaGDK_KEY_Thai_lekhokGDK_KEY_Thai_lekchetGDK_KEY_Thai_lekpaetGDK_KEY_Thai_lekkaoGDK_KEY_HangulGDK_KEY_Hangul_StartGDK_KEY_Hangul_EndGDK_KEY_Hangul_HanjaGDK_KEY_Hangul_JamoGDK_KEY_Hangul_RomajaGDK_KEY_Hangul_CodeinputGDK_KEY_Hangul_JeonjaGDK_KEY_Hangul_BanjaGDK_KEY_Hangul_PreHanjaGDK_KEY_Hangul_PostHanjaGDK_KEY_Hangul_SingleCandidateGDK_KEY_Hangul_MultipleCandidateGDK_KEY_Hangul_PreviousCandidateGDK_KEY_Hangul_SpecialGDK_KEY_Hangul_switchGDK_KEY_Hangul_KiyeogGDK_KEY_Hangul_SsangKiyeogGDK_KEY_Hangul_KiyeogSios

Page 607: Apostila PHP GTK

GDK_KEY_Hangul_NieunGDK_KEY_Hangul_NieunJieujGDK_KEY_Hangul_NieunHieuhGDK_KEY_Hangul_DikeudGDK_KEY_Hangul_SsangDikeudGDK_KEY_Hangul_RieulGDK_KEY_Hangul_RieulKiyeogGDK_KEY_Hangul_RieulMieumGDK_KEY_Hangul_RieulPieubGDK_KEY_Hangul_RieulSiosGDK_KEY_Hangul_RieulTieutGDK_KEY_Hangul_RieulPhieufGDK_KEY_Hangul_RieulHieuhGDK_KEY_Hangul_MieumGDK_KEY_Hangul_PieubGDK_KEY_Hangul_SsangPieubGDK_KEY_Hangul_PieubSiosGDK_KEY_Hangul_SiosGDK_KEY_Hangul_SsangSiosGDK_KEY_Hangul_IeungGDK_KEY_Hangul_JieujGDK_KEY_Hangul_SsangJieujGDK_KEY_Hangul_CieucGDK_KEY_Hangul_KhieuqGDK_KEY_Hangul_TieutGDK_KEY_Hangul_PhieufGDK_KEY_Hangul_HieuhGDK_KEY_Hangul_AGDK_KEY_Hangul_AEGDK_KEY_Hangul_YAGDK_KEY_Hangul_YAEGDK_KEY_Hangul_EOGDK_KEY_Hangul_EGDK_KEY_Hangul_YEOGDK_KEY_Hangul_YEGDK_KEY_Hangul_OGDK_KEY_Hangul_WAGDK_KEY_Hangul_WAEGDK_KEY_Hangul_OEGDK_KEY_Hangul_YOGDK_KEY_Hangul_UGDK_KEY_Hangul_WEOGDK_KEY_Hangul_WEGDK_KEY_Hangul_WIGDK_KEY_Hangul_YUGDK_KEY_Hangul_EUGDK_KEY_Hangul_YIGDK_KEY_Hangul_IGDK_KEY_Hangul_J_KiyeogGDK_KEY_Hangul_J_SsangKiyeogGDK_KEY_Hangul_J_KiyeogSiosGDK_KEY_Hangul_J_NieunGDK_KEY_Hangul_J_NieunJieujGDK_KEY_Hangul_J_NieunHieuh

Page 608: Apostila PHP GTK

GDK_KEY_Hangul_J_DikeudGDK_KEY_Hangul_J_RieulGDK_KEY_Hangul_J_RieulKiyeogGDK_KEY_Hangul_J_RieulMieumGDK_KEY_Hangul_J_RieulPieubGDK_KEY_Hangul_J_RieulSiosGDK_KEY_Hangul_J_RieulTieutGDK_KEY_Hangul_J_RieulPhieufGDK_KEY_Hangul_J_RieulHieuhGDK_KEY_Hangul_J_MieumGDK_KEY_Hangul_J_PieubGDK_KEY_Hangul_J_PieubSiosGDK_KEY_Hangul_J_SiosGDK_KEY_Hangul_J_SsangSiosGDK_KEY_Hangul_J_IeungGDK_KEY_Hangul_J_JieujGDK_KEY_Hangul_J_CieucGDK_KEY_Hangul_J_KhieuqGDK_KEY_Hangul_J_TieutGDK_KEY_Hangul_J_PhieufGDK_KEY_Hangul_J_HieuhGDK_KEY_Hangul_RieulYeorinHieuhGDK_KEY_Hangul_SunkyeongeumMieumGDK_KEY_Hangul_SunkyeongeumPieubGDK_KEY_Hangul_PanSiosGDK_KEY_Hangul_KkogjiDalrinIeungGDK_KEY_Hangul_SunkyeongeumPhieufGDK_KEY_Hangul_YeorinHieuhGDK_KEY_Hangul_AraeAGDK_KEY_Hangul_AraeAEGDK_KEY_Hangul_J_PanSiosGDK_KEY_Hangul_J_KkogjiDalrinIeungGDK_KEY_Hangul_J_YeorinHieuhGDK_KEY_Korean_Won