Hilaire, try this. Menus are something that hasn't fully been addressed by Polymorph yet so looks a little cumbersome (though less so if the indivdual parts had their own methods, like #fileMenu...). exampleWindowWithToolbars "Open an example window with toolbars." |win fileMenu tools dock text holder| win := StandardWindow new. fileMenu := win newMenu. fileMenu addToggle: 'Open' translated target: nil "would be model" selector: #openFile. fileMenu lastItem font: win theme menuFont; icon: MenuIcons smallOpenIcon; keyText: 'Ctrl+O'. fileMenu addToggle: 'Save' translated target: nil selector: #saveFile getStateSelector: nil enablementSelector: nil. fileMenu lastItem font: win theme menuFont; keyText: 'Ctrl+S'. fileMenu addToggle: 'Print...' translated target: nil selector: #print. fileMenu lastItem font: win theme menuFont; icon: MenuIcons smallPrintIcon; keyText: 'Ctrl+P'. tools := win newToolbar: {win newButtonFor: nil "if we had a model it would go here" getState: nil action: #openFile arguments: nil getEnabled: nil label: (ImageMorph new image: MenuIcons smallOpenIcon) help: 'Open file' translated. win newButtonFor: nil getState: nil action: #saveFile arguments: nil getEnabled: nil label: (ImageMorph new image: MenuIcons smallSaveIcon) help: 'Save file' translated. win newButtonFor: nil getState: nil action: #print arguments: nil getEnabled: nil label: (ImageMorph new image: MenuIcons smallPrintIcon) help: 'Print' translated}. holder := StringHolder new. text := win newTextEditorFor: holder getText: #contents setText: #contents: getEnabled: nil. dock := win newToolDockingBar. dock add: 'File' translated font: win theme menuBarFont icon: MenuIcons smallOpenIcon help: 'File operations' translated subMenu: fileMenu; addMorphBack: tools. win addMorph: dock fullFrame: (LayoutFrame fractions: (0@0 corner: 1@0) offsets: (0@0 corner: 0 @ dock minExtent y)); addMorph: text fullFrame: (LayoutFrame fractions: (0@0 corner: 1@1) offsets: (0@dock minExtent y corner: 0 @ 0)). win themeChanged; openInWorld Having no real model to perform the actions you'll get a walkback if any menu/tool item is chosen. Apologies for the requirement of #themeChanged near the end, must get around to fixing that! Regards, Gary. ----- Original Message ----- From: "Hilaire Fernandes" <hilaire@ofset.org> To: "An open mailing list to discuss any topics related to an open-sourceSmalltalk" <pharo-project@lists.gforge.inria.fr> Sent: Monday, September 15, 2008 1:32 PM Subject: Re: [Pharo-project] Learning how to use Polymorph
2008/9/15 Gary Chambers <gazzaguru2@btinternet.com>:
Of course, if you want a window then you can use a StandardWindow (subclass of SystemWindow) that includes the TEasilyThemed trait and delegate requests for widgets to that instead.
Hope that helps...
Yep, I figure out during the week-end. I am now converting step by step to Polymorph. I see that Trait can really make such thinkgs easier.
One think not obvious to me: how to pack a menu bar, toolbar in StandardWindow, as you did for your professionnal application. A canonical exemple will be very usefull
Hilaire
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project