|
From: Luc T. <li...@ta...> - 2003-09-02 22:08:29
|
MessageDaan, here is a small contribution example, built on your =
explanations.
It may fit in the samples, to illustrate these interesting features from =
wxHaskell. it needs a bitmap in the current directory, say =
haskell_icon.gif
You will note that "wxNB_RIGHT" seems to work on XP, finally.
Still, one glitch is the popupmenu that I was expecting near the button, =
not top left.
Also, I did not use a Use a "wxBitmapButton" as u mentions, I did not =
found it, neither what it should provides.. hm ?
{-|=20
Author : Luc Taesch 2003
=20
Maintainer : da...@cs...
Stability : provisional
Portability : portable ? (tested on XP)
=20
Illustrate more controls from wxHaskell, Hacked from Controls.hs ( =
Daan Leijen 2003)
namely bitmapButtons, righ click menus, vertical labels on =
notebooks, usage of tooltips
-}
module Main where
import Graphics.UI.WX
import Graphics.UI.WXH=20
main :: IO ()
main
=3D start gui
gui :: IO ()
gui
=3D do -- main gui elements: frame, panel, text control, and the =
notebook
f <- frame [text :=3D "Controls" ]
p <- panel f []
nb <- notebook2 p []
textlog <- textCtrl p WrapLine [enable :=3D False]
file <- menuList "&File" []
aRightClick <- menuItem file "Say Something\tCtrl+Q" "An =
interesting Message" []=20
-- use text control as logger
textCtrlMakeLogActiveTarget textlog
logMessage "logging enabled" =20
-- button page
p1 <- panel nb [text :=3D "buttons"]
bm <- bitmapCreateFromFile ".\\haskell_icon.gif"
ok <- bitmapButton p1 0 bm [text :=3D "Ok", on command :=3D =
logMessage "bitmap button pressed",=20
tooltip :=3D "tooltip",
on clickRight :=3D (\pt -> =
menuPopup file pt p)]
=20
-- specify layout
set f [layout :=3D
container p $
column 0
[ tabs nb
[container p1 $ margin 10 $ floatCentre $ row 5 =20
$ [widget ok]
]
, hfill $ widget textlog =20
]
, on (menu aRightClick) :=3D infoDialog f "Say.." =
"Something"
, clientSize :=3D sz 400 300 ]
return ()
where
logSelect labels w
=3D do i <- get w selection
s <- get w (item i)
logMessage ("selected index: " ++ show i ++ ": " ++ s)
=20
-- like notebook, with labels created on the side ( rather than on top): =
wxNB_RIGHT
notebook2 parent props=20
=3D do nb <- notebookCreate parent idAny rectNull ( wxCLIP_CHILDREN + =
wxNB_RIGHT)
set nb props
return nb
=20
-- like buttonEx, with a bitmap instead of the label=20
bitmapButton parent flags bm props=20
=3D do --bm <- bitmapCreateFromFile ".\\haskell_icon.gif"
b <- bitmapButtonCreate parent idAny bm rectNull flags
set b props
return b
----- Original Message -----=20
From: Daan Leijen=20
To: 'Luc Taesch' ; wxh...@li...=20
Sent: Monday, September 01, 2003 11:36 AM
Subject: [wxhaskell-users] drag and drop, notebook, bitmapbuttons, =
rightclick
Hi Luc,
I will just answer all your questions in one go :-)
does wxhaskell support drag and drop ?=20
No, not yet. It needs some more C wrapper support. However,
it is easy to add and it will be there in version 0.3 or something.
(I plan to release 0.2 in a few weeks). (unless you add it for me and
send me the patches... see wxDropTarget and friends).
> Is there any (layout ?) possibilities to have the notebook =
"buttons" on the (right side) rather than on the top ?=20
Yes. You have to create the notebook with the "wxNB_RIGHT" flag. Look =
at the
source code in "WX.Controls" to see how to create a notebook control.
(it seems from the docs though that "wxNB_RIGHT" is not supported yet =
by=20
wxWindows under windowsXP).
> doew wxhaskell support bitmapbuttons ?=20
Yes. Use a "wxBitmapButton". with "bitmapButtonCreate".
> does wxHaskell support rightclick menu, an dideally specific to an =
area , say on a button ?
Yes. Use "on clickRight" together with "menuPopup".
I hope this helps,
All the best.
Daan.
ps. I think you could have answered the last three questions yourself =
by=20
studying the documentation and samples. Don't worry though :-), I am =
very
happy that you use my stuff and I have no problem answering any
questions at all -- however, any time I spend on email can't be spend =
on
advancing wxHaskell. Therefore, try to experiment and study the docs a =
little
bit before asking questions.=20
|