Download ??
Enviado: 20 Jun 2008 10:21
Onde baixo ? Como uso na versão WINDOWS ??
Código: Selecionar todos
#INCLUDE "gtk.ch"
#INCLUDE "xhgtk.ch"
PROCEDURE Main()
LOCAL cPrograma := "Menu Principal"
LOCAL oWindow , oToolBar , oMenuBar , oVBox
LOCAL oMenuArquivo , oArquivo , oAbrir , oFechar , oSalvar , oSair
LOCAL oMenuEditar , oEditar , oCopiar , oRecortar , oColar
LOCAL oMenuFerramentas , oFerramentas , oProcurar , oSubstituir
LOCAL oMenuAjuda , oAjuda , oSobre
// Inicializar a GTK e definir a janela
Gtk_Init()
oWindow := Gtk_Window_New( GTK_WINDOW_TOPLEVEL )
Gtk_Widget_Set_Size_Request( oWindow , 640 , 480 )
Gtk_Window_Set_Title( oWindow , cPrograma )
Gtk_Window_Set_Position( oWindow , GTK_WIN_POS_CENTER )
// Criar um objeto VBox para "guardar" o objeto MENU
oVBox := Gtk_VBox_New( .F. , 0 )
Gtk_Container_Add( oWindow , oVBox )
// Criar um objeto MENU BAR
oMenuBar := Gtk_Menu_Bar_New()
// Crias as opcoes do menu ARQUIVO
oMenuArquivo := Gtk_Menu_New()
oArquivo := Gtk_Menu_Item_New_With_Label( "Arquivo" )
oAbrir := Gtk_Menu_Item_New_With_Label( "Abrir" )
oSalvar := Gtk_Menu_Item_New_With_Label( "Salvar" )
oFechar := Gtk_Menu_Item_New_With_Label( "Fechar" )
oSair := Gtk_Menu_Item_New_With_Label( "Sair" )
Gtk_Menu_Item_Set_SubMenu( oArquivo , oMenuArquivo )
Gtk_Menu_Shell_Append( oMenuArquivo , oAbrir )
Gtk_Menu_Shell_Append( oMenuArquivo , oSalvar )
Gtk_Menu_Shell_Append( oMenuArquivo , oFechar )
Gtk_Menu_Shell_Append( oMenuArquivo , oSair )
Gtk_Menu_Shell_Append( oMenuBar , oArquivo )
// Crias as opcoes do menu EDITAR
oMenuEditar := Gtk_Menu_New()
oEditar := Gtk_Menu_Item_New_With_Label( "Editar" )
oCopiar := Gtk_Menu_Item_New_With_Label( "Copiar" )
oRecortar := Gtk_Menu_Item_New_With_Label( "Recortar" )
oColar := Gtk_Menu_Item_New_With_Label( "Colar" )
Gtk_Menu_Item_Set_SubMenu( oEditar , oMenuEditar )
Gtk_Menu_Shell_Append( oMenuEditar , oCopiar )
Gtk_Menu_Shell_Append( oMenuEditar , oRecortar )
Gtk_Menu_Shell_Append( oMenuEditar , oColar )
Gtk_Menu_Shell_Append( oMenuBar , oEditar )
// Crias as opcoes do menu FERRAMENTAS
oMenuFerramentas := Gtk_Menu_New()
oFerramentas := Gtk_Menu_Item_New_With_Label( "Ferramentas" )
oProcurar := Gtk_Menu_Item_New_With_Label( "Procurar" )
oSubstituir := Gtk_Menu_Item_New_With_Label( "Substituir" )
Gtk_Menu_Item_Set_SubMenu( oFerramentas , oMenuFerramentas )
Gtk_Menu_Shell_Append( oMenuFerramentas , oProcurar )
Gtk_Menu_Shell_Append( oMenuFerramentas , oSubstituir )
Gtk_Menu_Shell_Append( oMenuBar , oFerramentas )
// Crias as opcoes do menu AJUDA
oMenuAjuda := Gtk_Menu_New()
oAjuda := Gtk_Menu_Item_New_With_Label( "Ajuda" )
oSobre := Gtk_Menu_Item_New_With_Label( "Sobre" )
Gtk_Menu_Item_Set_SubMenu( oAjuda , oMenuAjuda )
Gtk_Menu_Shell_Append( oMenuAjuda , oSobre )
Gtk_Menu_Shell_Append( oMenuBar , oAjuda )
// Informar ao objeto VBOX que conterá o objeto MENUBAR
Gtk_Box_Pack_Start( oVBox , oMenuBar , .F. , .F. , 3 )
// Informar quais funções serão chamada quando selecionar uma opcao do menu
Gtk_Signal_Connect( oWindow , "destroy" , { || Gtk_Main_Quit() } )
Gtk_Signal_Connect( oAbrir , "activate" , { || MsgInfo( "Abrir" ) } )
Gtk_Signal_Connect( oSalvar , "activate" , { || MsgYesNo( "Salvar" ) } )
Gtk_Signal_Connect( oSair , "activate" , { || Gtk_Main_Quit() } )
Gtk_Signal_Connect( oSobre , "activate" , { || MsgInfo( "Demonstração da Lib GTK" + CRLF + "Ela é Multiplataforma" + CRLF + "Pode compilar este exemplo em Linux e Windows" + CRLF + "Voce não precisará alterar uma linha de código" ) } )
// Manda mostrar todos os objetos
Gtk_Widget_Show_All( oWindow )
// Inicia o loop principal
Gtk_Main()Código: Selecionar todos
oMenuArquivo := Gtk_Menu_New()
oArquivo := Gtk_Menu_Item_New_With_Mnemonic( "_Arquivo" )
oAbrir := Gtk_Menu_Item_New_With_Mnemonic( "A_brir" )
oSalvar := Gtk_Menu_Item_New_With_Mnemonic( "_Salvar" )
oFechar := Gtk_Menu_Item_New_With_Mnemonic( "_Fechar" )
oSair := Gtk_Menu_Item_New_With_Mnemonic( "Sa_ir" )Não sei se entendi corretamente o problema, mas veja a explicação abaixo:clebervn escreveu:Vc tem algum exemplo qq de menu q funcione... ?? porque pego tipo glade e é complicado
os normais, ele executa a ACTION antes de abrir propriamente a abertura da tela... complicado
Preciso disso como pontapé inicial pelo menos
Na seção de arquivos, no grupo no Yahoo, tem alguns documentos sobre o Glade:jamazevedo escreveu:Voltando ao glade sou completamente ignorante neste assunto já olhei os fontes inclusive o .glade e não fica muito claro para mim. Vou continuar estudando isso.